audit.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: cuigaosheng <cuigaosheng1@huawei.com>
To: Paul Moore <paul@paul-moore.com>
Cc: <eparis@redhat.com>, <audit@vger.kernel.org>
Subject: Re: [PATCH -next] audit: let the caller of audit_get_sk() ensure that net is valid
Date: Fri, 24 Mar 2023 10:31:20 +0800	[thread overview]
Message-ID: <a885021e-ba9e-7b53-5ae4-384487640b40@huawei.com> (raw)
In-Reply-To: <CAHC9VhS1Q9Ks_TYjxRe=S8L7kOXS5tuhLV59OA=fnAXN3q3fJg@mail.gmail.com>

> I'd prefer to keep this check in place, and I think it may be required
> to ensure proper behavior in kauditd_thread()/kauditd_send_queue().

ok,thanks for taking time to review this patch.

On 2023/3/23 23:40, Paul Moore wrote:
> On Thu, Mar 16, 2023 at 11:38 PM Gaosheng Cui <cuigaosheng1@huawei.com> wrote:
>> The caller of audit_get_sk() must ensure that net is valid, otherwise
>> there will be null-prt-defer, for example, in the netlink_unicast().
>>
>> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
>> ---
>>   kernel/audit.c | 7 ++-----
>>   1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/kernel/audit.c b/kernel/audit.c
>> index 9bc0b0301198..6a42a3801d01 100644
>> --- a/kernel/audit.c
>> +++ b/kernel/audit.c
>> @@ -285,16 +285,13 @@ static pid_t auditd_pid_vnr(void)
>>    * @net: the destination network namespace
>>    *
>>    * Description:
>> - * Returns the sock pointer if valid, NULL otherwise.  The caller must ensure
>> - * that a reference is held for the network namespace while the sock is in use.
>> + * Returns the sock pointer. The caller must ensure than net is valid and
>> + * a reference is held for the network namespace while the sock is in use.
>>    */
>>   static struct sock *audit_get_sk(const struct net *net)
>>   {
>>          struct audit_net *aunet;
>>
>> -       if (!net)
>> -               return NULL;
> I'd prefer to keep this check in place, and I think it may be required
> to ensure proper behavior in kauditd_thread()/kauditd_send_queue().
>
>>          aunet = net_generic(net, audit_net_id);
>>          return aunet->sk;
>>   }
>> --
>> 2.25.1

      reply	other threads:[~2023-03-24  2:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-17  3:37 [PATCH -next] audit: let the caller of audit_get_sk() ensure that net is valid Gaosheng Cui
2023-03-23 15:40 ` Paul Moore
2023-03-24  2:31   ` cuigaosheng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a885021e-ba9e-7b53-5ae4-384487640b40@huawei.com \
    --to=cuigaosheng1@huawei.com \
    --cc=audit@vger.kernel.org \
    --cc=eparis@redhat.com \
    --cc=paul@paul-moore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).