aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells2012-05-21 06:32:13 -0500
committerJames Morris2012-05-25 05:51:42 -0500
commit423b9788023263364ea5de04189f02bd9b6a12db (patch)
treefc3ee4814aa8322fb2abb01c50d96568aa51bd9b /security/keys
parentff2bb047c4bce9742e94911eeb44b4d6ff4734ab (diff)
downloadam43-linux-kernel-423b9788023263364ea5de04189f02bd9b6a12db.tar.gz
am43-linux-kernel-423b9788023263364ea5de04189f02bd9b6a12db.tar.xz
am43-linux-kernel-423b9788023263364ea5de04189f02bd9b6a12db.zip
KEYS: Fix some sparse warnings
Fix some sparse warnings in the keyrings code: (1) compat_keyctl_instantiate_key_iov() should be static. (2) There were a couple of places where a pointer was being compared against integer 0 rather than NULL. (3) keyctl_instantiate_key_common() should not take a __user-labelled iovec pointer as the caller must have copied the iovec to kernel space. (4) __key_link_begin() takes and __key_link_end() releases keyring_serialise_link_sem under some circumstances and so this should be declared. Note that adding __acquires() and __releases() for this doesn't help cure the warnings messages - something only commenting out both helps. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: James Morris <james.l.morris@oracle.com>
Diffstat (limited to 'security/keys')
-rw-r--r--security/keys/compat.c4
-rw-r--r--security/keys/internal.h2
-rw-r--r--security/keys/keyctl.c2
-rw-r--r--security/keys/keyring.c2
4 files changed, 6 insertions, 4 deletions
diff --git a/security/keys/compat.c b/security/keys/compat.c
index fab4f8dda6c..e35ae1d208a 100644
--- a/security/keys/compat.c
+++ b/security/keys/compat.c
@@ -24,7 +24,7 @@
24 * 24 *
25 * If successful, 0 will be returned. 25 * If successful, 0 will be returned.
26 */ 26 */
27long compat_keyctl_instantiate_key_iov( 27static long compat_keyctl_instantiate_key_iov(
28 key_serial_t id, 28 key_serial_t id,
29 const struct compat_iovec __user *_payload_iov, 29 const struct compat_iovec __user *_payload_iov,
30 unsigned ioc, 30 unsigned ioc,
@@ -33,7 +33,7 @@ long compat_keyctl_instantiate_key_iov(
33 struct iovec iovstack[UIO_FASTIOV], *iov = iovstack; 33 struct iovec iovstack[UIO_FASTIOV], *iov = iovstack;
34 long ret; 34 long ret;
35 35
36 if (_payload_iov == 0 || ioc == 0) 36 if (!_payload_iov || !ioc)
37 goto no_payload; 37 goto no_payload;
38 38
39 ret = compat_rw_copy_check_uvector(WRITE, _payload_iov, ioc, 39 ret = compat_rw_copy_check_uvector(WRITE, _payload_iov, ioc,
diff --git a/security/keys/internal.h b/security/keys/internal.h
index f711b094ed4..f173be2ce3e 100644
--- a/security/keys/internal.h
+++ b/security/keys/internal.h
@@ -240,7 +240,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
240extern long keyctl_invalidate_key(key_serial_t); 240extern long keyctl_invalidate_key(key_serial_t);
241 241
242extern long keyctl_instantiate_key_common(key_serial_t, 242extern long keyctl_instantiate_key_common(key_serial_t,
243 const struct iovec __user *, 243 const struct iovec *,
244 unsigned, size_t, key_serial_t); 244 unsigned, size_t, key_serial_t);
245 245
246/* 246/*
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index ddb3e05bc5f..b61c063888b 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -1106,7 +1106,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
1106 struct iovec iovstack[UIO_FASTIOV], *iov = iovstack; 1106 struct iovec iovstack[UIO_FASTIOV], *iov = iovstack;
1107 long ret; 1107 long ret;
1108 1108
1109 if (_payload_iov == 0 || ioc == 0) 1109 if (!_payload_iov || !ioc)
1110 goto no_payload; 1110 goto no_payload;
1111 1111
1112 ret = rw_copy_check_uvector(WRITE, _payload_iov, ioc, 1112 ret = rw_copy_check_uvector(WRITE, _payload_iov, ioc,
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 7445875f681..81e7852d281 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -751,6 +751,7 @@ static void keyring_unlink_rcu_disposal(struct rcu_head *rcu)
751int __key_link_begin(struct key *keyring, const struct key_type *type, 751int __key_link_begin(struct key *keyring, const struct key_type *type,
752 const char *description, unsigned long *_prealloc) 752 const char *description, unsigned long *_prealloc)
753 __acquires(&keyring->sem) 753 __acquires(&keyring->sem)
754 __acquires(&keyring_serialise_link_sem)
754{ 755{
755 struct keyring_list *klist, *nklist; 756 struct keyring_list *klist, *nklist;
756 unsigned long prealloc; 757 unsigned long prealloc;
@@ -960,6 +961,7 @@ void __key_link(struct key *keyring, struct key *key,
960void __key_link_end(struct key *keyring, struct key_type *type, 961void __key_link_end(struct key *keyring, struct key_type *type,
961 unsigned long prealloc) 962 unsigned long prealloc)
962 __releases(&keyring->sem) 963 __releases(&keyring->sem)
964 __releases(&keyring_serialise_link_sem)
963{ 965{
964 BUG_ON(type == NULL); 966 BUG_ON(type == NULL);
965 BUG_ON(type->name == NULL); 967 BUG_ON(type->name == NULL);