Fix undefined symbol references for module build post cnum changes
PATCH 1/1 Fix undefined symbol references for module build post cnum changes
Seeing the following on bpf-next:
DESCEND objtool
DESCEND bpf/resolve_btfids
INSTALL libsubcmd_headers
INSTALL libsubcmd_headers
MODPOST Module.symvers
ERROR: modpost: "cnum64_umin" [drivers/net/ethernet/netronome/nfp/nfp.ko] undefined!
ERROR: modpost: "cnum64_umax" [drivers/net/ethernet/netronome/nfp/nfp.ko] undefined! make[2]: *** [scripts/Makefile.modpost:147: Module.symvers] Error 1 make[1]: *** [bpf-next/Makefile:2089: modpost] Error 2
make: *** [Makefile:248: __sub-make] Error 2
Further investigation suggests nfp indeed does pull in those symbols, likely due to references in include/linux/bpf_verifier.h:
static inline s64 reg_smax(const struct bpf_reg_state *reg)
{
return cnum64_smax(reg->r64);
}static inline u64 reg_umin(const struct bpf_reg_state *reg)
{
return cnum64_umin(reg->r64);
}...
Export symbols for these references.
--- kernel/bpf/cnum_defs.h | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/bpf/cnum_defs.h +7 -0
@@ -6,6 +6,7 @@#endif #include <linux/cnum.h> +#include <linux/kernel.h> #include <linux/limits.h> #include <linux/minmax.h> #include <linux/compiler_types.h>
@@ -23,6 +24,7 @@ struct cnum_t FN(from_urange)(ut min, ut max) {return (struct cnum_t ){ .base = min, .size = (ut )max - min }; } +EXPORT_SYMBOL_GPL (FN (from_urange));struct cnum_t FN (from_srange )(st min,st max) {
@@ -31,6 +33,7 @@ struct cnum_t FN(from_srange)(st min, st max)return (struct cnum_t ){ .base = base, .size = size }; } +EXPORT_SYMBOL_GPL (FN (from_srange));/* True if this cnum represents two unsigned ranges. */ static inline bool FN (urange_overflow )(struct cnum_t cnum)
@@ -48,11 +51,13 @@ ut FN(umin)(struct cnum_t cnum) {return FN (urange_overflow)(cnum) ?0 : cnum.base; } +EXPORT_SYMBOL_GPL (FN (umin));ut FN (umax )(struct cnum_t cnum) {return FN (urange_overflow)(cnum) ?UT_MAX : cnum.base + cnum.size; } +EXPORT_SYMBOL_GPL (FN (umax));/* True if this cnum represents two signed ranges. */ static inline bool FN (srange_overflow )(struct cnum_t cnum)
@@ -71,6 +76,7 @@ st FN(smin)(struct cnum_t cnum) ? ST_MIN :min ((st )cnum.base, (st)(cnum.base + cnum.size)); } +EXPORT_SYMBOL_GPL (FN (smin));st FN (smax )(struct cnum_t cnum) {
@@ -78,6 +84,7 @@ st FN(smax)(struct cnum_t cnum) ? ST_MAX :max ((st )cnum.base, (st)(cnum.base + cnum.size)); } +EXPORT_SYMBOL_GPL (FN (smax));/* * Returns a possibly empty intersection of cnums 'a' and 'b'.
Signature · 1 line
2.39.3
Quoted 97 lines · Alan Maguire
Seeing the following on bpf-next:
DESCEND objtool
DESCEND bpf/resolve_btfids
INSTALLlibsubcmd_headers
INSTALLlibsubcmd_headers
MODPOST Module.symvers
ERROR: modpost: "cnum64_umin" [drivers/net/ethernet/netronome/nfp/nfp.ko] undefined!
ERROR: modpost: "cnum64_umax" [drivers/net/ethernet/netronome/nfp/nfp.ko] undefined! make[2]: *** [scripts/Makefile.modpost:147: Module.symvers] Error 1 make[1]: *** [bpf-next/Makefile:2089: modpost] Error 2
make: *** [Makefile:248: __sub-make] Error 2Further investigation suggests nfp indeed does pull in those symbols, likely due to references in
include/linux/bpf_verifier.h:static inline s64
reg_smax(const struct bpf_reg_state *reg){ return cnum64_smax(reg->r64); }static inline u64
reg_umin(const struct bpf_reg_state *reg){ return cnum64_umin(reg->r64); }...
Export symbols for these references.
Reported-by Kaitao Cheng <[email protected]>Fixes bbc631085503 ("bpf: replace min/max fields with struct cnum{32,64}")Signed-off-by Alan Maguire <[email protected]>--- kernel/bpf/cnum_defs.h | 7 +++++++ 1 file changed, 7 insertions(+)kernel/bpf/cnum_defs.h +7
-1@@ -6,6 +6,7 @@#endif #include <linux/cnum.h> +#include <linux/kernel.h> #include <linux/limits.h> #include <linux/minmax.h> #include <linux/compiler_types.h> @@ -23,6 +24,7 @@ struct cnum_t FN(from_urange)(ut min, ut max) {return (struct cnum_t ){ .base = min, .size = (ut )max - min }; } +EXPORT_SYMBOL_GPL (FN (from_urange));struct cnum_t FN (from_srange )(st min,st max) {@@ -31,6 +33,7 @@ struct cnum_t FN(from_srange)(st min, st max)return (struct cnum_t ){ .base = base, .size = size }; } +EXPORT_SYMBOL_GPL (FN (from_srange));/* True if this cnum represents two unsigned ranges. */ static inline bool FN (urange_overflow )(struct cnum_t cnum)@@ -48,11 +51,13 @@ ut FN(umin)(struct cnum_t cnum) {return FN (urange_overflow)(cnum) ?0 : cnum.base; } +EXPORT_SYMBOL_GPL (FN (umin));ut FN (umax )(struct cnum_t cnum) {return FN (urange_overflow)(cnum) ?UT_MAX : cnum.base + cnum.size; } +EXPORT_SYMBOL_GPL (FN (umax));/* True if this cnum represents two signed ranges. */ static inline bool FN (srange_overflow )(struct cnum_t cnum)@@ -71,6 +76,7 @@ st FN(smin)(struct cnum_t cnum) ? ST_MIN :min ((st )cnum.base, (st)(cnum.base + cnum.size)); } +EXPORT_SYMBOL_GPL (FN (smin));st FN (smax )(struct cnum_t cnum) {@@ -78,6 +84,7 @@ st FN(smax)(struct cnum_t cnum) ? ST_MAX :max ((st )cnum.base, (st)(cnum.base + cnum.size)); } +EXPORT_SYMBOL_GPL (FN (smax));/* * Returns a possibly empty intersection of cnums 'a' and 'b'. --
Quoted 2 lines
2.39.3
LGFM.
Signature · 2 lines
Yours, Chengkaitao
Quoted 26 lines · Alan Maguire
Seeing the following on bpf-next:
DESCEND objtool
DESCEND bpf/resolve_btfids
INSTALLlibsubcmd_headers
INSTALLlibsubcmd_headers
MODPOST Module.symvers
ERROR: modpost: "cnum64_umin" [drivers/net/ethernet/netronome/nfp/nfp.ko] undefined!
ERROR: modpost: "cnum64_umax" [drivers/net/ethernet/netronome/nfp/nfp.ko] undefined! make[2]: *** [scripts/Makefile.modpost:147: Module.symvers] Error 1 make[1]: *** [bpf-next/Makefile:2089: modpost] Error 2
make: *** [Makefile:248: __sub-make] Error 2Further investigation suggests nfp indeed does pull in those symbols, likely due to references in
include/linux/bpf_verifier.h:static inline s64
reg_smax(const struct bpf_reg_state *reg){ return cnum64_smax(reg->r64); }static inline u64
reg_umin(const struct bpf_reg_state *reg){ return cnum64_umin(reg->r64); }
Quoted 8 lines
...
Export symbols for these references.
Reported-by Kaitao Cheng <[email protected]>Fixes bbc631085503 ("bpf: replace min/max fields with struct cnum{32,64}")Signed-off-by Alan Maguire <[email protected]>---
Hi Alan,
thank you for the fix, apologies for breaking this.
[...]
Eduard Zingerman
maintainerQuoted 36 lines · Eduard Zingerman
Quoted 26 lines · Alan Maguire
Seeing the following on bpf-next:
DESCEND objtool
DESCEND bpf/resolve_btfids
INSTALLlibsubcmd_headers
INSTALLlibsubcmd_headers
MODPOST Module.symvers
ERROR: modpost: "cnum64_umin" [drivers/net/ethernet/netronome/nfp/nfp.ko] undefined!
ERROR: modpost: "cnum64_umax" [drivers/net/ethernet/netronome/nfp/nfp.ko] undefined! make[2]: *** [scripts/Makefile.modpost:147: Module.symvers] Error 1 make[1]: *** [bpf-next/Makefile:2089: modpost] Error 2
make: *** [Makefile:248: __sub-make] Error 2Further investigation suggests nfp indeed does pull in those symbols, likely due to references in
include/linux/bpf_verifier.h:static inline s64
reg_smax(const struct bpf_reg_state *reg){ return cnum64_smax(reg->r64); }static inline u64
reg_umin(const struct bpf_reg_state *reg){ return cnum64_umin(reg->r64); }Quoted 8 lines
...
Export symbols for these references.
Reported-by Kaitao Cheng <[email protected]>Fixes bbc631085503 ("bpf: replace min/max fields with struct cnum{32,64}")Signed-off-by Alan Maguire <[email protected]>---
Quoted 5 lines
Hi Alan,
thank you for the fix, apologies for breaking this.
Acked-by Eduard Zingerman <[email protected]>
However, Alexei raises a valid question.
Netronome code uses the following accessors:
- cnum{32,64}_reg_umin
- cnum{32,64}_reg_umax
However, this patch also exports the following on top:
- cnum{32,64}_from_{urange,srange}
- cnum{32,64}_reg_smin
- cnum{32,64}_reg_smax
Why export extra accessors?
Quoted 49 lines · Eduard Zingerman
Quoted 36 lines · Eduard Zingerman
Quoted 26 lines · Alan Maguire
Seeing the following on bpf-next:
DESCEND objtool
DESCEND bpf/resolve_btfids
INSTALLlibsubcmd_headers
INSTALLlibsubcmd_headers
MODPOST Module.symvers
ERROR: modpost: "cnum64_umin" [drivers/net/ethernet/netronome/nfp/nfp.ko] undefined!
ERROR: modpost: "cnum64_umax" [drivers/net/ethernet/netronome/nfp/nfp.ko] undefined! make[2]: *** [scripts/Makefile.modpost:147: Module.symvers] Error 1 make[1]: *** [bpf-next/Makefile:2089: modpost] Error 2
make: *** [Makefile:248: __sub-make] Error 2Further investigation suggests nfp indeed does pull in those symbols, likely due to references in
include/linux/bpf_verifier.h:static inline s64
reg_smax(const struct bpf_reg_state *reg){ return cnum64_smax(reg->r64); }static inline u64
reg_umin(const struct bpf_reg_state *reg){ return cnum64_umin(reg->r64); }Quoted 8 lines
...
Export symbols for these references.
Reported-by Kaitao Cheng <[email protected]>Fixes bbc631085503 ("bpf: replace min/max fields with struct cnum{32,64}")Signed-off-by Alan Maguire <[email protected]>---
Quoted 5 lines
Hi Alan,
thank you for the fix, apologies for breaking this.
Acked-by Eduard Zingerman <[email protected]>However, Alexei raises a valid question.
Netronome code uses the following accessors:
- cnum{32,64}_reg_umin
- cnum{32,64}_reg_umax
Quoted 6 lines
However, this patch also exports the following on top:
- cnum{32,64}_from_{urange,srange}
- cnum{32,64}_reg_smin
- cnum{32,64}_reg_smaxWhy export extra accessors?
I left only 2 while applying and rewrote commit log.
Quoted 50 lines · Alexei Starovoitov
Quoted 49 lines · Eduard Zingerman
Quoted 36 lines · Eduard Zingerman
Quoted 26 lines · Alan Maguire
Seeing the following on bpf-next:
DESCEND objtool
DESCEND bpf/resolve_btfids
INSTALLlibsubcmd_headers
INSTALLlibsubcmd_headers
MODPOST Module.symvers
ERROR: modpost: "cnum64_umin" [drivers/net/ethernet/netronome/nfp/nfp.ko] undefined!
ERROR: modpost: "cnum64_umax" [drivers/net/ethernet/netronome/nfp/nfp.ko] undefined! make[2]: *** [scripts/Makefile.modpost:147: Module.symvers] Error 1 make[1]: *** [bpf-next/Makefile:2089: modpost] Error 2
make: *** [Makefile:248: __sub-make] Error 2Further investigation suggests nfp indeed does pull in those symbols, likely due to references in
include/linux/bpf_verifier.h:static inline s64
reg_smax(const struct bpf_reg_state *reg){ return cnum64_smax(reg->r64); }static inline u64
reg_umin(const struct bpf_reg_state *reg){ return cnum64_umin(reg->r64); }Quoted 8 lines
...
Export symbols for these references.
Reported-by Kaitao Cheng <[email protected]>Fixes bbc631085503 ("bpf: replace min/max fields with struct cnum{32,64}")Signed-off-by Alan Maguire <[email protected]>---
Quoted 5 lines
Hi Alan,
thank you for the fix, apologies for breaking this.
Acked-by Eduard Zingerman <[email protected]>However, Alexei raises a valid question.
Netronome code uses the following accessors:
- cnum{32,64}_reg_umin
- cnum{32,64}_reg_umax
Quoted 8 lines
Quoted 6 lines
However, this patch also exports the following on top:
- cnum{32,64}_from_{urange,srange}
- cnum{32,64}_reg_smin
- cnum{32,64}_reg_smaxWhy export extra accessors?
I left only 2 while applying and rewrote commit log.
Yep, I just added the accessors as they are potentially available to consumers via bpf_verifier.h. No actual users today though as far as I could see. Thanks!