audit.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] audit: let the caller of audit_get_sk() ensure that net is valid
@ 2023-03-17  3:37 Gaosheng Cui
  2023-03-23 15:40 ` Paul Moore
  0 siblings, 1 reply; 3+ messages in thread
From: Gaosheng Cui @ 2023-03-17  3:37 UTC (permalink / raw)
  To: paul, eparis, cuigaosheng1; +Cc: audit

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;
-
 	aunet = net_generic(net, audit_net_id);
 	return aunet->sk;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] audit: let the caller of audit_get_sk() ensure that net is valid
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Moore @ 2023-03-23 15:40 UTC (permalink / raw)
  To: Gaosheng Cui; +Cc: eparis, audit

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

-- 
paul-moore.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] audit: let the caller of audit_get_sk() ensure that net is valid
  2023-03-23 15:40 ` Paul Moore
@ 2023-03-24  2:31   ` cuigaosheng
  0 siblings, 0 replies; 3+ messages in thread
From: cuigaosheng @ 2023-03-24  2:31 UTC (permalink / raw)
  To: Paul Moore; +Cc: eparis, audit

> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-24  2:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).