Skip to contentSkip to conversation

IMA/EVM interfaces

DISCUSSION Denis Efremov 3 participants 5 messages Jul 28, 2020 – Jul 31, 2020 Keys-trusted

lore
Share & tools
lore
#0 lore raw

Hi,

I've started to add integrity interfaces descriptions to syzkaller
(https://github.com/google/syzkaller/pull/1970).

I've got a question, if you don't mind:

If I write 2 to /sys/kernel/security/integrity/evm/evm before loading keys, subsequent fs operations will fail with -ENOKEY.

$ echo 2 > /sys/kernel/security/integrity/evm/evm
$ touch test.txt
[  526.976855][ T5771] evm: HMAC key is not set
[  526.977892][ T5771] evm: init_desc failed
touch: cannot touch 'test.txt': Required key not available

Is this a desired behavior? Should there be a check in evm_write_key() for loaded keys (encrypted evm-key, keys in _evm, _ima keyrings) before changing the evm_initialized bit? Is it correct to set second bit without first bit?

Thanks,
Denis

#1 lore raw
Quoted 19 lines

From: [email protected] [mailto:linux-integrity- [email protected]] On Behalf Of Denis Efremov
Sent: Tuesday, July 28, 2020 12:32 PM
Hi,

I've started to add integrity interfaces descriptions to syzkaller
(https://github.com/google/syzkaller/pull/1970).

I've got a question, if you don't mind:

If I write 2 to /sys/kernel/security/integrity/evm/evm before loading keys, subsequent fs operations will fail with -ENOKEY.

$ echo 2 > /sys/kernel/security/integrity/evm/evm
$ touch test.txt
[  526.976855][ T5771] evm: HMAC key is not set
[  526.977892][ T5771] evm: init_desc failed
touch: cannot touch 'test.txt': Required key not available
Quoted 4 lines

Is this a desired behavior? Should there be a check in evm_write_key() for loaded keys (encrypted evm-key, keys in _evm, _ima keyrings) before changing the evm_initialized bit? Is it correct to set second bit without first bit?

Hi Denis

can you please try this patch?

https://lore.kernel.org/linux-integrity/[email protected]/

Thanks

Roberto

HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Li Peng, Li Jian, Shi Yanli

#2 lore raw
Quoted 24 lines · Roberto Sassu
Quoted 19 lines

From: [email protected] [mailto:linux-integrity- [email protected]] On Behalf Of Denis Efremov
Sent: Tuesday, July 28, 2020 12:32 PM
Hi,

I've started to add integrity interfaces descriptions to syzkaller
(https://github.com/google/syzkaller/pull/1970).

I've got a question, if you don't mind:

If I write 2 to /sys/kernel/security/integrity/evm/evm before loading keys, subsequent fs operations will fail with -ENOKEY.

$ echo 2 > /sys/kernel/security/integrity/evm/evm
$ touch test.txt
[  526.976855][ T5771] evm: HMAC key is not set
[  526.977892][ T5771] evm: init_desc failed
touch: cannot touch 'test.txt': Required key not available
Quoted 4 lines

Is this a desired behavior? Should there be a check in evm_write_key() for loaded keys (encrypted evm-key, keys in _evm, _ima keyrings) before changing the evm_initialized bit? Is it correct to set second bit without first bit?

Quoted 7 lines

Hi Denis

can you please try this patch?

https://lore.kernel.org/linux-integrity/[email protected]/

$ cat /proc/cmdline
console=ttyS0 root=/dev/sda earlyprintk=serial ima_appraise=fix evm=fix
$ echo 2 > /sys/kernel/security/integrity/evm/evm
[   44.116084][ T4108] evm: HMAC key is not set
$ touch test.txt
$ cat /sys/kernel/security/integrity/evm/evm
2
$ keyctl add user kmk-user "`cat /etc/keys/kmk-user.blob`" @u
$ keyctl add encrypted evm-key "load `cat /etc/keys/evm-user.blob`" @u
$ echo 1 > /sys/kernel/security/integrity/evm/evm
[  574.328262] evm: key initialized

Regards,
Denis

#3 lore raw
Quoted 11 lines

From: Denis Efremov [mailto:[email protected]]
Sent: Wednesday, July 29, 2020 11:59 PM

Quoted 5 lines · Roberto Sassu
Quoted 5 lines

From: [email protected] [mailto:linux-integrity- [email protected]] On Behalf Of Denis Efremov
Sent: Tuesday, July 28, 2020 12:32 PM
Hi,

Quoted 11 lines
Quoted 6 lines
Quoted 6 lines

I've started to add integrity interfaces descriptions to syzkaller
(https://github.com/google/syzkaller/pull/1970).

I've got a question, if you don't mind:

If I write 2 to /sys/kernel/security/integrity/evm/evm before loading

keys,

Quoted 4 lines
Quoted 4 lines

subsequent fs operations will fail with -ENOKEY.

$ echo 2 > /sys/kernel/security/integrity/evm/evm
$ touch test.txt

Looks good. Mimi, could you please take this patch, and if possible, the others in the patch set?

Thanks

Roberto

HUAWEI TECHNOLOGIES Duesseldorf GmbH, HRB 56063
Managing Director: Li Peng, Li Jian, Shi Yanli

Quoted 33 lines
Quoted 6 lines
Quoted 6 lines
[  526.976855][ T5771] evm: HMAC key is not set
[  526.977892][ T5771] evm: init_desc failed

touch: cannot touch 'test.txt': Required key not available

Is this a desired behavior? Should there be a check in evm_write_key() for loaded keys (encrypted evm-key, keys in _evm, _ima keyrings)

before

Quoted 8 lines
Quoted 2 lines

changing the evm_initialized bit? Is it correct to set second bit without first bit?

Hi Denis

can you please try this patch?

https://lore.kernel.org/linux-integrity/20200618160133.937-1-

[email protected]/

Quoted 2 lines
$ cat /proc/cmdline
console=ttyS0 root=/dev/sda earlyprintk=serial ima_appraise=fix evm=fix
$ echo 2 > /sys/kernel/security/integrity/evm/evm
[   44.116084][ T4108] evm: HMAC key is not set
$ touch test.txt
$ cat /sys/kernel/security/integrity/evm/evm
2
$ keyctl add user kmk-user "`cat /etc/keys/kmk-user.blob`" @u
$ keyctl add encrypted evm-key "load `cat /etc/keys/evm-user.blob`" @u
$ echo 1 > /sys/kernel/security/integrity/evm/evm
[  574.328262] evm: key initialized

Regards,
Denis

maintainer
#4 lore raw
Quoted 20 lines · Roberto Sassu
Quoted 20 lines

From: Denis Efremov [mailto:[email protected]]
Sent: Wednesday, July 29, 2020 11:59 PM

Quoted 14 lines · Roberto Sassu
Quoted 14 lines

From: [email protected] [mailto:linux- integrity-
[email protected]] On Behalf Of Denis Efremov
Sent: Tuesday, July 28, 2020 12:32 PM
Hi,

I've started to add integrity interfaces descriptions to syzkaller
(https://github.com/google/syzkaller/pull/1970).

I've got a question, if you don't mind:

If I write 2 to /sys/kernel/security/integrity/evm/evm before loading

Quoted 8 lines
Quoted 5 lines

keys,

Quoted 4 lines
Quoted 4 lines

subsequent fs operations will fail with -ENOKEY.

$ echo 2 > /sys/kernel/security/integrity/evm/evm
$ touch test.txt

Looks good. Mimi, could you please take this patch, and if possible, the others in the patch set?

Just needing to finish up the ima-evm-utils release and finish
reviewing Kees' " Introduce partial kernel_read_file() support" patchset. Will circle back around to EVM shortly.

In the meantime, could you take a look at the syzbot "possible deadlock
in process_measurement" report. According to Amir Goldstein, this
isn't a lock order inversion. It just needs to be properly annotated.

thanks,

Mimi