From: Alexei Starovoitov Date: Tue, 3 Mar 2026 16:47:23 +0000 (-0800) Subject: Merge branch 'bpf-allow-void-return-type-for-global-subprogs' X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=44dd647b668984fb52b7fb73952cb1668b76ebed;p=thirdparty%2Flinux.git Merge branch 'bpf-allow-void-return-type-for-global-subprogs' Emil Tsalapatis says: ==================== bpf: Allow void return type for global subprogs Global subprogs are currently not allowed to return void. Adjust verifier logic to allow global functions with a void return type. Exception callbacks are excluded from this change, and still require a scalar return type. Adding additional logic for void globals significantly complicates check_return_code(), mainly because of how the new feature interacts with bpf_throw(). To avoid complicating the code, refactor the return value range validation logic into two separate functions, one for program exits through BPF_EXIT and one for program exits through bpf_throw(). The changes are non-functional. Also adjust existing selftests that were ensuring that global subprogs with void return types fail to verify. These tests should now load successfully. Patches 1-3 refactor check_return_code into two separate functions, one for BPF_EXIT and one for bpf_throw(). No functional changes. Patches 4-5 enable void globals in the verifier and add additional selftests. v5 -> v6 (https://lore.kernel.org/bpf/20260227154616.6846-1-emil@etsalapatis.com/) Patch 1: - Removed unused variables (kernel test robot) - Add break; on empty default to suppress warning (kernel test robot) - Added explanation on why change in switch statement for BPF_PROG_TYPE_TRACING in check_return_code is a no-op Patches 2/3: - Added From: tags to Eduard's patches and changed my Reviewed-by to Signed-off-by to properly denote patch route (submitting-patches.rst) - Renamed check_subprogram_return_code for into check_global_subprog_return_code (Eduard) Patch 4: - Remove unnecessary subprog_is_global() check in check_return_code (Eduard) - Fix indentation on patch 4 (AI) Patch 5: - Fix unused data in selftests (Eduard) v4 -> v5 (https://lore.kernel.org/bpf/20260225033356.518313-1-emil@etsalapatis.com/) - Split value validation logic from throw/nonthrow to main prog/subprog (Eduard) - Turn return_retval_range() to bool and incorporate return_32bit in retval (Eduard) - Adjust if-else chain in return_retval_range for cgroup programs into switch statement to bring it in line with the other program types v3 -> v4 (https://lore.kernel.org/bpf/20260223215046.1706110-1-emil@etsalapatis.com/) - Factor out bpf_throw() return value validation logic into its own function (Eduard) - Validate the range of bpf_throw() return values from void globals (Eduard) - Move new selftest to verifier_global_subprogs.c (Eduard) - Remove unnecessary verifier_bug_if() statements (Eduard) - Add new test to ensure void globals can call bpf_throw v2 -> v3 (https://lore.kernel.org/bpf/20260210183257.217285-1-emil@etsalapatis.com/) - Allow freplace for global programs that return void and add selftests (Kumar) v1 -> v2 (https://lore.kernel.org/bpf/20260127231414.359283-1-emil@etsalapatis.com/) - Only mark R0 as valid for non-void global functions (AI) - Rename subprog_is_void to subprog_returns_void (Kumar) - Add test that R0 is invalid after calling a void global (Alexei) - Add check to ensure exception callbacks do not return void and associated selftest Cc: Kumar Kartikeya Dwivedi ==================== Link: https://patch.msgid.link/20260228184759.108145-1-emil@etsalapatis.com Signed-off-by: Alexei Starovoitov --- 44dd647b668984fb52b7fb73952cb1668b76ebed