diff options
author | Miloslav Trmač <mitr@redhat.com> | 2010-07-20 02:26:33 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2010-07-21 20:13:43 +0200 |
commit | 15d18ae53061d716a892adb04d65baa9c6e7fbf1 (patch) | |
tree | f816488db39fe319fa4b0727eac342ffe821e6da /cryptodev_main.c | |
parent | 5689c9734223fb349bba526d620823a803c3b67e (diff) | |
download | cryptodev-linux-15d18ae53061d716a892adb04d65baa9c6e7fbf1.tar.gz cryptodev-linux-15d18ae53061d716a892adb04d65baa9c6e7fbf1.tar.xz cryptodev-linux-15d18ae53061d716a892adb04d65baa9c6e7fbf1.zip |
Fix more incorrect copy_*_user error handling
Diffstat (limited to 'cryptodev_main.c')
-rw-r--r-- | cryptodev_main.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/cryptodev_main.c b/cryptodev_main.c index 2390f78..2a0503c 100644 --- a/cryptodev_main.c +++ b/cryptodev_main.c @@ -465,9 +465,10 @@ __crypto_run_std(struct csession *ses_ptr, struct crypt_op *cop) while(nbytes > 0) { size_t current_len = nbytes > bufsize ? bufsize : nbytes; - ret = copy_from_user(data, src, current_len); - if (unlikely(ret)) + if (unlikely(copy_from_user(data, src, current_len))) { + ret = -EFAULT; break; + } sg_init_one(&sg, data, current_len); @@ -477,9 +478,10 @@ __crypto_run_std(struct csession *ses_ptr, struct crypt_op *cop) break; if (ses_ptr->cdata.init != 0) { - ret = copy_to_user(dst, data, current_len); - if (unlikely(ret)) + if (unlikely(copy_to_user(dst, data, current_len))) { + ret = -EFAULT; break; + } } dst += current_len; @@ -658,6 +660,7 @@ static int crypto_run(struct fcrypt *fcr, struct crypt_op *cop) ret = copy_from_user(iv, cop->iv, min( (int)sizeof(iv), (ses_ptr->cdata.ivsize))); if (unlikely(ret)) { dprintk(1, KERN_ERR, "error copying IV (%d bytes)\n", min( (int)sizeof(iv), (ses_ptr->cdata.ivsize))); + ret = -EFAULT; goto out_unlock; } @@ -680,8 +683,10 @@ static int crypto_run(struct fcrypt *fcr, struct crypt_op *cop) goto out_unlock; } - if (unlikely(copy_to_user(cop->mac, hash_output, ses_ptr->hdata.digestsize))) + if (unlikely(copy_to_user(cop->mac, hash_output, ses_ptr->hdata.digestsize))) { + ret = -EFAULT; goto out_unlock; + } } #if defined(CRYPTODEV_STATS) |