Skip to contentSkip to conversation

bpf: mark get_entry_ip as __maybe_unused

PATCH In review Jonas Rabenstein 3 participants 7 messages Nov 3, 2022 – Nov 7, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: mark get_entry_ip as __maybe_unused

Commit c09eb2e578eb1668bbc ("bpf: Adjust kprobe_multi entry_ip for CONFIG_X86_KERNEL_IBT") introduced the get_entry_ip() function. Depending on CONFIG_X86_KERNEL_IBT it is a static function or only a macro definition. The only user of this symbol so far is in kprobe_multi_link_handler() if CONFIG_FPROBE is enabled. If CONFIG_FROBE is not set, the symbol is not used and - depending on CONFIG_X86_KERNEL_IBT - a warning for get_entry_ip() is emitted. To solve this, the function should be marked as __maybe_unused.

---
 kernel/trace/bpf_trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/bpf_trace.c +1 -1
index f2d8d070d024..19131aae0bc3 100644
@@ -1032,7 +1032,7 @@ static const struct bpf_func_proto bpf_get_func_ip_proto_tracing = {
 };
 
 #ifdef CONFIG_X86_KERNEL_IBT
-static unsigned long get_entry_ip(unsigned long fentry_ip)
+static unsigned long __maybe_unused get_entry_ip(unsigned long fentry_ip)
 {
 	u32 instr;
 
Signature · 1 line
2.37.4
#1 lore raw

Hi again,
after sending this out, I noticed this is only a problem in the stable versions (starting from v6.0.3), as c09eb2e578eb1668bbc has been applied (as 03f148c159a250dd454) but not 0e253f7e558a3e250902 ("bpf: Return value in kprobe get_func_ip only for entry address") which makes always use of get_entry_ip. I therefore think, 0e253f7e558a3e250902 needs to be added to the stable v6.0 series as well as otherwise it can't be compiled with -Werror if CONFIG_X6_KERNEL_IBT is set but CONFIG_FPROBE isn't.

- Jonas

Quoted 30 lines · Jonas Rabenstein

Commit c09eb2e578eb1668bbc ("bpf: Adjust kprobe_multi entry_ip for CONFIG_X86_KERNEL_IBT") introduced the get_entry_ip() function. Depending on CONFIG_X86_KERNEL_IBT it is a static function or only a macro definition. The only user of this symbol so far is in kprobe_multi_link_handler() if CONFIG_FPROBE is enabled. If CONFIG_FROBE is not set, the symbol is not used and - depending on CONFIG_X86_KERNEL_IBT - a warning for get_entry_ip() is emitted. To solve this, the function should be marked as __maybe_unused.

---
 kernel/trace/bpf_trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/bpf_trace.c +1 -1
index f2d8d070d024..19131aae0bc3 100644
@@ -1032,7 +1032,7 @@ static const struct bpf_func_proto bpf_get_func_ip_proto_tracing = {
 };
 
 #ifdef CONFIG_X86_KERNEL_IBT
-static unsigned long get_entry_ip(unsigned long fentry_ip)
+static unsigned long __maybe_unused get_entry_ip(unsigned long fentry_ip)
 {
 	u32 instr;
 
Signature · 1 line
2.37.4
maintainer
#2 lore raw
Quoted 8 lines · Jonas Rabenstein

Hi again,
after sending this out, I noticed this is only a problem in the stable versions (starting from v6.0.3), as c09eb2e578eb1668bbc has been applied (as 03f148c159a250dd454) but not 0e253f7e558a3e250902 ("bpf: Return value in kprobe get_func_ip only for entry address") which makes always use of get_entry_ip. I therefore think, 0e253f7e558a3e250902 needs to be added to the stable v6.0 series as well as otherwise it can't be compiled with -Werror if CONFIG_X6_KERNEL_IBT is set but CONFIG_FPROBE isn't.

Thanks for the info, Jonas. Added Greg wrt stable cherry-pick.

Quoted 31 lines · Jonas Rabenstein
Quoted 30 lines

Commit c09eb2e578eb1668bbc ("bpf: Adjust kprobe_multi entry_ip for CONFIG_X86_KERNEL_IBT") introduced the get_entry_ip() function. Depending on CONFIG_X86_KERNEL_IBT it is a static function or only a macro definition. The only user of this symbol so far is in kprobe_multi_link_handler() if CONFIG_FPROBE is enabled. If CONFIG_FROBE is not set, the symbol is not used and - depending on CONFIG_X86_KERNEL_IBT - a warning for get_entry_ip() is emitted. To solve this, the function should be marked as __maybe_unused.

---
  kernel/trace/bpf_trace.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/bpf_trace.c +1 -1
index f2d8d070d024..19131aae0bc3 100644
@@ -1032,7 +1032,7 @@ static const struct bpf_func_proto bpf_get_func_ip_proto_tracing = {
  };
 
  #ifdef CONFIG_X86_KERNEL_IBT
-static unsigned long get_entry_ip(unsigned long fentry_ip)
+static unsigned long __maybe_unused get_entry_ip(unsigned long fentry_ip)
  {
  	u32 instr;
 
Signature · 1 line
2.37.4
maintainer
#3 lore raw
In reply to Jonas Rabenstein
Quoted 8 lines · Jonas Rabenstein

Hi again,
after sending this out, I noticed this is only a problem in the stable versions (starting from v6.0.3), as c09eb2e578eb1668bbc has been applied (as 03f148c159a250dd454) but not 0e253f7e558a3e250902 ("bpf: Return value in kprobe get_func_ip only for entry address") which makes always use of get_entry_ip. I therefore think, 0e253f7e558a3e250902 needs to be added to the stable v6.0 series as well as otherwise it can't be compiled with -Werror if CONFIG_X6_KERNEL_IBT is set but CONFIG_FPROBE isn't.

Ok, now queued up, thanks.

greg k-h

maintainer
#4 lore raw
Quoted 11 lines · Greg KH
Quoted 8 lines · Jonas Rabenstein

Hi again,
after sending this out, I noticed this is only a problem in the stable versions (starting from v6.0.3), as c09eb2e578eb1668bbc has been applied (as 03f148c159a250dd454) but not 0e253f7e558a3e250902 ("bpf: Return value in kprobe get_func_ip only for entry address") which makes always use of get_entry_ip. I therefore think, 0e253f7e558a3e250902 needs to be added to the stable v6.0 series as well as otherwise it can't be compiled with -Werror if CONFIG_X6_KERNEL_IBT is set but CONFIG_FPROBE isn't.

Ok, now queued up, thanks.

Oops, this breaks the build, now dropping.

greg k-h

#5 lore raw
Quoted 11 lines · Greg KH
Quoted 10 lines · Greg KH
Quoted 8 lines · Jonas Rabenstein

Hi again,
after sending this out, I noticed this is only a problem in the stable versions (starting from v6.0.3), as c09eb2e578eb1668bbc has been applied (as 03f148c159a250dd454) but not 0e253f7e558a3e250902 ("bpf: Return value in kprobe get_func_ip only for entry address") which makes always use of get_entry_ip. I therefore think, 0e253f7e558a3e250902 needs to be added to the stable v6.0 series as well as otherwise it can't be compiled with -Werror if CONFIG_X6_KERNEL_IBT is set but CONFIG_FPROBE isn't.

Quoted 3 lines
Quoted 1 line

Ok, now queued up, thanks.

Oops, this breaks the build, now dropping.

Sorry, 0e253f7e558a3e250902 ("bpf: Return value in kprobe get_func_ip only for entry address") uses the macro KPROBE_FLAG_ON_FUNC_ENTRY that was introduced in bf7a87f1075f67c286f7 ("kprobes: Add new KPROBE_FLAG_ON_FUNC_ENTRY kprobe flag"). Applying those on top of v6.0.7 fixes the original compilation problem (CONFIG_X6_KERNEL_IBT but !CONFIG_FPROBE) and should not break anything
- jonas

Quoted 2 lines

greg k-h

maintainer
#6 lore raw
Quoted 12 lines · Jonas Rabenstein
Quoted 11 lines · Greg KH
Quoted 10 lines · Greg KH
Quoted 8 lines · Jonas Rabenstein

Hi again,
after sending this out, I noticed this is only a problem in the stable versions (starting from v6.0.3), as c09eb2e578eb1668bbc has been applied (as 03f148c159a250dd454) but not 0e253f7e558a3e250902 ("bpf: Return value in kprobe get_func_ip only for entry address") which makes always use of get_entry_ip. I therefore think, 0e253f7e558a3e250902 needs to be added to the stable v6.0 series as well as otherwise it can't be compiled with -Werror if CONFIG_X6_KERNEL_IBT is set but CONFIG_FPROBE isn't.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Ok, now queued up, thanks.

Oops, this breaks the build, now dropping.

Sorry, 0e253f7e558a3e250902 ("bpf: Return value in kprobe get_func_ip only for entry address") uses the macro KPROBE_FLAG_ON_FUNC_ENTRY that was introduced in bf7a87f1075f67c286f7 ("kprobes: Add new KPROBE_FLAG_ON_FUNC_ENTRY kprobe flag"). Applying those on top of v6.0.7 fixes the original compilation problem (CONFIG_X6_KERNEL_IBT but !CONFIG_FPROBE) and should not break anything

Please submit a set of backports that you have verified works properly so that I know it is correct.

thanks,

greg k-h