Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KEYS: asymmetric: Copy sig and digest in public_key_verify_signature() #222

Open
wants to merge 1 commit into
base: dev-6.1
Choose a base branch
from

Conversation

stefanberger
Copy link

Commit ac4e97a ("scatterlist: sg_set_buf() argument must be in linear mapping") checks that both the signature and the digest reside in the linear mapping area.

However, more recently commit ba14a19 ("fork: Add generic vmalloced stack support") made it possible to move the stack in the vmalloc area, which is not contiguous, and thus not suitable for sg_set_buf() which needs adjacent pages.

Always make a copy of the signature and digest in the same buffer used to store the key and its parameters, and pass them to sg_init_one(). Prefer it to conditionally doing the copy if necessary, to keep the code simple. The buffer allocated with kmalloc() is in the linear mapping area.

Cc: [email protected] # 4.9.x
Fixes: ba14a19 ("fork: Add generic vmalloced stack support")
Link: https://lore.kernel.org/linux-integrity/[email protected]/
Suggested-by: Eric Biggers [email protected]

Reviewed-by: Eric Biggers [email protected]
Tested-by: Stefan Berger [email protected]

Commit ac4e97a ("scatterlist: sg_set_buf() argument must be in linear
mapping") checks that both the signature and the digest reside in the
linear mapping area.

However, more recently commit ba14a19 ("fork: Add generic vmalloced
stack support") made it possible to move the stack in the vmalloc area,
which is not contiguous, and thus not suitable for sg_set_buf() which needs
adjacent pages.

Always make a copy of the signature and digest in the same buffer used to
store the key and its parameters, and pass them to sg_init_one(). Prefer it
to conditionally doing the copy if necessary, to keep the code simple. The
buffer allocated with kmalloc() is in the linear mapping area.

Cc: [email protected] # 4.9.x
Fixes: ba14a19 ("fork: Add generic vmalloced stack support")
Link: https://lore.kernel.org/linux-integrity/[email protected]/
Suggested-by: Eric Biggers <[email protected]>
Signed-off-by: Roberto Sassu <[email protected]>
Reviewed-by: Eric Biggers <[email protected]>
Tested-by: Stefan Berger <[email protected]>
@stefanberger
Copy link
Author

stefanberger commented Jun 5, 2023

This particular patch has now been merged upstream: torvalds@c3d03e8

I need this patch for proper EVM signature enforcement and will drop it from my OpenBMC series of patches once the OpenBMC Linux build includes this patch. I have been carrying this patch here lately: https://gerrit.openbmc.org/c/openbmc/openbmc/+/63909

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants