Discussion:
[PATCH v3 1/3] KEYS: Don't write out to userspace while holding key semaphore
(too old to reply)
Jarkko Sakkinen
2020-03-16 13:53:30 UTC
Permalink
I guess we cannot sanely define fixes tag for this one, can we?
Fixes: ^1da177e4c3f4 ("Linux-2.6.12-rc2")
David
Longmao, please include this to the next version.

/Jarkko
David Howells
2020-03-16 14:24:32 UTC
Permalink
I wonder if it's worth merging this into patch 2. I'm not sure it's really
worth its own patch. If you want to generalise kvzfree(), then that could go
as its own patch first.

David
Waiman Long
2020-03-16 15:21:29 UTC
Permalink
Post by David Howells
I wonder if it's worth merging this into patch 2. I'm not sure it's really
worth its own patch. If you want to generalise kvzfree(), then that could go
as its own patch first.
David
Sure, I can merge it into patch 2.

Thanks,
Longman
Jarkko Sakkinen
2020-03-16 22:19:06 UTC
Permalink
Post by David Howells
I wonder if it's worth merging this into patch 2. I'm not sure it's really
worth its own patch. If you want to generalise kvzfree(), then that could go
as its own patch first.
David
Also in the sense that there is no senseful situation where you'd
only wanted to pick either but not both.

/Jarkko
Waiman Long
2020-03-16 16:33:17 UTC
Permalink
Post by Jarkko Sakkinen
I guess we cannot sanely define fixes tag for this one, can we?
Fixes: ^1da177e4c3f4 ("Linux-2.6.12-rc2")
David
Longmao, please include this to the next version.
/Jarkko
Sure, will do.

Cheers,
Longman
Waiman Long
2020-03-17 18:09:53 UTC
Permalink
include/linux/key-type.h | 2 +-
security/keys/big_key.c | 11 ++---
security/keys/encrypted-keys/encrypted.c | 7 ++-
security/keys/keyctl.c | 57 +++++++++++++++++++----
security/keys/keyring.c | 6 +--
security/keys/request_key_auth.c | 7 ++-
security/keys/trusted-keys/trusted_tpm1.c | 14 +-----
security/keys/user_defined.c | 5 +-
...
- long (*read)(const struct key *key, char __user *buffer, size_t buflen);
+ long (*read)(const struct key *key, char *buffer, size_t buflen);
Note that there are read functions outside of security/keys/ that also need
fixing - dns_resolver_read() and rxrpc_read().
David
Yes, I am going to fix that. Sorry for the delay as I am juggling a few
different tasks.

Cheers,
Longman
Waiman Long
2020-03-17 18:10:22 UTC
Permalink
Post by Jarkko Sakkinen
I guess we cannot sanely define fixes tag for this one, can we?
Fixes: ^1da177e4c3f4 ("Linux-2.6.12-rc2")
David
Longmao, please include this to the next version.
/Jarkko
Sure, will do.

Cheers,
Longman
Waiman Long
2020-03-17 18:36:50 UTC
Permalink
- * Read methods will just return the required length
- * without any copying if the provided length isn't big
- * enough.
+ * We don't want an erronous -ENOMEM error due to an
+ * arbitrary large user-supplied buflen. So if buflen
+ * exceeds a threshold (1024 bytes in this case), we call
+ * the read method twice. The first time to get the buffer
+ * length and the second time to read out the key data.
+ *
+ * N.B. All the read methods will return the required
+ * buffer length with a NULL input buffer or when
+ * the input buffer length isn't large enough.
*/
+ if (buflen <= 0x400) {
1. The overwhelmingly long comment. Will be destined to rotten.
2. Magic number.
3. The cap must be updated both in comment and code, and not only
that, but the numbers use a different base (dec and hex).
/Jarkko
Thank for the comment. I will make the necessary change.

Cheers,
Longman

Loading...