containers / ocicrypt

Encryption libraries for Encrypted OCI Container images
Apache License 2.0
146 stars 33 forks source link

FYI: pkcs11 test crashes on Fedora (softhsm 2.6.1-5) #96

Closed stefanberger closed 12 months ago

stefanberger commented 1 year ago

The pkcs11 test crash on Fedora with softhsm 2.6.1-5. Also miekg's test cases with softhsm crash on Fedora (test needs proper path adjustment for softhsm shared object). The pkcs11 test runs stable on Ubuntu 21.10 for example with softhsm 2.6.1-2.

Example crash output:

=== RUN   TestPkcs11EncryptDecrypt
Inconsistency detected by ld.so: dl-close.c: 256: _dl_close_worker: Assertion `imap->l_type == lt_loaded && !imap->l_nodelete_active' failed!
FAIL    github.com/containers/ocicrypt/crypto/pkcs11    1.323s
=== RUN   TestKeyWrapPkcs11Success
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x45 pc=0x7fa4e83ea4f5]

runtime stack:
runtime.throw({0x67995a?, 0xffffffffffffffb8?})
        /usr/lib/golang/src/runtime/panic.go:1047 +0x5d fp=0x7fa4bbffe8c0 sp=0x7fa4bbffe890 pc=0x43a61d
runtime.sigpanic()
        /usr/lib/golang/src/runtime/signal_unix.go:825 +0x3e9 fp=0x7fa4bbffe920 sp=0x7fa4bbffe8c0 pc=0x4516e9

goroutine 6 [syscall]:
runtime.cgocall(0x6124c0, 0xc0000d1ac8)
        /usr/lib/golang/src/runtime/cgocall.go:157 +0x5c fp=0xc0000d1aa0 sp=0xc0000d1a68 pc=0x4080bc
github.com/miekg/pkcs11._Cfunc_Destroy(0x7fa4b4001010)
        _cgo_gotypes.go:700 +0x45 fp=0xc0000d1ac8 sp=0xc0000d1aa0 pc=0x5852e5
github.com/miekg/pkcs11.(*Ctx).Destroy.func1(0x0?)
        /home/stefanb/go/pkg/mod/github.com/miekg/pkcs11@v1.1.1/pkcs11.go:802 +0x3a fp=0xc0000d1b00 sp=0xc0000d1ac8 pc=0x58725a
github.com/miekg/pkcs11.(*Ctx).Destroy(0xc0000142f8)
        /home/stefanb/go/pkg/mod/github.com/miekg/pkcs11@v1.1.1/pkcs11.go:802 +0x29 fp=0xc0000d1b18 sp=0xc0000d1b00 pc=0x5871c9
github.com/containers/ocicrypt/crypto/pkcs11.pkcs11Logout(0x1?, 0x2?)
        /home/stefanb/src/github/containers/ocicrypt/crypto/pkcs11/pkcs11helpers.go:214 +0x48 fp=0xc0000d1b48 sp=0xc0000d1b18 pc=0x58c168
github.com/containers/ocicrypt/crypto/pkcs11.publicEncryptOAEP.func2()
        /home/stefanb/src/github/containers/ocicrypt/crypto/pkcs11/pkcs11helpers.go:269 +0x2a fp=0xc0000d1b68 sp=0xc0000d1b48 pc=0x58d0ca
runtime.deferreturn()
        /usr/lib/golang/src/runtime/panic.go:476 +0x33 fp=0xc0000d1ba8 sp=0xc0000d1b68 pc=0x439073
github.com/containers/ocicrypt/crypto/pkcs11.publicEncryptOAEP(0xc0000142e8, {0xc00001a660, 0x18, 0x18})
        /home/stefanb/src/github/containers/ocicrypt/crypto/pkcs11/pkcs11helpers.go:306 +0x510 fp=0xc0000d1d70 sp=0xc0000d1ba8 pc=0x58ccb0
github.com/containers/ocicrypt/crypto/pkcs11.EncryptMultiple({0xc000071d10, 0x1, 0x1?}, {0xc00001a660, 0x18, 0x18})
        /home/stefanb/src/github/containers/ocicrypt/crypto/pkcs11/pkcs11helpers.go:404 +0x145 fp=0xc0000d1e30 sp=0xc0000d1d70 pc=0x58db45
github.com/containers/ocicrypt/keywrap/pkcs11.(*pkcs11KeyWrapper).WrapKeys(0x670e55?, 0xc000070d00, {0xc00001a660, 0x18, 0x18})
        /home/stefanb/src/github/containers/ocicrypt/keywrap/pkcs11/keywrapper_pkcs11.go:57 +0x1cb fp=0xc0000d1ea8 sp=0xc0000d1e30 pc=0x60ea0b
github.com/containers/ocicrypt/keywrap/pkcs11.TestKeyWrapPkcs11Success(0xc0000d8820)
        /home/stefanb/src/github/containers/ocicrypt/keywrap/pkcs11/keywrapper_pkcs11_test.go:171 +0x197 fp=0xc0000d1f70 sp=0xc0000d1ea8 pc=0x6106b7
testing.tRunner(0xc0000d8820, 0x6954d0)
        /usr/lib/golang/src/testing/testing.go:1576 +0x10b fp=0xc0000d1fc0 sp=0xc0000d1f70 pc=0x4e51ab
testing.(*T).Run.func1()
        /usr/lib/golang/src/testing/testing.go:1629 +0x2a fp=0xc0000d1fe0 sp=0xc0000d1fc0 pc=0x4e61ea
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000d1fe8 sp=0xc0000d1fe0 pc=0x46ee81
created by testing.(*T).Run
        /usr/lib/golang/src/testing/testing.go:1629 +0x3ea

goroutine 1 [chan receive]:
runtime.gopark(0x821fe0?, 0xc0000140d0?, 0x30?, 0xec?, 0xc0000d5a28?)
        /usr/lib/golang/src/runtime/proc.go:381 +0xd6 fp=0xc0000d59a8 sp=0xc0000d5988 pc=0x43d376
runtime.chanrecv(0xc00007c2a0, 0xc0000d5aa7, 0x1)
        /usr/lib/golang/src/runtime/chan.go:583 +0x49d fp=0xc0000d5a38 sp=0xc0000d59a8 pc=0x40ae3d
runtime.chanrecv1(0x8214a0?, 0x62c520?)
        /usr/lib/golang/src/runtime/chan.go:442 +0x18 fp=0xc0000d5a60 sp=0xc0000d5a38 pc=0x40a978
testing.(*T).Run(0xc0000d8680, {0x672115?, 0x4e4ec5?}, 0x6954d0)
        /usr/lib/golang/src/testing/testing.go:1630 +0x405 fp=0xc0000d5b20 sp=0xc0000d5a60 pc=0x4e6065
testing.runTests.func1(0x821fe0?)
        /usr/lib/golang/src/testing/testing.go:2036 +0x45 fp=0xc0000d5b70 sp=0xc0000d5b20 pc=0x4e81c5
testing.tRunner(0xc0000d8680, 0xc0000d5c88)
        /usr/lib/golang/src/testing/testing.go:1576 +0x10b fp=0xc0000d5bc0 sp=0xc0000d5b70 pc=0x4e51ab
testing.runTests(0xc0000aa640?, {0x7fcee0, 0x2, 0x2}, {0xc0000a2190?, 0x100c0000d5d10?, 0x821740?})
        /usr/lib/golang/src/testing/testing.go:2034 +0x489 fp=0xc0000d5cb8 sp=0xc0000d5bc0 pc=0x4e80a9
testing.(*M).Run(0xc0000aa640)
        /usr/lib/golang/src/testing/testing.go:1906 +0x63a fp=0xc0000d5f00 sp=0xc0000d5cb8 pc=0x4e6a1a
main.main()
        _testmain.go:49 +0x1aa fp=0xc0000d5f80 sp=0xc0000d5f00 pc=0x610e0a
runtime.main()
        /usr/lib/golang/src/runtime/proc.go:250 +0x207 fp=0xc0000d5fe0 sp=0xc0000d5f80 pc=0x43cf47
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000d5fe8 sp=0xc0000d5fe0 pc=0x46ee81

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/lib/golang/src/runtime/proc.go:381 +0xd6 fp=0xc00005afb0 sp=0xc00005af90 pc=0x43d376
runtime.goparkunlock(...)
        /usr/lib/golang/src/runtime/proc.go:387
runtime.forcegchelper()
        /usr/lib/golang/src/runtime/proc.go:305 +0xb0 fp=0xc00005afe0 sp=0xc00005afb0 pc=0x43d1b0
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005afe8 sp=0xc00005afe0 pc=0x46ee81
created by runtime.init.6
        /usr/lib/golang/src/runtime/proc.go:293 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/lib/golang/src/runtime/proc.go:381 +0xd6 fp=0xc00005b780 sp=0xc00005b760 pc=0x43d376
runtime.goparkunlock(...)
        /usr/lib/golang/src/runtime/proc.go:387
runtime.bgsweep(0x0?)
        /usr/lib/golang/src/runtime/mgcsweep.go:278 +0x8e fp=0xc00005b7c8 sp=0xc00005b780 pc=0x427e8e
runtime.gcenable.func1()
        /usr/lib/golang/src/runtime/mgc.go:178 +0x26 fp=0xc00005b7e0 sp=0xc00005b7c8 pc=0x41d146
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005b7e8 sp=0xc00005b7e0 pc=0x46ee81
created by runtime.gcenable
        /usr/lib/golang/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc00007c000?, 0x6cee70?, 0x1?, 0x0?, 0x0?)
        /usr/lib/golang/src/runtime/proc.go:381 +0xd6 fp=0xc00005bf70 sp=0xc00005bf50 pc=0x43d376
runtime.goparkunlock(...)
        /usr/lib/golang/src/runtime/proc.go:387
runtime.(*scavengerState).park(0x8217c0)
        /usr/lib/golang/src/runtime/mgcscavenge.go:400 +0x53 fp=0xc00005bfa0 sp=0xc00005bf70 pc=0x425db3
runtime.bgscavenge(0x0?)
        /usr/lib/golang/src/runtime/mgcscavenge.go:628 +0x45 fp=0xc00005bfc8 sp=0xc00005bfa0 pc=0x426385
runtime.gcenable.func2()
        /usr/lib/golang/src/runtime/mgc.go:179 +0x26 fp=0xc00005bfe0 sp=0xc00005bfc8 pc=0x41d0e6
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005bfe8 sp=0xc00005bfe0 pc=0x46ee81
created by runtime.gcenable
        /usr/lib/golang/src/runtime/mgc.go:179 +0xaa

goroutine 5 [finalizer wait]:
runtime.gopark(0x1a0?, 0x821fe0?, 0x60?, 0x78?, 0xc00005a770?)
        /usr/lib/golang/src/runtime/proc.go:381 +0xd6 fp=0xc00005a628 sp=0xc00005a608 pc=0x43d376
runtime.runfinq()
        /usr/lib/golang/src/runtime/mfinal.go:193 +0x107 fp=0xc00005a7e0 sp=0xc00005a628 pc=0x41c187
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005a7e8 sp=0xc00005a7e0 pc=0x46ee81
created by runtime.createfing
        /usr/lib/golang/src/runtime/mfinal.go:163 +0x45
FAIL    github.com/containers/ocicrypt/keywrap/pkcs11   6.752s

The miekg's pkcs11 test cases crash in a similar way on ctxt.Destroy():

?       github.com/miekg/pkcs11/p11     [no test files]
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x7fa337116487]

runtime stack:
runtime.throw({0x5a4580?, 0x4?})
        /usr/lib/golang/src/runtime/panic.go:1047 +0x5d fp=0x7ffd249390d0 sp=0x7ffd249390a0 pc=0x43a0dd
runtime.sigpanic()
        /usr/lib/golang/src/runtime/signal_unix.go:825 +0x3e9 fp=0x7ffd24939130 sp=0x7ffd249390d0 pc=0x4511a9

goroutine 10 [syscall]:
runtime.cgocall(0x5564f0, 0xc00006eda8)
        /usr/lib/golang/src/runtime/cgocall.go:157 +0x5c fp=0xc00006ed80 sp=0xc00006ed48 pc=0x40807c
github.com/miekg/pkcs11._Cfunc_Destroy(0x1f4fa50)
        _cgo_gotypes.go:709 +0x45 fp=0xc00006eda8 sp=0xc00006ed80 pc=0x54a4a5
github.com/miekg/pkcs11.(*Ctx).Destroy.func1(0x100?)
        /home/stefanb/src/github/miekg/pkcs11/pkcs11.go:804 +0x3a fp=0xc00006ede0 sp=0xc00006eda8 pc=0x54d9da
github.com/miekg/pkcs11.(*Ctx).Destroy(0xc0000158c8)
        /home/stefanb/src/github/miekg/pkcs11/pkcs11.go:804 +0x29 fp=0xc00006edf8 sp=0xc00006ede0 pc=0x54d949
github.com/miekg/pkcs11.finishSession(0xc000197550?, 0xc000015928?)
        /home/stefanb/src/github/miekg/pkcs11/pkcs11_test.go:96 +0x48 fp=0xc00006ee28 sp=0xc00006edf8 pc=0x545208
github.com/miekg/pkcs11.TestOAEPParams.func1()
        /home/stefanb/src/github/miekg/pkcs11/params_test.go:89 +0x2a fp=0xc00006ee48 sp=0xc00006ee28 pc=0x54408a
github.com/miekg/pkcs11.TestOAEPParams(0xc0000c0d00)
        /home/stefanb/src/github/miekg/pkcs11/params_test.go:113 +0x4f7 fp=0xc00006ef70 sp=0xc00006ee48 pc=0x543ff7
testing.tRunner(0xc0000c0d00, 0x5a7a08)
        /usr/lib/golang/src/testing/testing.go:1576 +0x10b fp=0xc00006efc0 sp=0xc00006ef70 pc=0x4cb08b
testing.(*T).Run.func1()
        /usr/lib/golang/src/testing/testing.go:1629 +0x2a fp=0xc00006efe0 sp=0xc00006efc0 pc=0x4cc0ca
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00006efe8 sp=0xc00006efe0 pc=0x46e061
created by testing.(*T).Run
        /usr/lib/golang/src/testing/testing.go:1629 +0x3ea

goroutine 1 [chan receive]:
runtime.gopark(0x6c2d20?, 0xc0000158c0?, 0xf0?, 0x28?, 0xc00006da28?)
        /usr/lib/golang/src/runtime/proc.go:381 +0xd6 fp=0xc00006d9a8 sp=0xc00006d988 pc=0x43ce36
runtime.chanrecv(0xc00007c1c0, 0xc00006daa7, 0x1)
        /usr/lib/golang/src/runtime/chan.go:583 +0x49d fp=0xc00006da38 sp=0xc00006d9a8 pc=0x40adfd
runtime.chanrecv1(0x6c22c0?, 0x56a3c0?)
        /usr/lib/golang/src/runtime/chan.go:442 +0x18 fp=0xc00006da60 sp=0xc00006da38 pc=0x40a938
testing.(*T).Run(0xc0000c01a0, {0x59c337?, 0x4cada5?}, 0x5a7a08)
        /usr/lib/golang/src/testing/testing.go:1630 +0x405 fp=0xc00006db20 sp=0xc00006da60 pc=0x4cbf45
testing.runTests.func1(0x6c2d20?)
        /usr/lib/golang/src/testing/testing.go:2036 +0x45 fp=0xc00006db70 sp=0xc00006db20 pc=0x4ce0a5
testing.tRunner(0xc0000c01a0, 0xc00006dc88)
        /usr/lib/golang/src/testing/testing.go:1576 +0x10b fp=0xc00006dbc0 sp=0xc00006db70 pc=0x4cb08b
testing.runTests(0xc0000ac0a0?, {0x6a8960, 0x10, 0x10}, {0xc0000a1a78?, 0x100c00006dd10?, 0x6c2480?})
        /usr/lib/golang/src/testing/testing.go:2034 +0x489 fp=0xc00006dcb8 sp=0xc00006dbc0 pc=0x4cdf89
testing.(*M).Run(0xc0000ac0a0)
        /usr/lib/golang/src/testing/testing.go:1906 +0x63a fp=0xc00006df00 sp=0xc00006dcb8 pc=0x4cc8fa
main.main()
        _testmain.go:79 +0x1aa fp=0xc00006df80 sp=0xc00006df00 pc=0x554e2a
runtime.main()
        /usr/lib/golang/src/runtime/proc.go:250 +0x207 fp=0xc00006dfe0 sp=0xc00006df80 pc=0x43ca07
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00006dfe8 sp=0xc00006dfe0 pc=0x46e061

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/lib/golang/src/runtime/proc.go:381 +0xd6 fp=0xc00005afb0 sp=0xc00005af90 pc=0x43ce36
runtime.goparkunlock(...)
        /usr/lib/golang/src/runtime/proc.go:387
runtime.forcegchelper()
        /usr/lib/golang/src/runtime/proc.go:305 +0xb0 fp=0xc00005afe0 sp=0xc00005afb0 pc=0x43cc70
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005afe8 sp=0xc00005afe0 pc=0x46e061
created by runtime.init.6
        /usr/lib/golang/src/runtime/proc.go:293 +0x25

goroutine 3 [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
        /usr/lib/golang/src/runtime/proc.go:381 +0xd6 fp=0xc00005b780 sp=0xc00005b760 pc=0x43ce36
runtime.goparkunlock(...)
        /usr/lib/golang/src/runtime/proc.go:387
runtime.bgsweep(0x0?)
        /usr/lib/golang/src/runtime/mgcsweep.go:278 +0x8e fp=0xc00005b7c8 sp=0xc00005b780 pc=0x42794e
runtime.gcenable.func1()
        /usr/lib/golang/src/runtime/mgc.go:178 +0x26 fp=0xc00005b7e0 sp=0xc00005b7c8 pc=0x41cc06
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005b7e8 sp=0xc00005b7e0 pc=0x46e061
created by runtime.gcenable
        /usr/lib/golang/src/runtime/mgc.go:178 +0x6b

goroutine 4 [GC scavenge wait]:
runtime.gopark(0xc00007c000?, 0x5cdf90?, 0x1?, 0x0?, 0x0?)
        /usr/lib/golang/src/runtime/proc.go:381 +0xd6 fp=0xc00005bf70 sp=0xc00005bf50 pc=0x43ce36
runtime.goparkunlock(...)
        /usr/lib/golang/src/runtime/proc.go:387
runtime.(*scavengerState).park(0x6c2500)
        /usr/lib/golang/src/runtime/mgcscavenge.go:400 +0x53 fp=0xc00005bfa0 sp=0xc00005bf70 pc=0x425873
runtime.bgscavenge(0x0?)
        /usr/lib/golang/src/runtime/mgcscavenge.go:628 +0x45 fp=0xc00005bfc8 sp=0xc00005bfa0 pc=0x425e45
runtime.gcenable.func2()
        /usr/lib/golang/src/runtime/mgc.go:179 +0x26 fp=0xc00005bfe0 sp=0xc00005bfc8 pc=0x41cba6
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005bfe8 sp=0xc00005bfe0 pc=0x46e061
created by runtime.gcenable
        /usr/lib/golang/src/runtime/mgc.go:179 +0xaa

goroutine 5 [finalizer wait]:
runtime.gopark(0x1a0?, 0x6c2d20?, 0x60?, 0x78?, 0xc00005a770?)
        /usr/lib/golang/src/runtime/proc.go:381 +0xd6 fp=0xc00005a628 sp=0xc00005a608 pc=0x43ce36
runtime.runfinq()
        /usr/lib/golang/src/runtime/mfinal.go:193 +0x107 fp=0xc00005a7e0 sp=0xc00005a628 pc=0x41bc47
runtime.goexit()
        /usr/lib/golang/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc00005a7e8 sp=0xc00005a7e0 pc=0x46e061
created by runtime.createfing
        /usr/lib/golang/src/runtime/mfinal.go:163 +0x45
FAIL    github.com/miekg/pkcs11 1.148s
FAIL
stefanberger commented 1 year ago

@mtrmac Just FYI.

stefanberger commented 12 months ago

Strange, now the pkcs11 tests with softhsm are working fine on two Fedora 38 machines. Maybe a dependency was fixed because softhsm wasn't changed.