CRED: Wrap task credential accesses in the CIFS filesystem
authorDavid Howells <dhowells@redhat.com>
Thu, 13 Nov 2008 23:38:47 +0000 (10:38 +1100)
committerJames Morris <jmorris@namei.org>
Thu, 13 Nov 2008 23:38:47 +0000 (10:38 +1100)
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>
fs/cifs/cifs_fs_sb.h
fs/cifs/cifsproto.h
fs/cifs/connect.c
fs/cifs/dir.c
fs/cifs/inode.c
fs/cifs/ioctl.c
fs/cifs/misc.c

index 877c85409f1f90e8cbd0805bd2dda85359b0a68c..1e7b87497f2640d08fd02638369ba675db33cab6 100644 (file)
@@ -19,7 +19,7 @@
 #define _CIFS_FS_SB_H
 
 #define CIFS_MOUNT_NO_PERM      1 /* do not do client vfs_perm check */
-#define CIFS_MOUNT_SET_UID      2 /* set current->euid in create etc. */
+#define CIFS_MOUNT_SET_UID      2 /* set current's euid in create etc. */
 #define CIFS_MOUNT_SERVER_INUM  4 /* inode numbers from uniqueid from server */
 #define CIFS_MOUNT_DIRECT_IO    8 /* do not write nor read through page cache */
 #define CIFS_MOUNT_NO_XATTR     0x10  /* if set - disable xattr support       */
index 6f21ecb85ce517b07d36d973cfb030d478e08ebf..9d8b978137ad171e7a2db74c276d9fdeabacce04 100644 (file)
@@ -39,7 +39,7 @@ extern int smb_send(struct socket *, struct smb_hdr *,
                        unsigned int /* length */ , struct sockaddr *, bool);
 extern unsigned int _GetXid(void);
 extern void _FreeXid(unsigned int);
-#define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__func__, xid,current->fsuid));
+#define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__func__, xid,current_fsuid()));
 #define FreeXid(curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__func__,curr_xid,(int)rc));}
 extern char *build_path_from_dentry(struct dentry *);
 extern char *build_wildcard_path_from_dentry(struct dentry *direntry);
index e9f9248cb3feff13deeeb4d5eeae1d2a65f79ebe..e5dca9a48d9f2d22021aa68b97f689a22d588004 100644 (file)
@@ -833,8 +833,8 @@ cifs_parse_mount_options(char *options, const char *devname,
        /* null target name indicates to use *SMBSERVR default called name
           if we end up sending RFC1001 session initialize */
        vol->target_rfc1001_name[0] = 0;
-       vol->linux_uid = current->uid;  /* current->euid instead? */
-       vol->linux_gid = current->gid;
+       vol->linux_uid = current_uid();  /* use current_euid() instead? */
+       vol->linux_gid = current_gid();
        vol->dir_mode = S_IRWXUGO;
        /* 2767 perms indicate mandatory locking support */
        vol->file_mode = (S_IRWXUGO | S_ISGID) & (~S_IXGRP);
index e962e75e6f7b1e8f3d8011488f2d4c08c490a43e..2f02c52db666f59c8a6abe52a7cd818ea6f6bd03 100644 (file)
@@ -235,11 +235,11 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
                        };
 
                        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
-                               args.uid = (__u64) current->fsuid;
+                               args.uid = (__u64) current_fsuid();
                                if (inode->i_mode & S_ISGID)
                                        args.gid = (__u64) inode->i_gid;
                                else
-                                       args.gid = (__u64) current->fsgid;
+                                       args.gid = (__u64) current_fsgid();
                        } else {
                                args.uid = NO_CHANGE_64;
                                args.gid = NO_CHANGE_64;
@@ -271,13 +271,13 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
                                if ((oplock & CIFS_CREATE_ACTION) &&
                                    (cifs_sb->mnt_cifs_flags &
                                     CIFS_MOUNT_SET_UID)) {
-                                       newinode->i_uid = current->fsuid;
+                                       newinode->i_uid = current_fsuid();
                                        if (inode->i_mode & S_ISGID)
                                                newinode->i_gid =
                                                        inode->i_gid;
                                        else
                                                newinode->i_gid =
-                                                       current->fsgid;
+                                                       current_fsgid();
                                }
                        }
                }
@@ -375,8 +375,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
                        .device = device_number,
                };
                if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
-                       args.uid = (__u64) current->fsuid;
-                       args.gid = (__u64) current->fsgid;
+                       args.uid = (__u64) current_fsuid();
+                       args.gid = (__u64) current_fsgid();
                } else {
                        args.uid = NO_CHANGE_64;
                        args.gid = NO_CHANGE_64;
index ff8c68de4a9205a9d0cd592d8a0c58872b0e8e65..8b7305e73d7eab00188b0aa50569fd05b5271d62 100644 (file)
@@ -1143,11 +1143,11 @@ mkdir_get_info:
                                .device = 0,
                        };
                        if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
-                               args.uid = (__u64)current->fsuid;
+                               args.uid = (__u64)current_fsuid();
                                if (inode->i_mode & S_ISGID)
                                        args.gid = (__u64)inode->i_gid;
                                else
-                                       args.gid = (__u64)current->fsgid;
+                                       args.gid = (__u64)current_fsgid();
                        } else {
                                args.uid = NO_CHANGE_64;
                                args.gid = NO_CHANGE_64;
@@ -1184,13 +1184,13 @@ mkdir_get_info:
                                if (cifs_sb->mnt_cifs_flags &
                                     CIFS_MOUNT_SET_UID) {
                                        direntry->d_inode->i_uid =
-                                               current->fsuid;
+                                               current_fsuid();
                                        if (inode->i_mode & S_ISGID)
                                                direntry->d_inode->i_gid =
                                                        inode->i_gid;
                                        else
                                                direntry->d_inode->i_gid =
-                                                       current->fsgid;
+                                                       current_fsgid();
                                }
                        }
                }
index 0088a5b5256460cd73737ef12db8e718a0c6902f..f94650683a00355d48f6fa545e72baaf6721e95e 100644 (file)
@@ -65,7 +65,7 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg)
        switch (command) {
                case CIFS_IOC_CHECKUMOUNT:
                        cFYI(1, ("User unmount attempted"));
-                       if (cifs_sb->mnt_uid == current->uid)
+                       if (cifs_sb->mnt_uid == current_uid())
                                rc = 0;
                        else {
                                rc = -EACCES;
index 88786ba02d277fac25923893c29bb96206e42827..ec36410a9125ec2f527d74cc82794eced2cf6817 100644 (file)
@@ -347,13 +347,13 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ ,
                /*  BB Add support for establishing new tCon and SMB Session  */
                /*      with userid/password pairs found on the smb session   */
                /*      for other target tcp/ip addresses               BB    */
-                               if (current->fsuid != treeCon->ses->linux_uid) {
+                               if (current_fsuid() != treeCon->ses->linux_uid) {
                                        cFYI(1, ("Multiuser mode and UID "
                                                 "did not match tcon uid"));
                                        read_lock(&GlobalSMBSeslock);
                                        list_for_each(temp_item, &GlobalSMBSessionList) {
                                                ses = list_entry(temp_item, struct cifsSesInfo, cifsSessionList);
-                                               if (ses->linux_uid == current->fsuid) {
+                                               if (ses->linux_uid == current_fsuid()) {
                                                        if (ses->server == treeCon->ses->server) {
                                                                cFYI(1, ("found matching uid substitute right smb_uid"));
                                                                buffer->Uid = ses->Suid;