From: Andrei Gherzan <[email protected]>

This will fix clang-based builds.

Signed-off-by: Andrei Gherzan <[email protected]>
---
 ...efine-ActKillThread-equal-to-ActKill.patch | 90 +++++++++++++++++++
 .../runc/runc-opencontainers_git.bb           |  1 +
 2 files changed, 91 insertions(+)
 create mode 100644 
recipes-containers/runc/files/0002-Define-ActKillThread-equal-to-ActKill.patch

diff --git 
a/recipes-containers/runc/files/0002-Define-ActKillThread-equal-to-ActKill.patch
 
b/recipes-containers/runc/files/0002-Define-ActKillThread-equal-to-ActKill.patch
new file mode 100644
index 0000000..8ed5503
--- /dev/null
+++ 
b/recipes-containers/runc/files/0002-Define-ActKillThread-equal-to-ActKill.patch
@@ -0,0 +1,90 @@
+From f2aa0359bcc776239bda8a4eb84957b97ef55c35 Mon Sep 17 00:00:00 2001
+From: Tonis Tiigi <[email protected]>
+Date: Fri, 28 Jan 2022 14:44:56 -0800
+Subject: [PATCH] Define ActKillThread equal to ActKill
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+These constants are equal in libseccomp but Go definitions
+were defined separately. This resulted in dead code that
+never executed due to identical case statements in switch.
+Go can usually detect these error cases and refuses to build
+but for some reason this detection doesn’t work with cgo+gcc.
+Clang detects the equal constants correctly and therefore
+libseccomp-golang builds with clang broke after ActKillThread
+was added.
+
+In order to fix the clang build only removal of the
+switch case is needed. But I assumed that the setter/getter
+logic is supposed to work for ActKillThread as well
+and only way to ensure that is to set them equal like they
+are in C.
+
+Signed-off-by: Tonis Tiigi <[email protected]>
+Signed-off-by: Sebastiaan van Stijn <[email protected]>
+Acked-by: Tom Hromatka <[email protected]>
+Signed-off-by: Paul Moore <[email protected]>
+Signed-off-by: Andrei Gherzan <[email protected]>
+Upstrea-status: Backport 
[https://github.com/seccomp/libseccomp-golang/commit/c35397d0ea8f285a0be78693bb2fd37b06952453]
+---
+ seccomp.go          | 8 ++++----
+ seccomp_internal.go | 4 ----
+ 2 files changed, 4 insertions(+), 8 deletions(-)
+
+diff --git a/seccomp.go b/seccomp.go
+index e9b92e2..32f6ab2 100644
+--- a/seccomp.go
++++ b/seccomp.go
+@@ -214,14 +214,14 @@ const (
+       // This action is only usable when libseccomp API level 3 or higher is
+       // supported.
+       ActLog ScmpAction = iota
+-      // ActKillThread kills the thread that violated the rule. It is the 
same as ActKill.
+-      // All other threads from the same thread group will continue to 
execute.
+-      ActKillThread ScmpAction = iota
+       // ActKillProcess kills the process that violated the rule.
+       // All threads in the thread group are also terminated.
+       // This action is only usable when libseccomp API level 3 or higher is
+       // supported.
+       ActKillProcess ScmpAction = iota
++      // ActKillThread kills the thread that violated the rule. It is the 
same as ActKill.
++      // All other threads from the same thread group will continue to 
execute.
++      ActKillThread = ActKill
+ )
+ 
+ const (
+@@ -394,7 +394,7 @@ func (a ScmpCompareOp) String() string {
+ // String returns a string representation of a seccomp match action
+ func (a ScmpAction) String() string {
+       switch a & 0xFFFF {
+-      case ActKill, ActKillThread:
++      case ActKillThread:
+               return "Action: Kill thread"
+       case ActKillProcess:
+               return "Action: Kill process"
+diff --git a/seccomp_internal.go b/seccomp_internal.go
+index 8dc7b29..8fc9914 100644
+--- a/seccomp_internal.go
++++ b/seccomp_internal.go
+@@ -612,8 +612,6 @@ func (a ScmpCompareOp) toNative() C.int {
+ func actionFromNative(a C.uint32_t) (ScmpAction, error) {
+       aTmp := a & 0xFFFF
+       switch a & 0xFFFF0000 {
+-      case C.C_ACT_KILL:
+-              return ActKill, nil
+       case C.C_ACT_KILL_PROCESS:
+               return ActKillProcess, nil
+       case C.C_ACT_KILL_THREAD:
+@@ -638,8 +636,6 @@ func actionFromNative(a C.uint32_t) (ScmpAction, error) {
+ // Only use with sanitized actions, no error handling
+ func (a ScmpAction) toNative() C.uint32_t {
+       switch a & 0xFFFF {
+-      case ActKill:
+-              return C.C_ACT_KILL
+       case ActKillProcess:
+               return C.C_ACT_KILL_PROCESS
+       case ActKillThread:
+-- 
+2.25.1
+
diff --git a/recipes-containers/runc/runc-opencontainers_git.bb 
b/recipes-containers/runc/runc-opencontainers_git.bb
index 14570b9..f9dae6a 100644
--- a/recipes-containers/runc/runc-opencontainers_git.bb
+++ b/recipes-containers/runc/runc-opencontainers_git.bb
@@ -4,6 +4,7 @@ SRCREV = "b507e2da6c6a3a328f208fa415a56ad7cd58761b"
 SRC_URI = " \
     git://github.com/opencontainers/runc;branch=release-1.1;protocol=https \
     file://0001-Makefile-respect-GOBUILDFLAGS-for-runc-and-remove-re.patch \
+    
file://0002-Define-ActKillThread-equal-to-ActKill.patch;patchdir=src/import/vendor/github.com/seccomp/libseccomp-golang
 \
     "
 RUNC_VERSION = "1.1.2"
 
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#7482): 
https://lists.yoctoproject.org/g/meta-virtualization/message/7482
Mute This Topic: https://lists.yoctoproject.org/mt/92766872/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to