Re: [PATCH bpf-next] bpf: Use sha1() instead of sha1_transform() in bpf_prog_calc_tag()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 11, 2025 at 5:58 PM Song Liu <song@xxxxxxxxxx> wrote:
>
> On Mon, Aug 11, 2025 at 1:17 PM Eric Biggers <ebiggers@xxxxxxxxxx> wrote:
> >
> > Now that there's a proper SHA-1 library API, just use that instead of
> > the low-level SHA-1 compression function.  This eliminates the need for
> > bpf_prog_calc_tag() to implement the SHA-1 padding itself.  No
> > functional change; the computed tags remain the same.
> >
> > Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
> > ---
> >  include/linux/filter.h |  6 -----
> >  kernel/bpf/core.c      | 50 ++++++++----------------------------------
> >  2 files changed, 9 insertions(+), 47 deletions(-)
>
> Nice clean up!
>
> It appears this patch changes the sha1 of some programs, but not
> some other programs. For example, sha1 of program
> test_task_kfunc_flavor_relo_not_found from task_kfunc_success.bpf.o
> stays the same before and after the patch, while other programs from
> task_kfunc_success.bpf.o have different sha1 after the patch.
>
> Is this expected?
>

I modified veristat.c locally to print prog tags, and they were
identical before and after. So I'm landing the patch as it's a nice
clean up (and it looks like we might change sha1 for sha256 soon
anyways with KP's work on signing). Thanks!

$ sudo ./veristat task_kfunc_success.bpf.o
Processing 'task_kfunc_success.bpf.o'...
TAG for task_kfunc_success.bpf.o/test_task_kfunc_flavor_relo: 3ec44141eafbb946
TAG for task_kfunc_success.bpf.o/test_task_kfunc_flavor_relo_not_found:
a2b1538278853bab
TAG for task_kfunc_success.bpf.o/test_task_acquire_release_argument:
81814696d4ca6b04
TAG for task_kfunc_success.bpf.o/test_task_acquire_release_current:
da78e4661f6fc0f5
TAG for task_kfunc_success.bpf.o/test_task_acquire_leave_in_map:
6987ab3c231b11c8
TAG for task_kfunc_success.bpf.o/test_task_xchg_release: 243afeabd9545c81
TAG for task_kfunc_success.bpf.o/test_task_map_acquire_release: 52c2aa84fd0f4163
TAG for task_kfunc_success.bpf.o/test_task_current_acquire_release:
0a49c6127a61f92e
TAG for task_kfunc_success.bpf.o/test_task_from_pid_arg: f2c0d6eb9d6f1c87
TAG for task_kfunc_success.bpf.o/test_task_from_pid_current: 3a7cc6125deb0920
TAG for task_kfunc_success.bpf.o/test_task_from_pid_invalid: a41a7678b91b0f12
TAG for task_kfunc_success.bpf.o/task_kfunc_acquire_trusted_walked:
8c38bae3eeaab179
TAG for task_kfunc_success.bpf.o/test_task_from_vpid_current: 4d5bd93fd0615005
TAG for task_kfunc_success.bpf.o/test_task_from_vpid_invalid: 87a101256cffd707
File                      Program
Verdict  Duration (us)  Insns  States  Program size  Jited size
------------------------  -------------------------------------
-------  -------------  -----  ------  ------------  ----------
task_kfunc_success.bpf.o  task_kfunc_acquire_trusted_walked
success           1111     13       1            13          73
task_kfunc_success.bpf.o  test_task_acquire_leave_in_map
success            376     73       7            57         282
task_kfunc_success.bpf.o  test_task_acquire_release_argument
success            211     18       2            41          83
task_kfunc_success.bpf.o  test_task_acquire_release_current
success            229     18       2            41          82
task_kfunc_success.bpf.o  test_task_current_acquire_release
success            212     20       2            19          96
task_kfunc_success.bpf.o  test_task_from_pid_arg
success            235     31       3            26         173
task_kfunc_success.bpf.o  test_task_from_pid_current
success            239     32       3            27         181
task_kfunc_success.bpf.o  test_task_from_pid_invalid
success            234     42       4            42         213
task_kfunc_success.bpf.o  test_task_from_vpid_current
success            139     21       2            19         106
task_kfunc_success.bpf.o  test_task_from_vpid_invalid
success            107     29       3            19         107
task_kfunc_success.bpf.o  test_task_kfunc_flavor_relo
success            270     17       1            37          88
task_kfunc_success.bpf.o  test_task_kfunc_flavor_relo_not_found
success            146      8       0            13          38
task_kfunc_success.bpf.o  test_task_map_acquire_release
success            428    126      12            95         469
task_kfunc_success.bpf.o  test_task_xchg_release
success            634    202      19           173         854
------------------------  -------------------------------------
-------  -------------  -----  ------  ------------  ----------
Done. Processed 1 files, 0 programs. Skipped 14 files, 0 programs.

> Thanks,
> Song





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux