[PATCH v7 0/2] bpftool: Refactor config parsing and add CET symbol matching

chenyuan_fl@163.com posted 2 patches 1 month, 1 week ago
There is a newer version of this series
tools/bpf/bpftool/common.c  | 93 +++++++++++++++++++++++++++++++++++++
tools/bpf/bpftool/feature.c | 86 ++--------------------------------
tools/bpf/bpftool/link.c    | 38 ++++++++++++++-
tools/bpf/bpftool/main.h    |  9 ++++
4 files changed, 142 insertions(+), 84 deletions(-)
[PATCH v7 0/2] bpftool: Refactor config parsing and add CET symbol matching
Posted by chenyuan_fl@163.com 1 month, 1 week ago
From: Yuan CHen <chenyuan@kylinos.cn>

1. **Refactor kernel config parsing**  
   - Moves duplicate config file handling from feature.c to common.c  
   - Keeps all existing functionality while enabling code reuse  

2. **Add CET-aware symbol matching**  
   - Adjusts kprobe hook detection for x86_64 CET (endbr32/64 prefixes)  
   - Matches symbols at both original and CET-adjusted addresses  

Changed in PATCH v4:
* Refactor repeated code into a function.
* Add detection for the x86 architecture.

Changed int PATH v5:
* Remove detection for the x86 architecture.

 Changed in PATCH v6:
* Add new helper patch (1/2) to refactor kernel config reading
* Use the new read_kernel_config() in CET symbol matching (2/2) to check CONFIG_X86_KERNEL_IBT

Changed in PATCH v7:
* Display actual kprobe attachment addresses instead of symbol addresses

Yuan Chen (2):
  bpftool: Refactor kernel config reading into common helper
  bpftool: Add CET-aware symbol matching for x86_64 architectures

 tools/bpf/bpftool/common.c  | 93 +++++++++++++++++++++++++++++++++++++
 tools/bpf/bpftool/feature.c | 86 ++--------------------------------
 tools/bpf/bpftool/link.c    | 38 ++++++++++++++-
 tools/bpf/bpftool/main.h    |  9 ++++
 4 files changed, 142 insertions(+), 84 deletions(-)

-- 
2.39.5
Re: [PATCH v7 0/2] bpftool: Refactor config parsing and add CET symbol matching
Posted by Andrii Nakryiko 1 month ago
On Sun, Aug 24, 2025 at 7:20 PM <chenyuan_fl@163.com> wrote:
>
> From: Yuan CHen <chenyuan@kylinos.cn>
>
> 1. **Refactor kernel config parsing**
>    - Moves duplicate config file handling from feature.c to common.c
>    - Keeps all existing functionality while enabling code reuse
>
> 2. **Add CET-aware symbol matching**
>    - Adjusts kprobe hook detection for x86_64 CET (endbr32/64 prefixes)
>    - Matches symbols at both original and CET-adjusted addresses
>

Quentin, can you please take a quick look at this patch set, when you
get a chance? Thanks!

> Changed in PATCH v4:
> * Refactor repeated code into a function.
> * Add detection for the x86 architecture.
>
> Changed int PATH v5:
> * Remove detection for the x86 architecture.
>
>  Changed in PATCH v6:
> * Add new helper patch (1/2) to refactor kernel config reading
> * Use the new read_kernel_config() in CET symbol matching (2/2) to check CONFIG_X86_KERNEL_IBT
>
> Changed in PATCH v7:
> * Display actual kprobe attachment addresses instead of symbol addresses
>
> Yuan Chen (2):
>   bpftool: Refactor kernel config reading into common helper
>   bpftool: Add CET-aware symbol matching for x86_64 architectures
>
>  tools/bpf/bpftool/common.c  | 93 +++++++++++++++++++++++++++++++++++++
>  tools/bpf/bpftool/feature.c | 86 ++--------------------------------
>  tools/bpf/bpftool/link.c    | 38 ++++++++++++++-
>  tools/bpf/bpftool/main.h    |  9 ++++
>  4 files changed, 142 insertions(+), 84 deletions(-)
>
> --
> 2.39.5
>
Re: [PATCH v7 0/2] bpftool: Refactor config parsing and add CET symbol matching
Posted by Quentin Monnet 1 month ago
2025-08-27 14:53 UTC-0700 ~ Andrii Nakryiko <andrii.nakryiko@gmail.com>
> On Sun, Aug 24, 2025 at 7:20 PM <chenyuan_fl@163.com> wrote:
>>
>> From: Yuan CHen <chenyuan@kylinos.cn>
>>
>> 1. **Refactor kernel config parsing**
>>    - Moves duplicate config file handling from feature.c to common.c
>>    - Keeps all existing functionality while enabling code reuse
>>
>> 2. **Add CET-aware symbol matching**
>>    - Adjusts kprobe hook detection for x86_64 CET (endbr32/64 prefixes)
>>    - Matches symbols at both original and CET-adjusted addresses
>>
> 
> Quentin, can you please take a quick look at this patch set, when you
> get a chance? Thanks!


Yes! Both patches look good to me. For the series:

Acked-by: Quentin Monnet <qmo@kernel.org>

Thanks for this work
Re: [PATCH v7 0/2] bpftool: Refactor config parsing and add CET symbol matching
Posted by Jiri Olsa 1 month, 1 week ago
On Mon, Aug 25, 2025 at 03:20:00AM +0100, chenyuan_fl@163.com wrote:
> From: Yuan CHen <chenyuan@kylinos.cn>
> 
> 1. **Refactor kernel config parsing**  
>    - Moves duplicate config file handling from feature.c to common.c  
>    - Keeps all existing functionality while enabling code reuse  
> 
> 2. **Add CET-aware symbol matching**  
>    - Adjusts kprobe hook detection for x86_64 CET (endbr32/64 prefixes)  
>    - Matches symbols at both original and CET-adjusted addresses  
> 
> Changed in PATCH v4:
> * Refactor repeated code into a function.
> * Add detection for the x86 architecture.
> 
> Changed int PATH v5:
> * Remove detection for the x86 architecture.
> 
>  Changed in PATCH v6:
> * Add new helper patch (1/2) to refactor kernel config reading
> * Use the new read_kernel_config() in CET symbol matching (2/2) to check CONFIG_X86_KERNEL_IBT
> 
> Changed in PATCH v7:
> * Display actual kprobe attachment addresses instead of symbol addresses

Acked-by: Jiri Olsa <jolsa@kernel.org>

thanks,
jirka


> 
> Yuan Chen (2):
>   bpftool: Refactor kernel config reading into common helper
>   bpftool: Add CET-aware symbol matching for x86_64 architectures
> 
>  tools/bpf/bpftool/common.c  | 93 +++++++++++++++++++++++++++++++++++++
>  tools/bpf/bpftool/feature.c | 86 ++--------------------------------
>  tools/bpf/bpftool/link.c    | 38 ++++++++++++++-
>  tools/bpf/bpftool/main.h    |  9 ++++
>  4 files changed, 142 insertions(+), 84 deletions(-)
> 
> -- 
> 2.39.5
>