diff options
-rw-r--r-- | cryptodev_cipher.c | 6 | ||||
-rw-r--r-- | cryptodev_main.c | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/cryptodev_cipher.c b/cryptodev_cipher.c index 97998fe..60a55db 100644 --- a/cryptodev_cipher.c +++ b/cryptodev_cipher.c @@ -148,7 +148,11 @@ static inline int waitfor (struct cryptodev_result* cr, ssize_t ret) case -EINPROGRESS: case -EBUSY: wait_for_completion(&cr->completion); - /* no error from wait_for_completion */ + /* At this point we known for sure the request has finished, + * because wait_for_completion above was not interruptible. + * This is important because otherwise hardware or driver + * might try to access memory which will be freed or reused for + * another request. */ if (cr->err) { dprintk(0,KERN_ERR,"error from async request: %zd \n", ret); diff --git a/cryptodev_main.c b/cryptodev_main.c index 1d6b614..63ce162 100644 --- a/cryptodev_main.c +++ b/cryptodev_main.c @@ -345,7 +345,7 @@ crypto_run(struct fcrypt *fcr, struct crypt_op *cop) unsigned int ivsize=0; size_t nbytes, bufsize; int ret = 0; - uint8_t hash_output[HASH_MAX_LEN]; + uint8_t hash_output[AALG_MAX_RESULT_LEN]; if (unlikely(cop->op != COP_ENCRYPT && cop->op != COP_DECRYPT)) { dprintk(1, KERN_DEBUG, "invalid operation op=%u\n", cop->op); @@ -405,7 +405,7 @@ crypto_run(struct fcrypt *fcr, struct crypt_op *cop) copy_from_user(data, src, current_len); - sg_set_buf(&sg, data, current_len); + sg_init_one(&sg, data, current_len); /* Always hash before encryption and after decryption. Maybe * we should introduce a flag to switch... TBD later on. @@ -586,7 +586,7 @@ struct file_operations cryptodev_fops = { }; struct miscdevice cryptodev = { - .minor = CRYPTODEV_MINOR, + .minor = MISC_DYNAMIC_MINOR, .name = "crypto", .fops = &cryptodev_fops, }; |