aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/loop.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 5c4ee70d5cf3..fb06ed659212 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -936,8 +936,10 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
936{ 936{
937 int err; 937 int err;
938 struct loop_func_table *xfer; 938 struct loop_func_table *xfer;
939 uid_t uid = current_uid();
939 940
940 if (lo->lo_encrypt_key_size && lo->lo_key_owner != current->uid && 941 if (lo->lo_encrypt_key_size &&
942 lo->lo_key_owner != uid &&
941 !capable(CAP_SYS_ADMIN)) 943 !capable(CAP_SYS_ADMIN))
942 return -EPERM; 944 return -EPERM;
943 if (lo->lo_state != Lo_bound) 945 if (lo->lo_state != Lo_bound)
@@ -992,7 +994,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
992 if (info->lo_encrypt_key_size) { 994 if (info->lo_encrypt_key_size) {
993 memcpy(lo->lo_encrypt_key, info->lo_encrypt_key, 995 memcpy(lo->lo_encrypt_key, info->lo_encrypt_key,
994 info->lo_encrypt_key_size); 996 info->lo_encrypt_key_size);
995 lo->lo_key_owner = current->uid; 997 lo->lo_key_owner = uid;
996 } 998 }
997 999
998 return 0; 1000 return 0;