File: 0008-fix-patchpbf-test-on-32-bit.patch

package info (click to toggle)
runc 1.0.0~rc93%2Bds1-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 3,172 kB
  • sloc: sh: 1,679; ansic: 1,039; makefile: 139
file content (72 lines) | stat: -rw-r--r-- 2,845 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
From: Aleksa Sarai <asarai@suse.de>
Date: Tue, 2 Feb 2021 16:30:59 -0800
Subject: fix patchpbf test on 32-bit

Origin: https://github.com/opencontainers/runc/pull/2768/commits/47a96495208f5dfdceabc1a2acbfa1c0517aac80
---
 libcontainer/seccomp/patchbpf/enosys_linux_test.go | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/libcontainer/seccomp/patchbpf/enosys_linux_test.go b/libcontainer/seccomp/patchbpf/enosys_linux_test.go
index 17b92af..f9a4bf6 100644
--- a/libcontainer/seccomp/patchbpf/enosys_linux_test.go
+++ b/libcontainer/seccomp/patchbpf/enosys_linux_test.go
@@ -159,7 +159,7 @@ func testEnosysStub(t *testing.T, defaultAction configs.Action, arches []string)
 			type syscallTest struct {
 				syscall  string
 				sysno    libseccomp.ScmpSyscall
-				expected int
+				expected uint32
 			}
 
 			scmpArch, err := libseccomp.GetArchFromString(arch)
@@ -177,9 +177,9 @@ func testEnosysStub(t *testing.T, defaultAction configs.Action, arches []string)
 			// Add explicit syscalls (whether they will return -ENOSYS
 			// depends on the filter rules).
 			for idx, syscall := range explicitSyscalls {
-				expected := int(retFallthrough)
+				expected := retFallthrough
 				if idx >= enosysStart {
-					expected = int(retErrnoEnosys)
+					expected = retErrnoEnosys
 				}
 				sysno, err := libseccomp.GetSyscallFromNameByArch(syscall, scmpArch)
 				if err != nil {
@@ -201,7 +201,7 @@ func testEnosysStub(t *testing.T, defaultAction configs.Action, arches []string)
 				syscallTests = append(syscallTests, syscallTest{
 					sysno:    sysno,
 					syscall:  syscall,
-					expected: int(retFallthrough),
+					expected: retFallthrough,
 				})
 			}
 
@@ -216,7 +216,7 @@ func testEnosysStub(t *testing.T, defaultAction configs.Action, arches []string)
 				syscallTests = append(syscallTests, syscallTest{
 					sysno:    sysno,
 					syscall:  fmt.Sprintf("syscall_%#x", sysno),
-					expected: int(retErrnoEnosys),
+					expected: retErrnoEnosys,
 				})
 			}
 
@@ -224,14 +224,17 @@ func testEnosysStub(t *testing.T, defaultAction configs.Action, arches []string)
 			for _, test := range syscallTests {
 				// Override the expected value in the two special cases.
 				if !archSet[arch] || isAllowAction(defaultAction) {
-					test.expected = int(retFallthrough)
+					test.expected = retFallthrough
 				}
 
 				payload := mockSyscallPayload(t, test.sysno, nativeArch, 0x1337, 0xF00BA5)
-				ret, err := filter.Run(payload)
+				// NOTE: golang.org/x/net/bpf returns int here rather
+				// than uint32.
+				rawRet, err := filter.Run(payload)
 				if err != nil {
 					t.Fatalf("error running filter: %v", err)
 				}
+				ret := uint32(rawRet)
 				if ret != test.expected {
 					t.Logf("mock filter for %v %v:", arches, allowedSyscalls)
 					for idx, insn := range program {