diff options
Diffstat (limited to 'fs/ecryptfs/miscdev.c')
-rw-r--r-- | fs/ecryptfs/miscdev.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c index 788995efd1d..50c994a249a 100644 --- a/fs/ecryptfs/miscdev.c +++ b/fs/ecryptfs/miscdev.c | |||
@@ -243,7 +243,6 @@ ecryptfs_miscdev_read(struct file *file, char __user *buf, size_t count, | |||
243 | struct ecryptfs_daemon *daemon; | 243 | struct ecryptfs_daemon *daemon; |
244 | struct ecryptfs_msg_ctx *msg_ctx; | 244 | struct ecryptfs_msg_ctx *msg_ctx; |
245 | size_t packet_length_size; | 245 | size_t packet_length_size; |
246 | u32 counter_nbo; | ||
247 | char packet_length[3]; | 246 | char packet_length[3]; |
248 | size_t i; | 247 | size_t i; |
249 | size_t total_length; | 248 | size_t total_length; |
@@ -257,12 +256,14 @@ ecryptfs_miscdev_read(struct file *file, char __user *buf, size_t count, | |||
257 | mutex_lock(&daemon->mux); | 256 | mutex_lock(&daemon->mux); |
258 | if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) { | 257 | if (daemon->flags & ECRYPTFS_DAEMON_ZOMBIE) { |
259 | rc = 0; | 258 | rc = 0; |
259 | mutex_unlock(&ecryptfs_daemon_hash_mux); | ||
260 | printk(KERN_WARNING "%s: Attempt to read from zombified " | 260 | printk(KERN_WARNING "%s: Attempt to read from zombified " |
261 | "daemon\n", __func__); | 261 | "daemon\n", __func__); |
262 | goto out_unlock_daemon; | 262 | goto out_unlock_daemon; |
263 | } | 263 | } |
264 | if (daemon->flags & ECRYPTFS_DAEMON_IN_READ) { | 264 | if (daemon->flags & ECRYPTFS_DAEMON_IN_READ) { |
265 | rc = 0; | 265 | rc = 0; |
266 | mutex_unlock(&ecryptfs_daemon_hash_mux); | ||
266 | goto out_unlock_daemon; | 267 | goto out_unlock_daemon; |
267 | } | 268 | } |
268 | /* This daemon will not go away so long as this flag is set */ | 269 | /* This daemon will not go away so long as this flag is set */ |
@@ -326,20 +327,18 @@ check_list: | |||
326 | "pending message\n", __func__, count, total_length); | 327 | "pending message\n", __func__, count, total_length); |
327 | goto out_unlock_msg_ctx; | 328 | goto out_unlock_msg_ctx; |
328 | } | 329 | } |
329 | i = 0; | 330 | rc = -EFAULT; |
330 | buf[i++] = msg_ctx->type; | 331 | if (put_user(msg_ctx->type, buf)) |
331 | counter_nbo = cpu_to_be32(msg_ctx->counter); | 332 | goto out_unlock_msg_ctx; |
332 | memcpy(&buf[i], (char *)&counter_nbo, 4); | 333 | if (put_user(cpu_to_be32(msg_ctx->counter), (__be32 __user *)(buf + 1))) |
333 | i += 4; | 334 | goto out_unlock_msg_ctx; |
335 | i = 5; | ||
334 | if (msg_ctx->msg) { | 336 | if (msg_ctx->msg) { |
335 | memcpy(&buf[i], packet_length, packet_length_size); | 337 | if (copy_to_user(&buf[i], packet_length, packet_length_size)) |
338 | goto out_unlock_msg_ctx; | ||
336 | i += packet_length_size; | 339 | i += packet_length_size; |
337 | rc = copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size); | 340 | if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size)) |
338 | if (rc) { | ||
339 | printk(KERN_ERR "%s: copy_to_user returned error " | ||
340 | "[%d]\n", __func__, rc); | ||
341 | goto out_unlock_msg_ctx; | 341 | goto out_unlock_msg_ctx; |
342 | } | ||
343 | i += msg_ctx->msg_size; | 342 | i += msg_ctx->msg_size; |
344 | } | 343 | } |
345 | rc = i; | 344 | rc = i; |
@@ -450,7 +449,8 @@ static ssize_t | |||
450 | ecryptfs_miscdev_write(struct file *file, const char __user *buf, | 449 | ecryptfs_miscdev_write(struct file *file, const char __user *buf, |
451 | size_t count, loff_t *ppos) | 450 | size_t count, loff_t *ppos) |
452 | { | 451 | { |
453 | u32 counter_nbo, seq; | 452 | __be32 counter_nbo; |
453 | u32 seq; | ||
454 | size_t packet_size, packet_size_length, i; | 454 | size_t packet_size, packet_size_length, i; |
455 | ssize_t sz = 0; | 455 | ssize_t sz = 0; |
456 | char *data; | 456 | char *data; |
@@ -483,7 +483,7 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf, | |||
483 | count); | 483 | count); |
484 | goto out_free; | 484 | goto out_free; |
485 | } | 485 | } |
486 | memcpy((char *)&counter_nbo, &data[i], 4); | 486 | memcpy(&counter_nbo, &data[i], 4); |
487 | seq = be32_to_cpu(counter_nbo); | 487 | seq = be32_to_cpu(counter_nbo); |
488 | i += 4; | 488 | i += 4; |
489 | rc = ecryptfs_parse_packet_length(&data[i], &packet_size, | 489 | rc = ecryptfs_parse_packet_length(&data[i], &packet_size, |