bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: core: sysctl: fix compiler warning when only cBPF is present
@ 2019-12-18  9:18 Alexander Lobakin
  2019-12-19 16:20 ` Daniel Borkmann
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Lobakin @ 2019-12-18  9:18 UTC (permalink / raw)
  To: David S. Miller
  Cc: Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, Eric Dumazet, Andrew Morton,
	Soheil Hassas Yeganeh, Aaron Tomlin, Matteo Croce,
	Alexander Lobakin, Cong Wang, Edward Cree, netdev, linux-kernel,
	bpf

proc_dointvec_minmax_bpf_restricted() has been firstly introduced
in commit 2e4a30983b0f ("bpf: restrict access to core bpf sysctls")
under CONFIG_HAVE_EBPF_JIT. Then, this ifdef has been removed in
ede95a63b5e8 ("bpf: add bpf_jit_limit knob to restrict unpriv
allocations"), because a new sysctl, bpf_jit_limit, made use of it.
Finally, this parameter has become long instead of integer with
fdadd04931c2 ("bpf: fix bpf_jit_limit knob for PAGE_SIZE >= 64K")
and thus, a new proc_dolongvec_minmax_bpf_restricted() has been
added.
With this last change, we got back to that
proc_dointvec_minmax_bpf_restricted() is used only under
CONFIG_HAVE_EBPF_JIT, but the corresponding ifdef has not been
brought back.

So, in configurations like CONFIG_BPF_JIT=y && CONFIG_HAVE_EBPF_JIT=n
since v4.20 we have:

  CC      net/core/sysctl_net_core.o
net/core/sysctl_net_core.c:292:1: warning: ‘proc_dointvec_minmax_bpf_restricted’ defined but not used [-Wunused-function]
  292 | proc_dointvec_minmax_bpf_restricted(struct ctl_table *table, int write,
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Suppress this by guarding it with CONFIG_HAVE_EBPF_JIT again.

Fixes: fdadd04931c2 ("bpf: fix bpf_jit_limit knob for PAGE_SIZE >= 64K")
Signed-off-by: Alexander Lobakin <alobakin@dlink.ru>
---
 net/core/sysctl_net_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
index eb29e5adc84d..70211c9edb02 100644
--- a/net/core/sysctl_net_core.c
+++ b/net/core/sysctl_net_core.c
@@ -288,6 +288,7 @@ static int proc_dointvec_minmax_bpf_enable(struct ctl_table *table, int write,
 	return ret;
 }
 
+#ifdef CONFIG_HAVE_EBPF_JIT
 static int
 proc_dointvec_minmax_bpf_restricted(struct ctl_table *table, int write,
 				    void __user *buffer, size_t *lenp,
@@ -298,6 +299,7 @@ proc_dointvec_minmax_bpf_restricted(struct ctl_table *table, int write,
 
 	return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
 }
+#endif /* CONFIG_HAVE_EBPF_JIT */
 
 static int
 proc_dolongvec_minmax_bpf_restricted(struct ctl_table *table, int write,
-- 
2.24.1


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

* Re: [PATCH net] net: core: sysctl: fix compiler warning when only cBPF is present
  2019-12-18  9:18 [PATCH net] net: core: sysctl: fix compiler warning when only cBPF is present Alexander Lobakin
@ 2019-12-19 16:20 ` Daniel Borkmann
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2019-12-19 16:20 UTC (permalink / raw)
  To: Alexander Lobakin
  Cc: David S. Miller, Alexei Starovoitov, Martin KaFai Lau, Song Liu,
	Yonghong Song, Andrii Nakryiko, Eric Dumazet, Andrew Morton,
	Soheil Hassas Yeganeh, Aaron Tomlin, Matteo Croce, Cong Wang,
	Edward Cree, netdev, linux-kernel, bpf

On Wed, Dec 18, 2019 at 12:18:21PM +0300, Alexander Lobakin wrote:
> proc_dointvec_minmax_bpf_restricted() has been firstly introduced
> in commit 2e4a30983b0f ("bpf: restrict access to core bpf sysctls")
> under CONFIG_HAVE_EBPF_JIT. Then, this ifdef has been removed in
> ede95a63b5e8 ("bpf: add bpf_jit_limit knob to restrict unpriv
> allocations"), because a new sysctl, bpf_jit_limit, made use of it.
> Finally, this parameter has become long instead of integer with
> fdadd04931c2 ("bpf: fix bpf_jit_limit knob for PAGE_SIZE >= 64K")
> and thus, a new proc_dolongvec_minmax_bpf_restricted() has been
> added.
> With this last change, we got back to that
> proc_dointvec_minmax_bpf_restricted() is used only under
> CONFIG_HAVE_EBPF_JIT, but the corresponding ifdef has not been
> brought back.
> 
> So, in configurations like CONFIG_BPF_JIT=y && CONFIG_HAVE_EBPF_JIT=n
> since v4.20 we have:
> 
>   CC      net/core/sysctl_net_core.o
> net/core/sysctl_net_core.c:292:1: warning: ‘proc_dointvec_minmax_bpf_restricted’ defined but not used [-Wunused-function]
>   292 | proc_dointvec_minmax_bpf_restricted(struct ctl_table *table, int write,
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Suppress this by guarding it with CONFIG_HAVE_EBPF_JIT again.
> 
> Fixes: fdadd04931c2 ("bpf: fix bpf_jit_limit knob for PAGE_SIZE >= 64K")
> Signed-off-by: Alexander Lobakin <alobakin@dlink.ru>

Applied, thanks!

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

end of thread, other threads:[~2019-12-19 16:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18  9:18 [PATCH net] net: core: sysctl: fix compiler warning when only cBPF is present Alexander Lobakin
2019-12-19 16:20 ` Daniel Borkmann

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).