!52 [sync] PR-50: fix undefined behavior in scmp_bpf_sim.c causing issues when building with clang

From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
This commit is contained in:
openeuler-ci-bot 2024-07-31 09:29:25 +00:00 committed by Gitee
commit b2a8f8c25b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 31 additions and 1 deletions

View File

@ -0,0 +1,25 @@
From 3292da1d4dafab2d18c7b750fa278bcc8a362d04 Mon Sep 17 00:00:00 2001
From: q66 <q66@chimera-linux.org>
Date: Wed, 20 Dec 2023 04:01:42 +0100
Subject: [PATCH] fix UB-ass UB in scmp_bpf_sim
---
tools/scmp_bpf_sim.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/scmp_bpf_sim.c b/tools/scmp_bpf_sim.c
index a381314..eeaa5bc 100644
--- a/tools/scmp_bpf_sim.c
+++ b/tools/scmp_bpf_sim.c
@@ -182,7 +182,8 @@ static void bpf_execute(const struct bpf_program *prg,
switch (code) {
case BPF_LD+BPF_W+BPF_ABS:
if (k < BPF_SYSCALL_MAX) {
- uint32_t val = *((uint32_t *)&sys_data_b[k]);
+ uint32_t val;
+ memcpy(&val, &sys_data_b[k], sizeof(val));
state.acc = ttoh32(arch, val);
} else
exit_error(ERANGE, ip_c);
--
2.43.0

View File

@ -1,6 +1,6 @@
Name: libseccomp
Version: 2.5.4
Release: 2
Release: 3
Summary: Interface to the syscall filtering mechanism
License: LGPLv2
URL: https://github.com/seccomp/libseccomp
@ -9,6 +9,8 @@ Source0: https://github.com/seccomp/libseccomp/releases/download/v%{version}/%{n
Patch2: backport-arch-disambiguate-in-arch-syscall-validate.patch
Patch3: Add-64-bit-LoongArch-support.patch
Patch4: fix-build-error-for-libseccomp.patch
# https://github.com/chimera-linux/cports/pull/1099
Patch5: fix_undefined_behavior_in_scmp_bpf_sim.patch
BuildRequires: gcc gperf autoconf automake
@ -79,6 +81,9 @@ make check
%{_mandir}/man*/*
%changelog
* Fri May 10 2024 jchzhou <zhoujiacheng@iscas.ac.cn> - 2.5.4-3
- fix undefined behavior in scmp_bpf_sim.c causing issues when building with clang
* Mon Jul 31 2023 Jingyun Hua<huajingyun@loongson.cn> - 2.5.4-2
- add loongarch64 support for libseccomp