diff options
author | David Howells <dhowells@redhat.com> | 2008-11-13 18:38:41 -0500 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2008-11-13 18:38:41 -0500 |
commit | b0fafa816ece0080771355de6158b4dfa8531a95 (patch) | |
tree | c26b6a2acde2692ab5018752d04c91aca34962c1 /drivers/block/loop.c | |
parent | 350b4da71f8326b9319ada7b701f2bce2e1285b7 (diff) |
CRED: Wrap task credential accesses in the block loopback driver
Wrap access to task credentials so that they can be separated more easily from
the task_struct during the introduction of COW creds.
Change most current->(|e|s|fs)[ug]id to current_(|e|s|fs)[ug]id().
Change some task->e?[ug]id to task_e?[ug]id(). In some places it makes more
sense to use RCU directly rather than a convenient wrapper; these will be
addressed by later patches.
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: James Morris <jmorris@namei.org>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'drivers/block/loop.c')
-rw-r--r-- | drivers/block/loop.c | 6 |
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; |