netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bpfilter: allow to build bpfilter_umh as a module without static library
@ 2020-07-01  9:26 Masahiro Yamada
  2020-07-01 12:57 ` Michal Kubecek
  2020-07-01 17:46 ` Alexei Starovoitov
  0 siblings, 2 replies; 5+ messages in thread
From: Masahiro Yamada @ 2020-07-01  9:26 UTC (permalink / raw)
  To: Alexei Starovoitov, netdev, bpf
  Cc: linux-kbuild, Michal Kubecek, linux-kernel, Masahiro Yamada,
	Andrii Nakryiko, Daniel Borkmann, David S. Miller,
	Jakub Kicinski, John Fastabend, KP Singh, Martin KaFai Lau,
	Sam Ravnborg, Song Liu, Valdis Kl ē tnieks, Yonghong Song

Originally, bpfilter_umh was linked with -static only when
CONFIG_BPFILTER_UMH=y.

Commit 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build
bpfilter_umh") silently, accidentally dropped the CONFIG_BPFILTER_UMH=y
test in the Makefile. Revive it in order to link it dynamically when
CONFIG_BPFILTER_UMH=m.

Since commit b1183b6dca3e ("bpfilter: check if $(CC) can link static
libc in Kconfig"), the compiler must be capable of static linking to
enable CONFIG_BPFILTER_UMH, but it requires more than needed.

To loosen the compiler requirement, I changed the dependency as follows:

    depends on CC_CAN_LINK
    depends on m || CC_CAN_LINK_STATIC

If CONFIG_CC_CAN_LINK_STATIC in unset, CONFIG_BPFILTER_UMH is restricted
to 'm' or 'n'.

In theory, CONFIG_CC_CAN_LINK is not required for CONFIG_BPFILTER_UMH=y,
but I did not come up with a good way to describe it.

Fixes: 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build bpfilter_umh")
Reported-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 net/bpfilter/Kconfig  | 10 ++++++----
 net/bpfilter/Makefile |  2 ++
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/bpfilter/Kconfig b/net/bpfilter/Kconfig
index 84015ef3ee27..73d0b12789f1 100644
--- a/net/bpfilter/Kconfig
+++ b/net/bpfilter/Kconfig
@@ -9,12 +9,14 @@ menuconfig BPFILTER
 if BPFILTER
 config BPFILTER_UMH
 	tristate "bpfilter kernel module with user mode helper"
-	depends on CC_CAN_LINK_STATIC
+	depends on CC_CAN_LINK
+	depends on m || CC_CAN_LINK_STATIC
 	default m
 	help
 	  This builds bpfilter kernel module with embedded user mode helper
 
-	  Note: your toolchain must support building static binaries, since
-	  rootfs isn't mounted at the time when __init functions are called
-	  and do_execv won't be able to find the elf interpreter.
+	  Note: To compile this as built-in, your toolchain must support
+	  building static binaries, since rootfs isn't mounted at the time
+	  when __init functions are called and do_execv won't be able to find
+	  the elf interpreter.
 endif
diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile
index f23b53294fba..cdac82b8c53a 100644
--- a/net/bpfilter/Makefile
+++ b/net/bpfilter/Makefile
@@ -7,10 +7,12 @@ userprogs := bpfilter_umh
 bpfilter_umh-objs := main.o
 userccflags += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi
 
+ifeq ($(CONFIG_BPFILTER_UMH), y)
 # builtin bpfilter_umh should be linked with -static
 # since rootfs isn't mounted at the time of __init
 # function is called and do_execv won't find elf interpreter
 userldflags += -static
+endif
 
 $(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umh
 
-- 
2.25.1


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

* Re: [PATCH] bpfilter: allow to build bpfilter_umh as a module without static library
  2020-07-01  9:26 [PATCH] bpfilter: allow to build bpfilter_umh as a module without static library Masahiro Yamada
@ 2020-07-01 12:57 ` Michal Kubecek
  2020-07-01 17:46 ` Alexei Starovoitov
  1 sibling, 0 replies; 5+ messages in thread
From: Michal Kubecek @ 2020-07-01 12:57 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Alexei Starovoitov, netdev, bpf, linux-kbuild, linux-kernel,
	Andrii Nakryiko, Daniel Borkmann, David S. Miller,
	Jakub Kicinski, John Fastabend, KP Singh, Martin KaFai Lau,
	Sam Ravnborg, Song Liu, Valdis Kl ē tnieks, Yonghong Song

[-- Attachment #1: Type: text/plain, Size: 3052 bytes --]

On Wed, Jul 01, 2020 at 06:26:44PM +0900, Masahiro Yamada wrote:
> Originally, bpfilter_umh was linked with -static only when
> CONFIG_BPFILTER_UMH=y.
> 
> Commit 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build
> bpfilter_umh") silently, accidentally dropped the CONFIG_BPFILTER_UMH=y
> test in the Makefile. Revive it in order to link it dynamically when
> CONFIG_BPFILTER_UMH=m.
> 
> Since commit b1183b6dca3e ("bpfilter: check if $(CC) can link static
> libc in Kconfig"), the compiler must be capable of static linking to
> enable CONFIG_BPFILTER_UMH, but it requires more than needed.
> 
> To loosen the compiler requirement, I changed the dependency as follows:
> 
>     depends on CC_CAN_LINK
>     depends on m || CC_CAN_LINK_STATIC
> 
> If CONFIG_CC_CAN_LINK_STATIC in unset, CONFIG_BPFILTER_UMH is restricted
> to 'm' or 'n'.
> 
> In theory, CONFIG_CC_CAN_LINK is not required for CONFIG_BPFILTER_UMH=y,
> but I did not come up with a good way to describe it.
> 
> Fixes: 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build bpfilter_umh")
> Reported-by: Michal Kubecek <mkubecek@suse.cz>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Tested-by: Michal Kubecek <mkubecek@suse.cz>

Thank you,
Michal

> ---
> 
>  net/bpfilter/Kconfig  | 10 ++++++----
>  net/bpfilter/Makefile |  2 ++
>  2 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/net/bpfilter/Kconfig b/net/bpfilter/Kconfig
> index 84015ef3ee27..73d0b12789f1 100644
> --- a/net/bpfilter/Kconfig
> +++ b/net/bpfilter/Kconfig
> @@ -9,12 +9,14 @@ menuconfig BPFILTER
>  if BPFILTER
>  config BPFILTER_UMH
>  	tristate "bpfilter kernel module with user mode helper"
> -	depends on CC_CAN_LINK_STATIC
> +	depends on CC_CAN_LINK
> +	depends on m || CC_CAN_LINK_STATIC
>  	default m
>  	help
>  	  This builds bpfilter kernel module with embedded user mode helper
>  
> -	  Note: your toolchain must support building static binaries, since
> -	  rootfs isn't mounted at the time when __init functions are called
> -	  and do_execv won't be able to find the elf interpreter.
> +	  Note: To compile this as built-in, your toolchain must support
> +	  building static binaries, since rootfs isn't mounted at the time
> +	  when __init functions are called and do_execv won't be able to find
> +	  the elf interpreter.
>  endif
> diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile
> index f23b53294fba..cdac82b8c53a 100644
> --- a/net/bpfilter/Makefile
> +++ b/net/bpfilter/Makefile
> @@ -7,10 +7,12 @@ userprogs := bpfilter_umh
>  bpfilter_umh-objs := main.o
>  userccflags += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi
>  
> +ifeq ($(CONFIG_BPFILTER_UMH), y)
>  # builtin bpfilter_umh should be linked with -static
>  # since rootfs isn't mounted at the time of __init
>  # function is called and do_execv won't find elf interpreter
>  userldflags += -static
> +endif
>  
>  $(obj)/bpfilter_umh_blob.o: $(obj)/bpfilter_umh
>  
> -- 
> 2.25.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] bpfilter: allow to build bpfilter_umh as a module without static library
  2020-07-01  9:26 [PATCH] bpfilter: allow to build bpfilter_umh as a module without static library Masahiro Yamada
  2020-07-01 12:57 ` Michal Kubecek
@ 2020-07-01 17:46 ` Alexei Starovoitov
  2020-07-01 17:50   ` Masahiro Yamada
  1 sibling, 1 reply; 5+ messages in thread
From: Alexei Starovoitov @ 2020-07-01 17:46 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Alexei Starovoitov, netdev, bpf, linux-kbuild, Michal Kubecek,
	linux-kernel, Andrii Nakryiko, Daniel Borkmann, David S. Miller,
	Jakub Kicinski, John Fastabend, KP Singh, Martin KaFai Lau,
	Sam Ravnborg, Song Liu, Valdis Kl ē tnieks, Yonghong Song

On Wed, Jul 01, 2020 at 06:26:44PM +0900, Masahiro Yamada wrote:
> Originally, bpfilter_umh was linked with -static only when
> CONFIG_BPFILTER_UMH=y.
> 
> Commit 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build
> bpfilter_umh") silently, accidentally dropped the CONFIG_BPFILTER_UMH=y
> test in the Makefile. Revive it in order to link it dynamically when
> CONFIG_BPFILTER_UMH=m.
> 
> Since commit b1183b6dca3e ("bpfilter: check if $(CC) can link static
> libc in Kconfig"), the compiler must be capable of static linking to
> enable CONFIG_BPFILTER_UMH, but it requires more than needed.
> 
> To loosen the compiler requirement, I changed the dependency as follows:
> 
>     depends on CC_CAN_LINK
>     depends on m || CC_CAN_LINK_STATIC
> 
> If CONFIG_CC_CAN_LINK_STATIC in unset, CONFIG_BPFILTER_UMH is restricted
> to 'm' or 'n'.
> 
> In theory, CONFIG_CC_CAN_LINK is not required for CONFIG_BPFILTER_UMH=y,
> but I did not come up with a good way to describe it.
> 
> Fixes: 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build bpfilter_umh")
> Reported-by: Michal Kubecek <mkubecek@suse.cz>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

lgtm
Do you mind I'll take it into bpf-next tree?
Eric is working on a bunch of patches in this area. I'll take his set
into bpf-next as well and then can apply this patch.
Just to make sure there are no conflicts.

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

* Re: [PATCH] bpfilter: allow to build bpfilter_umh as a module without static library
  2020-07-01 17:46 ` Alexei Starovoitov
@ 2020-07-01 17:50   ` Masahiro Yamada
  2020-07-14 19:39     ` Alexei Starovoitov
  0 siblings, 1 reply; 5+ messages in thread
From: Masahiro Yamada @ 2020-07-01 17:50 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Alexei Starovoitov, Networking, bpf, Linux Kbuild mailing list,
	Michal Kubecek, Linux Kernel Mailing List, Andrii Nakryiko,
	Daniel Borkmann, David S. Miller, Jakub Kicinski, John Fastabend,
	KP Singh, Martin KaFai Lau, Sam Ravnborg, Song Liu,
	Valdis Kl ē tnieks, Yonghong Song

On Thu, Jul 2, 2020 at 2:46 AM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Wed, Jul 01, 2020 at 06:26:44PM +0900, Masahiro Yamada wrote:
> > Originally, bpfilter_umh was linked with -static only when
> > CONFIG_BPFILTER_UMH=y.
> >
> > Commit 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build
> > bpfilter_umh") silently, accidentally dropped the CONFIG_BPFILTER_UMH=y
> > test in the Makefile. Revive it in order to link it dynamically when
> > CONFIG_BPFILTER_UMH=m.
> >
> > Since commit b1183b6dca3e ("bpfilter: check if $(CC) can link static
> > libc in Kconfig"), the compiler must be capable of static linking to
> > enable CONFIG_BPFILTER_UMH, but it requires more than needed.
> >
> > To loosen the compiler requirement, I changed the dependency as follows:
> >
> >     depends on CC_CAN_LINK
> >     depends on m || CC_CAN_LINK_STATIC
> >
> > If CONFIG_CC_CAN_LINK_STATIC in unset, CONFIG_BPFILTER_UMH is restricted
> > to 'm' or 'n'.
> >
> > In theory, CONFIG_CC_CAN_LINK is not required for CONFIG_BPFILTER_UMH=y,
> > but I did not come up with a good way to describe it.
> >
> > Fixes: 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build bpfilter_umh")
> > Reported-by: Michal Kubecek <mkubecek@suse.cz>
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>
> lgtm
> Do you mind I'll take it into bpf-next tree?
> Eric is working on a bunch of patches in this area. I'll take his set
> into bpf-next as well and then can apply this patch.
> Just to make sure there are no conflicts.

Please go ahead.

Thank you.


-- 
Best Regards
Masahiro Yamada

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

* Re: [PATCH] bpfilter: allow to build bpfilter_umh as a module without static library
  2020-07-01 17:50   ` Masahiro Yamada
@ 2020-07-14 19:39     ` Alexei Starovoitov
  0 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2020-07-14 19:39 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Alexei Starovoitov, Networking, bpf, Linux Kbuild mailing list,
	Michal Kubecek, Linux Kernel Mailing List, Andrii Nakryiko,
	Daniel Borkmann, David S. Miller, Jakub Kicinski, John Fastabend,
	KP Singh, Martin KaFai Lau, Sam Ravnborg, Song Liu,
	Valdis Kl ē tnieks, Yonghong Song

On Wed, Jul 1, 2020 at 10:50 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Thu, Jul 2, 2020 at 2:46 AM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
> >
> > On Wed, Jul 01, 2020 at 06:26:44PM +0900, Masahiro Yamada wrote:
> > > Originally, bpfilter_umh was linked with -static only when
> > > CONFIG_BPFILTER_UMH=y.
> > >
> > > Commit 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build
> > > bpfilter_umh") silently, accidentally dropped the CONFIG_BPFILTER_UMH=y
> > > test in the Makefile. Revive it in order to link it dynamically when
> > > CONFIG_BPFILTER_UMH=m.
> > >
> > > Since commit b1183b6dca3e ("bpfilter: check if $(CC) can link static
> > > libc in Kconfig"), the compiler must be capable of static linking to
> > > enable CONFIG_BPFILTER_UMH, but it requires more than needed.
> > >
> > > To loosen the compiler requirement, I changed the dependency as follows:
> > >
> > >     depends on CC_CAN_LINK
> > >     depends on m || CC_CAN_LINK_STATIC
> > >
> > > If CONFIG_CC_CAN_LINK_STATIC in unset, CONFIG_BPFILTER_UMH is restricted
> > > to 'm' or 'n'.
> > >
> > > In theory, CONFIG_CC_CAN_LINK is not required for CONFIG_BPFILTER_UMH=y,
> > > but I did not come up with a good way to describe it.
> > >
> > > Fixes: 8a2cc0505cc4 ("bpfilter: use 'userprogs' syntax to build bpfilter_umh")
> > > Reported-by: Michal Kubecek <mkubecek@suse.cz>
> > > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> >
> > lgtm
> > Do you mind I'll take it into bpf-next tree?
> > Eric is working on a bunch of patches in this area. I'll take his set
> > into bpf-next as well and then can apply this patch.
> > Just to make sure there are no conflicts.
>
> Please go ahead.

I've merged Eric's set and applied yours on top.
Thanks

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

end of thread, other threads:[~2020-07-14 19:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-01  9:26 [PATCH] bpfilter: allow to build bpfilter_umh as a module without static library Masahiro Yamada
2020-07-01 12:57 ` Michal Kubecek
2020-07-01 17:46 ` Alexei Starovoitov
2020-07-01 17:50   ` Masahiro Yamada
2020-07-14 19:39     ` Alexei Starovoitov

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