Skip to content

fix(driver): use correct syntax for flexible array member#2760

Merged
irozzo-1A merged 1 commit intofalcosecurity:masterfrom
irozzo-1A:fix-flexible-array-synthax
Dec 16, 2025
Merged

fix(driver): use correct syntax for flexible array member#2760
irozzo-1A merged 1 commit intofalcosecurity:masterfrom
irozzo-1A:fix-flexible-array-synthax

Conversation

@irozzo-1A
Copy link
Copy Markdown
Contributor

@irozzo-1A irozzo-1A commented Dec 16, 2025

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind test

/kind feature

/kind sync

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area API-version

/area build

/area CI

/area driver-kmod

/area driver-bpf

/area driver-modern-bpf

/area libscap-engine-bpf

/area libscap-engine-gvisor

/area libscap-engine-kmod

/area libscap-engine-modern-bpf

/area libscap-engine-nodriver

/area libscap-engine-noop

/area libscap-engine-source-plugin

/area libscap-engine-savefile

/area libscap

/area libpman

/area libsinsp

/area tests

/area proposals

Does this PR require a change in the driver versions?

/version driver-API-version-major

/version driver-API-version-minor

/version driver-API-version-patch

/version driver-SCHEMA-version-major

/version driver-SCHEMA-version-minor

/version driver-SCHEMA-version-patch

What this PR does / why we need it:

UBSAN (Undefined Behaviour Sanitizer) performs compile-time and runtime checks based on declared array bounds. Flaxible Array Member used to be declared with the [0] syntax, but should now be expressed with [] syntax to respect C99 standard (§6.7.2.1).

Which issue(s) this PR fixes:

Fixes #2752

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

fix(driver): address UBSAN violation related to Flexible Array Member.

UBSAN (Undefined Behaviour Sanitizer) performs compile-time and runtime
checks based on declared array bounds. Flaxible Array Member used to be
declared with the [0] synthax, but should now be expressed with []
syntax to respect C99 standard (§6.7.2.1).

Signed-off-by: irozzo-1A <iacopo@sysdig.com>
@github-actions
Copy link
Copy Markdown

Please double check driver/API_VERSION file. See versioning.

/hold

@github-actions
Copy link
Copy Markdown

Please double check driver/SCHEMA_VERSION file. See versioning.

/hold

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.57%. Comparing base (d4fb9de) to head (bbf64c4).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2760   +/-   ##
=======================================
  Coverage   74.57%   74.57%           
=======================================
  Files         292      292           
  Lines       30025    30025           
  Branches     4657     4657           
=======================================
  Hits        22392    22392           
  Misses       7633     7633           
Flag Coverage Δ
libsinsp 74.57% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.

int64_t n_entries;
int64_t max_entries;
struct ppm_proc_info entries[0];
struct ppm_proc_info entries[];
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.

Good catch, indeed '[]' is the modern, more portable way to define flexible arrays.

@github-actions
Copy link
Copy Markdown

Perf diff from master - unit tests

     4.48%    +13.40%  [.] 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)
     3.58%    +11.81%  [.] std::__shared_count<(__gnu_cxx::_Lock_policy)2>::_M_get_use_count() const
     4.19%     +9.21%  [.] sinsp_threadinfo::get_main_thread()
     3.35%     +7.98%  [.] sinsp_threadinfo::update_main_fdtable()
     3.51%     +7.52%  [.] std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_add_ref_lock_nothrow()
     6.01%     +6.32%  [.] std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release()
     3.15%     +5.72%  [.] sinsp_threadinfo::get_fd_table()
    11.45%     -5.38%  [.] sinsp::next(sinsp_evt**)
     2.09%     +5.26%  [.] std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count(std::__weak_count<(__gnu_cxx::_Lock_policy)2> const&, std::nothrow_t)
     1.84%     +3.48%  [.] thread_group_info::get_first_thread() const

Heap diff from master - unit tests

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

Heap diff from master - scap file

peak heap memory consumption: -24B
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.0373         -0.0374           248           238           247           238
BM_sinsp_split_median                                          -0.0373         -0.0374           248           238           247           238
BM_sinsp_split_stddev                                          +0.6871         +0.6381             1             2             1             2
BM_sinsp_split_cv                                              +0.7524         +0.7017             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                  +0.0846         +0.0845            70            76            70            76
BM_sinsp_concatenate_paths_relative_path_median                +0.0935         +0.0934            70            76            69            76
BM_sinsp_concatenate_paths_relative_path_stddev                -0.1572         -0.1576             1             1             1             1
BM_sinsp_concatenate_paths_relative_path_cv                    -0.2229         -0.2232             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                     -0.0691         -0.0692            44            41            44            41
BM_sinsp_concatenate_paths_empty_path_median                   -0.0810         -0.0811            44            40            44            40
BM_sinsp_concatenate_paths_empty_path_stddev                   +0.4902         +0.4915             1             1             1             1
BM_sinsp_concatenate_paths_empty_path_cv                       +0.6008         +0.6023             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                  +0.0372         +0.0371            71            74            71            74
BM_sinsp_concatenate_paths_absolute_path_median                +0.0357         +0.0356            71            74            71            74
BM_sinsp_concatenate_paths_absolute_path_stddev                +3.8259         +3.9819             0             1             0             1
BM_sinsp_concatenate_paths_absolute_path_cv                    +3.6528         +3.8036             0             0             0             0

@irozzo-1A irozzo-1A marked this pull request as ready for review December 16, 2025 09:52
@poiana poiana requested a review from terror96 December 16, 2025 09:52
@irozzo-1A
Copy link
Copy Markdown
Contributor Author

https://github.com/falcosecurity/libs/actions/runs/20261424717/job/58174173864?pr=2760 is a false positive, this change does not affect the SCHEMA_VERSION

@ekoops ekoops modified the milestones: 0.23.0, next-driver Dec 16, 2025
Copy link
Copy Markdown
Contributor

@ekoops ekoops left a comment

Choose a reason for hiding this comment

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

/approve

@poiana
Copy link
Copy Markdown
Contributor

poiana commented Dec 16, 2025

LGTM label has been added.

DetailsGit tree hash: 6e923e39cd48afe75d362399d2406fd94fa408c9

Copy link
Copy Markdown
Contributor

@terror96 terror96 left a comment

Choose a reason for hiding this comment

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

/lgtm

@github-project-automation github-project-automation bot moved this from Todo to In progress in Falco Roadmap Dec 16, 2025
@poiana
Copy link
Copy Markdown
Contributor

poiana commented Dec 16, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ekoops, irozzo-1A, terror96

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

The pull request process is described 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

@irozzo-1A irozzo-1A merged commit eb2c1a3 into falcosecurity:master Dec 16, 2025
56 of 59 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Falco Roadmap Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

UBSAN: array-index-out-of-bounds in main.c:860:27

4 participants