Skip to content

fix(driver/modern_bpf): read signal_deliver siginfo via BPF_CORE_READ - #3119

Open
adduali1310 wants to merge 1 commit into
falcosecurity:masterfrom
adduali1310:fix/modern-bpf-signal-deliver-scalar-siginfo
Open

adduali1310 wants to merge 1 commit into
falcosecurity:masterfrom
adduali1310:fix/modern-bpf-signal-deliver-scalar-siginfo

Conversation

@adduali1310

@adduali1310 adduali1310 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Signal tracepoints can receive the SEND_SIG_NOINFO (0) and SEND_SIG_PRIV (1) sentinels in place of a real kernel_siginfo pointer. Since SEND_SIG_PRIV survives a NULL check, kernel commit 77515ab12e49 ("bpf: Mark signal tracepoint siginfo arguments as scalar") lists signal_generate and signal_deliver in raw_tp_null_args[] and exposes the info argument to tp_btf programs as a scalar.

With that change the verifier rejects the direct info->... accesses in the signal_deliver program with "invalid mem access 'scalar'", and since all programs are loaded together the modern probe fails to load entirely (seen on 6.18.53).

Read the fields through BPF_CORE_READ instead. It is accepted both when info is a scalar and when it is a BTF pointer, so older kernels keep working. The resulting spid values are unchanged.

Link: torvalds/linux@77515ab

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

/area driver-modern-bpf

What this PR does / why we need it:

Newer kernels add signal_generate and signal_deliver to raw_tp_null_args[] and expose their info argument to tp_btf programs as a scalar, because it can be the SEND_SIG_PRIV (1) sentinel rather than a real
pointer. The verifier then rejects the direct info->... dereferences in our signal_deliver program (invalid mem access 'scalar') and the whole modern probe fails to load (seen on 6.18.53).

This switches those reads to BPF_CORE_READ, which the verifier accepts for both the scalar and the BTF pointer case, so older kernels are unaffected. The kmod is not affected.

Kernel commit: 77515ab12e49 ("bpf: Mark signal tracepoint siginfo arguments as scalar")

Which issue(s) this PR fixes:

Fixes #3118

Special notes for your reviewer:

Does this PR introduce a user-facing change?:
No

fix(driver/modern_bpf): fix `signal_deliver` verifier failure on kernels exposing the siginfo argument as a scalar

