diff options
author | Miloslav Trmač <mitr@redhat.com> | 2010-07-09 10:59:34 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-19 09:26:33 +0200 |
commit | d420d44c9c8ba98dc7696530f8eeb55f4cbe32ed (patch) | |
tree | 0763c5e372afa0e3e114138f755621b9ac20ddc3 | |
parent | ef0a304388b3d17a7730f04aa58aef5f94fcbf35 (diff) | |
download | cryptodev-linux-d420d44c9c8ba98dc7696530f8eeb55f4cbe32ed.tar.gz cryptodev-linux-d420d44c9c8ba98dc7696530f8eeb55f4cbe32ed.tar.xz cryptodev-linux-d420d44c9c8ba98dc7696530f8eeb55f4cbe32ed.zip |
sparse: Fix __user annotations
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
-rw-r--r-- | cryptodev.h | 14 | ||||
-rw-r--r-- | cryptodev_cipher.c | 2 | ||||
-rw-r--r-- | cryptodev_main.c | 34 | ||||
-rw-r--r-- | ncr.c | 47 | ||||
-rw-r--r-- | ncr.h | 5 |
5 files changed, 52 insertions, 50 deletions
diff --git a/cryptodev.h b/cryptodev.h index 572b3c3..4d6b712 100644 --- a/cryptodev.h +++ b/cryptodev.h @@ -7,6 +7,8 @@ #ifndef __KERNEL__ #include <inttypes.h> +#define __user +#else #endif /* API extensions for linux */ @@ -73,9 +75,9 @@ struct session_op { uint32_t mac; /* cryptodev_crypto_op_t */ uint32_t keylen; - uint8_t * key; + uint8_t __user *key; uint32_t mackeylen; - uint8_t * mackey; + uint8_t __user *mackey; uint32_t ses; /* session identifier */ }; @@ -89,10 +91,10 @@ struct session_op { uint16_t op; /* COP_ENCRYPT or COP_DECRYPT */ uint16_t flags; /* no usage so far, use 0 */ uint32_t len; /* length of source data */ - uint8_t * src; /* source data */ - uint8_t * dst; /* pointer to output data */ - uint8_t * mac; /* pointer to output data for hash/MAC operations */ - uint8_t * iv; /* initialization vector for encryption operations */ + uint8_t __user *src; /* source data */ + uint8_t __user *dst; /* pointer to output data */ + uint8_t __user *mac; /* pointer to output data for hash/MAC operations */ + uint8_t __user *iv; /* initialization vector for encryption operations */ }; /* Stuff for bignum arithmetic and public key diff --git a/cryptodev_cipher.c b/cryptodev_cipher.c index 85f218c..e7d1b6d 100644 --- a/cryptodev_cipher.c +++ b/cryptodev_cipher.c @@ -133,7 +133,7 @@ void cryptodev_cipher_deinit(struct cipher_data* cdata) } } -void cryptodev_cipher_set_iv(struct cipher_data* cdata, void __user* iv, size_t iv_size) +void cryptodev_cipher_set_iv(struct cipher_data* cdata, void *iv, size_t iv_size) { memcpy(cdata->async.iv, iv, min(iv_size,sizeof(cdata->async.iv))); } diff --git a/cryptodev_main.c b/cryptodev_main.c index 05beb34..0a1e383 100644 --- a/cryptodev_main.c +++ b/cryptodev_main.c @@ -598,9 +598,10 @@ clonefd(struct file *filp) static int cryptodev_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg_) { - int __user *p = (void __user *)arg; + void __user *arg = (void __user *)arg_; + int __user *p = arg; struct session_op sop; struct crypt_op cop; struct crypt_priv *pcr = filp->private_data; @@ -625,40 +626,37 @@ cryptodev_ioctl(struct inode *inode, struct file *filp, } return ret; case CIOCGSESSION: - if (unlikely(copy_from_user(&sop, (void*)arg, - sizeof(sop)))) + if (unlikely(copy_from_user(&sop, arg, sizeof(sop)))) return -EFAULT; ret = crypto_create_session(fcr, &sop); if (unlikely(ret)) return ret; - ret = copy_to_user((void*)arg, &sop, sizeof(sop)); + ret = copy_to_user(arg, &sop, sizeof(sop)); if (unlikely(ret)) { crypto_finish_session(fcr, sop.ses); return -EFAULT; } return ret; case CIOCFSESSION: - ret = get_user(ses, (uint32_t*)arg); + ret = get_user(ses, (uint32_t __user *)arg); if (unlikely(ret)) return ret; ret = crypto_finish_session(fcr, ses); return ret; case CIOCCRYPT: - if (unlikely(copy_from_user(&cop, (void*)arg, - sizeof(cop)))) + if (unlikely(copy_from_user(&cop, arg, sizeof(cop)))) return -EFAULT; ret = crypto_run(fcr, &cop); if (unlikely(ret)) return ret; - if (unlikely(copy_to_user((void*)arg, &cop, - sizeof(cop)))) + if (unlikely(copy_to_user(arg, &cop, sizeof(cop)))) return -EFAULT; return 0; default: - return ncr_ioctl(pcr->ncr, filp, cmd, arg); + return ncr_ioctl(pcr->ncr, filp, cmd, arg_); } } @@ -720,8 +718,9 @@ crypt_op_to_compat(struct crypt_op *cop, struct compat_crypt_op *compat) } static long -cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg_) { + void __user *arg = (void __user *)arg_; struct fcrypt *fcr = file->private_data; struct session_op sop; struct compat_session_op compat_sop; @@ -736,10 +735,10 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case CIOCASYMFEAT: case CRIOGET: case CIOCFSESSION: - return cryptodev_ioctl(NULL, file, cmd, arg); + return cryptodev_ioctl(NULL, file, cmd, arg_); case COMPAT_CIOCGSESSION: - if (unlikely(copy_from_user(&compat_sop, (void *)arg, + if (unlikely(copy_from_user(&compat_sop, arg, sizeof(compat_sop)))) return -EFAULT; compat_to_session_op(&compat_sop, &sop); @@ -749,8 +748,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return ret; session_op_to_compat(&sop, &compat_sop); - ret = copy_to_user((void*)arg, - &compat_sop, sizeof(compat_sop)); + ret = copy_to_user(arg, &compat_sop, sizeof(compat_sop)); if (unlikely(ret)) { crypto_finish_session(fcr, sop.ses); return -EFAULT; @@ -758,7 +756,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return ret; case COMPAT_CIOCCRYPT: - if (unlikely(copy_from_user(&compat_cop, (void*)arg, + if (unlikely(copy_from_user(&compat_cop, arg, sizeof(compat_cop)))) return -EFAULT; @@ -769,7 +767,7 @@ cryptodev_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return ret; crypt_op_to_compat(&cop, &compat_cop); - if (unlikely(copy_to_user((void*)arg, &compat_cop, + if (unlikely(copy_to_user(arg, &compat_cop, sizeof(compat_cop)))) return -EFAULT; return 0; @@ -76,7 +76,7 @@ void ncr_master_key_reset(void) memset(&master_key, 0, sizeof(master_key)); } -static int ncr_master_key_set(void* __user arg) +static int ncr_master_key_set(void __user *arg) { struct ncr_master_key_st st; @@ -116,57 +116,58 @@ struct ncr_master_key_st st; int ncr_ioctl(struct ncr_lists* lst, struct file *filp, - unsigned int cmd, unsigned long arg) + unsigned int cmd, unsigned long arg_) { + void __user *arg = (void __user *)arg_; if (unlikely(!lst)) BUG(); switch (cmd) { case NCRIO_DATA_INIT: - return ncr_data_init(&lst->data, (void*)arg); + return ncr_data_init(&lst->data, arg); case NCRIO_DATA_GET: - return ncr_data_get(&lst->data, (void*)arg); + return ncr_data_get(&lst->data, arg); case NCRIO_DATA_SET: - return ncr_data_set(&lst->data, (void*)arg); + return ncr_data_set(&lst->data, arg); case NCRIO_DATA_DEINIT: - return ncr_data_deinit(&lst->data, (void*)arg); + return ncr_data_deinit(&lst->data, arg); case NCRIO_KEY_INIT: - return ncr_key_init(&lst->key, (void*)arg); + return ncr_key_init(&lst->key, arg); case NCRIO_KEY_DEINIT: - return ncr_key_deinit(&lst->key, (void*)arg); + return ncr_key_deinit(&lst->key, arg); case NCRIO_KEY_GENERATE: - return ncr_key_generate(&lst->key, (void*)arg); + return ncr_key_generate(&lst->key, arg); case NCRIO_KEY_EXPORT: - return ncr_key_export(&lst->data, &lst->key, (void*)arg); + return ncr_key_export(&lst->data, &lst->key, arg); case NCRIO_KEY_IMPORT: - return ncr_key_import(&lst->data, &lst->key, (void*)arg); + return ncr_key_import(&lst->data, &lst->key, arg); case NCRIO_KEY_GET_INFO: - return ncr_key_info(&lst->key, (void*)arg); + return ncr_key_info(&lst->key, arg); case NCRIO_KEY_WRAP: - return ncr_key_wrap(&lst->key, &lst->data, (void*)arg); + return ncr_key_wrap(&lst->key, &lst->data, arg); case NCRIO_KEY_UNWRAP: - return ncr_key_unwrap(&lst->key, &lst->data, (void*)arg); + return ncr_key_unwrap(&lst->key, &lst->data, arg); case NCRIO_KEY_STORAGE_WRAP: - return ncr_key_storage_wrap(&lst->key, &lst->data, (void*)arg); + return ncr_key_storage_wrap(&lst->key, &lst->data, arg); case NCRIO_KEY_STORAGE_UNWRAP: - return ncr_key_storage_unwrap(&lst->key, &lst->data, (void*)arg); + return ncr_key_storage_unwrap(&lst->key, &lst->data, arg); case NCRIO_SESSION_INIT: - return ncr_session_init(lst, (void*)arg); + return ncr_session_init(lst, arg); case NCRIO_SESSION_UPDATE: - return ncr_session_update(lst, (void*)arg); + return ncr_session_update(lst, arg); case NCRIO_SESSION_FINAL: - return ncr_session_final(lst, (void*)arg); + return ncr_session_final(lst, arg); case NCRIO_SESSION_ONCE: - return ncr_session_once(lst, (void*)arg); + return ncr_session_once(lst, arg); case NCRIO_MASTER_KEY_SET: - return ncr_master_key_set((void*)arg); + return ncr_master_key_set(arg); case NCRIO_KEY_GENERATE_PAIR: - return ncr_key_generate_pair(&lst->key, (void*)arg); + return ncr_key_generate_pair(&lst->key, arg); #if 0 case NCRIO_KEY_DERIVE: - return ncr_key_derive(&lst->key, (void*)arg); + return ncr_key_derive(&lst->key, arg); #endif default: return -EINVAL; @@ -3,6 +3,7 @@ #ifndef __KERNEL__ #include <inttypes.h> +#define __user #endif #define NCR_CIPHER_MAX_BLOCK_LEN 32 @@ -63,13 +64,13 @@ struct ncr_data_init_st { ncr_data_t desc; size_t max_object_size; unsigned int flags; - void* initial_data; /* can be null */ + void __user *initial_data; /* can be null */ size_t initial_data_size; }; struct ncr_data_st { ncr_data_t desc; - void* data; + void __user* data; size_t data_size; /* rw in get */ unsigned int append_flag; /* only when used with NCRIO_DATA_SET */ }; |