Skip to content

Commit c35397d

Browse files
tonistiigipcmoore
authored andcommitted
Define ActKillThread equal to ActKill
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]>
1 parent e214ef1 commit c35397d

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

seccomp.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ const (
202202
// This action is only usable when libseccomp API level 3 or higher is
203203
// supported.
204204
ActLog
205-
// ActKillThread kills the thread that violated the rule. It is the same as ActKill.
206-
// All other threads from the same thread group will continue to execute.
207-
ActKillThread
208205
// ActKillProcess kills the process that violated the rule.
209206
// All threads in the thread group are also terminated.
210207
// This action is only usable when libseccomp API level 3 or higher is
211208
// supported.
212209
ActKillProcess
210+
// ActKillThread kills the thread that violated the rule. It is the same as ActKill.
211+
// All other threads from the same thread group will continue to execute.
212+
ActKillThread = ActKill
213213
)
214214

215215
const (
@@ -385,7 +385,7 @@ func (a ScmpCompareOp) String() string {
385385
// String returns a string representation of a seccomp match action
386386
func (a ScmpAction) String() string {
387387
switch a & 0xFFFF {
388-
case ActKill, ActKillThread:
388+
case ActKillThread:
389389
return "Action: Kill thread"
390390
case ActKillProcess:
391391
return "Action: Kill process"

seccomp_internal.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,6 @@ func (a ScmpCompareOp) toNative() C.int {
629629
func actionFromNative(a C.uint32_t) (ScmpAction, error) {
630630
aTmp := a & 0xFFFF
631631
switch a & 0xFFFF0000 {
632-
case C.C_ACT_KILL:
633-
return ActKill, nil
634632
case C.C_ACT_KILL_PROCESS:
635633
return ActKillProcess, nil
636634
case C.C_ACT_KILL_THREAD:
@@ -655,8 +653,6 @@ func actionFromNative(a C.uint32_t) (ScmpAction, error) {
655653
// Only use with sanitized actions, no error handling
656654
func (a ScmpAction) toNative() C.uint32_t {
657655
switch a & 0xFFFF {
658-
case ActKill:
659-
return C.C_ACT_KILL
660656
case ActKillProcess:
661657
return C.C_ACT_KILL_PROCESS
662658
case ActKillThread:

0 commit comments

Comments
 (0)