Signal tracepoints can receive the `SEND_SIG_NOINFO` (0) and
`SEND_SIG_PRIV` (1) sentinels in place of a real `kernel_siginfo`
pointer. Since `SEND_SIG_PRIV` survives a NULL check, kernel commit
77515ab12e49 ("bpf: Mark signal tracepoint siginfo arguments as
scalar") lists `signal_generate` and `signal_deliver` in
`raw_tp_null_args[]` and exposes the `info` argument to `tp_btf`
programs as a scalar.

With that change the verifier rejects the direct `info->...` accesses
in the `signal_deliver` program with "invalid mem access 'scalar'",
and since all programs are loaded together the modern probe fails to
load entirely (seen on 6.18.53).

Read the fields through `BPF_CORE_READ` instead. It is accepted both
when `info` is a scalar and when it is a BTF pointer, so older
kernels keep working. The resulting `spid` values are unchanged.

Link: torvalds/linux@77515ab
Signed-off-by: Adnan Ali <adduali1310@hotmail.com>
@github-actions

Copy link
Copy Markdown

Perf diff from master - unit tests

    15.59%     +5.71%  [.] sinsp_thread_manager::create_thread_dependencies(std::shared_ptr<sinsp_threadinfo> const&)
    16.25%     -4.42%  [.] sinsp_threadinfo::get_main_thread()
    20.58%     -0.72%  [.] std::__shared_ptr<sinsp_threadinfo, (__gnu_cxx::_Lock_policy)2>::__shared_ptr(std::__weak_ptr<sinsp_threadinfo, (__gnu_cxx::_Lock_policy)2> const&, std::nothrow_t)
     9.43%     -0.50%  [.] std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release()
     9.26%     -0.47%  [.] std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_add_ref_lock_nothrow()
     8.63%     +0.43%  [.] std::__shared_count<(__gnu_cxx::_Lock_policy)2>::_M_get_use_count() const
     3.86%     -0.11%  [.] sinsp_threadinfo::get_fd_table() const
     0.03%     +0.11%  [.] sinsp_parser::parse_clone_exit_child(sinsp_evt&, sinsp_parser_verdict&) const
     0.19%     -0.10%  [.] void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char const*>(char const*, char const*, std::forward_iterator_tag)
     0.14%     -0.07%  [.] std::basic_string_view<char, std::char_traits<char> >::substr(unsigned long, unsigned long) const

Heap diff from master - unit tests

peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Heap diff from master - scap file

peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Benchmarks diff from master

Comparing gbench_data.json to /root/actions-runner/_work/libs/libs/build/gbench_data.json
Benchmark                                                                             Time             CPU      Time Old      Time New       CPU Old       CPU New
------------------------------------------------------------------------------------------------------------------------------------------------------------------
BM_sinsp_split_mean                                                                +0.0122         +0.0122           276           279           276           279
BM_sinsp_split_median                                                              +0.0118         +0.0120           276           279           276           279
BM_sinsp_split_stddev                                                              -0.6110         -0.6182             3             1             3             1
BM_sinsp_split_cv                                                                  -0.6157         -0.6228             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                                      +0.0063         +0.0064            68            69            68            69
BM_sinsp_concatenate_paths_relative_path_median                                    +0.0144         +0.0146            67            68            67            68
BM_sinsp_concatenate_paths_relative_path_stddev                                    -0.2132         -0.2123             2             1             2             1
BM_sinsp_concatenate_paths_relative_path_cv                                        -0.2181         -0.2173             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                                         +0.0040         +0.0040            45            45            45            45
BM_sinsp_concatenate_paths_empty_path_median                                       +0.0278         +0.0274            45            46            44            46
BM_sinsp_concatenate_paths_empty_path_stddev                                       +0.1248         +0.1343             1             1             1             1
BM_sinsp_concatenate_paths_empty_path_cv                                           +0.1204         +0.1298             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                                      -0.0051         -0.0052            67            66            67            66
BM_sinsp_concatenate_paths_absolute_path_median                                    -0.0181         -0.0179            67            66            67            66
BM_sinsp_concatenate_paths_absolute_path_stddev                                    -0.7805         -0.7786             1             0             1             0
BM_sinsp_concatenate_paths_absolute_path_cv                                        -0.7794         -0.7774             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_ascii_short_mean                                  -0.0220         -0.0219            15            15            15            15
BM_sinsp_utf8_sanitize_fast_path_ascii_short_median                                -0.0005         -0.0001            15            15            15            15
BM_sinsp_utf8_sanitize_fast_path_ascii_short_stddev                                -0.9898         -0.9889             1             0             1             0
BM_sinsp_utf8_sanitize_fast_path_ascii_short_cv                                    -0.9895         -0.9886             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_ascii_long_mean                                   +0.0098         +0.0099            68            69            68            69
BM_sinsp_utf8_sanitize_fast_path_ascii_long_median                                 +0.0101         +0.0102            68            69            68            69
BM_sinsp_utf8_sanitize_fast_path_ascii_long_stddev                                 -0.5788         -0.5914             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_ascii_long_cv                                     -0.5829         -0.5954             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_multibyte_short_mean                              +0.0615         +0.0615            11            12            11            12
BM_sinsp_utf8_sanitize_fast_path_multibyte_short_median                            +0.1049         +0.1049            11            12            11            12
BM_sinsp_utf8_sanitize_fast_path_multibyte_short_stddev                            -0.1491         -0.1485             1             1             1             1
BM_sinsp_utf8_sanitize_fast_path_multibyte_short_cv                                -0.1984         -0.1979             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_multibyte_long_mean                               -0.0158         -0.0158          3709          3650          3708          3649
BM_sinsp_utf8_sanitize_fast_path_multibyte_long_median                             -0.0009         -0.0006          3653          3650          3651          3649
BM_sinsp_utf8_sanitize_fast_path_multibyte_long_stddev                             -0.9839         -0.9870            71             1            71             1
BM_sinsp_utf8_sanitize_fast_path_multibyte_long_cv                                 -0.9837         -0.9868             0             0             0             0
BM_sinsp_utf8_sanitize_fast_path_mixed_long_mean                                   -0.0299         -0.0298          1966          1907          1965          1907
BM_sinsp_utf8_sanitize_fast_path_mixed_long_median                                 -0.0023         -0.0025          1963          1959          1963          1958
BM_sinsp_utf8_sanitize_fast_path_mixed_long_stddev                                 +8.6931         +8.7417            11           111            11           111
BM_sinsp_utf8_sanitize_fast_path_mixed_long_cv                                     +8.9915         +9.0414             0             0             0             0
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_alloc_mean                       -0.0561         -0.0561          1344          1269          1344          1268
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_alloc_median                     -0.0561         -0.0561          1344          1269          1344          1268
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_alloc_stddev                     -0.3128         -0.2627             1             0             1             0
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_alloc_cv                         -0.2720         -0.2188             0             0             0             0
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_noalloc_mean                     -0.1358         -0.1358          1342          1160          1342          1159
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_noalloc_median                   -0.0762         -0.0763          1342          1240          1341          1239
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_noalloc_stddev                 +144.3106       +146.8244             1           114             1           114
BM_sinsp_utf8_sanitize_slow_path_c1_controls_long_noalloc_cv                     +167.1435       +170.0593             0             0             0             0
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_alloc_mean                    -0.0085         -0.0085           243           241           242           240
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_alloc_median                  -0.0002         -0.0001           241           241           241           241
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_alloc_stddev                  +0.6759         +0.6736             4             7             4             7
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_alloc_cv                      +0.6902         +0.6879             0             0             0             0
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_noalloc_mean                  -0.0058         -0.0058           132           131           132           131
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_noalloc_median                -0.0065         -0.0065           132           131           132           131
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_noalloc_stddev                -0.0582         -0.0567             2             2             2             2
BM_sinsp_utf8_sanitize_slow_path_sparse_invalid_long_noalloc_cv                    -0.0527         -0.0512             0             0             0             0
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_alloc_mean                       +0.0479         +0.0479         11373         11917         11369         11913
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_alloc_median                     +0.0009         +0.0010         11727         11738         11724         11735
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_alloc_stddev                     -0.4852         -0.4850           573           295           572           295
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_alloc_cv                         -0.5087         -0.5086             0             0             0             0
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_noalloc_mean                     +0.0798         +0.0799         10645         11494         10641         11491
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_noalloc_median                   +0.0698         +0.0697         10777         11529         10774         11525
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_noalloc_stddev                   -0.4067         -0.4087           407           241           408           241
BM_sinsp_utf8_sanitize_slow_path_all_invalid_long_noalloc_cv                       -0.4505         -0.4524             0             0             0             0
BM_sinsp_concatenate_paths_long_normalizing_path_mean                              +0.0010         +0.0009           821           822           821           822
BM_sinsp_concatenate_paths_long_normalizing_path_median                            +0.0012         +0.0009           821           822           821           822
BM_sinsp_concatenate_paths_long_normalizing_path_stddev                            +0.1504         +0.1890             1             1             1             1
BM_sinsp_concatenate_paths_long_normalizing_path_cv                                +0.1493         +0.1880             0             0             0             0
BM_sinsp_concatenate_paths_too_long_path_mean                                      -0.0023         -0.0023          3243          3235          3242          3235
BM_sinsp_concatenate_paths_too_long_path_median                                    -0.0023         -0.0023          3243          3235          3242          3234
BM_sinsp_concatenate_paths_too_long_path_stddev                                    -0.5605         -0.6318             3             1             2             1
BM_sinsp_concatenate_paths_too_long_path_cv                                        -0.5594         -0.6309             0             0             0             0
BM_sinsp_concatenate_paths_beyond_scratch_mean                                     -0.0409         -0.0410            49            47            49            47
BM_sinsp_concatenate_paths_beyond_scratch_median                                   -0.0532         -0.0533            49            47            49            47
BM_sinsp_concatenate_paths_beyond_scratch_stddev                                   -0.9776         -0.9761             1             0             1             0
BM_sinsp_concatenate_paths_beyond_scratch_cv                                       -0.9767         -0.9751             0             0             0             0

@codecov

codecov Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.71%. Comparing base (4b61d08) to head (eb8174e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3119   +/-   ##
=======================================
  Coverage   76.71%   76.71%           
=======================================
  Files         303      303           
  Lines       34393    34393           
  Branches     5151     5149    -2     
=======================================
  Hits        26386    26386           
  Misses       8007     8007           
Flag Coverage Δ
libsinsp 76.71% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@terror96 terror96 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@poiana

poiana commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: b3ec0173e4485f1923acdb7fbf81a072d887c35f

@poiana

poiana commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: adduali1310, terror96
Once this PR has been reviewed and has the lgtm label, please assign hbrueckner for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@leogr

leogr commented Sep 25, 2026

Copy link
Copy Markdown
Member

cc @gnosek

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

modern_bpf: signal_deliver fails verification on kernels exposing siginfo as scalar (e.g.Linux 6.18.53), Falco fails to start

4 participants