From: David Howells <dhowells@redhat.com>
To: torvalds@osdl.org, akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Keys: Fix key management syscall interface bugs
Date: Thu, 04 Aug 2005 11:50:01 +0100 [thread overview]
Message-ID: <8602.1123152601@warthog.cambridge.redhat.com> (raw)
The attached patch fixes five bugs in the key management syscall interface:
(1) add_key() returns 0 rather than EINVAL if the key type is "".
Checking the key type isn't "" should be left to lookup_user_key().
(2) request_key() returns ENOKEY rather than EPERM if the key type begins
with a ".".
lookup_user_key() can't do this because internal key types begin with a
".".
(3) Key revocation always returns 0, even if it fails.
(4) Key read can return EAGAIN rather than EACCES under some circumstances.
A key is permitted to by read by a process if it doesn't grant read
access, but it does grant search access and it is in the process's
keyrings. That search returns EAGAIN if it fails, and this needs
translating to EACCES.
(5) request_key() never adds the new key to the destination keyring if one is
supplied.
The wrong macro was being used to test for an error condition: PTR_ERR()
will always return true, whether or not there's an error; this should've
been IS_ERR().
Signed-Off-By: David Howells <dhowells@redhat.com>
---
warthog>diffstat -p1 keys-ui-fixes-2613rc2mm1.diff
security/keys/keyctl.c | 11 +++++++----
security/keys/request_key.c | 2 +-
2 files changed, 8 insertions(+), 5 deletions(-)
diff -uNrp linux-2.6.13-rc2-mm1/security/keys/keyctl.c linux-2.6.13-rc2-mm1-keys/security/keys/keyctl.c
--- linux-2.6.13-rc2-mm1/security/keys/keyctl.c 2005-07-07 22:23:15.000000000 +0100
+++ linux-2.6.13-rc2-mm1-keys/security/keys/keyctl.c 2005-08-04 11:48:12.000000000 +0100
@@ -49,9 +49,6 @@ asmlinkage long sys_add_key(const char _
goto error;
type[31] = '\0';
- if (!type[0])
- goto error;
-
ret = -EPERM;
if (type[0] == '.')
goto error;
@@ -144,6 +141,10 @@ asmlinkage long sys_request_key(const ch
goto error;
type[31] = '\0';
+ ret = -EPERM;
+ if (type[0] == '.')
+ goto error;
+
/* pull the description into kernel space */
ret = -EFAULT;
dlen = strnlen_user(_description, PAGE_SIZE - 1);
@@ -362,7 +363,7 @@ long keyctl_revoke_key(key_serial_t id)
key_put(key);
error:
- return 0;
+ return ret;
} /* end keyctl_revoke_key() */
@@ -685,6 +686,8 @@ long keyctl_read_key(key_serial_t keyid,
goto can_read_key2;
ret = PTR_ERR(skey);
+ if (ret == -EAGAIN)
+ ret = -EACCES;
goto error2;
}
diff -uNrp linux-2.6.13-rc2-mm1/security/keys/request_key.c linux-2.6.13-rc2-mm1-keys/security/keys/request_key.c
--- linux-2.6.13-rc2-mm1/security/keys/request_key.c 2005-07-07 22:23:15.000000000 +0100
+++ linux-2.6.13-rc2-mm1-keys/security/keys/request_key.c 2005-08-04 11:48:12.000000000 +0100
@@ -405,7 +405,7 @@ struct key *request_key_and_link(struct
key_user_put(user);
/* link the new key into the appropriate keyring */
- if (!PTR_ERR(key))
+ if (!IS_ERR(key))
request_key_link(key, dest_keyring);
}
reply other threads:[~2005-08-04 10:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8602.1123152601@warthog.cambridge.redhat.com \
--to=dhowells@redhat.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.