diff options
author | David Howells <dhowells@redhat.com> | 2008-11-13 18:38:47 -0500 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2008-11-13 18:38:47 -0500 |
commit | a001e5b558f25eb1e588522d73ac949b643b7a37 (patch) | |
tree | 96370a4535bd0d7b3e9908f04b58a8b3e94ed908 | |
parent | 1109b07b7dcb938de7a0d65efc1b4739dc4e9787 (diff) |
CRED: Wrap task credential accesses in the CIFS filesystem
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: Steve French <sfrench@samba.org>
Cc: linux-cifs-client@lists.samba.org
Signed-off-by: James Morris <jmorris@namei.org>
-rw-r--r-- | fs/cifs/cifs_fs_sb.h | 2 | ||||
-rw-r--r-- | fs/cifs/cifsproto.h | 2 | ||||
-rw-r--r-- | fs/cifs/connect.c | 4 | ||||
-rw-r--r-- | fs/cifs/dir.c | 12 | ||||
-rw-r--r-- | fs/cifs/inode.c | 8 | ||||
-rw-r--r-- | fs/cifs/ioctl.c | 2 | ||||
-rw-r--r-- | fs/cifs/misc.c | 4 |
7 files changed, 17 insertions, 17 deletions
diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h index 877c85409f1f..1e7b87497f26 100644 --- a/fs/cifs/cifs_fs_sb.h +++ b/fs/cifs/cifs_fs_sb.h | |||
@@ -19,7 +19,7 @@ | |||
19 | #define _CIFS_FS_SB_H | 19 | #define _CIFS_FS_SB_H |
20 | 20 | ||
21 | #define CIFS_MOUNT_NO_PERM 1 /* do not do client vfs_perm check */ | 21 | #define CIFS_MOUNT_NO_PERM 1 /* do not do client vfs_perm check */ |
22 | #define CIFS_MOUNT_SET_UID 2 /* set current->euid in create etc. */ | 22 | #define CIFS_MOUNT_SET_UID 2 /* set current's euid in create etc. */ |
23 | #define CIFS_MOUNT_SERVER_INUM 4 /* inode numbers from uniqueid from server */ | 23 | #define CIFS_MOUNT_SERVER_INUM 4 /* inode numbers from uniqueid from server */ |
24 | #define CIFS_MOUNT_DIRECT_IO 8 /* do not write nor read through page cache */ | 24 | #define CIFS_MOUNT_DIRECT_IO 8 /* do not write nor read through page cache */ |
25 | #define CIFS_MOUNT_NO_XATTR 0x10 /* if set - disable xattr support */ | 25 | #define CIFS_MOUNT_NO_XATTR 0x10 /* if set - disable xattr support */ |
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 6f21ecb85ce5..9d8b978137ad 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -39,7 +39,7 @@ extern int smb_send(struct socket *, struct smb_hdr *, | |||
39 | unsigned int /* length */ , struct sockaddr *, bool); | 39 | unsigned int /* length */ , struct sockaddr *, bool); |
40 | extern unsigned int _GetXid(void); | 40 | extern unsigned int _GetXid(void); |
41 | extern void _FreeXid(unsigned int); | 41 | extern void _FreeXid(unsigned int); |
42 | #define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__func__, xid,current->fsuid)); | 42 | #define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__func__, xid,current_fsuid())); |
43 | #define FreeXid(curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__func__,curr_xid,(int)rc));} | 43 | #define FreeXid(curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__func__,curr_xid,(int)rc));} |
44 | extern char *build_path_from_dentry(struct dentry *); | 44 | extern char *build_path_from_dentry(struct dentry *); |
45 | extern char *build_wildcard_path_from_dentry(struct dentry *direntry); | 45 | extern char *build_wildcard_path_from_dentry(struct dentry *direntry); |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index e9f9248cb3fe..e5dca9a48d9f 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -833,8 +833,8 @@ cifs_parse_mount_options(char *options, const char *devname, | |||
833 | /* null target name indicates to use *SMBSERVR default called name | 833 | /* null target name indicates to use *SMBSERVR default called name |
834 | if we end up sending RFC1001 session initialize */ | 834 | if we end up sending RFC1001 session initialize */ |
835 | vol->target_rfc1001_name[0] = 0; | 835 | vol->target_rfc1001_name[0] = 0; |
836 | vol->linux_uid = current->uid; /* current->euid instead? */ | 836 | vol->linux_uid = current_uid(); /* use current_euid() instead? */ |
837 | vol->linux_gid = current->gid; | 837 | vol->linux_gid = current_gid(); |
838 | vol->dir_mode = S_IRWXUGO; | 838 | vol->dir_mode = S_IRWXUGO; |
839 | /* 2767 perms indicate mandatory locking support */ | 839 | /* 2767 perms indicate mandatory locking support */ |
840 | vol->file_mode = (S_IRWXUGO | S_ISGID) & (~S_IXGRP); | 840 | vol->file_mode = (S_IRWXUGO | S_ISGID) & (~S_IXGRP); |
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index e962e75e6f7b..2f02c52db666 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c | |||
@@ -235,11 +235,11 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, | |||
235 | }; | 235 | }; |
236 | 236 | ||
237 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { | 237 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { |
238 | args.uid = (__u64) current->fsuid; | 238 | args.uid = (__u64) current_fsuid(); |
239 | if (inode->i_mode & S_ISGID) | 239 | if (inode->i_mode & S_ISGID) |
240 | args.gid = (__u64) inode->i_gid; | 240 | args.gid = (__u64) inode->i_gid; |
241 | else | 241 | else |
242 | args.gid = (__u64) current->fsgid; | 242 | args.gid = (__u64) current_fsgid(); |
243 | } else { | 243 | } else { |
244 | args.uid = NO_CHANGE_64; | 244 | args.uid = NO_CHANGE_64; |
245 | args.gid = NO_CHANGE_64; | 245 | args.gid = NO_CHANGE_64; |
@@ -271,13 +271,13 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, | |||
271 | if ((oplock & CIFS_CREATE_ACTION) && | 271 | if ((oplock & CIFS_CREATE_ACTION) && |
272 | (cifs_sb->mnt_cifs_flags & | 272 | (cifs_sb->mnt_cifs_flags & |
273 | CIFS_MOUNT_SET_UID)) { | 273 | CIFS_MOUNT_SET_UID)) { |
274 | newinode->i_uid = current->fsuid; | 274 | newinode->i_uid = current_fsuid(); |
275 | if (inode->i_mode & S_ISGID) | 275 | if (inode->i_mode & S_ISGID) |
276 | newinode->i_gid = | 276 | newinode->i_gid = |
277 | inode->i_gid; | 277 | inode->i_gid; |
278 | else | 278 | else |
279 | newinode->i_gid = | 279 | newinode->i_gid = |
280 | current->fsgid; | 280 | current_fsgid(); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | } | 283 | } |
@@ -375,8 +375,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, | |||
375 | .device = device_number, | 375 | .device = device_number, |
376 | }; | 376 | }; |
377 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { | 377 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { |
378 | args.uid = (__u64) current->fsuid; | 378 | args.uid = (__u64) current_fsuid(); |
379 | args.gid = (__u64) current->fsgid; | 379 | args.gid = (__u64) current_fsgid(); |
380 | } else { | 380 | } else { |
381 | args.uid = NO_CHANGE_64; | 381 | args.uid = NO_CHANGE_64; |
382 | args.gid = NO_CHANGE_64; | 382 | args.gid = NO_CHANGE_64; |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index ff8c68de4a92..8b7305e73d7e 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -1143,11 +1143,11 @@ mkdir_get_info: | |||
1143 | .device = 0, | 1143 | .device = 0, |
1144 | }; | 1144 | }; |
1145 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { | 1145 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { |
1146 | args.uid = (__u64)current->fsuid; | 1146 | args.uid = (__u64)current_fsuid(); |
1147 | if (inode->i_mode & S_ISGID) | 1147 | if (inode->i_mode & S_ISGID) |
1148 | args.gid = (__u64)inode->i_gid; | 1148 | args.gid = (__u64)inode->i_gid; |
1149 | else | 1149 | else |
1150 | args.gid = (__u64)current->fsgid; | 1150 | args.gid = (__u64)current_fsgid(); |
1151 | } else { | 1151 | } else { |
1152 | args.uid = NO_CHANGE_64; | 1152 | args.uid = NO_CHANGE_64; |
1153 | args.gid = NO_CHANGE_64; | 1153 | args.gid = NO_CHANGE_64; |
@@ -1184,13 +1184,13 @@ mkdir_get_info: | |||
1184 | if (cifs_sb->mnt_cifs_flags & | 1184 | if (cifs_sb->mnt_cifs_flags & |
1185 | CIFS_MOUNT_SET_UID) { | 1185 | CIFS_MOUNT_SET_UID) { |
1186 | direntry->d_inode->i_uid = | 1186 | direntry->d_inode->i_uid = |
1187 | current->fsuid; | 1187 | current_fsuid(); |
1188 | if (inode->i_mode & S_ISGID) | 1188 | if (inode->i_mode & S_ISGID) |
1189 | direntry->d_inode->i_gid = | 1189 | direntry->d_inode->i_gid = |
1190 | inode->i_gid; | 1190 | inode->i_gid; |
1191 | else | 1191 | else |
1192 | direntry->d_inode->i_gid = | 1192 | direntry->d_inode->i_gid = |
1193 | current->fsgid; | 1193 | current_fsgid(); |
1194 | } | 1194 | } |
1195 | } | 1195 | } |
1196 | } | 1196 | } |
diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c index 0088a5b52564..f94650683a00 100644 --- a/fs/cifs/ioctl.c +++ b/fs/cifs/ioctl.c | |||
@@ -65,7 +65,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) | |||
65 | switch (command) { | 65 | switch (command) { |
66 | case CIFS_IOC_CHECKUMOUNT: | 66 | case CIFS_IOC_CHECKUMOUNT: |
67 | cFYI(1, ("User unmount attempted")); | 67 | cFYI(1, ("User unmount attempted")); |
68 | if (cifs_sb->mnt_uid == current->uid) | 68 | if (cifs_sb->mnt_uid == current_uid()) |
69 | rc = 0; | 69 | rc = 0; |
70 | else { | 70 | else { |
71 | rc = -EACCES; | 71 | rc = -EACCES; |
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 88786ba02d27..ec36410a9125 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
@@ -347,13 +347,13 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , | |||
347 | /* BB Add support for establishing new tCon and SMB Session */ | 347 | /* BB Add support for establishing new tCon and SMB Session */ |
348 | /* with userid/password pairs found on the smb session */ | 348 | /* with userid/password pairs found on the smb session */ |
349 | /* for other target tcp/ip addresses BB */ | 349 | /* for other target tcp/ip addresses BB */ |
350 | if (current->fsuid != treeCon->ses->linux_uid) { | 350 | if (current_fsuid() != treeCon->ses->linux_uid) { |
351 | cFYI(1, ("Multiuser mode and UID " | 351 | cFYI(1, ("Multiuser mode and UID " |
352 | "did not match tcon uid")); | 352 | "did not match tcon uid")); |
353 | read_lock(&GlobalSMBSeslock); | 353 | read_lock(&GlobalSMBSeslock); |
354 | list_for_each(temp_item, &GlobalSMBSessionList) { | 354 | list_for_each(temp_item, &GlobalSMBSessionList) { |
355 | ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList); | 355 | ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList); |
356 | if (ses->linux_uid == current->fsuid) { | 356 | if (ses->linux_uid == current_fsuid()) { |
357 | if (ses->server == treeCon->ses->server) { | 357 | if (ses->server == treeCon->ses->server) { |
358 | cFYI(1, ("found matching uid substitute right smb_uid")); | 358 | cFYI(1, ("found matching uid substitute right smb_uid")); |
359 | buffer->Uid = ses->Suid; | 359 | buffer->Uid = ses->Suid; |