All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: NULL pointer check is not needed in BPF_CGROUP_RUN_PROG_INET_SOCK
@ 2018-02-23  6:58 Yafang Shao
  2018-02-23 15:30 ` Daniel Borkmann
  2018-02-23 17:44 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Yafang Shao @ 2018-02-23  6:58 UTC (permalink / raw)
  To: dsa, ast, daniel; +Cc: netdev, linux-kernel, Yafang Shao

sk is already allocated in inet_create/inet6_create, hence when
BPF_CGROUP_RUN_PROG_INET_SOCK is executed sk will never be NULL.

The logic is as bellow,
	sk = sk_alloc();
	if (!sk)
		goto out;
	BPF_CGROUP_RUN_PROG_INET_SOCK(sk);

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 include/linux/bpf-cgroup.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h
index a7f16e0..8a45666 100644
--- a/include/linux/bpf-cgroup.h
+++ b/include/linux/bpf-cgroup.h
@@ -96,7 +96,7 @@ int __cgroup_bpf_check_dev_permission(short dev_type, u32 major, u32 minor,
 #define BPF_CGROUP_RUN_PROG_INET_SOCK(sk)				       \
 ({									       \
 	int __ret = 0;							       \
-	if (cgroup_bpf_enabled && sk) {					       \
+	if (cgroup_bpf_enabled) {					       \
 		__ret = __cgroup_bpf_run_filter_sk(sk,			       \
 						 BPF_CGROUP_INET_SOCK_CREATE); \
 	}								       \
--
1.8.3.1

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

* Re: [PATCH bpf-next] bpf: NULL pointer check is not needed in BPF_CGROUP_RUN_PROG_INET_SOCK
  2018-02-23  6:58 [PATCH bpf-next] bpf: NULL pointer check is not needed in BPF_CGROUP_RUN_PROG_INET_SOCK Yafang Shao
@ 2018-02-23 15:30 ` Daniel Borkmann
  2018-02-23 17:44 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2018-02-23 15:30 UTC (permalink / raw)
  To: Yafang Shao, dsa, ast; +Cc: netdev, linux-kernel

On 02/23/2018 07:58 AM, Yafang Shao wrote:
> sk is already allocated in inet_create/inet6_create, hence when
> BPF_CGROUP_RUN_PROG_INET_SOCK is executed sk will never be NULL.
> 
> The logic is as bellow,
> 	sk = sk_alloc();
> 	if (!sk)
> 		goto out;
> 	BPF_CGROUP_RUN_PROG_INET_SOCK(sk);
> 
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>

Agree, applied to bpf-next, thanks Yafang!

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

* Re: [PATCH bpf-next] bpf: NULL pointer check is not needed in BPF_CGROUP_RUN_PROG_INET_SOCK
  2018-02-23  6:58 [PATCH bpf-next] bpf: NULL pointer check is not needed in BPF_CGROUP_RUN_PROG_INET_SOCK Yafang Shao
  2018-02-23 15:30 ` Daniel Borkmann
@ 2018-02-23 17:44 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-02-23 17:44 UTC (permalink / raw)
  To: laoar.shao; +Cc: dsa, ast, daniel, netdev, linux-kernel

From: Yafang Shao <laoar.shao@gmail.com>
Date: Fri, 23 Feb 2018 14:58:41 +0800

> sk is already allocated in inet_create/inet6_create, hence when
> BPF_CGROUP_RUN_PROG_INET_SOCK is executed sk will never be NULL.
> 
> The logic is as bellow,
> 	sk = sk_alloc();
> 	if (!sk)
> 		goto out;
> 	BPF_CGROUP_RUN_PROG_INET_SOCK(sk);
> 
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>

Acked-by: David S. Miller <davem@davemloft.net>

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

end of thread, other threads:[~2018-02-23 17:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-23  6:58 [PATCH bpf-next] bpf: NULL pointer check is not needed in BPF_CGROUP_RUN_PROG_INET_SOCK Yafang Shao
2018-02-23 15:30 ` Daniel Borkmann
2018-02-23 17:44 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.