Introduce credential record
Subsystems (46)
David Howells
maintainercover Introduce credential record
Hi Al,
Here's a set of patches to partially implement cred passing. This is in no way complete yet.
The only complete chain is mkdir(), and only Ext3 and NFS are fully altered, though I think NFS really needs redoing. I'd like to come up with a way of caching the rpc_cred struct inside the struct cred, but that needs some thought.
Most of the vfs_xxxx() structs grab current->cred and pass it on down. vfs_mkdir() is currently the only one that gets given it.
There are also holes in fs/buffer.c that need patching up, and most of the other filesystems haven't yet been touched.
Note that I haven't included keyrings or capabilties or LSM data at this time.
Note also that this patch set is built on top of the iget patch set I've posted to LKML earlier today.
David
David Howells
maintainerPATCH 1/52 CRED: Introduce a COW credentials record
Introduce a copy on write credentials record (struct cred). The fsuid, fsgid, supplementary groups list move into it (DAC security). The session, process and thread keyrings are reflected in it, but don't primarily reside there as they aren't per-thread and occasionally need to be instantiated or replaced by other threads or processes.
The LSM security information (MAC security) does *not* migrate from task_struct at this point, but will be addressed by a later patch.
task_struct then gains an RCU-governed pointer to the credentials as a replacement to the members it lost.
struct file gains a pointer to (f_cred) and a reference on the cred struct that the opener was using at the time the file was opened. This replaces f_uid and f_gid.
To alter the credentials record, a copy must be made. This copy may then be altered and then the pointer in the task_struct redirected to it. From that point on the new record should be considered immutable.
In addition, the default setting of i_uid and i_gid to fsuid and fsgid has been moved from the callers of new_inode() into new_inode() itself.
---
arch/ia64/kernel/perfmon.c | 4 - arch/mips/kernel/kspd.c | 9 +- arch/powerpc/platforms/cell/spufs/inode.c | 4 - drivers/isdn/capi/capifs.c | 4 - drivers/usb/core/inode.c | 4 - fs/9p/vfs_inode.c | 4 - fs/9p/vfs_super.c | 4 - fs/affs/inode.c | 4 - fs/anon_inodes.c | 4 - fs/attr.c | 4 - fs/bfs/dir.c | 4 - fs/cifs/cifsproto.h | 2 fs/cifs/dir.c | 12 +- fs/cifs/inode.c | 8 + fs/cifs/misc.c | 4 - fs/coda/cache.c | 6 + fs/coda/file.c | 2 fs/coda/upcall.c | 4 - fs/devpts/inode.c | 4 - fs/dquot.c | 2 fs/exec.c | 29 ++++- fs/ext2/balloc.c | 2 fs/ext2/ialloc.c | 4 - fs/ext3/balloc.c | 2 fs/ext3/ialloc.c | 4 - fs/ext4/balloc.c | 2 fs/ext4/ialloc.c | 4 - fs/file_table.c | 3 - fs/fuse/dev.c | 4 - fs/gfs2/inode.c | 10 +- fs/hfs/inode.c | 4 - fs/hfsplus/inode.c | 4 - fs/hpfs/namei.c | 24 ++-- fs/hugetlbfs/inode.c | 16 +-- fs/jffs2/fs.c | 4 - fs/jfs/jfs_inode.c | 4 - fs/locks.c | 2 fs/minix/bitmap.c | 4 - fs/namei.c | 8 + fs/nfsd/auth.c | 32 ++++-- fs/nfsd/nfs4callback.c | 16 ++- fs/nfsd/nfs4recover.c | 54 +++++----- fs/nfsd/vfs.c | 4 - fs/ocfs2/dlm/dlmfs.c | 8 + fs/ocfs2/namei.c | 4 - fs/open.c | 21 ++-- fs/pipe.c | 4 - fs/posix_acl.c | 4 - fs/proc/array.c | 12 +- fs/ramfs/inode.c | 4 - fs/reiserfs/namei.c | 4 - fs/sysv/ialloc.c | 4 - fs/udf/ialloc.c | 4 - fs/udf/namei.c | 2 fs/ufs/ialloc.c | 4 - fs/xfs/linux-2.6/xfs_cred.h | 4 - fs/xfs/linux-2.6/xfs_linux.h | 4 - fs/xfs/xfs_acl.c | 6 + include/linux/binfmts.h | 1 include/linux/cred.h | 163 +++++++++++++++++++++++++++++ include/linux/fs.h | 5 + include/linux/init_task.h | 4 - include/linux/sched.h | 7 + include/linux/sunrpc/auth.h | 18 +-- ipc/mqueue.c | 4 - kernel/Makefile | 2 kernel/auditsc.c | 13 ++ kernel/cpuset.c | 4 - kernel/cred.c | 123 ++++++++++++++++++++++ kernel/exit.c | 1 kernel/fork.c | 22 +++- kernel/kernel-int.h | 15 +++ kernel/sys.c | 144 +++++++++++++++++++------- kernel/uid16.c | 7 + mm/shmem.c | 8 + net/9p/client.c | 2 net/socket.c | 4 - net/sunrpc/auth.c | 25 +--- net/sunrpc/auth_gss/auth_gss.c | 6 + net/sunrpc/auth_null.c | 4 - net/sunrpc/auth_unix.c | 6 + security/commoncap.c | 8 + security/dummy.c | 13 ++ security/keys/key.c | 3 - security/keys/keyctl.c | 2 security/keys/permission.c | 16 ++- security/keys/process_keys.c | 6 + security/keys/request_key.c | 14 +- security/keys/request_key_auth.c | 2 89 files changed, 740 insertions(+), 334 deletions(-)
arch/ia64/kernel/perfmon.c +2 -2
@@ -2212,8 +2212,8 @@ pfm_alloc_fd(struct file **cfile)DPRINT (("new inode ino=%ld @%p\n" , inode->i_ino, inode)); inode->i_mode =S_IFCHR |S_IRUGO ; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid;sprintf (name,"[%lu]" , inode->i_ino); this.name = name;
arch/mips/kernel/kspd.c +4 -5
@@ -174,11 +174,10 @@ static unsigned int translate_open_flags(int flags)static void sp_setfsuidgid (uid_t uid,gid_t gid) { - current->fsuid = uid; - current->fsgid = gid; - -key_fsuid_changed (current); -key_fsgid_changed (current); +struct cred *cred =dup_cred (current->cred); +change_fsuid (cred, uid); +change_fsgid (cred, gid); +set_current_cred (cred); }/*
arch/powerpc/platforms/cell/spufs/inode.c +2 -2
@@ -85,8 +85,8 @@ spufs_new_inode(struct super_block *sb, int mode) goto out; inode->i_mode = mode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_blocks =0 ; inode->i_atime = inode->i_mtime = inode->i_ctime =CURRENT_TIME ; out:
drivers/isdn/capi/capifs.c +2 -2
@@ -148,8 +148,8 @@ void capifs_new_ncci(unsigned int number, dev_t device)if (!inode)return ; inode->i_ino = number+2 ; - inode->i_uid = config.setuid ? config.uid : current->fsuid; - inode->i_gid = config.setgid ? config.gid : current->fsgid; + inode->i_uid = config.setuid ? config.uid : current->cred->uid; + inode->i_gid = config.setgid ? config.gid : current->cred->gid; inode->i_mtime = inode->i_atime = inode->i_ctime =CURRENT_TIME ;init_special_inode (inode,S_IFCHR |config.mode, device);//inode->i_op = &capifs_file_inode_operations;
drivers/usb/core/inode.c +2 -2
@@ -246,8 +246,8 @@ static struct inode *usbfs_get_inode (struct super_block *sb, int mode, dev_t deif (inode) { inode->i_mode = mode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_blocks =0 ; inode->i_atime = inode->i_mtime = inode->i_ctime =CURRENT_TIME ;switch (mode &S_IFMT ) {
fs/9p/vfs_inode.c +2 -2
@@ -202,8 +202,8 @@ struct inode *v9fs_get_inode(struct super_block *sb, int mode) inode =new_inode (sb);if (inode) { inode->i_mode = mode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_blocks =0 ; inode->i_rdev =0 ; inode->i_atime = inode->i_mtime = inode->i_ctime =CURRENT_TIME ;
fs/9p/vfs_super.c +2 -2
@@ -112,8 +112,8 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,struct v9fs_session_info *v9ses =NULL ;struct p9_stat *st =NULL ;int mode =S_IRWXUGO |S_ISVTX ; -uid_t uid = current->fsuid; -gid_t gid = current->fsgid; +uid_t uid = current->cred->uid; +gid_t gid = current->cred->gid;struct p9_fid *fid;int retval =0 ;
fs/affs/inode.c +2 -2
@@ -311,8 +311,8 @@ affs_new_inode(struct inode *dir)mark_buffer_dirty_inode (bh, inode);affs_brelse (bh); - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_ino = block; inode->i_nlink =1 ; inode->i_mtime = inode->i_atime = inode->i_ctime =CURRENT_TIME_SEC ;
fs/anon_inodes.c +2 -2
@@ -163,8 +163,8 @@ static struct inode *anon_inode_mkinode(void)*/ inode->i_state =I_DIRTY ; inode->i_mode =S_IRUSR |S_IWUSR ; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_atime = inode->i_mtime = inode->i_ctime =CURRENT_TIME ;return inode; }
fs/attr.c +2 -2
@@ -29,13 +29,13 @@ int inode_change_ok(struct inode *inode, struct iattr *attr)/* Make sure a caller can chown. */ if ((ia_valid &ATTR_UID ) && - (current->fsuid != inode->i_uid || + (current->cred->uid != inode->i_uid || attr->ia_uid != inode->i_uid) && !capable (CAP_CHOWN )) goto error;/* Make sure caller can chgrp. */ if ((ia_valid &ATTR_GID ) && - (current->fsuid != inode->i_uid || + (current->cred->uid != inode->i_uid || (!in_group_p (attr->ia_gid) && attr->ia_gid != inode->i_gid)) && !capable (CAP_CHOWN )) goto error;
fs/bfs/dir.c +2 -2
@@ -99,8 +99,8 @@ static int bfs_create(struct inode * dir, struct dentry * dentry, int mode, }set_bit (ino, info->si_imap); info->si_freei--; - inode->i_uid = current->fsuid; - inode->i_gid = (dir->i_mode &S_ISGID ) ? dir->i_gid : current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = (dir->i_mode &S_ISGID ) ? dir->i_gid : current->cred->gid; inode->i_mtime = inode->i_atime = inode->i_ctime =CURRENT_TIME_SEC ; inode->i_blocks =0 ; inode->i_op = &bfs_file_inops;
fs/cifs/cifsproto.h +1 -1
@@ -39,7 +39,7 @@ extern int smb_send(struct socket *, struct smb_hdr *, unsigned int /* length */ , struct sockaddr *);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",__FUNCTION__, xid,current->fsuid)); +#define GetXid () (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__FUNCTION__, xid,current->cred->uid));#define FreeXid (curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__FUNCTION__,curr_xid,(int)rc));}extern char *build_path_from_dentry (struct dentry *);extern char *build_wildcard_path_from_dentry (struct dentry *direntry);
fs/cifs/dir.c +6 -6
@@ -211,8 +211,8 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode, mode &= ~current->fs->umask;if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SET_UID ) { CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, - (__u64)current->fsuid, - (__u64)current->fsgid, + (__u64)current->cred->uid, + (__u64)current->cred->gid, 0 /* dev */, cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
@@ -246,8 +246,8 @@ 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_gid = current->fsgid; + newinode->i_uid = current->cred->uid; + newinode->i_gid = current->cred->gid; } } }
@@ -340,8 +340,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode, mode &= ~current->fs->umask;if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SET_UID ) { rc =CIFSSMBUnixSetPerms (xid, pTcon, full_path, - mode, (__u64 )current->fsuid, - (__u64 )current->fsgid, + mode, (__u64 )current->cred->uid, + (__u64 )current->cred->gid, device_number, cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR );
fs/cifs/inode.c +4 -4
@@ -1020,8 +1020,8 @@ mkdir_get_info:if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SET_UID ) { CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, - (__u64)current->fsuid, - (__u64)current->fsgid, + (__u64)current->cred->uid, + (__u64)current->cred->gid, 0 /* dev_t */, cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
@@ -1044,9 +1044,9 @@ mkdir_get_info:if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SET_UID ) { direntry->d_inode->i_uid = - current->fsuid; + current->cred->uid; direntry->d_inode->i_gid = - current->fsgid; + current->cred->gid; } } }
fs/cifs/misc.c +2 -2
@@ -352,13 +352,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->cred->uid != 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->cred->uid) {if (ses->server == treeCon->ses->server) {cFYI (1 , ("found matching uid substitute right smb_uid" )); buffer->Uid = ses->Suid;
fs/coda/cache.c +3 -3
@@ -32,8 +32,8 @@ void coda_cache_enter(struct inode *inode, int mask)struct coda_inode_info *cii =ITOC (inode); cii->c_cached_epoch =atomic_read (&permission_epoch); -if (cii->c_uid != current->fsuid) { - cii->c_uid = current->fsuid; +if (cii->c_uid != current->cred->uid) { + cii->c_uid = current->cred->uid; cii->c_cached_perm = mask; }else cii->c_cached_perm |= mask;
@@ -60,7 +60,7 @@ int coda_cache_check(struct inode *inode, int mask)int hit; hit = (mask & cii->c_cached_perm) == mask && - cii->c_uid == current->fsuid && + cii->c_uid == current->cred->uid && cii->c_cached_epoch ==atomic_read (&permission_epoch);return hit;
fs/coda/file.c +1 -1
@@ -174,7 +174,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)BUG_ON (!cfi || cfi->cfi_magic !=CODA_MAGIC ); err =venus_close (coda_inode->i_sb,coda_i2f (coda_inode), - coda_flags, coda_file->f_uid); + coda_flags, coda_file->f_cred->uid); host_inode = cfi->cfi_container->f_path.dentry->d_inode; cii =ITOC (coda_inode);
fs/coda/upcall.c +2 -2
@@ -54,9 +54,9 @@ static void *alloc_upcall(int opcode, int size) inp->ih.pgid =process_group (current);#ifdef CONFIG_CODA_FS_OLD_API memset (&inp->ih.cred,0 ,sizeof (struct coda_cred )); - inp->ih.cred.cr_fsuid = current->fsuid; + inp->ih.cred.cr_fsuid = current->cred->uid;#else - inp->ih.uid = current->fsuid; + inp->ih.uid = current->cred->uid;#endif return (void *)inp; }
fs/devpts/inode.c +2 -2
@@ -172,8 +172,8 @@ int devpts_pty_new(struct tty_struct *tty)return -ENOMEM ; inode->i_ino = number+2 ; - inode->i_uid = config.setuid ? config.uid : current->fsuid; - inode->i_gid = config.setgid ? config.gid : current->fsgid; + inode->i_uid = config.setuid ? config.uid : current->cred->uid; + inode->i_gid = config.setgid ? config.gid : current->cred->gid; inode->i_mtime = inode->i_atime = inode->i_ctime =CURRENT_TIME ;init_special_inode (inode,S_IFCHR |config.mode, device); inode->i_private = tty;
fs/dquot.c +1 -1
@@ -832,7 +832,7 @@ static inline int need_print_warning(struct dquot *dquot)switch (dquot->dq_type) {case USRQUOTA : -return current->fsuid == dquot->dq_id; +return current->cred->uid == dquot->dq_id;case GRPQUOTA :return in_group_p (dquot->dq_id); }
fs/exec.c +23 -6
@@ -1137,6 +1137,11 @@ int prepare_binprm(struct linux_binprm *bprm) } } +/* prepare the new credentials */ + bprm->cred =dup_cred (current->cred); +if (!bprm->cred) +return -ENOMEM ; +/* fill in binprm security blob */ retval =security_bprm_set (bprm);if (retval)
@@ -1178,7 +1183,9 @@ void compute_creds(struct linux_binprm *bprm)task_lock (current); unsafe =unsafe_exec (current);security_bprm_apply_creds (bprm, unsafe); +set_current_cred (bprm->cred);task_unlock (current); + bprm->cred =NULL ;security_bprm_post_apply_creds (bprm); }EXPORT_SYMBOL (compute_creds);
@@ -1409,6 +1416,8 @@ out:free_arg_pages (bprm);if (bprm->security)security_bprm_free (bprm); +if (bprm->cred) +put_cred (bprm->cred); out_mm:if (bprm->mm)
@@ -1716,8 +1725,8 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)struct linux_binfmt * binfmt;struct inode * inode;struct file * file; +struct cred *cred;int retval =0 ; -int fsuid = current->fsuid;int flag =0 ;int ispipe =0 ;
@@ -1732,6 +1741,10 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs) goto fail; } + cred =dup_cred (current->cred); +if (!cred) + goto fail; +/* * We cannot trust fsuid as being the "true" uid of the * process nor do we know its entire history. We only know it
@@ -1739,13 +1752,13 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)*/ if (get_dumpable (mm) ==2 ) {/* Setuid core dump mode */ flag =O_EXCL ;/* Stop rewrite attacks */ - current->fsuid =0 ;/* Dump root private */ +change_fsuid (cred,0 );/* Dump root private */ }set_dumpable (mm,0 ); retval =coredump_wait (exit_code);if (retval <0 ) - goto fail; + goto fail_cred;/* * Clear any false indication of pending signals that might
@@ -1763,19 +1776,20 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)lock_kernel (); ispipe =format_corename (corename, core_pattern, signr);unlock_kernel (); + cred =__set_current_cred (cred);if (ispipe) {/* SIGPIPE can happen, but it's just never processed */ if (call_usermodehelper_pipe (corename+1 ,NULL ,NULL , &file)) {printk (KERN_INFO "Core dump to %s pipe failed\n" , corename); - goto fail_unlock; + goto fail_restore_cred; } }else file =filp_open (corename,O_CREAT |2 |O_NOFOLLOW |O_LARGEFILE | flag,0600 );if (IS_ERR (file)) - goto fail_unlock; + goto fail_restore_cred; inode = file->f_path.dentry->d_inode;if (inode->i_nlink >1 ) goto close_fail;/* multiple links - don't dump */
@@ -1799,9 +1813,12 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs) current->signal->group_exit_code |=0x80 ; close_fail:filp_close (file,NULL ); +fail_restore_cred: +set_current_cred (cred); fail_unlock: - current->fsuid = fsuid;complete_all (&mm->core_done); +fail_cred: +put_cred (cred); fail:return retval; }
fs/ext2/balloc.c +1 -1
@@ -112,7 +112,7 @@ static int reserve_blocks(struct super_block *sb, int count) count = free_blocks;if (free_blocks < root_blocks + count && !capable (CAP_SYS_RESOURCE ) && - sbi->s_resuid != current->fsuid && + sbi->s_resuid != current->cred->uid && (sbi->s_resgid ==0 || !in_group_p (sbi->s_resgid))) {/* * We are too close to reserve and we are not privileged.
fs/ext2/ialloc.c +2 -2
@@ -562,7 +562,7 @@ got: sb->s_dirt =1 ;mark_buffer_dirty (bh2); - inode->i_uid = current->fsuid; + inode->i_uid = current->cred->uid;if (test_opt (sb,GRPID )) inode->i_gid = dir->i_gid;else if (dir->i_mode &S_ISGID ) {
@@ -570,7 +570,7 @@ got:if (S_ISDIR (mode)) mode |=S_ISGID ; }else - inode->i_gid = current->fsgid; + inode->i_gid = current->cred->gid; inode->i_mode = mode; inode->i_ino = ino;
fs/ext3/balloc.c +1 -1
@@ -1360,7 +1360,7 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi) free_blocks =percpu_counter_read_positive (&sbi->s_freeblocks_counter); root_blocks =le32_to_cpu (sbi->s_es->s_r_blocks_count);if (free_blocks < root_blocks +1 && !capable (CAP_SYS_RESOURCE ) && - sbi->s_resuid != current->fsuid && + sbi->s_resuid != current->cred->uid && (sbi->s_resgid ==0 || !in_group_p (sbi->s_resgid))) {return 0 ; }
fs/ext3/ialloc.c +2 -2
@@ -546,7 +546,7 @@ got:percpu_counter_inc (&sbi->s_dirs_counter); sb->s_dirt =1 ; - inode->i_uid = current->fsuid; + inode->i_uid = current->cred->uid;if (test_opt (sb,GRPID )) inode->i_gid = dir->i_gid;else if (dir->i_mode &S_ISGID ) {
@@ -554,7 +554,7 @@ got:if (S_ISDIR (mode)) mode |=S_ISGID ; }else - inode->i_gid = current->fsgid; + inode->i_gid = current->cred->gid; inode->i_mode = mode; inode->i_ino = ino;
fs/ext4/balloc.c +1 -1
@@ -1377,7 +1377,7 @@ static int ext4_has_free_blocks(struct ext4_sb_info *sbi) free_blocks =percpu_counter_read_positive (&sbi->s_freeblocks_counter); root_blocks =ext4_r_blocks_count (sbi->s_es);if (free_blocks < root_blocks +1 && !capable (CAP_SYS_RESOURCE ) && - sbi->s_resuid != current->fsuid && + sbi->s_resuid != current->cred->uid && (sbi->s_resgid ==0 || !in_group_p (sbi->s_resgid))) {return 0 ; }
fs/ext4/ialloc.c +2 -2
@@ -549,7 +549,7 @@ got:percpu_counter_inc (&sbi->s_dirs_counter); sb->s_dirt =1 ; - inode->i_uid = current->fsuid; + inode->i_uid = current->cred->uid;if (test_opt (sb,GRPID )) inode->i_gid = dir->i_gid;else if (dir->i_mode &S_ISGID ) {
@@ -557,7 +557,7 @@ got:if (S_ISDIR (mode)) mode |=S_ISGID ; }else - inode->i_gid = current->fsgid; + inode->i_gid = current->cred->gid; inode->i_mode = mode; inode->i_ino = ino;
fs/file_table.c +1 -2
@@ -115,8 +115,7 @@ struct file *get_empty_filp(void)INIT_LIST_HEAD (&f->f_u.fu_list);atomic_set (&f->f_count,1 );rwlock_init (&f->f_owner.lock); - f->f_uid = tsk->fsuid; - f->f_gid = tsk->fsgid; + f->f_cred =get_current_cred ();eventpoll_init_file (f);/* f->f_version: 0 */ return f;
fs/fuse/dev.c +2 -2
@@ -79,8 +79,8 @@ static void __fuse_put_request(struct fuse_req *req)static void fuse_req_init_context (struct fuse_req *req) { - req->in.h.uid = current->fsuid; - req->in.h.gid = current->fsgid; + req->in.h.uid = current->cred->uid; + req->in.h.gid = current->cred->gid; req->in.h.pid = current->pid; }
fs/gfs2/inode.c +5 -5
@@ -633,18 +633,18 @@ static void munge_mode_uid_gid(struct gfs2_inode *dip, unsigned int *mode, (dip->i_inode.i_mode & S_ISUID) && dip->i_inode.i_uid) {if (S_ISDIR (*mode)) *mode |=S_ISUID ; -else if (dip->i_inode.i_uid != current->fsuid) +else if (dip->i_inode.i_uid != current->cred->uid) *mode &= ~07111 ; *uid = dip->i_inode.i_uid; } else - *uid = current->fsuid; + *uid = current->cred->uid;if (dip->i_inode.i_mode &S_ISGID ) {if (S_ISDIR (*mode)) *mode |=S_ISGID ; *gid = dip->i_inode.i_gid; }else - *gid = current->fsgid; + *gid = current->cred->gid; }static int alloc_dinode (struct gfs2_inode *dip,u64 *no_addr,u64 *generation)
@@ -1048,8 +1048,8 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,return -EPERM ;if ((dip->i_inode.i_mode &S_ISVTX ) && - dip->i_inode.i_uid != current->fsuid && - ip->i_inode.i_uid != current->fsuid && !capable (CAP_FOWNER )) + dip->i_inode.i_uid != current->cred->uid && + ip->i_inode.i_uid != current->cred->uid && !capable (CAP_FOWNER ))return -EPERM ;if (IS_APPEND (&dip->i_inode))
fs/hfs/inode.c +2 -2
@@ -151,8 +151,8 @@ struct inode *hfs_new_inode(struct inode *dir, struct qstr *name, int mode)hfs_cat_build_key (sb, (btree_key *)&HFS_I (inode)->cat_key, dir->i_ino, name); inode->i_ino =HFS_SB (sb)->next_id++; inode->i_mode = mode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_nlink =1 ; inode->i_mtime = inode->i_atime = inode->i_ctime =CURRENT_TIME_SEC ;HFS_I (inode)->flags =0 ;
fs/hfsplus/inode.c +2 -2
@@ -308,8 +308,8 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode) inode->i_ino =HFSPLUS_SB (sb).next_cnid++; inode->i_mode = mode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_nlink =1 ; inode->i_mtime = inode->i_atime = inode->i_ctime =CURRENT_TIME_SEC ;INIT_LIST_HEAD (&HFSPLUS_I (inode).open_dir_list);
fs/hpfs/namei.c +12 -12
@@ -92,11 +92,11 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)inc_nlink (dir);insert_inode_hash (result); -if (result->i_uid != current->fsuid || - result->i_gid != current->fsgid || +if (result->i_uid != current->cred->uid || + result->i_gid != current->cred->gid || result->i_mode != (mode |S_IFDIR )) { - result->i_uid = current->fsuid; - result->i_gid = current->fsgid; + result->i_uid = current->cred->uid; + result->i_gid = current->cred->gid; result->i_mode = mode |S_IFDIR ;hpfs_write_inode_nolock (result); }
@@ -184,11 +184,11 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, strucinsert_inode_hash (result); -if (result->i_uid != current->fsuid || - result->i_gid != current->fsgid || +if (result->i_uid != current->cred->uid || + result->i_gid != current->cred->gid || result->i_mode != (mode |S_IFREG )) { - result->i_uid = current->fsuid; - result->i_gid = current->fsgid; + result->i_uid = current->cred->uid; + result->i_gid = current->cred->gid; result->i_mode = mode |S_IFREG ;hpfs_write_inode_nolock (result); }
@@ -247,8 +247,8 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t result->i_mtime.tv_nsec =0 ; result->i_atime.tv_nsec =0 ;hpfs_i (result)->i_ea_size =0 ; - result->i_uid = current->fsuid; - result->i_gid = current->fsgid; + result->i_uid = current->cred->uid; + result->i_gid = current->cred->gid; result->i_nlink =1 ; result->i_size =0 ; result->i_blocks =1 ;
@@ -325,8 +325,8 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy result->i_atime.tv_nsec =0 ;hpfs_i (result)->i_ea_size =0 ; result->i_mode =S_IFLNK |0777 ; - result->i_uid = current->fsuid; - result->i_gid = current->fsgid; + result->i_uid = current->cred->uid; + result->i_gid = current->cred->gid; result->i_blocks =1 ; result->i_nlink =1 ; result->i_size =strlen (symlink);
fs/hugetlbfs/inode.c +8 -8
@@ -422,9 +422,9 @@ static int hugetlbfs_mknod(struct inode *dir,if (S_ISDIR (mode)) mode |=S_ISGID ; }else { - gid = current->fsgid; + gid = current->cred->gid; } - inode =hugetlbfs_get_inode (dir->i_sb, current->fsuid, gid, mode, dev); + inode =hugetlbfs_get_inode (dir->i_sb, current->cred->uid, gid, mode, dev);if (inode) { dir->i_ctime = dir->i_mtime =CURRENT_TIME ;d_instantiate (dentry, inode);
@@ -457,9 +457,9 @@ static int hugetlbfs_symlink(struct inode *dir,if (dir->i_mode &S_ISGID ) gid = dir->i_gid;else - gid = current->fsgid; + gid = current->cred->gid; - inode =hugetlbfs_get_inode (dir->i_sb, current->fsuid, + inode =hugetlbfs_get_inode (dir->i_sb, current->cred->uid, gid,S_IFLNK |S_IRWXUGO ,0 );if (inode) {int l =strlen (symname)+1 ;
@@ -697,8 +697,8 @@ hugetlbfs_fill_super(struct super_block *sb, void *data, int silent) config.nr_blocks =-1 ;/* No limit on size by default */ config.nr_inodes =-1 ;/* No limit on number of inodes by default */ - config.uid = current->fsuid; - config.gid = current->fsgid; + config.uid = current->cred->uid; + config.gid = current->cred->gid; config.mode =0755 ; ret =hugetlbfs_parse_options (data, &config);if (ret)
@@ -816,8 +816,8 @@ struct file *hugetlb_file_setup(const char *name, size_t size) goto out_dentry; error = -ENOSPC ; - inode =hugetlbfs_get_inode (root->d_sb, current->fsuid, - current->fsgid,S_IFREG |S_IRWXUGO ,0 ); + inode =hugetlbfs_get_inode (root->d_sb, current->cred->uid, + current->cred->gid,S_IFREG |S_IRWXUGO ,0 );if (!inode) goto out_file;
fs/jffs2/fs.c +2 -2
@@ -434,14 +434,14 @@ struct inode *jffs2_new_inode (struct inode *dir_i, int mode, struct jffs2_raw_imemset (ri,0 ,sizeof (*ri));/* Set OS-specific defaults for new inodes */ - ri->uid =cpu_to_je16 (current->fsuid); + ri->uid =cpu_to_je16 (current->cred->uid);if (dir_i->i_mode &S_ISGID ) { ri->gid =cpu_to_je16 (dir_i->i_gid);if (S_ISDIR (mode)) mode |=S_ISGID ; }else { - ri->gid =cpu_to_je16 (current->fsgid); + ri->gid =cpu_to_je16 (current->cred->gid); } ri->mode =cpu_to_jemode (mode); ret =jffs2_do_new_inode (c, f, mode, ri);
fs/jfs/jfs_inode.c +2 -2
@@ -93,13 +93,13 @@ struct inode *ialloc(struct inode *parent, umode_t mode)return ERR_PTR (rc); } - inode->i_uid = current->fsuid; + inode->i_uid = current->cred->uid;if (parent->i_mode &S_ISGID ) { inode->i_gid = parent->i_gid;if (S_ISDIR (mode)) mode |=S_ISGID ; }else - inode->i_gid = current->fsgid; + inode->i_gid = current->cred->gid;/* * New inodes need to save sane values on disk when
fs/locks.c +1 -1
@@ -1341,7 +1341,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)struct inode *inode = dentry->d_inode;int error, rdlease_count =0 , wrlease_count =0 ; -if ((current->fsuid != inode->i_uid) && !capable (CAP_LEASE )) +if ((current->cred->uid != inode->i_uid) && !capable (CAP_LEASE ))return -EACCES ;if (!S_ISREG (inode->i_mode))return -EINVAL ;
fs/minix/bitmap.c +2 -2
@@ -262,8 +262,8 @@ struct inode * minix_new_inode(const struct inode * dir, int * error)iput (inode);return NULL ; } - inode->i_uid = current->fsuid; - inode->i_gid = (dir->i_mode &S_ISGID ) ? dir->i_gid : current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = (dir->i_mode &S_ISGID ) ? dir->i_gid : current->cred->gid; inode->i_ino = j; inode->i_mtime = inode->i_atime = inode->i_ctime =CURRENT_TIME_SEC ; inode->i_blocks =0 ;
fs/namei.c +4 -4
@@ -185,7 +185,7 @@ int generic_permission(struct inode *inode, int mask, {umode_t mode = inode->i_mode; -if (current->fsuid == inode->i_uid) +if (current->cred->uid == inode->i_uid) mode >>=6 ;else {if (IS_POSIXACL (inode) && (mode &S_IRWXG ) && check_acl) {
@@ -437,7 +437,7 @@ static int exec_permission_lite(struct inode *inode,if (inode->i_op && inode->i_op->permission)return -EAGAIN ; -if (current->fsuid == inode->i_uid) +if (current->cred->uid == inode->i_uid) mode >>=6 ;else if (in_group_p (inode->i_gid)) mode >>=3 ;
@@ -1406,9 +1406,9 @@ static inline int check_sticky(struct inode *dir, struct inode *inode) {if (!(dir->i_mode &S_ISVTX ))return 0 ; -if (inode->i_uid == current->fsuid) +if (inode->i_uid == current->cred->uid)return 0 ; -if (dir->i_uid == current->fsuid) +if (dir->i_uid == current->cred->uid)return 0 ;return !capable (CAP_FOWNER ); }
fs/nfsd/auth.c +21 -11
@@ -29,9 +29,13 @@ int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)int nfsd_setuser (struct svc_rqst *rqstp,struct svc_export *exp) {struct svc_cred cred = rqstp->rq_cred; +struct cred *vfscred;int i;int flags =nfsexp_flags (rqstp, exp); -int ret; + + vfscred =dup_cred (current->cred); +if (!vfscred) +return -ENOMEM ;if (flags &NFSEXP_ALLSQUASH ) { cred.cr_uid = exp->ex_anon_uid;
@@ -55,24 +59,30 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp) }else get_group_info (cred.cr_group_info); +if (!cred.cr_group_info) { +put_cred (vfscred); +return -ENOMEM ; + } +if (cred.cr_uid != (uid_t) -1 ) - current->fsuid = cred.cr_uid; +change_fsuid (vfscred, cred.cr_uid);else - current->fsuid = exp->ex_anon_uid; +change_fsuid (vfscred, exp->ex_anon_uid);if (cred.cr_gid != (gid_t) -1 ) - current->fsgid = cred.cr_gid; +change_fsgid (vfscred, cred.cr_gid);else - current->fsgid = exp->ex_anon_gid; +change_fsgid (vfscred, exp->ex_anon_gid); -if (!cred.cr_group_info) -return -ENOMEM ; - ret =set_current_groups (cred.cr_group_info); +change_groups (vfscred, cred.cr_group_info);put_group_info (cred.cr_group_info);if ((cred.cr_uid)) { -cap_t (current->cap_effective) &= ~CAP_NFSD_MASK ; +cap_t (vfscred->cap_effective) &= ~CAP_NFSD_MASK ; }else { -cap_t (current->cap_effective) |= (CAP_NFSD_MASK & +cap_t (vfscred->cap_effective) |= (CAP_NFSD_MASK & current->cap_permitted); } -return ret; + + current->_cap_effective = vfscred->cap_effective; +set_current_cred (vfscred); +return 0 ; }
fs/nfsd/nfs4callback.c +9 -7
@@ -349,19 +349,21 @@ static struct rpc_version * nfs_cb_version[] = {static struct rpc_cred *nfsd4_lookupcred (struct nfs4_client *clp,int taskflags) { -struct auth_cred acred; +struct cred *acred;struct rpc_clnt *clnt = clp->cl_callback.cb_client;struct rpc_cred *ret; -get_group_info (clp->cl_cred.cr_group_info); - acred.uid = clp->cl_cred.cr_uid; - acred.gid = clp->cl_cred.cr_gid; - acred.group_info = clp->cl_cred.cr_group_info; + acred =dup_cred (&init_cred); +if (!acred) +return ERR_PTR (-ENOMEM ); +change_fsuid (acred, clp->cl_cred.cr_uid); +change_fsgid (acred, clp->cl_cred.cr_gid); +change_groups (acred, clp->cl_cred.cr_group_info);dprintk ("NFSD: looking up %s cred\n" , clnt->cl_auth->au_ops->au_name); - ret =rpcauth_lookup_credcache (clnt->cl_auth, &acred, taskflags); -put_group_info (clp->cl_cred.cr_group_info); + ret =rpcauth_lookup_credcache (clnt->cl_auth, acred, taskflags); +put_cred (acred);return ret; }
fs/nfsd/nfs4recover.c +28 -26
131 lines not on this page · raw message
fs/nfsd/vfs.c +2 -2
@@ -1833,7 +1833,7 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp,IS_APPEND (inode)?" append" :"" , IS_RDONLY(inode)? " ro" : "");dprintk (" owner %d/%d user %d/%d\n" , - inode->i_uid, inode->i_gid, current->fsuid, current->fsgid); + inode->i_uid, inode->i_gid, current->cred->uid, current->cred->gid);#endif /* Normally we reject any write/sattr etc access on a read-only file
@@ -1875,7 +1875,7 @@ nfsd_permission(struct svc_rqst *rqstp, struct svc_export *exp,* with NFSv3. */ if ((acc &MAY_OWNER_OVERRIDE ) && - inode->i_uid == current->fsuid) + inode->i_uid == current->cred->uid)return 0 ; err =permission (inode, acc & (MAY_READ |MAY_WRITE |MAY_EXEC ),NULL );
fs/ocfs2/dlm/dlmfs.c +4 -4
@@ -329,8 +329,8 @@ static struct inode *dlmfs_get_root_inode(struct super_block *sb) ip =DLMFS_I (inode); inode->i_mode = mode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_blocks =0 ; inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; inode->i_atime = inode->i_mtime = inode->i_ctime =CURRENT_TIME ;
@@ -355,8 +355,8 @@ static struct inode *dlmfs_get_inode(struct inode *parent,return NULL ; inode->i_mode = mode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_blocks =0 ; inode->i_mapping->backing_dev_info = &dlmfs_backing_dev_info; inode->i_atime = inode->i_mtime = inode->i_ctime =CURRENT_TIME ;
fs/ocfs2/namei.c +2 -2
@@ -542,13 +542,13 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, fe->i_blkno =cpu_to_le64 (fe_blkno); fe->i_suballoc_bit =cpu_to_le16 (suballoc_bit); fe->i_suballoc_slot =cpu_to_le16 (osb->slot_num); - fe->i_uid =cpu_to_le32 (current->fsuid); + fe->i_uid =cpu_to_le32 (current->cred->uid);if (dir->i_mode &S_ISGID ) { fe->i_gid =cpu_to_le32 (dir->i_gid);if (S_ISDIR (mode)) mode |=S_ISGID ; }else - fe->i_gid =cpu_to_le32 (current->fsgid); + fe->i_gid =cpu_to_le32 (current->cred->gid); fe->i_mode =cpu_to_le16 (mode);if (S_ISCHR (mode) ||S_ISBLK (mode)) fe->id1.dev1.i_rdev =cpu_to_le64 (huge_encode_dev (dev));
fs/open.c +14 -7
@@ -421,19 +421,26 @@ out:asmlinkage long sys_faccessat (int dfd,const char __user *filename,int mode) {struct nameidata nd; -int old_fsuid, old_fsgid;kernel_cap_t old_cap; +struct cred *cred;int res;if (mode & ~S_IRWXO )/* where's F_OK, X_OK, W_OK, R_OK? */ return -EINVAL ; - old_fsuid = current->fsuid; - old_fsgid = current->fsgid; old_cap = current->cap_effective; - current->fsuid = current->uid; - current->fsgid = current->gid; +if (current->cred->uid != current->uid || + current->cred->gid != current->gid) { + cred =dup_cred (current->cred); +if (!cred) +return -ENOMEM ; + +change_fsuid (cred, current->uid); +change_fsgid (cred, current->gid); + }else { + cred =get_current_cred (); + }/* * Clear the capabilities if we switch to a non-root user
@@ -448,6 +455,7 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode)else current->cap_effective = current->cap_permitted; + cred =__set_current_cred (cred); res =__user_walk_fd (dfd, filename,LOOKUP_FOLLOW |LOOKUP_ACCESS , &nd);if (res) goto out;
@@ -464,8 +472,7 @@ asmlinkage long sys_faccessat(int dfd, const char __user *filename, int mode) out_path_release:path_release (&nd); out: - current->fsuid = old_fsuid; - current->fsgid = old_fsgid; +set_current_cred (cred); current->cap_effective = old_cap;return res;
fs/pipe.c +2 -2
@@ -939,8 +939,8 @@ static struct inode * get_pipe_inode(void)*/ inode->i_state =I_DIRTY ; inode->i_mode =S_IFIFO |S_IRUSR |S_IWUSR ; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_atime = inode->i_mtime = inode->i_ctime =CURRENT_TIME ;return inode;
fs/posix_acl.c +2 -2
@@ -217,11 +217,11 @@ posix_acl_permission(struct inode *inode, const struct posix_acl *acl, int want)switch (pa->e_tag) {case ACL_USER_OBJ :/* (May have been checked already) */ -if (inode->i_uid == current->fsuid) +if (inode->i_uid == current->cred->uid) goto check_perm;break ;case ACL_USER : -if (pa->e_id == current->fsuid) +if (pa->e_id == current->cred->uid) goto mask;break ;case ACL_GROUP_OBJ :
fs/proc/array.c +6 -6
@@ -159,10 +159,12 @@ static inline const char *get_task_state(struct task_struct *tsk)static inline char *task_state (struct task_struct *p,char *buffer) {struct group_info *group_info; +struct cred *cred;int g;struct fdtable *fdt =NULL ;rcu_read_lock (); + cred =get_task_cred (p); buffer +=sprintf (buffer,"State:\t%s\n" "Tgid:\t%d\n"
@@ -175,8 +177,8 @@ static inline char *task_state(struct task_struct *p, char *buffer) p->tgid, p->pid,pid_alive (p) ?rcu_dereference (p->real_parent)->tgid :0 ,pid_alive (p) && p->ptrace ?rcu_dereference (p->parent)->pid :0 , - p->uid, p->euid, p->suid, p->fsuid, - p->gid, p->egid, p->sgid, p->fsgid); + p->uid, p->euid, p->suid, cred->uid, + p->gid, p->egid, p->sgid, cred->gid);task_lock (p);if (p->files)
@@ -186,14 +188,12 @@ static inline char *task_state(struct task_struct *p, char *buffer)"Groups:\t" , fdt ? fdt->max_fds : 0);rcu_read_unlock (); - - group_info = p->group_info; -get_group_info (group_info);task_unlock (p); + group_info = cred->group_info;for (g =0 ; g <min (group_info->ngroups,NGROUPS_SMALL ); g++) buffer +=sprintf (buffer,"%d " ,GROUP_AT (group_info, g)); -put_group_info (group_info); +put_cred (cred); buffer +=sprintf (buffer,"\n" );return buffer;
fs/ramfs/inode.c +2 -2
@@ -55,8 +55,8 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev)if (inode) { inode->i_mode = mode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_blocks =0 ; inode->i_mapping->a_ops = &ramfs_aops; inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info;
fs/reiserfs/namei.c +2 -2
@@ -582,7 +582,7 @@ static int new_inode_init(struct inode *inode, struct inode *dir, int mode)/* the quota init calls have to know who to charge the quota to, so ** we have to set uid and gid here */ - inode->i_uid = current->fsuid; + inode->i_uid = current->cred->uid; inode->i_mode = mode;/* Make inode invalid - just in case we are going to drop it before * the initialization happens */
@@ -593,7 +593,7 @@ static int new_inode_init(struct inode *inode, struct inode *dir, int mode)if (S_ISDIR (mode)) inode->i_mode |=S_ISGID ; }else { - inode->i_gid = current->fsgid; + inode->i_gid = current->cred->gid; }DQUOT_INIT (inode);return 0 ;
fs/sysv/ialloc.c +2 -2
@@ -165,9 +165,9 @@ struct inode * sysv_new_inode(const struct inode * dir, mode_t mode)if (S_ISDIR (mode)) mode |=S_ISGID ; }else - inode->i_gid = current->fsgid; + inode->i_gid = current->cred->gid; - inode->i_uid = current->fsuid; + inode->i_uid = current->cred->uid; inode->i_ino =fs16_to_cpu (sbi, ino); inode->i_mtime = inode->i_atime = inode->i_ctime =CURRENT_TIME_SEC ; inode->i_blocks =0 ;
fs/udf/ialloc.c +2 -2
@@ -105,13 +105,13 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)mark_buffer_dirty (UDF_SB_LVIDBH (sb)); } inode->i_mode = mode; - inode->i_uid = current->fsuid; + inode->i_uid = current->cred->uid;if (dir->i_mode &S_ISGID ) { inode->i_gid = dir->i_gid;if (S_ISDIR (mode)) mode |=S_ISGID ; }else { - inode->i_gid = current->fsgid; + inode->i_gid = current->cred->gid; }UDF_I_LOCATION (inode).logicalBlockNum = block;
fs/udf/namei.c +1 -1
@@ -636,7 +636,7 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,if (!inode) goto out; - inode->i_uid = current->fsuid; + inode->i_uid = current->cred->uid;init_special_inode (inode, mode, rdev);if (!(fi =udf_add_entry (dir, dentry, &fibh, &cfi, &err))) { inode->i_nlink--;
fs/ufs/ialloc.c +2 -2
@@ -303,13 +303,13 @@ cg_found: inode->i_ino = cg * uspi->s_ipg + bit; inode->i_mode = mode; - inode->i_uid = current->fsuid; + inode->i_uid = current->cred->uid;if (dir->i_mode &S_ISGID ) { inode->i_gid = dir->i_gid;if (S_ISDIR (mode)) inode->i_mode |=S_ISGID ; }else - inode->i_gid = current->fsgid; + inode->i_gid = current->cred->gid; inode->i_blocks =0 ; inode->i_generation =0 ;
fs/xfs/linux-2.6/xfs_cred.h +1 -3
@@ -23,9 +23,7 @@/* * Credentials */ -typedef struct cred { -/* EMPTY */ -}cred_t ; +typedef struct cred cred_t ;extern struct cred *sys_cred;
fs/xfs/linux-2.6/xfs_linux.h +2 -2
@@ -127,8 +127,8 @@#define current_cpu () (raw_smp_processor_id())#define current_pid () (current->pid) -#define current_fsuid (cred) (current->fsuid) -#define current_fsgid (cred) (current->fsgid) +#define current_fsuid (_cred) (current->cred->uid) +#define current_fsgid (_cred) (current->cred->gid)#define current_test_flags (f) (current->flags & (f))#define current_set_flags_nested (sp, f) \ (*(sp) = current->flags, current->flags |= (f))
fs/xfs/xfs_acl.c +3 -3
@@ -383,7 +383,7 @@ xfs_acl_allow_set( error =bhv_vop_getattr (vp, &va,0 ,NULL );if (error)return error; -if (va.va_uid != current->fsuid && !capable (CAP_FOWNER )) +if (va.va_uid != current->cred->uid && !capable (CAP_FOWNER ))return EPERM ;return error; }
@@ -457,13 +457,13 @@ xfs_acl_access(switch (fap->acl_entry[i].ae_tag) {case ACL_USER_OBJ : seen_userobj =1 ; -if (fuid != current->fsuid) +if (fuid != current->cred->uid)continue ; matched.ae_tag =ACL_USER_OBJ ; matched.ae_perm = allows;break ;case ACL_USER : -if (fap->acl_entry[i].ae_id != current->fsuid) +if (fap->acl_entry[i].ae_id != current->cred->uid)continue ; matched.ae_tag =ACL_USER ; matched.ae_perm = allows;
include/linux/binfmts.h +1 -0
@@ -39,6 +39,7 @@ struct linux_binprm{int e_uid, e_gid;kernel_cap_t cap_inheritable, cap_permitted, cap_effective;void *security; +struct cred *cred;int argc, envc;char * filename;/* Name of binary as seen by procps */ char * interp;/* Name of the binary really executed. Most
include/linux/cred.h new file +163 -0
163 lines not on this page · raw message
include/linux/fs.h +3 -2
@@ -285,6 +285,7 @@ extern int dir_notify_enable;#include <linux/mutex.h> #include <linux/sysctl.h> #include <linux/capability.h> +#include <linux/cred.h> #include <asm/atomic.h> #include <asm/semaphore.h>
@@ -736,7 +737,7 @@ struct file {mode_t f_mode;loff_t f_pos;struct fown_struct f_owner; -unsigned int f_uid, f_gid; +struct cred *f_cred;struct file_ra_state f_ra;unsigned long f_version;
@@ -999,7 +1000,7 @@ enum {#define has_fs_excl () atomic_read(¤t->fs_excl)#define is_owner_or_cap (inode) \ - ((current->fsuid == (inode)->i_uid) || capable(CAP_FOWNER)) + ((current->cred->uid == (inode)->i_uid) || capable(CAP_FOWNER))/* not quite ready to be deprecated, but... */ extern void lock_super (struct super_block *);
include/linux/init_task.h +1 -3
@@ -91,8 +91,6 @@ extern struct nsproxy init_nsproxy; .signalfd_wqh = __WAIT_QUEUE_HEAD_INITIALIZER(sighand.signalfd_wqh), \ } -extern struct group_info init_groups; -#define INIT_STRUCT_PID { \ .count = ATOMIC_INIT(1), \ .nr = 0, \
@@ -144,7 +142,7 @@ extern struct group_info init_groups; .children = LIST_HEAD_INIT(tsk.children), \ .sibling = LIST_HEAD_INIT(tsk.sibling), \ .group_leader = &tsk, \ - .group_info = &init_groups, \ + .cred = &init_cred, \ .cap_effective = CAP_INIT_EFF_SET, \ .cap_inheritable = CAP_INIT_INH_SET, \ .cap_permitted = CAP_FULL_SET, \
include/linux/sched.h +4 -3
@@ -80,6 +80,7 @@ struct sched_param {#include <linux/rcupdate.h> #include <linux/futex.h> #include <linux/rtmutex.h> +#include <linux/cred.h> #include <linux/time.h> #include <linux/param.h>
@@ -1034,9 +1035,9 @@ struct task_struct {struct list_head cpu_timers[3 ];/* process credentials */ -uid_t uid,euid,suid,fsuid; -gid_t gid,egid,sgid,fsgid; -struct group_info *group_info; +struct cred *cred; +uid_t uid,euid,suid; +gid_t gid,egid,sgid;kernel_cap_t cap_effective, cap_inheritable, cap_permitted; unsigned keep_capabilities:1;struct user_struct *user;
include/linux/sunrpc/auth.h +6 -12
@@ -21,13 +21,6 @@/* size of the nodename buffer */ #define UNX_MAXNODENAME 32 -/* Work around the lack of a VFS credential */ -struct auth_cred { -uid_t uid; -gid_t gid; -struct group_info *group_info; -}; -/* * Client user credentials */
@@ -94,6 +87,7 @@ struct rpc_auth {/* * Client authentication ops */ +struct cred ;struct rpc_authops {struct module *owner;rpc_authflavor_t au_flavor;/* flavor (RPC_AUTH_*) */
@@ -103,8 +97,8 @@ struct rpc_authops {struct rpc_auth * (*create)(struct rpc_clnt *,rpc_authflavor_t );void (*destroy)(struct rpc_auth *); -struct rpc_cred * (*lookup_cred)(struct rpc_auth *,struct auth_cred *,int ); -struct rpc_cred * (*crcreate)(struct rpc_auth *,struct auth_cred *,int ); +struct rpc_cred * (*lookup_cred)(struct rpc_auth *,struct cred *,int ); +struct rpc_cred * (*crcreate)(struct rpc_auth *,struct cred *,int ); };struct rpc_credops {
@@ -112,7 +106,7 @@ struct rpc_credops {int (*cr_init)(struct rpc_auth *,struct rpc_cred *);void (*crdestroy)(struct rpc_cred *); -int (*crmatch)(struct auth_cred *,struct rpc_cred *,int ); +int (*crmatch)(struct cred *,struct rpc_cred *,int );__be32 * (*crmarshal)(struct rpc_task *,__be32 *);int (*crrefresh)(struct rpc_task *);__be32 * (*crvalidate)(struct rpc_task *,__be32 *);
@@ -133,8 +127,8 @@ int rpcauth_register(const struct rpc_authops *);int rpcauth_unregister (const struct rpc_authops *);struct rpc_auth *rpcauth_create (rpc_authflavor_t ,struct rpc_clnt *);void rpcauth_release (struct rpc_auth *); -struct rpc_cred *rpcauth_lookup_credcache (struct rpc_auth *,struct auth_cred *,int ); -void rpcauth_init_cred (struct rpc_cred *,const struct auth_cred *,struct rpc_auth *,const struct rpc_credops *); +struct rpc_cred *rpcauth_lookup_credcache (struct rpc_auth *,struct cred *,int ); +void rpcauth_init_cred (struct rpc_cred *,const struct cred *,struct rpc_auth *,const struct rpc_credops *);struct rpc_cred *rpcauth_lookupcred (struct rpc_auth *,int );struct rpc_cred *rpcauth_bindcred (struct rpc_task *);void rpcauth_holdcred (struct rpc_task *);
ipc/mqueue.c +2 -2
@@ -113,8 +113,8 @@ static struct inode *mqueue_get_inode(struct super_block *sb, int mode, inode =new_inode (sb);if (inode) { inode->i_mode = mode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_blocks =0 ; inode->i_mtime = inode->i_ctime = inode->i_atime =CURRENT_TIME ;
kernel/Makefile +1 -1
@@ -9,7 +9,7 @@ obj-y = sched.o fork.o exec_domain.o panic.o printk.o profile.o \ rcupdate.o extable.o params.o posix-timers.o \ kthread.o wait.o kfifo.o sys_ni.o posix-cpu-timers.o mutex.o \ hrtimer.o rwsem.o latency.o nsproxy.o srcu.o die_notifier.o \ - utsname.o + utsname.o cred.o obj-$(CONFIG_STACKTRACE) += stacktrace.o obj-y += time/
kernel/auditsc.c +9 -4
@@ -303,7 +303,8 @@ static int audit_filter_rules(struct task_struct *tsk, result =audit_comparator (tsk->suid, f->op, f->val);break ;case AUDIT_FSUID : - result =audit_comparator (tsk->fsuid, f->op, f->val); + result =audit_comparator (task_fsuid (tsk), f->op, + f->val);break ;case AUDIT_GID : result =audit_comparator (tsk->gid, f->op, f->val);
@@ -315,7 +316,8 @@ static int audit_filter_rules(struct task_struct *tsk, result =audit_comparator (tsk->sgid, f->op, f->val);break ;case AUDIT_FSGID : - result =audit_comparator (tsk->fsgid, f->op, f->val); + result =audit_comparator (task_fsgid (tsk), f->op, + f->val);break ;case AUDIT_PERS : result =audit_comparator (tsk->personality, f->op, f->val);
@@ -885,12 +887,15 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts context->gid = tsk->gid; context->euid = tsk->euid; context->suid = tsk->suid; - context->fsuid = tsk->fsuid; context->egid = tsk->egid; context->sgid = tsk->sgid; - context->fsgid = tsk->fsgid; context->personality = tsk->personality; +rcu_read_lock (); + context->fsuid =__task_fsuid (tsk); + context->fsgid =__task_fsgid (tsk); +rcu_read_unlock (); + ab =audit_log_start (context,GFP_KERNEL ,AUDIT_SYSCALL );if (!ab)return ;/* audit_panic has been called */
kernel/cpuset.c +2 -2
@@ -286,8 +286,8 @@ static struct inode *cpuset_new_inode(mode_t mode)if (inode) { inode->i_mode = mode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_blocks =0 ; inode->i_atime = inode->i_mtime = inode->i_ctime =CURRENT_TIME ; inode->i_mapping->backing_dev_info = &cpuset_backing_dev_info;
kernel/cred.c new file +123 -0
123 lines not on this page · raw message
kernel/exit.c +1 -0
@@ -288,6 +288,7 @@ static void reparent_to_kthreadd(void)/* cpus_allowed? */ /* rt_priority? */ /* signals? */ +set_current_cred (get_cred (&init_cred));security_task_reparent_to_init (current);memcpy (current->signal->rlim, init_task.signal->rlim,sizeof (current->signal->rlim));
kernel/fork.c +17 -5
@@ -121,7 +121,7 @@ void __put_task_struct(struct task_struct *tsk)security_task_free (tsk);free_uid (tsk->user); -put_group_info (tsk->group_info); +put_cred (tsk->cred);delayacct_tsk_free (tsk);if (!profile_handoff_task (tsk))
@@ -949,6 +949,16 @@ static inline void rt_mutex_init_task(struct task_struct *p) }/* +* Copy a set of credentials +* - share it unless it contains something we can't copy +*/ +static int copy_cred (struct task_struct *p) +{ +atomic_inc (&p->cred->usage); +return 0 ; +} + +/* * This creates a new process as a copy of the old one, * but does not actually start it yet. *
@@ -1010,7 +1020,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,atomic_inc (&p->user->__count);atomic_inc (&p->user->processes); -get_group_info (p->group_info); +if ((retval =copy_cred (p) <0 )) + goto bad_fork_cleanup_count;/* * If multiple threads are within copy_process(), then this check
@@ -1018,10 +1029,10 @@ static struct task_struct *copy_process(unsigned long clone_flags,* to stop root fork bombs. */ if (nr_threads >= max_threads) - goto bad_fork_cleanup_count; + goto bad_fork_cleanup_cred;if (!try_module_get (task_thread_info (p)->exec_domain->module)) - goto bad_fork_cleanup_count; + goto bad_fork_cleanup_cred;if (p->binfmt && !try_module_get (p->binfmt->module)) goto bad_fork_cleanup_put_domain;
@@ -1309,8 +1320,9 @@ bad_fork_cleanup_delays_binfmt:module_put (p->binfmt->module); bad_fork_cleanup_put_domain:module_put (task_thread_info (p)->exec_domain->module); +bad_fork_cleanup_cred: +put_cred (p->cred); bad_fork_cleanup_count: -put_group_info (p->group_info);atomic_dec (&p->user->processes);free_uid (p->user); bad_fork_free:
kernel/kernel-int.h new file +15 -0
@@ -0,0 +1,15 @@ +/* kernel/ internal definitions +* +* Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. +* Written by David Howells ([email protected]) +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public Licence +* as published by the Free Software Foundation; either version +* 2 of the Licence, or (at your option) any later version. +*/ + +/* +* sys.c +*/ +extern struct group_info init_groups;
kernel/sys.c +104 -40
371 lines not on this page · raw message
kernel/uid16.c +3 -4
@@ -161,25 +161,24 @@ static int groups16_from_user(struct group_info *group_info,asmlinkage long sys_getgroups16 (int gidsetsize,old_gid_t __user *grouplist) { +struct group_info *group_info = current->cred->group_info;int i =0 ;if (gidsetsize <0 )return -EINVAL ; -get_group_info (current->group_info); - i = current->group_info->ngroups; + i = group_info->ngroups;if (gidsetsize) {if (i > gidsetsize) { i = -EINVAL ; goto out; } -if (groups16_to_user (grouplist, current->group_info)) { +if (groups16_to_user (grouplist, group_info)) { i = -EFAULT ; goto out; } } out: -put_group_info (current->group_info);return i; }
mm/shmem.c +4 -4
@@ -1394,8 +1394,8 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev) inode =new_inode (sb);if (inode) { inode->i_mode = mode; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid; inode->i_blocks =0 ; inode->i_mapping->a_ops = &shmem_aops; inode->i_mapping->backing_dev_info = &shmem_backing_dev_info;
@@ -2212,8 +2212,8 @@ static int shmem_fill_super(struct super_block *sb,struct inode *inode;struct dentry *root;int mode =S_IRWXUGO |S_ISVTX ; -uid_t uid = current->fsuid; -gid_t gid = current->fsgid; +uid_t uid = current->cred->uid; +gid_t gid = current->cred->gid;int err = -ENOMEM ;struct shmem_sb_info *sbinfo;unsigned long blocks =0 ;
net/9p/client.c +1 -1
@@ -935,7 +935,7 @@ static struct p9_fid *p9_fid_create(struct p9_client *clnt) fid->rdir_fpos =0 ; fid->rdir_pos =0 ; fid->rdir_fcall =NULL ; - fid->uid = current->fsuid; + fid->uid = current->cred->uid; fid->clnt = clnt; fid->aux =NULL ;
net/socket.c +2 -2
@@ -484,8 +484,8 @@ static struct socket *sock_alloc(void) sock =SOCKET_I (inode); inode->i_mode =S_IFSOCK |S_IRWXUGO ; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; + inode->i_uid = current->cred->uid; + inode->i_gid = current->cred->gid;get_cpu_var (sockets_in_use)++;put_cpu_var (sockets_in_use);
net/sunrpc/auth.c +4 -21
@@ -267,7 +267,7 @@ rpcauth_cache_shrinker(int nr_to_scan, gfp_t gfp_mask)* Look up a process' credentials in the authentication cache */ struct rpc_cred * -rpcauth_lookup_credcache (struct rpc_auth *auth,struct auth_cred * acred, +rpcauth_lookup_credcache (struct rpc_auth *auth,struct cred *acred,int flags) {LIST_HEAD (free);
@@ -336,23 +336,13 @@ out:struct rpc_cred *rpcauth_lookupcred (struct rpc_auth *auth,int flags) { -struct auth_cred acred = { - .uid = current->fsuid, - .gid = current->fsgid, - .group_info = current->group_info, - }; -struct rpc_cred *ret; -dprintk ("RPC: looking up %s cred\n" , auth->au_ops->au_name); -get_group_info (acred.group_info); - ret = auth->au_ops->lookup_cred (auth, &acred, flags); -put_group_info (acred.group_info); -return ret; +return auth->au_ops->lookup_cred (auth, current->cred, flags); }void -rpcauth_init_cred (struct rpc_cred *cred,const struct auth_cred *acred, +rpcauth_init_cred (struct rpc_cred *cred,const struct cred *acred,struct rpc_auth *auth,const struct rpc_credops *ops) {INIT_HLIST_NODE (&cred->cr_hash);
@@ -372,25 +362,18 @@ struct rpc_cred * rpcauth_bindcred(struct rpc_task *task) {struct rpc_auth *auth = task->tk_client->cl_auth; -struct auth_cred acred = { - .uid = current->fsuid, - .gid = current->fsgid, - .group_info = current->group_info, - };struct rpc_cred *ret;int flags =0 ;dprintk ("RPC: %5u looking up %s cred\n" , task->tk_pid, task->tk_client->cl_auth->au_ops->au_name); -get_group_info (acred.group_info);if (task->tk_flags &RPC_TASK_ROOTCREDS ) flags |=RPCAUTH_LOOKUP_ROOTCREDS ; - ret = auth->au_ops->lookup_cred (auth, &acred, flags); + ret = auth->au_ops->lookup_cred (auth, current->cred, flags);if (!IS_ERR (ret)) task->tk_msg.rpc_cred = ret;else task->tk_status =PTR_ERR (ret); -put_group_info (acred.group_info);return ret; }
net/sunrpc/auth_gss/auth_gss.c +3 -3
@@ -793,13 +793,13 @@ gss_destroy_cred(struct rpc_cred *cred)* Lookup RPCSEC_GSS cred for the current process */ static struct rpc_cred * -gss_lookup_cred (struct rpc_auth *auth,struct auth_cred *acred,int flags) +gss_lookup_cred (struct rpc_auth *auth,struct cred *acred,int flags) {return rpcauth_lookup_credcache (auth, acred, flags); }static struct rpc_cred * -gss_create_cred (struct rpc_auth *auth,struct auth_cred *acred,int flags) +gss_create_cred (struct rpc_auth *auth,struct cred *acred,int flags) { struct gss_auth *gss_auth = container_of(auth, struct gss_auth, rpc_auth);struct gss_cred *cred =NULL ;
@@ -840,7 +840,7 @@ gss_cred_init(struct rpc_auth *auth, struct rpc_cred *cred) }static int -gss_match (struct auth_cred *acred,struct rpc_cred *rc,int flags) +gss_match (struct cred *acred,struct rpc_cred *rc,int flags) { struct gss_cred *gss_cred = container_of(rc, struct gss_cred, gc_base);
net/sunrpc/auth_null.c +2 -2
@@ -34,7 +34,7 @@ nul_destroy(struct rpc_auth *auth)* Lookup NULL creds for current process */ static struct rpc_cred * -nul_lookup_cred (struct rpc_auth *auth,struct auth_cred *acred,int flags) +nul_lookup_cred (struct rpc_auth *auth,struct cred *acred,int flags) {return get_rpccred (&null_cred); }
@@ -51,7 +51,7 @@ nul_destroy_cred(struct rpc_cred *cred)* Match cred handle against current process */ static int -nul_match (struct auth_cred *acred,struct rpc_cred *cred,int taskflags) +nul_match (struct cred *acred,struct rpc_cred *cred,int taskflags) {return 1 ; }
net/sunrpc/auth_unix.c +3 -3
@@ -51,13 +51,13 @@ unx_destroy(struct rpc_auth *auth)* Lookup AUTH_UNIX creds for current process */ static struct rpc_cred * -unx_lookup_cred (struct rpc_auth *auth,struct auth_cred *acred,int flags) +unx_lookup_cred (struct rpc_auth *auth,struct cred *acred,int flags) {return rpcauth_lookup_credcache (auth, acred, flags); }static struct rpc_cred * -unx_create_cred (struct rpc_auth *auth,struct auth_cred *acred,int flags) +unx_create_cred (struct rpc_auth *auth,struct cred *acred,int flags) {struct unx_cred *cred;int i;
@@ -115,7 +115,7 @@ unx_destroy_cred(struct rpc_cred *cred)* request root creds (e.g. for NFS swapping). */ static int -unx_match (struct auth_cred *acred,struct rpc_cred *rcred,int flags) +unx_match (struct cred *acred,struct rpc_cred *rcred,int flags) { struct unx_cred *cred = container_of(rcred, struct unx_cred, uc_base);int i;
security/commoncap.c +4 -4
@@ -162,8 +162,8 @@ void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe) } } - current->suid = current->euid = current->fsuid = bprm->e_uid; - current->sgid = current->egid = current->fsgid = bprm->e_gid; + current->suid = current->euid = current->cred->uid = bprm->e_uid; + current->sgid = current->egid = current->cred->gid = bprm->e_gid;/* For init, we want to retain the capabilities set * in the init_task struct. Thus we skip the usual
@@ -280,11 +280,11 @@ int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid,*/ if (!issecure (SECURE_NO_SETUID_FIXUP )) { -if (old_fsuid ==0 && current->fsuid !=0 ) { +if (old_fsuid ==0 && current->cred->uid !=0 ) {cap_t (current->cap_effective) &= ~CAP_FS_MASK ; } -if (old_fsuid !=0 && current->fsuid ==0 ) { +if (old_fsuid !=0 && current->cred->uid ==0 ) {cap_t (current->cap_effective) |= (cap_t (current->cap_permitted) &CAP_FS_MASK );
security/dummy.c +9 -4
@@ -43,10 +43,12 @@ static int dummy_capget (struct task_struct *target, kernel_cap_t * effective, *permitted |= (~0 & ~CAP_FS_MASK ); *effective |= (~0 & ~CAP_TO_MASK (CAP_SETPCAP ) & ~CAP_FS_MASK ); } -if (target->fsuid ==0 ) { +rcu_read_lock (); +if (task_cred (target)->uid ==0 ) { *permitted |=CAP_FS_MASK ; *effective |=CAP_FS_MASK ; } +rcu_read_unlock (); }return 0 ; }
@@ -138,8 +140,11 @@ static void dummy_bprm_apply_creds (struct linux_binprm *bprm, int unsafe) } } - current->suid = current->euid = current->fsuid = bprm->e_uid; - current->sgid = current->egid = current->fsgid = bprm->e_gid; + current->suid = current->euid = bprm->e_uid; + current->sgid = current->egid = bprm->e_gid; + +change_fsuid (bprm->cred, bprm->e_uid); +change_fsgid (bprm->cred, bprm->e_gid);dummy_capget (current, ¤t->cap_effective, ¤t->cap_inheritable, ¤t->cap_permitted); }
@@ -572,7 +577,7 @@ static int dummy_task_prctl (int option, unsigned long arg2, unsigned long arg3,static void dummy_task_reparent_to_init (struct task_struct *p) { - p->euid = p->fsuid =0 ; + p->euid =0 ;return ; }
security/keys/key.c +2 -1
@@ -817,7 +817,8 @@ key_ref_t key_create_or_update(key_ref_t keyring_ref, perm |=KEY_USR_WRITE ;/* allocate a new key */ - key =key_alloc (ktype, description, current->fsuid, current->fsgid, + key =key_alloc (ktype, description, + current->cred->uid, current->cred->gid, current, perm, flags);if (IS_ERR (key)) { key_ref =ERR_CAST (key);
security/keys/keyctl.c +1 -1
@@ -806,7 +806,7 @@ long keyctl_setperm_key(key_serial_t id, key_perm_t perm)down_write (&key->sem);/* if we're not the sysadmin, we can only change a key that we own */ -if (capable (CAP_SYS_ADMIN ) || key->uid == current->fsuid) { +if (capable (CAP_SYS_ADMIN ) || key->uid == current->cred->uid) { key->perm = perm; ret =0 ; }
security/keys/permission.c +10 -6
@@ -22,14 +22,19 @@ int key_task_permission(const key_ref_t key_ref, struct task_struct *context, key_perm_t perm) { +struct cred *cred;struct key *key;key_perm_t kperm;int ret; +rcu_read_lock (); + cred =get_task_cred (context); +rcu_read_unlock (); + key =key_ref_to_ptr (key_ref);/* use the second 8-bits of permissions for keys the caller owns */ -if (key->uid == context->fsuid) { +if (key->uid == cred->uid) { kperm = key->perm >>16 ; goto use_these_perms; }
@@ -37,15 +42,12 @@ int key_task_permission(const key_ref_t key_ref,/* use the third 8-bits of permissions for keys the caller has a group * membership in common with */ if (key->gid !=-1 && key->perm &KEY_GRP_ALL ) { -if (key->gid == context->fsgid) { +if (key->gid == cred->gid) { kperm = key->perm >>8 ; goto use_these_perms; } -task_lock (context); - ret =groups_search (context->group_info, key->gid); -task_unlock (context); - + ret =groups_search (cred->group_info, key->gid);if (ret) { kperm = key->perm >>8 ; goto use_these_perms;
@@ -56,6 +58,8 @@ int key_task_permission(const key_ref_t key_ref, kperm = key->perm; use_these_perms: +put_cred (cred); +/* use the top 8-bits of permissions for keys the caller possesses * - possessor permissions are additive with other permissions */
security/keys/process_keys.c +4 -2
@@ -357,13 +357,14 @@ int suid_keys(struct task_struct *tsk)/*****************************************************************************/ /* * the filesystem user ID changed +* - can only be used for current task */ void key_fsuid_changed (struct task_struct *tsk) {/* update the ownership of the thread keyring */ if (tsk->thread_keyring) {down_write (&tsk->thread_keyring->sem); - tsk->thread_keyring->uid = tsk->fsuid; + tsk->thread_keyring->uid = tsk->cred->uid;up_write (&tsk->thread_keyring->sem); }
@@ -372,13 +373,14 @@ void key_fsuid_changed(struct task_struct *tsk)/*****************************************************************************/ /* * the filesystem group ID changed +* - can only be used for current task */ void key_fsgid_changed (struct task_struct *tsk) {/* update the ownership of the thread keyring */ if (tsk->thread_keyring) {down_write (&tsk->thread_keyring->sem); - tsk->thread_keyring->gid = tsk->fsgid; + tsk->thread_keyring->gid = tsk->cred->gid;up_write (&tsk->thread_keyring->sem); }
security/keys/request_key.c +7 -7
@@ -76,8 +76,8 @@ static int call_sbin_request_key(struct key_construction *cons,/* allocate a new session keyring */ sprintf (desc,"_req.%u" , key->serial); - keyring =keyring_alloc (desc, current->fsuid, current->fsgid, current, -KEY_ALLOC_QUOTA_OVERRUN ,NULL ); + keyring =keyring_alloc (desc, current->cred->uid, current->cred->gid, + current,KEY_ALLOC_QUOTA_OVERRUN ,NULL );if (IS_ERR (keyring)) { ret =PTR_ERR (keyring); goto error_alloc;
@@ -89,8 +89,8 @@ static int call_sbin_request_key(struct key_construction *cons, goto error_link;/* record the UID and GID */ -sprintf (uid_str,"%d" , current->fsuid); -sprintf (gid_str,"%d" , current->fsgid); +sprintf (uid_str,"%d" , current->cred->uid); +sprintf (gid_str,"%d" , current->cred->gid);/* we say which key is under construction */ sprintf (key_str,"%d" , key->serial);
@@ -277,8 +277,8 @@ static int construct_alloc_key(struct key_type *type,mutex_lock (&user->cons_lock); key =key_alloc (type, description, - current->fsuid, current->fsgid, current,KEY_POS_ALL , - flags); + current->cred->uid, current->cred->gid, current, +KEY_POS_ALL , flags);if (IS_ERR (key)) goto alloc_failed;
@@ -339,7 +339,7 @@ static struct key *construct_key_and_link(struct key_type *type,struct key *key;int ret; - user =key_user_lookup (current->fsuid); + user =key_user_lookup (current->cred->uid);if (!user)return ERR_PTR (-ENOMEM );
security/keys/request_key_auth.c +1 -1
@@ -192,7 +192,7 @@ struct key *request_key_auth_new(struct key *target, const char *callout_info)sprintf (desc,"%x" , target->serial); authkey =key_alloc (&key_type_request_key_auth, desc, - current->fsuid, current->fsgid, current, + current->cred->uid, current->cred->gid, current,KEY_POS_VIEW |KEY_POS_READ |KEY_POS_SEARCH |KEY_USR_VIEW ,KEY_ALLOC_NOT_IN_QUOTA );if (IS_ERR (authkey)) {
Re: [PATCH 01/52] CRED: Introduce a COW credentials record
fs/xfs/xfs_acl.c xfs_acl_allow_set( · line 386
Quoted 10 lines · David Howells
fs/xfs/xfs_acl.c +1
-1@@ -383,7 +383,7 @@ xfs_acl_allow_set( error =bhv_vop_getattr (vp, &va,0 ,NULL );if (error)return error; -if (va.va_uid != current->fsuid && !capable (CAP_FOWNER )) +if (va.va_uid != current->cred->uid && !capable (CAP_FOWNER ))
current_fsuid() should be used here.
Quoted 6 lines
fs/xfs/xfs_acl.c +0
-0return EPERM ;return error; }@@ -457,13 +457,13 @@ xfs_acl_access(switch (fap->acl_entry[i].ae_tag) {case ACL_USER_OBJ :
fs/xfs/xfs_acl.c xfs_acl_access( · line 466
Quoted 10 lines
fs/xfs/xfs_acl.c +2
-2seen_userobj =1 ; -if (fuid != current->fsuid) +if (fuid != current->cred->uid)continue ; matched.ae_tag =ACL_USER_OBJ ; matched.ae_perm = allows;break ;case ACL_USER : -if (fap->acl_entry[i].ae_id != current->fsuid) +if (fap->acl_entry[i].ae_id != current->cred->uid)
and here as well....
Cheers,
Dave.
Signature · 3 lines
Dave Chinner Principal Engineer SGI Australian Software Group
David Howells
maintainerPATCH 2/52 CRED: Give in_group_p() a cred pointer
In reply to David HowellsPass a credential record pointer to in_group_p() so that it refers to the credentials set of interest, rather than current credentials.
---
fs/attr.c | 12 ++++++++---- fs/configfs/inode.c | 3 ++- fs/dquot.c | 2 +- fs/ext2/balloc.c | 3 ++- fs/ext3/balloc.c | 3 ++- fs/ext4/balloc.c | 3 ++- fs/hugetlbfs/inode.c | 2 +- fs/jffs2/fs.c | 3 ++- fs/namei.c | 4 ++-- fs/posix_acl.c | 4 ++-- fs/proc/proc_sysctl.c | 2 +- fs/sysfs/inode.c | 3 ++- fs/xfs/linux-2.6/xfs_iops.c | 3 ++- fs/xfs/xfs_inode.c | 4 ++-- fs/xfs/xfs_vnodeops.c | 4 ++-- include/linux/sched.h | 4 ++-- ipc/util.c | 3 ++- kernel/sys.c | 5 ++--- security/keys/keyctl.c | 3 ++- 19 files changed, 41 insertions(+), 29 deletions(-)
fs/attr.c +8 -4
@@ -36,7 +36,8 @@ int inode_change_ok(struct inode *inode, struct iattr *attr)/* Make sure caller can chgrp. */ if ((ia_valid &ATTR_GID ) && (current->cred->uid != inode->i_uid || - (!in_group_p (attr->ia_gid) && attr->ia_gid != inode->i_gid)) && + (!in_group_p (current->cred, attr->ia_gid) && + attr->ia_gid != inode->i_gid)) && !capable (CAP_CHOWN )) goto error;
@@ -45,8 +46,10 @@ int inode_change_ok(struct inode *inode, struct iattr *attr)if (!is_owner_or_cap (inode)) goto error;/* Also check the setgid bit! */ -if (!in_group_p ((ia_valid &ATTR_GID ) ? attr->ia_gid : - inode->i_gid) && !capable (CAP_FSETID )) +if (!in_group_p (current->cred, + (ia_valid &ATTR_GID ) ? + attr->ia_gid : inode->i_gid) && + !capable (CAP_FSETID )) attr->ia_mode &= ~S_ISGID ; }
@@ -90,7 +93,8 @@ int inode_setattr(struct inode * inode, struct iattr * attr)if (ia_valid &ATTR_MODE ) {umode_t mode = attr->ia_mode; -if (!in_group_p (inode->i_gid) && !capable (CAP_FSETID )) +if (!in_group_p (current->cred, inode->i_gid) && + !capable (CAP_FSETID )) mode &= ~S_ISGID ; inode->i_mode = mode; }
fs/configfs/inode.c +2 -1
@@ -106,7 +106,8 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr)if (ia_valid &ATTR_MODE ) {umode_t mode = iattr->ia_mode; -if (!in_group_p (inode->i_gid) && !capable (CAP_FSETID )) +if (!in_group_p (current->cred, inode->i_gid) && + !capable (CAP_FSETID )) mode &= ~S_ISGID ; sd_iattr->ia_mode = sd->s_mode = mode; }
fs/dquot.c +1 -1
@@ -834,7 +834,7 @@ static inline int need_print_warning(struct dquot *dquot)case USRQUOTA :return current->cred->uid == dquot->dq_id;case GRPQUOTA : -return in_group_p (dquot->dq_id); +return in_group_p (current->cred, dquot->dq_id); }return 0 ; }
fs/ext2/balloc.c +2 -1
@@ -113,7 +113,8 @@ static int reserve_blocks(struct super_block *sb, int count)if (free_blocks < root_blocks + count && !capable (CAP_SYS_RESOURCE ) && sbi->s_resuid != current->cred->uid && - (sbi->s_resgid ==0 || !in_group_p (sbi->s_resgid))) { + (sbi->s_resgid ==0 || + !in_group_p (current->cred, sbi->s_resgid))) {/* * We are too close to reserve and we are not privileged. * Can we allocate anything at all?
fs/ext3/balloc.c +2 -1
@@ -1361,7 +1361,8 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi) root_blocks =le32_to_cpu (sbi->s_es->s_r_blocks_count);if (free_blocks < root_blocks +1 && !capable (CAP_SYS_RESOURCE ) && sbi->s_resuid != current->cred->uid && - (sbi->s_resgid ==0 || !in_group_p (sbi->s_resgid))) { + (sbi->s_resgid ==0 || + !in_group_p (current->cred, sbi->s_resgid))) {return 0 ; }return 1 ;
fs/ext4/balloc.c +2 -1
@@ -1378,7 +1378,8 @@ static int ext4_has_free_blocks(struct ext4_sb_info *sbi) root_blocks =ext4_r_blocks_count (sbi->s_es);if (free_blocks < root_blocks +1 && !capable (CAP_SYS_RESOURCE ) && sbi->s_resuid != current->cred->uid && - (sbi->s_resgid ==0 || !in_group_p (sbi->s_resgid))) { + (sbi->s_resgid ==0 || + !in_group_p (current->cred, sbi->s_resgid))) {return 0 ; }return 1 ;
fs/hugetlbfs/inode.c +1 -1
@@ -781,7 +781,7 @@ static struct vfsmount *hugetlbfs_vfsmount;static int can_do_hugetlb_shm (void ) {return likely (capable (CAP_IPC_LOCK ) || -in_group_p (sysctl_hugetlb_shm_group) || +in_group_p (current->cred, sysctl_hugetlb_shm_group) ||can_do_mlock ()); }
fs/jffs2/fs.c +2 -1
@@ -100,7 +100,8 @@ static int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)if (ivalid &ATTR_MODE )if (iattr->ia_mode &S_ISGID && - !in_group_p (je16_to_cpu (ri->gid)) && !capable (CAP_FSETID )) + !in_group_p (current->cred,je16_to_cpu (ri->gid)) && + !capable (CAP_FSETID )) ri->mode =cpu_to_jemode (iattr->ia_mode & ~S_ISGID );else ri->mode =cpu_to_jemode (iattr->ia_mode);
fs/namei.c +2 -2
@@ -196,7 +196,7 @@ int generic_permission(struct inode *inode, int mask,return error; } -if (in_group_p (inode->i_gid)) +if (in_group_p (current->cred, inode->i_gid)) mode >>=3 ; }
@@ -439,7 +439,7 @@ static int exec_permission_lite(struct inode *inode,if (current->cred->uid == inode->i_uid) mode >>=6 ; -else if (in_group_p (inode->i_gid)) +else if (in_group_p (current->cred, inode->i_gid)) mode >>=3 ;if (mode &MAY_EXEC )
fs/posix_acl.c +2 -2
@@ -225,14 +225,14 @@ posix_acl_permission(struct inode *inode, const struct posix_acl *acl, int want) goto mask;break ;case ACL_GROUP_OBJ : -if (in_group_p (inode->i_gid)) { +if (in_group_p (current->cred, inode->i_gid)) { found =1 ;if ((pa->e_perm & want) == want) goto mask; }break ;case ACL_GROUP : -if (in_group_p (pa->e_id)) { +if (in_group_p (current->cred, pa->e_id)) { found =1 ;if ((pa->e_perm & want) == want) goto mask;
fs/proc/proc_sysctl.c +1 -1
@@ -393,7 +393,7 @@ static int proc_sys_permission(struct inode *inode, int mask, struct nameidata *if (current->euid ==0 ) mode >>=6 ; -else if (in_group_p (0 )) +else if (in_group_p (current->cred,0 )) mode >>=3 ;if ((mode & mask & (MAY_READ |MAY_WRITE |MAY_EXEC )) == mask)
fs/sysfs/inode.c +2 -1
@@ -96,7 +96,8 @@ int sysfs_setattr(struct dentry * dentry, struct iattr * iattr)if (ia_valid &ATTR_MODE ) {umode_t mode = iattr->ia_mode; -if (!in_group_p (inode->i_gid) && !capable (CAP_FSETID )) +if (!in_group_p (current->cred, inode->i_gid) && + !capable (CAP_FSETID )) mode &= ~S_ISGID ; sd_iattr->ia_mode = sd->s_mode = mode; }
fs/xfs/linux-2.6/xfs_iops.c +2 -1
@@ -685,7 +685,8 @@ xfs_vn_setattr(if (ia_valid &ATTR_MODE ) { vattr.va_mask |=XFS_AT_MODE ; vattr.va_mode = attr->ia_mode; -if (!in_group_p (inode->i_gid) && !capable (CAP_FSETID )) +if (!in_group_p (current->cred, inode->i_gid) && + !capable (CAP_FSETID )) inode->i_mode &= ~S_ISGID ; }
fs/xfs/xfs_inode.c +2 -2
@@ -1175,7 +1175,7 @@ xfs_ialloc(*/ if ((irix_sgid_inherit) && (ip->i_d.di_mode &S_ISGID ) && - (!in_group_p ((gid_t )ip->i_d.di_gid))) { + (!in_group_p (current->cred, (gid_t )ip->i_d.di_gid))) { ip->i_d.di_mode &= ~S_ISGID ; }
@@ -3635,7 +3635,7 @@ xfs_iaccess(if (current_fsuid (cr) != ip->i_d.di_uid) { mode >>=3 ; -if (!in_group_p ((gid_t )ip->i_d.di_gid)) +if (!in_group_p (current->cred, (gid_t )ip->i_d.di_gid)) mode >>=3 ; }
fs/xfs/xfs_vnodeops.c +2 -2
@@ -393,7 +393,7 @@ xfs_setattr(if ((vap->va_mode &S_ISUID ) && !file_owner) m |=S_ISUID ;if ((vap->va_mode &S_ISGID ) && - !in_group_p ((gid_t )ip->i_d.di_gid)) + !in_group_p (current->cred, (gid_t )ip->i_d.di_gid)) m |=S_ISGID ;#if 0 /* Linux allows this, Irix doesn't. */
@@ -439,7 +439,7 @@ xfs_setattr(*/ if (restricted_chown && (iuid != uid || (igid != gid && - !in_group_p ((gid_t )gid))) && + !in_group_p (current->cred, (gid_t )gid))) && !capable (CAP_CHOWN )) { code =XFS_ERROR (EPERM ); goto error_return;
include/linux/sched.h +2 -2
@@ -835,7 +835,7 @@ struct group_info {extern struct group_info *groups_alloc (int gidsetsize);extern void groups_free (struct group_info *group_info);extern int set_current_groups (struct group_info *group_info); -extern int groups_search (struct group_info *group_info,gid_t grp); +extern int groups_search (const struct group_info *group_info,gid_t grp);/* access the groups "array" with this macro */ #define GROUP_AT (gi, i) \ ((gi)->blocks[(i)/NGROUPS_PER_BLOCK][(i)%NGROUPS_PER_BLOCK])
@@ -1493,7 +1493,7 @@ extern void FASTCALL(wake_up_new_task(struct task_struct * tsk,extern void sched_fork (struct task_struct *p,int clone_flags);extern void sched_dead (struct task_struct *p); -extern int in_group_p (gid_t ); +extern int in_group_p (const struct cred *,gid_t );extern int in_egroup_p (gid_t );extern void proc_caches_init (void );
ipc/util.c +2 -1
@@ -546,7 +546,8 @@ int ipcperms (struct kern_ipc_perm *ipcp, short flag) granted_mode = ipcp->mode;if (current->euid == ipcp->cuid || current->euid == ipcp->uid) granted_mode >>=6 ; -else if (in_group_p (ipcp->cgid) ||in_group_p (ipcp->gid)) +else if (in_group_p (current->cred, ipcp->cgid) || +in_group_p (current->cred, ipcp->gid)) granted_mode >>=3 ;/* is there some bit set in requested_mode but not in granted_mode? */ if ((requested_mode & ~granted_mode & 0007) &&
kernel/sys.c +2 -3
@@ -1796,7 +1796,7 @@ static void groups_sort(struct group_info *group_info) }/* a simple bsearch */ -int groups_search (struct group_info *group_info,gid_t grp) +int groups_search (const struct group_info *group_info,gid_t grp) {unsigned int left, right;
@@ -1901,9 +1901,8 @@ asmlinkage long sys_setgroups(int gidsetsize, gid_t __user *grouplist)/* * Check whether we're fsgid/egid or in the supplemental group.. */ -int in_group_p (gid_t grp) +int in_group_p (const struct cred *cred,gid_t grp) { -struct cred *cred = current->cred;int retval =1 ;if (grp != cred->gid)
security/keys/keyctl.c +2 -1
@@ -713,7 +713,8 @@ long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid)/* only the sysadmin can set the key's GID to a group other * than one of those that the current process subscribes to */ -if (gid != (gid_t) -1 && gid != key->gid && !in_group_p (gid)) +if (gid != (gid_t) -1 && gid != key->gid && + !in_group_p (current->cred, gid)) goto error_put; }
David Howells
maintainerPATCH 3/52 CRED: Pass credentials down to ext3 block allocator
In reply to David HowellsPass credentials down to the ext3 block allocator.
---
fs/ext3/acl.c | 24 ++++-- fs/ext3/acl.h | 5 + fs/ext3/balloc.c | 24 ++++-- fs/ext3/dir.c | 9 ++ fs/ext3/ialloc.c | 5 + fs/ext3/inode.c | 35 ++++++--- fs/ext3/namei.c | 174 +++++++++++++++++++++++++++------------------- fs/ext3/super.c | 6 +- fs/ext3/xattr.c | 23 ++++-- fs/ext3/xattr.h | 6 +- fs/ext3/xattr_security.c | 7 +- fs/ext3/xattr_trusted.c | 4 + fs/ext3/xattr_user.c | 4 + include/linux/ext3_fs.h | 22 ++++-- 14 files changed, 212 insertions(+), 136 deletions(-)
fs/ext3/acl.c +14 -10
@@ -221,7 +221,7 @@ ext3_get_acl(struct inode *inode, int type)*/ static int ext3_set_acl (handle_t *handle,struct inode *inode,int type, -struct posix_acl *acl) +struct posix_acl *acl,struct cred *cred) {struct ext3_inode_info *ei =EXT3_I (inode);int name_index;
@@ -265,7 +265,7 @@ ext3_set_acl(handle_t *handle, struct inode *inode, int type, } error =ext3_xattr_set_handle (handle, inode, name_index,"" , - value, size,0 ); + value, size,0 , cred);kfree (value);if (!error) {
@@ -311,7 +311,8 @@ ext3_permission(struct inode *inode, int mask, struct nameidata *nd)* inode->i_mutex: up (access to inode is still exclusive) */ int -ext3_init_acl (handle_t *handle,struct inode *inode,struct inode *dir) +ext3_init_acl (handle_t *handle,struct inode *inode,struct inode *dir, +struct cred *cred) {struct posix_acl *acl =NULL ;int error =0 ;
@@ -331,7 +332,7 @@ ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)if (S_ISDIR (inode->i_mode)) { error =ext3_set_acl (handle, inode, -ACL_TYPE_DEFAULT , acl); +ACL_TYPE_DEFAULT , acl, cred);if (error) goto cleanup; }
@@ -347,7 +348,8 @@ ext3_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)if (error >0 ) {/* This is an extended ACL */ error =ext3_set_acl (handle, inode, -ACL_TYPE_ACCESS , clone); +ACL_TYPE_ACCESS , clone, + cred); } }posix_acl_release (clone);
@@ -372,7 +374,7 @@ cleanup:* inode->i_mutex: down */ int -ext3_acl_chmod (struct inode *inode) +ext3_acl_chmod (struct inode *inode,struct cred *cred) {struct posix_acl *acl, *clone;int error;
@@ -401,10 +403,10 @@ ext3_acl_chmod(struct inode *inode)ext3_std_error (inode->i_sb, error); goto out; } - error =ext3_set_acl (handle, inode,ACL_TYPE_ACCESS , clone); + error =ext3_set_acl (handle, inode,ACL_TYPE_ACCESS , clone, cred);ext3_journal_stop (handle);if (error == -ENOSPC && -ext3_should_retry_alloc (inode->i_sb, &retries)) +ext3_should_retry_alloc (inode->i_sb, &retries, cred)) goto retry; } out:
@@ -483,6 +485,7 @@ static int ext3_xattr_set_acl(struct inode *inode, int type, const void *value, size_t size) { + struct cred *cred = current->cred;handle_t *handle;struct posix_acl *acl;int error, retries =0 ;
@@ -508,9 +511,10 @@ retry: handle =ext3_journal_start (inode,EXT3_DATA_TRANS_BLOCKS (inode->i_sb));if (IS_ERR (handle))return PTR_ERR (handle); - error =ext3_set_acl (handle, inode, type, acl); + error =ext3_set_acl (handle, inode, type, acl, cred);ext3_journal_stop (handle); -if (error == -ENOSPC &&ext3_should_retry_alloc (inode->i_sb, &retries)) +if (error == -ENOSPC && +ext3_should_retry_alloc (inode->i_sb, &retries, cred)) goto retry; release_and_out:
fs/ext3/acl.h +3 -2
@@ -59,8 +59,9 @@ static inline int ext3_acl_count(size_t size)/* acl.c */ extern int ext3_permission (struct inode *,int ,struct nameidata *); -extern int ext3_acl_chmod (struct inode *); -extern int ext3_init_acl (handle_t *,struct inode *,struct inode *); +extern int ext3_acl_chmod (struct inode *,struct cred *); +extern int ext3_init_acl (handle_t *,struct inode *,struct inode *, +struct cred *);#else /* CONFIG_EXT3_FS_POSIX_ACL */ #include <linux/sched.h>
fs/ext3/balloc.c +14 -10
@@ -1350,19 +1350,19 @@ out:/** * ext3_has_free_blocks() * @sbi: in-core super block structure. +* @cred: the credentials in force * * Check if filesystem has at least 1 free block available for allocation. */ -static int ext3_has_free_blocks (struct ext3_sb_info *sbi) +static int ext3_has_free_blocks (struct ext3_sb_info *sbi,struct cred *cred) {ext3_fsblk_t free_blocks, root_blocks; free_blocks =percpu_counter_read_positive (&sbi->s_freeblocks_counter); root_blocks =le32_to_cpu (sbi->s_es->s_r_blocks_count);if (free_blocks < root_blocks +1 && !capable (CAP_SYS_RESOURCE ) && - sbi->s_resuid != current->cred->uid && - (sbi->s_resgid ==0 || - !in_group_p (current->cred, sbi->s_resgid))) { + sbi->s_resuid != cred->uid && + (sbi->s_resgid ==0 || !in_group_p (cred, sbi->s_resgid))) {return 0 ; }return 1 ;
@@ -1372,6 +1372,7 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi)* ext3_should_retry_alloc() * @sb: super block * @retries number of attemps has been made +* @cred: the credentials in force * * ext3_should_retry_alloc() is called when ENOSPC is returned, and if * it is profitable to retry the operation, this function will wait
@@ -1380,9 +1381,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi)* * if the total number of retries exceed three times, return FALSE. */ -int ext3_should_retry_alloc (struct super_block *sb,int *retries) +int ext3_should_retry_alloc (struct super_block *sb,int *retries, +struct cred *cred) { -if (!ext3_has_free_blocks (EXT3_SB (sb)) || (*retries)++ >3 ) +if (!ext3_has_free_blocks (EXT3_SB (sb), cred) || (*retries)++ >3 )return 0 ;jbd_debug (1 ,"%s: retrying operation after ENOSPC\n" , sb->s_id);
@@ -1397,6 +1399,7 @@ int ext3_should_retry_alloc(struct super_block *sb, int *retries)* @goal: given target block(filesystem wide) * @count: target number of blocks to allocate * @errp: error code +* @cred: the credentials in force * * ext3_new_blocks uses a goal block to assist allocation. It tries to * allocate block(s) from the block group contains the goal block first. If that
@@ -1405,7 +1408,8 @@ int ext3_should_retry_alloc(struct super_block *sb, int *retries)* */ ext3_fsblk_t ext3_new_blocks (handle_t *handle,struct inode *inode, -ext3_fsblk_t goal,unsigned long *count,int *errp) +ext3_fsblk_t goal,unsigned long *count,int *errp, +struct cred *cred) {struct buffer_head *bitmap_bh =NULL ;struct buffer_head *gdp_bh;
@@ -1461,7 +1465,7 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) >0 )) my_rsv = &block_i->rsv_window_node; -if (!ext3_has_free_blocks (sbi)) { +if (!ext3_has_free_blocks (sbi, cred)) { *errp = -ENOSPC ; goto out; }
@@ -1668,11 +1672,11 @@ out: }ext3_fsblk_t ext3_new_block (handle_t *handle,struct inode *inode, -ext3_fsblk_t goal,int *errp) +ext3_fsblk_t goal,int *errp,struct cred *cred) {unsigned long count =1 ; -return ext3_new_blocks (handle, inode, goal, &count, errp); +return ext3_new_blocks (handle, inode, goal, &count, errp, cred); }/**
fs/ext3/dir.c +6 -3
@@ -96,6 +96,7 @@ int ext3_check_dir_entry (const char * function, struct inode * dir,static int ext3_readdir (struct file * filp,void * dirent,filldir_t filldir) { +struct cred *cred = filp->f_cred;int error =0 ;unsigned long offset;int i, stored;
@@ -134,7 +135,7 @@ static int ext3_readdir(struct file * filp, map_bh.b_state =0 ; err =ext3_get_blocks_handle (NULL , inode, blk,1 , - &map_bh,0 ,0 ); + &map_bh,0 ,0 , cred);if (err >0 ) {pgoff_t index = map_bh.b_blocknr >> (PAGE_CACHE_SHIFT - inode->i_blkbits);
@@ -144,7 +145,7 @@ static int ext3_readdir(struct file * filp, &filp->f_ra, filp, index, 1); filp->f_ra.prev_index = index; - bh =ext3_bread (NULL , inode, blk,0 , &err); + bh =ext3_bread (NULL , inode, blk,0 , &err, cred); }/*
@@ -432,6 +433,7 @@ static int call_filldir(struct file * filp, void * dirent,static int ext3_dx_readdir (struct file * filp,void * dirent,filldir_t filldir) { +struct cred *cred = filp->f_cred;struct dir_private_info *info = filp->private_data;struct inode *inode = filp->f_path.dentry->d_inode;struct fname *fname;
@@ -480,7 +482,8 @@ static int ext3_dx_readdir(struct file * filp, filp->f_version = inode->i_version; ret =ext3_htree_fill_tree (filp, info->curr_hash, info->curr_minor_hash, - &info->next_hash); + &info->next_hash, + cred);if (ret <0 )return ret;if (ret ==0 ) {
fs/ext3/ialloc.c +3 -2
@@ -421,7 +421,8 @@ static int find_group_other(struct super_block *sb, struct inode *parent)* For other inodes, search forward from the parent directory's block * group to find a free inode. */ -struct inode *ext3_new_inode (handle_t *handle,struct inode * dir,int mode) +struct inode *ext3_new_inode (handle_t *handle,struct inode * dir,int mode, +struct cred *cred) {struct super_block *sb;struct buffer_head *bitmap_bh =NULL ;
@@ -602,7 +603,7 @@ got: goto fail_drop; } - err =ext3_init_acl (handle, inode, dir); + err =ext3_init_acl (handle, inode, dir, cred);if (err) goto fail_free_drop;
fs/ext3/inode.c +22 -13
@@ -513,10 +513,12 @@ static int ext3_blks_to_allocate(Indirect *branch, int k, unsigned long blks,* the indirect blocks(if needed) and the first direct block, * @blks: on return it will store the total number of allocated * direct blocks +* @cred: the credentials in force */ static int ext3_alloc_blocks (handle_t *handle,struct inode *inode,ext3_fsblk_t goal,int indirect_blks,int blks, -ext3_fsblk_t new_blocks[4 ],int *err) +ext3_fsblk_t new_blocks[4 ],int *err, +struct cred *cred) {int target, i;unsigned long count =0 ;
@@ -537,7 +539,8 @@ static int ext3_alloc_blocks(handle_t *handle, struct inode *inode,while (1 ) { count = target;/* allocating blocks for indirect blocks and direct blocks */ - current_block =ext3_new_blocks (handle,inode,goal,&count,err); + current_block =ext3_new_blocks (handle,inode,goal,&count,err, + cred);if (*err) goto failed_out;
@@ -572,6 +575,7 @@ failed_out:* @blks: number of allocated direct blocks * @offsets: offsets (in the blocks) to store the pointers to next. * @branch: place to store the chain in. +* @cred: the credentials in force * * This function allocates blocks, zeroes out all but the last one, * links them into chain and (if we are synchronous) writes them to disk.
@@ -592,7 +596,7 @@ failed_out:*/ static int ext3_alloc_branch (handle_t *handle,struct inode *inode,int indirect_blks,int *blks,ext3_fsblk_t goal, -int *offsets,Indirect *branch) +int *offsets,Indirect *branch,struct cred *cred) {int blocksize = inode->i_sb->s_blocksize;int i, n =0 ;
@@ -603,7 +607,7 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode,ext3_fsblk_t current_block; num =ext3_alloc_blocks (handle, inode, goal, indirect_blks, - *blks, new_blocks, &err); + *blks, new_blocks, &err, cred);if (err)return err;
@@ -788,7 +792,7 @@ err_out:int ext3_get_blocks_handle (handle_t *handle,struct inode *inode,sector_t iblock,unsigned long maxblocks,struct buffer_head *bh_result, -int create,int extend_disksize) +int create,int extend_disksize,struct cred *cred) {int err = -EIO ;int offsets[4 ];
@@ -899,7 +903,7 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,* Block out ext3_truncate while we alter the tree */ err =ext3_alloc_branch (handle, inode, indirect_blks, &count, goal, - offsets + (partial - chain), partial); + offsets + (partial - chain), partial, cred);/* * The ext3_splice_branch call will free and forget any buffers
@@ -946,6 +950,7 @@ out:static int ext3_get_block (struct inode *inode,sector_t iblock,struct buffer_head *bh_result,int create) { +struct cred *cred = current->cred;handle_t *handle =ext3_journal_current_handle ();int ret =0 ;unsigned max_blocks = bh_result->b_size >> inode->i_blkbits;
@@ -984,7 +989,7 @@ static int ext3_get_block(struct inode *inode, sector_t iblock, get_block:if (ret ==0 ) { ret =ext3_get_blocks_handle (handle, inode, iblock, - max_blocks, bh_result, create,0 ); + max_blocks, bh_result, create,0 , cred);if (ret >0 ) { bh_result->b_size = (ret << inode->i_blkbits); ret =0 ;
@@ -997,7 +1002,8 @@ get_block:* `handle' can be NULL if create is zero */ struct buffer_head *ext3_getblk (handle_t *handle,struct inode *inode, -long block,int create,int *errp) +long block,int create,int *errp, +struct cred *cred) {struct buffer_head dummy;int fatal =0 , err;
@@ -1008,7 +1014,7 @@ struct buffer_head *ext3_getblk(handle_t *handle, struct inode *inode, dummy.b_blocknr =-1000 ;buffer_trace_init (&dummy.b_history); err =ext3_get_blocks_handle (handle, inode, block,1 , - &dummy, create,1 ); + &dummy, create,1 , cred);/* * ext3_get_blocks_handle() returns number of blocks * mapped. 0 in case of a HOLE.
@@ -1064,11 +1070,12 @@ err: }struct buffer_head *ext3_bread (handle_t *handle,struct inode *inode, -int block,int create,int *err) +int block,int create,int *err, +struct cred *cred) {struct buffer_head * bh; - bh =ext3_getblk (handle, inode, block, create, err); + bh =ext3_getblk (handle, inode, block, create, err, cred);if (!bh)return bh;if (buffer_uptodate (bh))
@@ -1175,7 +1182,8 @@ retry: prepare_write_failed:if (ret)ext3_journal_stop (handle); -if (ret == -ENOSPC &&ext3_should_retry_alloc (inode->i_sb, &retries)) +if (ret == -ENOSPC && +ext3_should_retry_alloc (inode->i_sb, &retries, file->f_cred)) goto retry; out:return ret;
@@ -2930,6 +2938,7 @@ int ext3_write_inode(struct inode *inode, int wait)*/ int ext3_setattr (struct dentry *dentry,struct iattr *attr) { +struct cred *cred = current->cred;struct inode *inode = dentry->d_inode;int error, rc =0 ;const unsigned int ia_valid = attr->ia_valid;
@@ -2992,7 +3001,7 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr)ext3_orphan_del (NULL , inode);if (!rc && (ia_valid &ATTR_MODE )) - rc =ext3_acl_chmod (inode); + rc =ext3_acl_chmod (inode, cred); err_out:ext3_std_error (inode->i_sb, error);
fs/ext3/namei.c +103 -71
618 lines not on this page · raw message
fs/ext3/super.c +4 -2
@@ -2671,6 +2671,7 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,static ssize_t ext3_quota_read (struct super_block *sb,int type,char *data,size_t len,loff_t off) { +struct cred *cred = current->cred;struct inode *inode =sb_dqopt (sb)->files[type];sector_t blk = off >>EXT3_BLOCK_SIZE_BITS (sb);int err =0 ;
@@ -2688,7 +2689,7 @@ static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data,while (toread >0 ) { tocopy = sb->s_blocksize - offset < toread ? sb->s_blocksize - offset : toread; - bh =ext3_bread (NULL , inode, blk,0 , &err); + bh =ext3_bread (NULL , inode, blk,0 , &err, cred);if (err)return err;if (!bh)/* A hole? */
@@ -2709,6 +2710,7 @@ static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data,static ssize_t ext3_quota_write (struct super_block *sb,int type,const char *data,size_t len,loff_t off) { +struct cred *cred = current->cred;struct inode *inode =sb_dqopt (sb)->files[type];sector_t blk = off >>EXT3_BLOCK_SIZE_BITS (sb);int err =0 ;
@@ -2729,7 +2731,7 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type,while (towrite >0 ) { tocopy = sb->s_blocksize - offset < towrite ? sb->s_blocksize - offset : towrite; - bh =ext3_bread (handle, inode, blk,1 , &err); + bh =ext3_bread (handle, inode, blk,1 , &err, cred);if (!bh) goto out;if (journal_quota) {
fs/ext3/xattr.c +14 -9
@@ -676,7 +676,8 @@ cleanup:static int ext3_xattr_block_set (handle_t *handle,struct inode *inode,struct ext3_xattr_info *i, -struct ext3_xattr_block_find *bs) +struct ext3_xattr_block_find *bs, +struct cred *cred) {struct super_block *sb = inode->i_sb;struct buffer_head *new_bh =NULL ;
@@ -805,7 +806,7 @@ inserted: (ext3_fsblk_t )EXT3_I (inode)->i_block_group *EXT3_BLOCKS_PER_GROUP (sb);ext3_fsblk_t block =ext3_new_block (handle, inode, - goal, &error); + goal, &error, cred);if (error) goto cleanup;ea_idebug (inode,"creating block %d" , block);
@@ -938,7 +939,7 @@ ext3_xattr_ibody_set(handle_t *handle, struct inode *inode,int ext3_xattr_set_handle (handle_t *handle,struct inode *inode,int name_index,const char *name,const void *value,size_t value_len, -int flags) +int flags,struct cred *cred) {struct ext3_xattr_info i = { .name_index = name_index,
@@ -996,14 +997,17 @@ ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,if (!is.s.not_found) error =ext3_xattr_ibody_set (handle, inode, &i, &is);else if (!bs.s.not_found) - error =ext3_xattr_block_set (handle, inode, &i, &bs); + error =ext3_xattr_block_set (handle, inode, &i, &bs, + cred); }else { error =ext3_xattr_ibody_set (handle, inode, &i, &is);if (!error && !bs.s.not_found) { i.value =NULL ; - error =ext3_xattr_block_set (handle, inode, &i, &bs); + error =ext3_xattr_block_set (handle, inode, &i, &bs, + cred); }else if (error == -ENOSPC ) { - error =ext3_xattr_block_set (handle, inode, &i, &bs); + error =ext3_xattr_block_set (handle, inode, &i, &bs, + cred);if (error) goto cleanup;if (!is.s.not_found) {
@@ -1043,7 +1047,8 @@ cleanup:*/ int ext3_xattr_set (struct inode *inode,int name_index,const char *name, -const void *value,size_t value_len,int flags) +const void *value,size_t value_len,int flags, +struct cred *cred) {handle_t *handle;int error, retries =0 ;
@@ -1056,10 +1061,10 @@ retry:int error2; error =ext3_xattr_set_handle (handle, inode, name_index, name, - value, value_len, flags); + value, value_len, flags, cred); error2 =ext3_journal_stop (handle);if (error == -ENOSPC && -ext3_should_retry_alloc (inode->i_sb, &retries)) +ext3_should_retry_alloc (inode->i_sb, &retries, cred)) goto retry;if (error ==0 ) error = error2;
fs/ext3/xattr.h +4 -2
@@ -68,8 +68,10 @@ extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);extern int ext3_xattr_get (struct inode *,int ,const char *,void *,size_t );extern int ext3_xattr_list (struct inode *,char *,size_t ); -extern int ext3_xattr_set (struct inode *,int ,const char *,const void *,size_t ,int ); -extern int ext3_xattr_set_handle (handle_t *,struct inode *,int ,const char *,const void *,size_t ,int ); +extern int ext3_xattr_set (struct inode *,int ,const char *,const void *, +size_t ,int ,struct cred *); +extern int ext3_xattr_set_handle (handle_t *,struct inode *,int ,const char *, +const void *,size_t ,int ,struct cred *);extern void ext3_xattr_delete_inode (handle_t *,struct inode *);extern void ext3_xattr_put_super (struct super_block *);
fs/ext3/xattr_security.c +5 -2
@@ -41,15 +41,18 @@ static int ext3_xattr_security_set(struct inode *inode, const char *name, const void *value, size_t size, int flags) { + struct cred *cred = current->cred; +if (strcmp (name,"" ) ==0 )return -EINVAL ;return ext3_xattr_set (inode,EXT3_XATTR_INDEX_SECURITY , name, - value, size, flags); + value, size, flags, cred); }int ext3_init_security (handle_t *handle,struct inode *inode,struct inode *dir) { +struct cred *cred = current->cred;int err;size_t len;void *value;
@@ -62,7 +65,7 @@ ext3_init_security(handle_t *handle, struct inode *inode, struct inode *dir)return err; } err =ext3_xattr_set_handle (handle, inode,EXT3_XATTR_INDEX_SECURITY , - name, value, len,0 ); + name, value, len,0 , cred);kfree (name);kfree (value);return err;
fs/ext3/xattr_trusted.c +3 -1
@@ -47,10 +47,12 @@ static int ext3_xattr_trusted_set(struct inode *inode, const char *name, const void *value, size_t size, int flags) { + struct cred *cred = current->cred; +if (strcmp (name,"" ) ==0 )return -EINVAL ;return ext3_xattr_set (inode,EXT3_XATTR_INDEX_TRUSTED , name, - value, size, flags); + value, size, flags, cred); } struct xattr_handler ext3_xattr_trusted_handler = {
fs/ext3/xattr_user.c +3 -1
@@ -47,12 +47,14 @@ static int ext3_xattr_user_set(struct inode *inode, const char *name, const void *value, size_t size, int flags) { + struct cred *cred = current->cred; +if (strcmp (name,"" ) ==0 )return -EINVAL ;if (!test_opt (inode->i_sb,XATTR_USER ))return -EOPNOTSUPP ;return ext3_xattr_set (inode,EXT3_XATTR_INDEX_USER , name, - value, size, flags); + value, size, flags, cred); } struct xattr_handler ext3_xattr_user_handler = {
include/linux/ext3_fs.h +14 -8
@@ -761,9 +761,10 @@ ext3_group_first_block_no(struct super_block *sb, unsigned long group_no)extern int ext3_bg_has_super (struct super_block *sb,int group);extern unsigned long ext3_bg_num_gdb (struct super_block *sb,int group);extern ext3_fsblk_t ext3_new_block (handle_t *handle,struct inode *inode, -ext3_fsblk_t goal,int *errp); +ext3_fsblk_t goal,int *errp,struct cred *cred);extern ext3_fsblk_t ext3_new_blocks (handle_t *handle,struct inode *inode, -ext3_fsblk_t goal,unsigned long *count,int *errp); +ext3_fsblk_t goal,unsigned long *count,int *errp, +struct cred *cred);extern void ext3_free_blocks (handle_t *handle,struct inode *inode,ext3_fsblk_t block,unsigned long count); extern void ext3_free_blocks_sb (handle_t *handle, struct super_block *sb,
@@ -774,7 +775,8 @@ extern void ext3_check_blocks_bitmap (struct super_block *);extern struct ext3_group_desc *ext3_get_group_desc (struct super_block * sb,unsigned int block_group,struct buffer_head ** bh); -extern int ext3_should_retry_alloc (struct super_block *sb,int *retries); +extern int ext3_should_retry_alloc (struct super_block *sb,int *retries, +struct cred *cred);extern void ext3_init_block_alloc_info (struct inode *);extern void ext3_rsv_window_add (struct super_block *sb,struct ext3_reserve_window_node *rsv);
@@ -795,7 +797,8 @@ extern int ext3fs_dirhash(const char *name, int len, struct dx_hash_info *hinfo);/* ialloc.c */ -extern struct inode *ext3_new_inode (handle_t *,struct inode *,int ); +extern struct inode *ext3_new_inode (handle_t *,struct inode *,int , +struct cred *);extern void ext3_free_inode (handle_t *,struct inode *);extern struct inode *ext3_orphan_get (struct super_block *,unsigned long );extern unsigned long ext3_count_free_inodes (struct super_block *);
@@ -807,11 +810,13 @@ extern unsigned long ext3_count_free (struct buffer_head *, unsigned);/* inode.c */ int ext3_forget (handle_t *handle,int is_metadata,struct inode *inode,struct buffer_head *bh,ext3_fsblk_t blocknr); -struct buffer_head *ext3_getblk (handle_t *,struct inode *,long ,int ,int *); -struct buffer_head *ext3_bread (handle_t *,struct inode *,int ,int ,int *); +struct buffer_head *ext3_getblk (handle_t *,struct inode *,long ,int ,int *, +struct cred *); +struct buffer_head *ext3_bread (handle_t *,struct inode *,int ,int ,int *, +struct cred *);int ext3_get_blocks_handle (handle_t *handle,struct inode *inode,sector_t iblock,unsigned long maxblocks,struct buffer_head *bh_result, -int create,int extend_disksize); +int create,int extend_disksize,struct cred *cred);extern struct inode *ext3_iget (struct super_block *,unsigned long );extern int ext3_write_inode (struct inode *,int );
@@ -836,7 +841,8 @@ extern long ext3_compat_ioctl (struct file *, unsigned int, unsigned long);extern int ext3_orphan_add (handle_t *,struct inode *);extern int ext3_orphan_del (handle_t *,struct inode *);extern int ext3_htree_fill_tree (struct file *dir_file,__u32 start_hash, -__u32 start_minor_hash,__u32 *next_hash); +__u32 start_minor_hash,__u32 *next_hash, +struct cred *cred);/* resize.c */ extern int ext3_group_add(struct super_block *sb,
David Howells
maintainerPATCH 4/52 CRED: Pass credentials down to ext3 inode allocator
In reply to David HowellsPass credentials down to the ext3 inode allocator.
---
fs/ext3/ialloc.c | 6 +++--- fs/ext3/xattr.h | 4 ++-- fs/ext3/xattr_security.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)
fs/ext3/ialloc.c +3 -3
@@ -547,7 +547,7 @@ got:percpu_counter_inc (&sbi->s_dirs_counter); sb->s_dirt =1 ; - inode->i_uid = current->cred->uid; + inode->i_uid = cred->uid;if (test_opt (sb,GRPID )) inode->i_gid = dir->i_gid;else if (dir->i_mode &S_ISGID ) {
@@ -555,7 +555,7 @@ got:if (S_ISDIR (mode)) mode |=S_ISGID ; }else - inode->i_gid = current->cred->gid; + inode->i_gid = cred->gid; inode->i_mode = mode; inode->i_ino = ino;
@@ -607,7 +607,7 @@ got:if (err) goto fail_free_drop; - err =ext3_init_security (handle,inode, dir); + err =ext3_init_security (handle,inode, dir, cred);if (err) goto fail_free_drop;
fs/ext3/xattr.h +2 -2
@@ -137,10 +137,10 @@ exit_ext3_xattr(void)#ifdef CONFIG_EXT3_FS_SECURITY extern int ext3_init_security (handle_t *handle,struct inode *inode, -struct inode *dir); +struct inode *dir,struct cred *cred);#else static inline int ext3_init_security (handle_t *handle,struct inode *inode, -struct inode *dir) +struct inode *dir,struct cred *cred) {return 0 ; }
fs/ext3/xattr_security.c +2 -2
@@ -50,9 +50,9 @@ ext3_xattr_security_set(struct inode *inode, const char *name, }int -ext3_init_security (handle_t *handle,struct inode *inode,struct inode *dir) +ext3_init_security (handle_t *handle,struct inode *inode,struct inode *dir, +struct cred *cred) { -struct cred *cred = current->cred;int err;size_t len;void *value;
David Howells
maintainerPATCH 5/52 CRED: Prepare TMPFS for cred passing
In reply to David HowellsPrepare TMPFS for cred passing.
---
mm/shmem.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-)
mm/shmem.c +13 -9
@@ -1375,7 +1375,7 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma) }static struct inode * -shmem_get_inode (struct super_block *sb,int mode,dev_t dev) +shmem_get_inode (struct super_block *sb,int mode,dev_t dev,struct cred *cred) {struct inode *inode;struct shmem_inode_info *info;
@@ -1394,8 +1394,8 @@ shmem_get_inode(struct super_block *sb, int mode, dev_t dev) inode =new_inode (sb);if (inode) { inode->i_mode = mode; - inode->i_uid = current->cred->uid; - inode->i_gid = current->cred->gid; + inode->i_uid = cred->uid; + inode->i_gid = cred->gid; inode->i_blocks =0 ; inode->i_mapping->a_ops = &shmem_aops; inode->i_mapping->backing_dev_info = &shmem_backing_dev_info;
@@ -1708,7 +1708,8 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf)static int shmem_mknod (struct inode *dir,struct dentry *dentry,int mode,dev_t dev) { -struct inode *inode =shmem_get_inode (dir->i_sb, mode, dev); +struct cred *cred = current->cred; +struct inode *inode =shmem_get_inode (dir->i_sb, mode, dev, cred);int error = -ENOSPC ;if (inode) {
@@ -1849,6 +1850,7 @@ static int shmem_rename(struct inode *old_dir, struct dentry *old_dentry, structstatic int shmem_symlink (struct inode *dir,struct dentry *dentry,const char *symname) { +struct cred *cred = current->cred;int error;int len;struct inode *inode;
@@ -1860,7 +1862,7 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *sif (len >PAGE_CACHE_SIZE )return -ENAMETOOLONG ; - inode =shmem_get_inode (dir->i_sb,S_IFLNK |S_IRWXUGO ,0 ); + inode =shmem_get_inode (dir->i_sb,S_IFLNK |S_IRWXUGO ,0 , cred);if (!inode)return -ENOSPC ;
@@ -2209,11 +2211,12 @@ static void shmem_put_super(struct super_block *sb)static int shmem_fill_super (struct super_block *sb,void *data,int silent) { +struct cred *cred = current->cred;struct inode *inode;struct dentry *root;int mode =S_IRWXUGO |S_ISVTX ; -uid_t uid = current->cred->uid; -gid_t gid = current->cred->gid; +uid_t uid = cred->uid; +gid_t gid = cred->gid;int err = -ENOMEM ;struct shmem_sb_info *sbinfo;unsigned long blocks =0 ;
@@ -2267,7 +2270,7 @@ static int shmem_fill_super(struct super_block *sb, sb->s_flags |=MS_POSIXACL ;#endif - inode =shmem_get_inode (sb,S_IFDIR | mode,0 ); + inode =shmem_get_inode (sb,S_IFDIR | mode,0 , cred);if (!inode) goto failed; inode->i_uid = uid;
@@ -2480,6 +2483,7 @@ module_init(init_tmpfs)*/ struct file *shmem_file_setup (char *name,loff_t size,unsigned long flags) { +struct cred *cred = current->cred;int error;struct file *file;struct inode *inode;
@@ -2510,7 +2514,7 @@ struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags) goto put_dentry; error = -ENOSPC ; - inode =shmem_get_inode (root->d_sb,S_IFREG |S_IRWXUGO ,0 ); + inode =shmem_get_inode (root->d_sb,S_IFREG |S_IRWXUGO ,0 , cred);if (!inode) goto close_file;
David Howells
maintainerPATCH 6/52 CRED: Prepare RAMFS for cred passing
In reply to David HowellsPrepare RAMFS for cred passing.
---
fs/ramfs/inode.c | 16 ++++++++++------ include/linux/ramfs.h | 3 ++- mm/tiny-shmem.c | 3 ++- 3 files changed, 14 insertions(+), 8 deletions(-)
fs/ramfs/inode.c +10 -6
@@ -49,14 +49,15 @@ static struct backing_dev_info ramfs_backing_dev_info = { BDI_CAP_READ_MAP | BDI_CAP_WRITE_MAP | BDI_CAP_EXEC_MAP, }; -struct inode *ramfs_get_inode (struct super_block *sb,int mode,dev_t dev) +struct inode *ramfs_get_inode (struct super_block *sb,int mode,dev_t dev, +struct cred *cred) {struct inode * inode =new_inode (sb);if (inode) { inode->i_mode = mode; - inode->i_uid = current->cred->uid; - inode->i_gid = current->cred->gid; + inode->i_uid = cred->uid; + inode->i_gid = cred->gid; inode->i_blocks =0 ; inode->i_mapping->a_ops = &ramfs_aops; inode->i_mapping->backing_dev_info = &ramfs_backing_dev_info;
@@ -92,7 +93,8 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev)static int ramfs_mknod (struct inode *dir,struct dentry *dentry,int mode,dev_t dev) { -struct inode * inode =ramfs_get_inode (dir->i_sb, mode, dev); +struct cred *cred = current->cred; +struct inode * inode =ramfs_get_inode (dir->i_sb, mode, dev, cred);int error = -ENOSPC ;if (inode) {
@@ -124,10 +126,11 @@ static int ramfs_create(struct inode *dir, struct dentry *dentry, int mode, strustatic int ramfs_symlink (struct inode * dir,struct dentry *dentry,const char * symname) { +struct cred *cred = current->cred;struct inode *inode;int error = -ENOSPC ; - inode =ramfs_get_inode (dir->i_sb,S_IFLNK |S_IRWXUGO ,0 ); + inode =ramfs_get_inode (dir->i_sb,S_IFLNK |S_IRWXUGO ,0 , cred);if (inode) {int l =strlen (symname)+1 ; error =page_symlink (inode, symname, l);
@@ -162,6 +165,7 @@ static const struct super_operations ramfs_ops = {static int ramfs_fill_super (struct super_block * sb,void * data,int silent) { +struct cred *cred = current->cred;struct inode * inode;struct dentry * root;
@@ -171,7 +175,7 @@ static int ramfs_fill_super(struct super_block * sb, void * data, int silent) sb->s_magic =RAMFS_MAGIC ; sb->s_op = &ramfs_ops; sb->s_time_gran =1 ; - inode =ramfs_get_inode (sb,S_IFDIR |0755 ,0 ); + inode =ramfs_get_inode (sb,S_IFDIR |0755 ,0 , cred);if (!inode)return -ENOMEM ;
include/linux/ramfs.h +2 -1
@@ -1,7 +1,8 @@#ifndef _LINUX_RAMFS_H#define _LINUX_RAMFS_H -struct inode *ramfs_get_inode (struct super_block *sb,int mode,dev_t dev); +struct inode *ramfs_get_inode (struct super_block *sb,int mode,dev_t dev, +struct cred *cred);extern int ramfs_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name,void *data,struct vfsmount *mnt);
mm/tiny-shmem.c +2 -1
@@ -48,6 +48,7 @@ module_init(init_tmpfs)*/ struct file *shmem_file_setup (char *name,loff_t size,unsigned long flags) { +struct cred *cred = current->cred;int error;struct file *file;struct inode *inode;
@@ -72,7 +73,7 @@ struct file *shmem_file_setup(char *name, loff_t size, unsigned long flags) goto put_dentry; error = -ENOSPC ; - inode =ramfs_get_inode (root->d_sb,S_IFREG |S_IRWXUGO ,0 ); + inode =ramfs_get_inode (root->d_sb,S_IFREG |S_IRWXUGO ,0 , cred);if (!inode) goto close_file;
David Howells
maintainerPATCH 7/52 CRED: Pass credentials down to ext2 block allocator
In reply to David HowellsPass credentials down to the ext2 block allocator.
---
fs/ext2/balloc.c | 11 ++++++----- fs/ext2/ext2.h | 2 +- fs/ext2/inode.c | 18 +++++++++++------- 3 files changed, 18 insertions(+), 13 deletions(-)
fs/ext2/balloc.c +6 -5
@@ -98,7 +98,7 @@ error_out:* Set sb->s_dirt here because the superblock was "logically" altered. We * need to recalculate its free blocks count and flush it out. */ -static int reserve_blocks (struct super_block *sb,int count) +static int reserve_blocks (struct super_block *sb,int count,struct cred *cred) {struct ext2_sb_info *sbi =EXT2_SB (sb);struct ext2_super_block *es = sbi->s_es;
@@ -112,9 +112,9 @@ static int reserve_blocks(struct super_block *sb, int count) count = free_blocks;if (free_blocks < root_blocks + count && !capable (CAP_SYS_RESOURCE ) && - sbi->s_resuid != current->cred->uid && + sbi->s_resuid != cred->uid && (sbi->s_resgid ==0 || - !in_group_p (current->cred, sbi->s_resgid))) { + !in_group_p (cred, sbi->s_resgid))) {/* * We are too close to reserve and we are not privileged. * Can we allocate anything at all?
@@ -325,7 +325,8 @@ got_it:* This function also updates quota and i_blocks field. */ int ext2_new_block (struct inode *inode,unsigned long goal, -u32 *prealloc_count,u32 *prealloc_block,int *err) +u32 *prealloc_count,u32 *prealloc_block,int *err, +struct cred *cred) {struct buffer_head *bitmap_bh =NULL ;struct buffer_head *gdp_bh;/* bh2 */
@@ -357,7 +358,7 @@ int ext2_new_block(struct inode *inode, unsigned long goal, prealloc_goal--; dq_alloc = prealloc_goal +1 ; - es_alloc =reserve_blocks (sb, dq_alloc); + es_alloc =reserve_blocks (sb, dq_alloc, cred);if (!es_alloc) { *err = -ENOSPC ; goto out_dquot;
fs/ext2/ext2.h +1 -1
@@ -92,7 +92,7 @@ static inline struct ext2_inode_info *EXT2_I(struct inode *inode)extern int ext2_bg_has_super (struct super_block *sb,int group);extern unsigned long ext2_bg_num_gdb (struct super_block *sb,int group);extern int ext2_new_block (struct inode *,unsigned long , -__u32 *,__u32 *,int *); +__u32 *,__u32 *,int *,struct cred *);extern void ext2_free_blocks (struct inode *,unsigned long ,unsigned long );extern unsigned long ext2_count_free_blocks (struct super_block *);
fs/ext2/inode.c +11 -7
@@ -107,7 +107,8 @@ void ext2_discard_prealloc (struct inode * inode)#endif } -static int ext2_alloc_block (struct inode * inode,unsigned long goal,int *err) +static int ext2_alloc_block (struct inode * inode,unsigned long goal,int *err, +struct cred *cred) {#ifdef EXT2FS_DEBUG static unsigned long alloc_hits, alloc_attempts;
@@ -134,9 +135,10 @@ static int ext2_alloc_block (struct inode * inode, unsigned long goal, int *err)if (S_ISREG (inode->i_mode)) result =ext2_new_block (inode, goal, &ei->i_prealloc_count, - &ei->i_prealloc_block, err); + &ei->i_prealloc_block, err, cred);else - result = ext2_new_block(inode, goal, NULL, NULL, err); + result =ext2_new_block (inode, goal,NULL ,NULL , err, + cred); }#else result =ext2_new_block (inode, goal,0 ,0 , err);
@@ -419,19 +421,20 @@ static int ext2_alloc_branch(struct inode *inode,int num, unsigned long goal, int *offsets, - Indirect *branch) + Indirect *branch, + struct cred *cred) { int blocksize = inode->i_sb->s_blocksize;int n =0 ;int err;int i; -int parent =ext2_alloc_block (inode, goal, &err); +int parent =ext2_alloc_block (inode, goal, &err, cred); branch[0 ].key =cpu_to_le32 (parent);if (parent)for (n =1 ; n < num; n++) {struct buffer_head *bh;/* Allocate the next block */ -int nr =ext2_alloc_block (inode, parent, &err); +int nr =ext2_alloc_block (inode, parent, &err, cred);if (!nr)break ; branch[n].key =cpu_to_le32 (nr);
@@ -546,6 +549,7 @@ changed:int ext2_get_block (struct inode *inode,sector_t iblock,struct buffer_head *bh_result,int create) { +struct cred *cred = current->cred;int err = -EIO ;int offsets[4 ];Indirect chain[4 ];
@@ -597,7 +601,7 @@ out: left = (chain + depth) - partial; err =ext2_alloc_branch (inode, left, goal, - offsets+(partial-chain), partial); + offsets+(partial-chain), partial, cred);if (err) goto cleanup;
David Howells
maintainerPATCH 8/52 CRED: Pass credentials down to ext2 inode allocator
In reply to David HowellsPass credentials down to the ext2 inode allocator.
---
fs/ext2/ext2.h | 2 +- fs/ext2/ialloc.c | 6 +++--- fs/ext2/namei.c | 12 ++++++++---- 3 files changed, 12 insertions(+), 8 deletions(-)
fs/ext2/ext2.h +1 -1
@@ -116,7 +116,7 @@ extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct pageextern int ext2_sync_file (struct file *,struct dentry *,int );/* ialloc.c */ -extern struct inode *ext2_new_inode (struct inode *,int ); +extern struct inode *ext2_new_inode (struct inode *,int ,struct cred *);extern void ext2_free_inode (struct inode *);extern unsigned long ext2_count_free_inodes (struct super_block *);extern void ext2_check_inodes_bitmap (struct super_block *);
fs/ext2/ialloc.c +3 -3
@@ -445,7 +445,7 @@ found:return group; } -struct inode *ext2_new_inode (struct inode *dir,int mode) +struct inode *ext2_new_inode (struct inode *dir,int mode,struct cred *cred) {struct super_block *sb;struct buffer_head *bitmap_bh =NULL ;
@@ -562,7 +562,7 @@ got: sb->s_dirt =1 ;mark_buffer_dirty (bh2); - inode->i_uid = current->cred->uid; + inode->i_uid = cred->uid;if (test_opt (sb,GRPID )) inode->i_gid = dir->i_gid;else if (dir->i_mode &S_ISGID ) {
@@ -570,7 +570,7 @@ got:if (S_ISDIR (mode)) mode |=S_ISGID ; }else - inode->i_gid = current->cred->gid; + inode->i_gid = cred->gid; inode->i_mode = mode; inode->i_ino = ino;
fs/ext2/namei.c +8 -4
@@ -105,7 +105,8 @@ struct dentry *ext2_get_parent(struct dentry *child)*/ static int ext2_create (struct inode * dir,struct dentry * dentry,int mode,struct nameidata *nd) { -struct inode * inode =ext2_new_inode (dir, mode); +struct cred *cred = current->cred; +struct inode * inode =ext2_new_inode (dir, mode, cred);int err =PTR_ERR (inode);if (!IS_ERR (inode)) { inode->i_op = &ext2_file_inode_operations;
@@ -127,13 +128,14 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, ststatic int ext2_mknod (struct inode * dir,struct dentry *dentry,int mode,dev_t rdev) { +struct cred *cred = current->cred;struct inode * inode;int err;if (!new_valid_dev (rdev))return -EINVAL ; - inode =ext2_new_inode (dir, mode); + inode =ext2_new_inode (dir, mode, cred); err =PTR_ERR (inode);if (!IS_ERR (inode)) {init_special_inode (inode, inode->i_mode, rdev);
@@ -149,6 +151,7 @@ static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_static int ext2_symlink (struct inode * dir,struct dentry * dentry,const char * symname) { +struct cred *cred = current->cred;struct super_block * sb = dir->i_sb;int err = -ENAMETOOLONG ;unsigned l =strlen (symname)+1 ;
@@ -157,7 +160,7 @@ static int ext2_symlink (struct inode * dir, struct dentry * dentry,if (l > sb->s_blocksize) goto out; - inode =ext2_new_inode (dir,S_IFLNK |S_IRWXUGO ); + inode =ext2_new_inode (dir,S_IFLNK |S_IRWXUGO , cred); err =PTR_ERR (inode);if (IS_ERR (inode)) goto out;
@@ -207,6 +210,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,static int ext2_mkdir (struct inode * dir,struct dentry * dentry,int mode) { +struct cred *cred = current->cred;struct inode * inode;int err = -EMLINK ;
@@ -215,7 +219,7 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)inode_inc_link_count (dir); - inode =ext2_new_inode (dir,S_IFDIR | mode); + inode =ext2_new_inode (dir,S_IFDIR | mode, cred); err =PTR_ERR (inode);if (IS_ERR (inode)) goto out_dir;
David Howells
maintainerPATCH 9/52 CRED: Pass credentials down to ext4 block allocator
In reply to David HowellsPass credentials down to the ext4 block allocator.
---
fs/ext4/balloc.c | 23 ++-- fs/ext4/dir.c | 15 ++- fs/ext4/extents.c | 129 +++++++++++++---------- fs/ext4/ialloc.c | 7 + fs/ext4/inode.c | 118 +++++++++++++-------- fs/ext4/ioctl.c | 4 + fs/ext4/namei.c | 221 +++++++++++++++++++++++---------------- fs/ext4/super.c | 8 + fs/ext4/xattr.c | 25 ++-- fs/ext4/xattr.h | 7 + fs/ext4/xattr_trusted.c | 4 + fs/ext4/xattr_user.c | 4 + include/linux/ext4_fs.h | 36 ++++-- include/linux/ext4_fs_extents.h | 2 include/linux/ext4_jbd2.h | 3 - 15 files changed, 359 insertions(+), 247 deletions(-)
fs/ext4/balloc.c +14 -9
@@ -1367,19 +1367,20 @@ out:/** * ext4_has_free_blocks() * @sbi: in-core super block structure. +* @cred: credentials currently in force * * Check if filesystem has at least 1 free block available for allocation. */ -static int ext4_has_free_blocks (struct ext4_sb_info *sbi) +static int ext4_has_free_blocks (struct ext4_sb_info *sbi,struct cred *cred) {ext4_fsblk_t free_blocks, root_blocks; free_blocks =percpu_counter_read_positive (&sbi->s_freeblocks_counter); root_blocks =ext4_r_blocks_count (sbi->s_es);if (free_blocks < root_blocks +1 && !capable (CAP_SYS_RESOURCE ) && - sbi->s_resuid != current->cred->uid && + sbi->s_resuid != cred->uid && (sbi->s_resgid ==0 || - !in_group_p (current->cred, sbi->s_resgid))) { + !in_group_p (cred, sbi->s_resgid))) {return 0 ; }return 1 ;
@@ -1389,6 +1390,7 @@ static int ext4_has_free_blocks(struct ext4_sb_info *sbi)* ext4_should_retry_alloc() * @sb: super block * @retries number of attemps has been made +* @cred: credentials currently in force * * ext4_should_retry_alloc() is called when ENOSPC is returned, and if * it is profitable to retry the operation, this function will wait
@@ -1397,9 +1399,10 @@ static int ext4_has_free_blocks(struct ext4_sb_info *sbi)* * if the total number of retries exceed three times, return FALSE. */ -int ext4_should_retry_alloc (struct super_block *sb,int *retries) +int ext4_should_retry_alloc (struct super_block *sb,int *retries, +struct cred *cred) { -if (!ext4_has_free_blocks (EXT4_SB (sb)) || (*retries)++ >3 ) +if (!ext4_has_free_blocks (EXT4_SB (sb), cred) || (*retries)++ >3 )return 0 ;jbd_debug (1 ,"%s: retrying operation after ENOSPC\n" , sb->s_id);
@@ -1414,6 +1417,7 @@ int ext4_should_retry_alloc(struct super_block *sb, int *retries)* @goal: given target block(filesystem wide) * @count: target number of blocks to allocate * @errp: error code +* @cred: credentials currently in force * * ext4_new_blocks uses a goal block to assist allocation. It tries to * allocate block(s) from the block group contains the goal block first. If that
@@ -1422,7 +1426,8 @@ int ext4_should_retry_alloc(struct super_block *sb, int *retries)* */ ext4_fsblk_t ext4_new_blocks (handle_t *handle,struct inode *inode, -ext4_fsblk_t goal,unsigned long *count,int *errp) +ext4_fsblk_t goal,unsigned long *count,int *errp, +struct cred *cred) {struct buffer_head *bitmap_bh =NULL ;struct buffer_head *gdp_bh;
@@ -1478,7 +1483,7 @@ ext4_fsblk_t ext4_new_blocks(handle_t *handle, struct inode *inode,if (block_i && ((windowsz = block_i->rsv_window_node.rsv_goal_size) >0 )) my_rsv = &block_i->rsv_window_node; -if (!ext4_has_free_blocks (sbi)) { +if (!ext4_has_free_blocks (sbi, cred)) { *errp = -ENOSPC ; goto out; }
@@ -1682,11 +1687,11 @@ out: }ext4_fsblk_t ext4_new_block (handle_t *handle,struct inode *inode, -ext4_fsblk_t goal,int *errp) +ext4_fsblk_t goal,int *errp,struct cred *cred) {unsigned long count =1 ; -return ext4_new_blocks (handle, inode, goal, &count, errp); +return ext4_new_blocks (handle, inode, goal, &count, errp, cred); }/**
fs/ext4/dir.c +9 -6
@@ -34,7 +34,7 @@ static unsigned char ext4_filetype_table[] = {static int ext4_readdir (struct file *,void *,filldir_t );static int ext4_dx_readdir (struct file * filp, -void * dirent,filldir_t filldir); +void * dirent,filldir_t filldir,struct cred *cred);static int ext4_release_dir (struct inode * inode,struct file * filp);
@@ -96,6 +96,7 @@ int ext4_check_dir_entry (const char * function, struct inode * dir,static int ext4_readdir (struct file * filp,void * dirent,filldir_t filldir) { +struct cred *cred = filp->f_cred;int error =0 ;unsigned long offset;int i, stored;
@@ -112,7 +113,7 @@ static int ext4_readdir(struct file * filp, EXT4_FEATURE_COMPAT_DIR_INDEX) && ((EXT4_I(inode)->i_flags & EXT4_INDEX_FL) || ((inode->i_size >> sb->s_blocksize_bits) == 1))) { - err =ext4_dx_readdir (filp, dirent, filldir); + err =ext4_dx_readdir (filp, dirent, filldir, cred);if (err !=ERR_BAD_DX_DIR ) { ret = err; goto out;
@@ -133,7 +134,8 @@ static int ext4_readdir(struct file * filp,struct buffer_head *bh =NULL ; map_bh.b_state =0 ; - err =ext4_get_blocks_wrap (NULL , inode, blk,1 , &map_bh,0 ,0 ); + err =ext4_get_blocks_wrap (NULL , inode, blk,1 , &map_bh,0 ,0 , + cred);if (err >0 ) {pgoff_t index = map_bh.b_blocknr >> (PAGE_CACHE_SHIFT - inode->i_blkbits);
@@ -143,7 +145,7 @@ static int ext4_readdir(struct file * filp, &filp->f_ra, filp, index, 1); filp->f_ra.prev_index = index; - bh =ext4_bread (NULL , inode, blk,0 , &err); + bh =ext4_bread (NULL , inode, blk,0 , &err, cred); }/*
@@ -430,7 +432,8 @@ static int call_filldir(struct file * filp, void * dirent, }static int ext4_dx_readdir (struct file * filp, -void * dirent,filldir_t filldir) +void * dirent,filldir_t filldir, +struct cred *cred) {struct dir_private_info *info = filp->private_data;struct inode *inode = filp->f_path.dentry->d_inode;
@@ -480,7 +483,7 @@ static int ext4_dx_readdir(struct file * filp, filp->f_version = inode->i_version; ret =ext4_htree_fill_tree (filp, info->curr_hash, info->curr_minor_hash, - &info->next_hash); + &info->next_hash, cred);if (ret <0 )return ret;if (ret ==0 ) {
fs/ext4/extents.c +75 -54
443 lines not on this page · raw message
fs/ext4/ialloc.c +4 -3
@@ -424,7 +424,8 @@ static int find_group_other(struct super_block *sb, struct inode *parent)* For other inodes, search forward from the parent directory's block * group to find a free inode. */ -struct inode *ext4_new_inode (handle_t *handle,struct inode * dir,int mode) +struct inode *ext4_new_inode (handle_t *handle,struct inode * dir,int mode, +struct cred *cred) {struct super_block *sb;struct buffer_head *bitmap_bh =NULL ;
@@ -613,14 +614,14 @@ got:if (err) goto fail_free_drop; - err =ext4_mark_inode_dirty (handle, inode); + err =ext4_mark_inode_dirty (handle, inode, cred);if (err) {ext4_std_error (sb, err); goto fail_free_drop; }if (test_opt (sb,EXTENTS )) {EXT4_I (inode)->i_flags |=EXT4_EXTENTS_FL ; -ext4_ext_tree_init (handle, inode); +ext4_ext_tree_init (handle, inode, cred);if (!EXT4_HAS_INCOMPAT_FEATURE (sb,EXT4_FEATURE_INCOMPAT_EXTENTS )) { err =ext4_journal_get_write_access (handle,EXT4_SB (sb)->s_sbh);if (err) goto fail;
fs/ext4/inode.c +73 -45
446 lines not on this page · raw message
fs/ext4/ioctl.c +3 -1
@@ -21,6 +21,7 @@ int ext4_ioctl (struct inode * inode, struct file * filp, unsigned int cmd, unsigned long arg) {struct ext4_inode_info *ei =EXT4_I (inode); +struct cred *cred = filp->f_cred;unsigned int flags;unsigned short rsv_window_size;
@@ -108,7 +109,8 @@ flags_err: }if ((jflag ^ oldflags) & (EXT4_JOURNAL_DATA_FL )) - err =ext4_change_inode_journal_flag (inode, jflag); + err =ext4_change_inode_journal_flag (inode, jflag, + cred);mutex_unlock (&inode->i_mutex);return err; }
fs/ext4/namei.c +128 -93
744 lines not on this page · raw message
fs/ext4/super.c +5 -3
@@ -2791,6 +2791,7 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id,static ssize_t ext4_quota_read (struct super_block *sb,int type,char *data,size_t len,loff_t off) { +struct cred *cred = current->cred;struct inode *inode =sb_dqopt (sb)->files[type];sector_t blk = off >>EXT4_BLOCK_SIZE_BITS (sb);int err =0 ;
@@ -2808,7 +2809,7 @@ static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,while (toread >0 ) { tocopy = sb->s_blocksize - offset < toread ? sb->s_blocksize - offset : toread; - bh =ext4_bread (NULL , inode, blk,0 , &err); + bh =ext4_bread (NULL , inode, blk,0 , &err, cred);if (err)return err;if (!bh)/* A hole? */
@@ -2829,6 +2830,7 @@ static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,static ssize_t ext4_quota_write (struct super_block *sb,int type,const char *data,size_t len,loff_t off) { +struct cred *cred = current->cred;struct inode *inode =sb_dqopt (sb)->files[type];sector_t blk = off >>EXT4_BLOCK_SIZE_BITS (sb);int err =0 ;
@@ -2849,7 +2851,7 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,while (towrite >0 ) { tocopy = sb->s_blocksize - offset < towrite ? sb->s_blocksize - offset : towrite; - bh =ext4_bread (handle, inode, blk,1 , &err); + bh =ext4_bread (handle, inode, blk,1 , &err, cred);if (!bh) goto out;if (journal_quota) {
@@ -2887,7 +2889,7 @@ out: } inode->i_version++; inode->i_mtime = inode->i_ctime =CURRENT_TIME ; -ext4_mark_inode_dirty (handle, inode); +ext4_mark_inode_dirty (handle, inode, cred);mutex_unlock (&inode->i_mutex);return len - towrite; }
fs/ext4/xattr.c +14 -11
@@ -686,7 +686,8 @@ cleanup:static int ext4_xattr_block_set (handle_t *handle,struct inode *inode,struct ext4_xattr_info *i, -struct ext4_xattr_block_find *bs) +struct ext4_xattr_block_find *bs, +struct cred *cred) {struct super_block *sb = inode->i_sb;struct buffer_head *new_bh =NULL ;
@@ -814,7 +815,7 @@ inserted: (ext4_fsblk_t )EXT4_I (inode)->i_block_group *EXT4_BLOCKS_PER_GROUP (sb);ext4_fsblk_t block =ext4_new_block (handle, inode, - goal, &error); + goal, &error, cred);if (error) goto cleanup;ea_idebug (inode,"creating block %d" , block);
@@ -947,7 +948,7 @@ ext4_xattr_ibody_set(handle_t *handle, struct inode *inode,int ext4_xattr_set_handle (handle_t *handle,struct inode *inode,int name_index,const char *name,const void *value,size_t value_len, -int flags) +int flags,struct cred *cred) {struct ext4_xattr_info i = { .name_index = name_index,
@@ -1005,14 +1006,14 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index,if (!is.s.not_found) error =ext4_xattr_ibody_set (handle, inode, &i, &is);else if (!bs.s.not_found) - error =ext4_xattr_block_set (handle, inode, &i, &bs); + error =ext4_xattr_block_set (handle, inode, &i, &bs, cred); }else { error =ext4_xattr_ibody_set (handle, inode, &i, &is);if (!error && !bs.s.not_found) { i.value =NULL ; - error =ext4_xattr_block_set (handle, inode, &i, &bs); + error =ext4_xattr_block_set (handle, inode, &i, &bs, cred); }else if (error == -ENOSPC ) { - error =ext4_xattr_block_set (handle, inode, &i, &bs); + error =ext4_xattr_block_set (handle, inode, &i, &bs, cred);if (error) goto cleanup;if (!is.s.not_found) {
@@ -1054,7 +1055,8 @@ cleanup:*/ int ext4_xattr_set (struct inode *inode,int name_index,const char *name, -const void *value,size_t value_len,int flags) +const void *value,size_t value_len,int flags, +struct cred *cred) {handle_t *handle;int error, retries =0 ;
@@ -1067,10 +1069,10 @@ retry:int error2; error =ext4_xattr_set_handle (handle, inode, name_index, name, - value, value_len, flags); + value, value_len, flags, cred); error2 =ext4_journal_stop (handle);if (error == -ENOSPC && -ext4_should_retry_alloc (inode->i_sb, &retries)) +ext4_should_retry_alloc (inode->i_sb, &retries, cred)) goto retry;if (error ==0 ) error = error2;
@@ -1109,7 +1111,8 @@ static void ext4_xattr_shift_entries(struct ext4_xattr_entry *entry,* Returns 0 on success or negative error number on failure. */ int ext4_expand_extra_isize_ea (struct inode *inode,int new_extra_isize, -struct ext4_inode *raw_inode,handle_t *handle) +struct ext4_inode *raw_inode,handle_t *handle, +struct cred *cred) {struct ext4_xattr_ibody_header *header;struct ext4_xattr_entry *entry, *last, *first;
@@ -1299,7 +1302,7 @@ retry: goto cleanup;/* Add entry which was removed from the inode into the block */ - error =ext4_xattr_block_set (handle, inode, &i, bs); + error =ext4_xattr_block_set (handle, inode, &i, bs, cred);if (error) goto cleanup;kfree (b_entry_name);
fs/ext4/xattr.h +4 -3
@@ -75,14 +75,15 @@ extern ssize_t ext4_listxattr(struct dentry *, char *, size_t);extern int ext4_xattr_get (struct inode *,int ,const char *,void *,size_t );extern int ext4_xattr_list (struct inode *,char *,size_t ); -extern int ext4_xattr_set (struct inode *,int ,const char *,const void *,size_t ,int ); -extern int ext4_xattr_set_handle (handle_t *,struct inode *,int ,const char *,const void *,size_t ,int ); +extern int ext4_xattr_set (struct inode *,int ,const char *,const void *,size_t ,int ,struct cred *); +extern int ext4_xattr_set_handle (handle_t *,struct inode *,int ,const char *,const void *,size_t ,int ,struct cred *);extern void ext4_xattr_delete_inode (handle_t *,struct inode *);extern void ext4_xattr_put_super (struct super_block *);extern int ext4_expand_extra_isize_ea (struct inode *inode,int new_extra_isize, -struct ext4_inode *raw_inode,handle_t *handle); +struct ext4_inode *raw_inode,handle_t *handle, +struct cred *cred);extern int init_ext4_xattr (void );extern void exit_ext4_xattr (void );
fs/ext4/xattr_trusted.c +3 -1
@@ -47,10 +47,12 @@ static int ext4_xattr_trusted_set(struct inode *inode, const char *name, const void *value, size_t size, int flags) { + struct cred *cred = current->cred; +if (strcmp (name,"" ) ==0 )return -EINVAL ;return ext4_xattr_set (inode,EXT4_XATTR_INDEX_TRUSTED , name, - value, size, flags); + value, size, flags, cred); } struct xattr_handler ext4_xattr_trusted_handler = {
fs/ext4/xattr_user.c +3 -1
@@ -47,12 +47,14 @@ static int ext4_xattr_user_set(struct inode *inode, const char *name, const void *value, size_t size, int flags) { + struct cred *cred = current->cred; +if (strcmp (name,"" ) ==0 )return -EINVAL ;if (!test_opt (inode->i_sb,XATTR_USER ))return -EOPNOTSUPP ;return ext4_xattr_set (inode,EXT4_XATTR_INDEX_USER , name, - value, size, flags); + value, size, flags, cred); } struct xattr_handler ext4_xattr_user_handler = {
include/linux/ext4_fs.h +21 -15
@@ -892,9 +892,10 @@ extern ext4_grpblk_t ext4_block_group_offset(struct super_block *sb,extern int ext4_bg_has_super (struct super_block *sb,int group);extern unsigned long ext4_bg_num_gdb (struct super_block *sb,int group);extern ext4_fsblk_t ext4_new_block (handle_t *handle,struct inode *inode, -ext4_fsblk_t goal,int *errp); +ext4_fsblk_t goal,int *errp,struct cred *cred);extern ext4_fsblk_t ext4_new_blocks (handle_t *handle,struct inode *inode, -ext4_fsblk_t goal,unsigned long *count,int *errp); +ext4_fsblk_t goal,unsigned long *count,int *errp, +struct cred *cred);extern void ext4_free_blocks (handle_t *handle,struct inode *inode,ext4_fsblk_t block,unsigned long count); extern void ext4_free_blocks_sb (handle_t *handle, struct super_block *sb,
@@ -905,7 +906,8 @@ extern void ext4_check_blocks_bitmap (struct super_block *);extern struct ext4_group_desc *ext4_get_group_desc (struct super_block * sb,unsigned int block_group,struct buffer_head ** bh); -extern int ext4_should_retry_alloc (struct super_block *sb,int *retries); +extern int ext4_should_retry_alloc (struct super_block *sb,int *retries, +struct cred *cred);extern void ext4_init_block_alloc_info (struct inode *);extern void ext4_rsv_window_add (struct super_block *sb,struct ext4_reserve_window_node *rsv);
@@ -926,7 +928,8 @@ extern int ext4fs_dirhash(const char *name, int len, struct dx_hash_info *hinfo);/* ialloc.c */ -extern struct inode *ext4_new_inode (handle_t *,struct inode *,int ); +extern struct inode *ext4_new_inode (handle_t *,struct inode *,int , +struct cred *);extern void ext4_free_inode (handle_t *,struct inode *);extern struct inode *ext4_orphan_get (struct super_block *,unsigned long );extern unsigned long ext4_count_free_inodes (struct super_block *);
@@ -938,11 +941,13 @@ extern unsigned long ext4_count_free (struct buffer_head *, unsigned);/* inode.c */ int ext4_forget (handle_t *handle,int is_metadata,struct inode *inode,struct buffer_head *bh,ext4_fsblk_t blocknr); -struct buffer_head *ext4_getblk (handle_t *,struct inode *,long ,int ,int *); -struct buffer_head *ext4_bread (handle_t *,struct inode *,int ,int ,int *); +struct buffer_head *ext4_getblk (handle_t *,struct inode *,long ,int ,int *, +struct cred *); +struct buffer_head *ext4_bread (handle_t *,struct inode *,int ,int ,int *, +struct cred *);int ext4_get_blocks_handle (handle_t *handle,struct inode *inode,sector_t iblock,unsigned long maxblocks,struct buffer_head *bh_result, -int create,int extend_disksize); +int create,int extend_disksize,struct cred *cred);extern struct inode *ext4_iget (struct super_block *,unsigned long );extern int ext4_write_inode (struct inode *,int );
@@ -951,7 +956,7 @@ extern void ext4_delete_inode (struct inode *);extern int ext4_sync_inode (handle_t *,struct inode *);extern void ext4_discard_reservation (struct inode *);extern void ext4_dirty_inode (struct inode *); -extern int ext4_change_inode_journal_flag (struct inode *,int ); +extern int ext4_change_inode_journal_flag (struct inode *,int ,struct cred *);extern int ext4_get_inode_loc (struct inode *,struct ext4_iloc *);extern void ext4_truncate (struct inode *);extern void ext4_set_inode_flags (struct inode *);
@@ -970,7 +975,8 @@ extern long ext4_compat_ioctl (struct file *, unsigned int, unsigned long);extern int ext4_orphan_add (handle_t *,struct inode *);extern int ext4_orphan_del (handle_t *,struct inode *);extern int ext4_htree_fill_tree (struct file *dir_file,__u32 start_hash, -__u32 start_minor_hash,__u32 *next_hash); +__u32 start_minor_hash,__u32 *next_hash, +struct cred *cred);/* resize.c */ extern int ext4_group_add(struct super_block *sb,
@@ -1068,13 +1074,13 @@ extern const struct inode_operations ext4_symlink_inode_operations;extern const struct inode_operations ext4_fast_symlink_inode_operations;/* extents.c */ -extern int ext4_ext_tree_init (handle_t *handle,struct inode *); +extern int ext4_ext_tree_init (handle_t *handle,struct inode *,struct cred *);extern int ext4_ext_writepage_trans_blocks (struct inode *,int );extern int ext4_ext_get_blocks (handle_t *handle,struct inode *inode,ext4_fsblk_t iblock,unsigned long max_blocks,struct buffer_head *bh_result, -int create,int extend_disksize); -extern void ext4_ext_truncate (struct inode *,struct page *); +int create,int extend_disksize,struct cred *cred); +extern void ext4_ext_truncate (struct inode *,struct page *,struct cred *);extern void ext4_ext_init (struct super_block *);extern void ext4_ext_release (struct super_block *); extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset,
@@ -1082,13 +1088,13 @@ extern long ext4_fallocate(struct inode *inode, int mode, loff_t offset,static inline int ext4_get_blocks_wrap (handle_t *handle,struct inode *inode,sector_t block,unsigned long max_blocks,struct buffer_head *bh, -int create,int extend_disksize) +int create,int extend_disksize,struct cred *cred) {if (EXT4_I (inode)->i_flags &EXT4_EXTENTS_FL )return ext4_ext_get_blocks (handle, inode, block, max_blocks, - bh, create, extend_disksize); + bh, create, extend_disksize, cred);return ext4_get_blocks_handle (handle, inode, block, max_blocks, bh, - create, extend_disksize); + create, extend_disksize, cred); }
include/linux/ext4_fs_extents.h +1 -1
@@ -232,7 +232,7 @@ extern int ext4_ext_try_to_merge(struct inode *inode,struct ext4_ext_path *path, struct ext4_extent *);extern unsigned int ext4_ext_check_overlap (struct inode *,struct ext4_extent *,struct ext4_ext_path *); -extern int ext4_ext_insert_extent (handle_t *,struct inode *,struct ext4_ext_path *,struct ext4_extent *); +extern int ext4_ext_insert_extent (handle_t *,struct inode *,struct ext4_ext_path *,struct ext4_extent *,struct cred *);extern int ext4_ext_walk_space (struct inode *,unsigned long ,unsigned long ,ext_prepare_callback ,void *);extern struct ext4_ext_path *ext4_ext_find_extent (struct inode *,int ,struct ext4_ext_path *);
include/linux/ext4_jbd2.h +2 -1
@@ -105,7 +105,8 @@ ext4_mark_iloc_dirty(handle_t *handle,int ext4_reserve_inode_write (handle_t *handle,struct inode *inode,struct ext4_iloc *iloc); -int ext4_mark_inode_dirty (handle_t *handle,struct inode *inode); +int ext4_mark_inode_dirty (handle_t *handle,struct inode *inode, +struct cred *cred);/* * Wrapper functions with which ext4 calls into JBD. The intent here is
David Howells
maintainerPATCH 10/52 CRED: Pass credentials down to ext4 inode allocator
In reply to David HowellsPass credentials down to the ext4 inode allocator.
---
fs/ext4/ialloc.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
fs/ext4/ialloc.c +2 -2
@@ -550,7 +550,7 @@ got:percpu_counter_inc (&sbi->s_dirs_counter); sb->s_dirt =1 ; - inode->i_uid = current->cred->uid; + inode->i_uid = cred->uid;if (test_opt (sb,GRPID )) inode->i_gid = dir->i_gid;else if (dir->i_mode &S_ISGID ) {
@@ -558,7 +558,7 @@ got:if (S_ISDIR (mode)) mode |=S_ISGID ; }else - inode->i_gid = current->cred->gid; + inode->i_gid = cred->gid; inode->i_mode = mode; inode->i_ino = ino;
David Howells
maintainerPATCH 11/52 CRED: Give the get_block() callback a credentials pointer
In reply to David HowellsGive the get_block() callback a credentials pointer.
---
fs/block_dev.c | 6 ++++-- fs/buffer.c | 18 ++++++++++++------ fs/direct-io.c | 3 ++- fs/ext3/inode.c | 7 ++++--- fs/fat/inode.c | 3 ++- fs/mpage.c | 6 ++++-- include/linux/fs.h | 3 ++- 7 files changed, 30 insertions(+), 16 deletions(-)
fs/block_dev.c +4 -2
@@ -112,7 +112,8 @@ EXPORT_SYMBOL(sb_min_blocksize);static int blkdev_get_block (struct inode *inode,sector_t iblock, -struct buffer_head *bh,int create) +struct buffer_head *bh,int create, +struct cred *cred) {if (iblock >=max_block (I_BDEV (inode))) {if (create)
@@ -134,7 +135,8 @@ blkdev_get_block(struct inode *inode, sector_t iblock,static int blkdev_get_blocks (struct inode *inode,sector_t iblock, -struct buffer_head *bh,int create) +struct buffer_head *bh,int create, +struct cred *cred) {sector_t end_block =max_block (I_BDEV (inode));unsigned long max_blocks = bh->b_size >> inode->i_blkbits;
fs/buffer.c +12 -6
@@ -1599,6 +1599,7 @@ EXPORT_SYMBOL(unmap_underlying_metadata);static int __block_write_full_page (struct inode *inode,struct page *page,get_block_t *get_block,struct writeback_control *wbc) { +struct cred *cred = current->cred;int err;sector_t block;sector_t last_block;
@@ -1647,7 +1648,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,set_buffer_uptodate (bh); }else if (!buffer_mapped (bh) &&buffer_dirty (bh)) {WARN_ON (bh->b_size != blocksize); - err =get_block (inode, block, bh,1 ); + err =get_block (inode, block, bh,1 , cred);if (err) goto recover;if (buffer_new (bh)) {
@@ -1760,6 +1761,7 @@ recover:static int __block_prepare_write (struct inode *inode,struct page *page,unsigned from,unsigned to,get_block_t *get_block) { +struct cred *cred = current->cred;unsigned block_start, block_end;sector_t block;int err =0 ;
@@ -1793,7 +1795,7 @@ static int __block_prepare_write(struct inode *inode, struct page *page,clear_buffer_new (bh);if (!buffer_mapped (bh)) {WARN_ON (bh->b_size != blocksize); - err =get_block (inode, block, bh,1 ); + err =get_block (inode, block, bh,1 , cred);if (err)break ;if (buffer_new (bh)) {
@@ -1917,6 +1919,7 @@ static int __block_commit_write(struct inode *inode, struct page *page,*/ int block_read_full_page (struct page *page,get_block_t *get_block) { +struct cred *cred = current->cred;struct inode *inode = page->mapping->host;sector_t iblock, lblock;struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE ];
@@ -1946,7 +1949,7 @@ int block_read_full_page(struct page *page, get_block_t *get_block) fully_mapped =0 ;if (iblock < lblock) {WARN_ON (bh->b_size != blocksize); - err =get_block (inode, iblock, bh,0 ); + err =get_block (inode, iblock, bh,0 , cred);if (err)SetPageError (page); }
@@ -2269,6 +2272,7 @@ static void end_buffer_read_nobh(struct buffer_head *bh, int uptodate)int nobh_prepare_write (struct page *page,unsigned from,unsigned to,get_block_t *get_block) { +struct cred *cred = current->cred;struct inode *inode = page->mapping->host;const unsigned blkbits = inode->i_blkbits;const unsigned blocksize =1 << blkbits;
@@ -2306,7 +2310,7 @@ int nobh_prepare_write(struct page *page, unsigned from, unsigned to, create =0 ; map_bh.b_size = blocksize; ret =get_block (inode, block_in_file + block_in_page, - &map_bh, create); + &map_bh, create, cred);if (ret) goto failed;if (!buffer_mapped (&map_bh))
@@ -2511,6 +2515,7 @@ EXPORT_SYMBOL(nobh_truncate_page);int block_truncate_page (struct address_space *mapping,loff_t from,get_block_t *get_block) { +struct cred *cred = current->cred;pgoff_t index = from >>PAGE_CACHE_SHIFT ;unsigned offset = from & (PAGE_CACHE_SIZE -1 );unsigned blocksize;
@@ -2551,7 +2556,7 @@ int block_truncate_page(struct address_space *mapping, err =0 ;if (!buffer_mapped (bh)) {WARN_ON (bh->b_size != blocksize); - err =get_block (inode, iblock, bh,0 ); + err =get_block (inode, iblock, bh,0 , cred);if (err) goto unlock;/* unmapped? It's a hole - nothing to do */
@@ -2625,12 +2630,13 @@ int block_write_full_page(struct page *page, get_block_t *get_block,sector_t generic_block_bmap (struct address_space *mapping,sector_t block,get_block_t *get_block) { +struct cred *cred = current->cred;struct buffer_head tmp;struct inode *inode = mapping->host; tmp.b_state =0 ; tmp.b_blocknr =0 ; tmp.b_size =1 << inode->i_blkbits; -get_block (inode, block, &tmp,0 ); +get_block (inode, block, &tmp,0 , cred);return tmp.b_blocknr; }
fs/direct-io.c +2 -1
@@ -499,6 +499,7 @@ static int dio_bio_reap(struct dio *dio)static int get_more_blocks (struct dio *dio) {int ret; +struct cred *cred = current->cred;struct buffer_head *map_bh = &dio->map_bh;sector_t fs_startblk;/* Into file, in filesystem-sized blocks */ unsigned long fs_count;/* Number of filesystem-sized blocks */
@@ -539,7 +540,7 @@ static int get_more_blocks(struct dio *dio)* writes. */ ret = (*dio->get_block)(dio->inode, fs_startblk, - map_bh, create); + map_bh, create, cred); }return ret; }
fs/ext3/inode.c +4 -3
@@ -948,9 +948,9 @@ out:#define DIO_CREDITS (EXT3_RESERVE_TRANS_BLOCKS + 32)static int ext3_get_block (struct inode *inode,sector_t iblock, -struct buffer_head *bh_result,int create) +struct buffer_head *bh_result,int create, +struct cred *cred) { -struct cred *cred = current->cred;handle_t *handle =ext3_journal_current_handle ();int ret =0 ;unsigned max_blocks = bh_result->b_size >> inode->i_blkbits;
@@ -1769,6 +1769,7 @@ void ext3_set_aops(struct inode *inode)static int ext3_block_truncate_page (handle_t *handle,struct page *page,struct address_space *mapping,loff_t from) { +struct cred *cred = current->cred;ext3_fsblk_t index = from >>PAGE_CACHE_SHIFT ;unsigned offset = from & (PAGE_CACHE_SIZE -1 );unsigned blocksize, iblock, length, pos;
@@ -1811,7 +1812,7 @@ static int ext3_block_truncate_page(handle_t *handle, struct page *page,if (!buffer_mapped (bh)) {BUFFER_TRACE (bh,"unmapped" ); -ext3_get_block (inode, iblock, bh,0 ); +ext3_get_block (inode, iblock, bh,0 , cred);/* unmapped? It's a hole - nothing to do */ if (!buffer_mapped (bh)) {BUFFER_TRACE (bh,"still unmapped" );
fs/fat/inode.c +2 -1
@@ -106,7 +106,8 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock, }static int fat_get_block (struct inode *inode,sector_t iblock, -struct buffer_head *bh_result,int create) +struct buffer_head *bh_result,int create, +struct cred *cred) {struct super_block *sb = inode->i_sb;unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits;
fs/mpage.c +4 -2
@@ -169,6 +169,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages, sector_t *last_block_in_bio, struct buffer_head *map_bh, unsigned long *first_logical_block, get_block_t get_block) { + struct cred *cred = current->cred;struct inode *inode = page->mapping->host;const unsigned blkbits = inode->i_blkbits;const unsigned blocks_per_page =PAGE_CACHE_SIZE >> blkbits;
@@ -229,7 +230,7 @@ do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,if (block_in_file < last_block) { map_bh->b_size = (last_block-block_in_file) << blkbits; -if (get_block (inode, block_in_file, map_bh,0 )) +if (get_block (inode, block_in_file, map_bh,0 , cred)) goto confused; *first_logical_block = block_in_file; }
@@ -456,6 +457,7 @@ struct mpage_data {static int __mpage_writepage (struct page *page,struct writeback_control *wbc,void *data) { +struct cred *cred = current->cred;struct mpage_data *mpd = data;struct bio *bio = mpd->bio;struct address_space *mapping = page->mapping;
@@ -538,7 +540,7 @@ static int __mpage_writepage(struct page *page, struct writeback_control *wbc, map_bh.b_state =0 ; map_bh.b_size =1 << blkbits; -if (mpd->get_block (inode, block_in_file, &map_bh,1 )) +if (mpd->get_block (inode, block_in_file, &map_bh,1 , cred)) goto confused;if (buffer_new (&map_bh)) unmap_underlying_metadata(map_bh.b_bdev,
include/linux/fs.h +2 -1
@@ -309,7 +309,8 @@ extern void __init files_init(unsigned long);struct buffer_head ;typedef int (get_block_t )(struct inode *inode,sector_t iblock, -struct buffer_head *bh_result,int create); +struct buffer_head *bh_result,int create, +struct cred *cred);typedef void (dio_iodone_t )(struct kiocb *iocb,loff_t offset,ssize_t bytes,void *private);
David Howells
maintainerPATCH 12/52 CRED: Make mpage read functions take a credentials pointer
In reply to David HowellsMake the mpage read functions take a credentials pointer.
---
fs/ext3/inode.c | 5 +++-- fs/fat/inode.c | 5 +++-- fs/mpage.c | 12 ++++++------ include/linux/mpage.h | 5 +++-- 4 files changed, 15 insertions(+), 12 deletions(-)
fs/ext3/inode.c +3 -2
@@ -1582,14 +1582,15 @@ out_unlock:static int ext3_readpage (struct file *file,struct page *page) { -return mpage_readpage (page, ext3_get_block); +return mpage_readpage (page, ext3_get_block, file->f_cred); }static int ext3_readpages (struct file *file,struct address_space *mapping,struct list_head *pages,unsigned nr_pages) { -return mpage_readpages (mapping, pages, nr_pages, ext3_get_block); +return mpage_readpages (mapping, pages, nr_pages, ext3_get_block, + file->f_cred); }static void ext3_invalidatepage (struct page *page,unsigned long offset)
fs/fat/inode.c +3 -2
@@ -133,13 +133,14 @@ static int fat_writepages(struct address_space *mapping,static int fat_readpage (struct file *file,struct page *page) { -return mpage_readpage (page, fat_get_block); +return mpage_readpage (page, fat_get_block, file->f_cred); }static int fat_readpages (struct file *file,struct address_space *mapping,struct list_head *pages,unsigned nr_pages) { -return mpage_readpages (mapping, pages, nr_pages, fat_get_block); +return mpage_readpages (mapping, pages, nr_pages, fat_get_block, + file->f_cred); } static int fat_prepare_write(struct file *file, struct page *page,
fs/mpage.c +6 -6
@@ -167,9 +167,9 @@ map_buffer_to_page(struct page *page, struct buffer_head *bh, int page_block)static struct bio *do_mpage_readpage (struct bio *bio,struct page *page,unsigned nr_pages,sector_t *last_block_in_bio,struct buffer_head *map_bh, -unsigned long *first_logical_block,get_block_t get_block) +unsigned long *first_logical_block,get_block_t get_block, +struct cred *cred) { -struct cred *cred = current->cred;struct inode *inode = page->mapping->host;const unsigned blkbits = inode->i_blkbits;const unsigned blocks_per_page =PAGE_CACHE_SIZE >> blkbits;
@@ -375,7 +375,7 @@ confused:*/ int mpage_readpages (struct address_space *mapping,struct list_head *pages, -unsigned nr_pages,get_block_t get_block) +unsigned nr_pages,get_block_t get_block,struct cred *cred) {struct bio *bio =NULL ;unsigned page_idx;
@@ -397,7 +397,7 @@ mpage_readpages(struct address_space *mapping, struct list_head *pages, nr_pages - page_idx, &last_block_in_bio, &map_bh, &first_logical_block, - get_block); + get_block, cred);if (!pagevec_add (&lru_pvec, page))__pagevec_lru_add (&lru_pvec); }else {
@@ -415,7 +415,7 @@ EXPORT_SYMBOL(mpage_readpages);/* * This isn't called much at all */ -int mpage_readpage (struct page *page,get_block_t get_block) +int mpage_readpage (struct page *page,get_block_t get_block,struct cred *cred) {struct bio *bio =NULL ;sector_t last_block_in_bio =0 ;
@@ -424,7 +424,7 @@ int mpage_readpage(struct page *page, get_block_t get_block)clear_buffer_mapped (&map_bh); bio =do_mpage_readpage (bio, page,1 , &last_block_in_bio, - &map_bh, &first_logical_block, get_block); + &map_bh, &first_logical_block, get_block, cred);if (bio)mpage_bio_submit (READ , bio);return 0 ;
include/linux/mpage.h +3 -2
@@ -14,8 +14,9 @@struct writeback_control ;int mpage_readpages (struct address_space *mapping,struct list_head *pages, -unsigned nr_pages,get_block_t get_block); -int mpage_readpage (struct page *page,get_block_t get_block); +unsigned nr_pages,get_block_t get_block, +struct cred *cred); +int mpage_readpage (struct page *page,get_block_t get_block,struct cred *cred);int mpage_writepages (struct address_space *mapping,struct writeback_control *wbc,get_block_t get_block); int mpage_writepage(struct page *page, get_block_t *get_block,
David Howells
maintainerPATCH 13/52 CRED: Make block_prepare_write() and co take a credentials pointer
In reply to David HowellsMake block_prepare_write() and co take a credentials pointer.
---
fs/block_dev.c | 2 +- fs/buffer.c | 23 +++++++++++++---------- fs/ext3/inode.c | 8 +++++--- fs/fat/inode.c | 3 ++- include/linux/buffer_head.h | 8 +++++--- 5 files changed, 26 insertions(+), 18 deletions(-)
fs/block_dev.c +1 -1
@@ -382,7 +382,7 @@ static int blkdev_readpage(struct file * file, struct page * page)static int blkdev_prepare_write (struct file *file,struct page *page,unsigned from,unsigned to) { -return block_prepare_write (page, from, to, blkdev_get_block); +return block_prepare_write (page, from, to, blkdev_get_block, file->f_cred); }static int blkdev_commit_write (struct file *file,struct page *page,unsigned from,unsigned to)
fs/buffer.c +13 -10
@@ -1759,9 +1759,9 @@ recover: }static int __block_prepare_write (struct inode *inode,struct page *page, -unsigned from,unsigned to,get_block_t *get_block) +unsigned from,unsigned to,get_block_t *get_block, +struct cred *cred) { -struct cred *cred = current->cred;unsigned block_start, block_end;sector_t block;int err =0 ;
@@ -2089,7 +2089,8 @@ int generic_cont_expand_simple(struct inode *inode, loff_t size)*/ int cont_prepare_write (struct page *page,unsigned offset, -unsigned to,get_block_t *get_block,loff_t *bytes) +unsigned to,get_block_t *get_block,loff_t *bytes, +struct cred *cred) {struct address_space *mapping = page->mapping;struct inode *inode = mapping->host;
@@ -2116,7 +2117,8 @@ int cont_prepare_write(struct page *page, unsigned offset, (*bytes)++; } status =__block_prepare_write (inode, new_page, zerofrom, -PAGE_CACHE_SIZE , get_block); +PAGE_CACHE_SIZE , get_block, + cred);if (status) goto out_unmap; zero_user_page(new_page, zerofrom, PAGE_CACHE_SIZE - zerofrom,
@@ -2143,7 +2145,8 @@ int cont_prepare_write(struct page *page, unsigned offset,if (offset <= zerofrom) zerofrom = offset; } - status =__block_prepare_write (inode, page, zerofrom, to, get_block); + status =__block_prepare_write (inode, page, zerofrom, to, get_block, + cred);if (status) goto out1;if (zerofrom < offset) {
@@ -2164,10 +2167,10 @@ out: }int block_prepare_write (struct page *page,unsigned from,unsigned to, -get_block_t *get_block) +get_block_t *get_block,struct cred *cred) {struct inode *inode = page->mapping->host; -int err =__block_prepare_write (inode, page, from, to, get_block); +int err =__block_prepare_write (inode, page, from, to, get_block, cred);if (err)ClearPageUptodate (page);return err;
@@ -2217,6 +2220,7 @@ block_page_mkwrite(struct vm_area_struct *vma, struct page *page, get_block_t get_block) {struct inode *inode = vma->vm_file->f_path.dentry->d_inode; +struct cred *cred = vma->vm_file->f_cred;unsigned long end;loff_t size;int ret = -EINVAL ;
@@ -2235,7 +2239,7 @@ block_page_mkwrite(struct vm_area_struct *vma, struct page *page,else end =PAGE_CACHE_SIZE ; - ret =block_prepare_write (page,0 , end, get_block); + ret =block_prepare_write (page,0 , end, get_block, cred);if (!ret) ret =block_commit_write (page,0 , end);
@@ -2270,9 +2274,8 @@ static void end_buffer_read_nobh(struct buffer_head *bh, int uptodate)* On exit the page is fully uptodate in the areas outside (from,to) */ int nobh_prepare_write (struct page *page,unsigned from,unsigned to, -get_block_t *get_block) +get_block_t *get_block,struct cred *cred) { -struct cred *cred = current->cred;struct inode *inode = page->mapping->host;const unsigned blkbits = inode->i_blkbits;const unsigned blocksize =1 << blkbits;
fs/ext3/inode.c +5 -3
@@ -1158,6 +1158,7 @@ static int ext3_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to) {struct inode *inode = page->mapping->host; +struct cred *cred = file->f_cred;int ret, needed_blocks =ext3_writepage_trans_blocks (inode);handle_t *handle;int retries =0 ;
@@ -1169,9 +1170,9 @@ retry: goto out; }if (test_opt (inode->i_sb,NOBH ) &&ext3_should_writeback_data (inode)) - ret =nobh_prepare_write (page, from, to, ext3_get_block); + ret =nobh_prepare_write (page, from, to, ext3_get_block, cred);else - ret =block_prepare_write (page, from, to, ext3_get_block); + ret =block_prepare_write (page, from, to, ext3_get_block, cred);if (ret) goto prepare_write_failed;
@@ -1525,6 +1526,7 @@ static int ext3_journalled_writepage(struct page *page, struct writeback_control *wbc) {struct inode *inode = page->mapping->host; +struct cred *cred = current->cred;handle_t *handle =NULL ;int ret =0 ;int err;
@@ -1545,7 +1547,7 @@ static int ext3_journalled_writepage(struct page *page,*/ ClearPageChecked (page); ret =block_prepare_write (page,0 ,PAGE_CACHE_SIZE , - ext3_get_block); + ext3_get_block, cred);if (ret !=0 ) {ext3_journal_stop (handle); goto out_unlock;
fs/fat/inode.c +2 -1
@@ -147,7 +147,8 @@ static int fat_prepare_write(struct file *file, struct page *page, unsigned from, unsigned to) {return cont_prepare_write (page, from, to, fat_get_block, - &MSDOS_I (page->mapping->host)->mmu_private); + &MSDOS_I (page->mapping->host)->mmu_private, + file->f_cred); } static int fat_commit_write(struct file *file, struct page *page,
include/linux/buffer_head.h +5 -3
@@ -203,9 +203,10 @@ void block_invalidatepage(struct page *page, unsigned long offset);int block_write_full_page (struct page *page,get_block_t *get_block,struct writeback_control *wbc);int block_read_full_page (struct page *,get_block_t *); -int block_prepare_write (struct page *,unsigned ,unsigned ,get_block_t *); +int block_prepare_write (struct page *,unsigned ,unsigned ,get_block_t *, +struct cred *);int cont_prepare_write (struct page *,unsigned ,unsigned ,get_block_t *, -loff_t *); +loff_t *,struct cred *);int generic_cont_expand (struct inode *inode,loff_t size);int generic_cont_expand_simple (struct inode *inode,loff_t size);int block_commit_write (struct page *page,unsigned from,unsigned to);
@@ -216,7 +217,8 @@ sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *);int generic_commit_write (struct file *,struct page *,unsigned ,unsigned );int block_truncate_page (struct address_space *,loff_t ,get_block_t *);int file_fsync (struct file *,struct dentry *,int ); -int nobh_prepare_write (struct page *,unsigned ,unsigned ,get_block_t *); +int nobh_prepare_write (struct page *,unsigned ,unsigned ,get_block_t *, +struct cred *);int nobh_commit_write (struct file *,struct page *,unsigned ,unsigned );int nobh_truncate_page (struct address_space *,loff_t ); int nobh_writepage(struct page *page, get_block_t *get_block,
David Howells
maintainerPATCH 14/52 CRED: Provide a writeback credentials record
In reply to David HowellsProvide a set of credentials specifically for the writeback functions. Since writeback may well occur in some other process context than the original write into the pagecache, the current process's credentials are not applicable, and so there are used instead.
If writeback needs to know the credentials, then those credentials should be cached by prepare_write(), page_mkwrite() or similar. Filesystems such as NFS and AFS need to do this as they need to communicate to a remote store the appropriate security details under which the write should be made. Filesystems such as Ext3 should perform allocation and reservation checks before letting the write to the pagecache occur.
---
fs/buffer.c | 2 +- fs/mpage.c | 2 +- include/linux/cred.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-)
fs/buffer.c +1 -1
@@ -1599,7 +1599,7 @@ EXPORT_SYMBOL(unmap_underlying_metadata);static int __block_write_full_page (struct inode *inode,struct page *page,get_block_t *get_block,struct writeback_control *wbc) { -struct cred *cred = current->cred; +struct cred *cred = &writeback_cred;int err;sector_t block;sector_t last_block;
fs/mpage.c +1 -1
@@ -457,7 +457,7 @@ struct mpage_data {static int __mpage_writepage (struct page *page,struct writeback_control *wbc,void *data) { -struct cred *cred = current->cred; +struct cred *cred = &writeback_cred;struct mpage_data *mpd = data;struct bio *bio = mpd->bio;struct address_space *mapping = page->mapping;
include/linux/cred.h +1 -0
@@ -29,6 +29,7 @@ struct cred { };extern struct cred init_cred; +#define writeback_cred init_credstruct inode ;
David Howells
maintainerPATCH 15/52 CRED: Make Ext3 use the writeback credentials
In reply to David HowellsMake Ext3 use the writeback credentials when performing writebacks.
---
fs/ext3/inode.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
fs/ext3/inode.c +1 -1
@@ -1526,7 +1526,7 @@ static int ext3_journalled_writepage(struct page *page, struct writeback_control *wbc) {struct inode *inode = page->mapping->host; -struct cred *cred = current->cred; +struct cred *cred = &writeback_cred;handle_t *handle =NULL ;int ret =0 ;int err;
David Howells
maintainerPATCH 16/52 CRED: Pass credentials through the internals of ext3 truncation
In reply to David HowellsPass credentials through the internals of ext3 truncation.
---
fs/ext3/inode.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
fs/ext3/inode.c +4 -3
@@ -1770,9 +1770,8 @@ void ext3_set_aops(struct inode *inode)* of that block so it doesn't yield old data if the file is later grown. */ static int ext3_block_truncate_page (handle_t *handle,struct page *page, -struct address_space *mapping,loff_t from) +struct address_space *mapping,loff_t from,struct cred *cred) { -struct cred *cred = current->cred;ext3_fsblk_t index = from >>PAGE_CACHE_SHIFT ;unsigned offset = from & (PAGE_CACHE_SIZE -1 );unsigned blocksize, iblock, length, pos;
@@ -2230,6 +2229,7 @@ static void ext3_free_branches(handle_t *handle, struct inode *inode,*/ void ext3_truncate (struct inode *inode) { +struct cred *cred = current->cred;handle_t *handle;struct ext3_inode_info *ei =EXT3_I (inode);__le32 *i_data = ei->i_data;
@@ -2281,7 +2281,8 @@ void ext3_truncate(struct inode *inode) >> EXT3_BLOCK_SIZE_BITS(inode->i_sb);if (page) -ext3_block_truncate_page (handle, page, mapping, inode->i_size); +ext3_block_truncate_page (handle, page, mapping, inode->i_size, + cred); n =ext3_block_to_path (inode, last_block, offsets,NULL );if (n ==0 )
David Howells
maintainerPATCH 17/52 CRED: Make rpcauth_lookupcred() take a credentials pointer
In reply to David HowellsMake rpcauth_lookupcred() take a credentials pointer.
---
fs/nfs/dir.c | 3 ++- fs/nfs/inode.c | 2 +- fs/nfs/nfs4proc.c | 12 ++++++++---- fs/nfs/unlink.c | 3 ++- include/linux/sunrpc/auth.h | 3 ++- net/sunrpc/auth.c | 4 ++-- 6 files changed, 17 insertions(+), 10 deletions(-)
fs/nfs/dir.c +2 -1
@@ -1959,6 +1959,7 @@ out:int nfs_permission (struct inode *inode,int mask,struct nameidata *nd) { +struct cred *acred = current->cred;struct rpc_cred *cred;int res =0 ;
@@ -1995,7 +1996,7 @@ force_lookup:if (!NFS_PROTO (inode)->access) goto out_notsup; - cred =rpcauth_lookupcred (NFS_CLIENT (inode)->cl_auth,0 ); + cred =rpcauth_lookupcred (NFS_CLIENT (inode)->cl_auth,0 , acred);if (!IS_ERR (cred)) { res =nfs_do_access (inode, cred, mask);put_rpccred (cred);
fs/nfs/inode.c +1 -1
@@ -555,7 +555,7 @@ int nfs_open(struct inode *inode, struct file *filp)struct nfs_open_context *ctx;struct rpc_cred *cred; - cred =rpcauth_lookupcred (NFS_CLIENT (inode)->cl_auth,0 ); + cred =rpcauth_lookupcred (NFS_CLIENT (inode)->cl_auth,0 , filp->f_cred);if (IS_ERR (cred))return PTR_ERR (cred); ctx =alloc_nfs_open_context (filp->f_path.mnt, filp->f_path.dentry, cred);
fs/nfs/nfs4proc.c +8 -4
@@ -1403,6 +1403,7 @@ out_close:struct dentry *nfs4_atomic_open (struct inode *dir,struct dentry *dentry,struct nameidata *nd) { +struct cred *acred = current->cred;struct path path = { .mnt = nd->mnt, .dentry = dentry,
@@ -1422,7 +1423,7 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd)BUG_ON (nd->intent.open.flags &O_CREAT ); } - cred =rpcauth_lookupcred (NFS_CLIENT (dir)->cl_auth,0 ); + cred =rpcauth_lookupcred (NFS_CLIENT (dir)->cl_auth,0 , acred);if (IS_ERR (cred))return (struct dentry *)cred; state =nfs4_do_open (dir, &path, nd->intent.open.flags, &attr, cred);
@@ -1442,6 +1443,7 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd)int nfs4_open_revalidate (struct inode *dir,struct dentry *dentry,int openflags,struct nameidata *nd) { +struct cred *acred = current->cred;struct path path = { .mnt = nd->mnt, .dentry = dentry,
@@ -1449,7 +1451,7 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, ststruct rpc_cred *cred;struct nfs4_state *state; - cred =rpcauth_lookupcred (NFS_CLIENT (dir)->cl_auth,0 ); + cred =rpcauth_lookupcred (NFS_CLIENT (dir)->cl_auth,0 , acred);if (IS_ERR (cred))return PTR_ERR (cred); state =nfs4_do_open (dir, &path, openflags,NULL , cred);
@@ -1657,6 +1659,7 @@ static int nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, struct iattr *sattr) { + struct cred *acred = current->cred;struct rpc_cred *cred;struct inode *inode = dentry->d_inode;struct nfs_open_context *ctx;
@@ -1665,7 +1668,7 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,nfs_fattr_init (fattr); - cred =rpcauth_lookupcred (NFS_CLIENT (inode)->cl_auth,0 ); + cred =rpcauth_lookupcred (NFS_CLIENT (inode)->cl_auth,0 , acred);if (IS_ERR (cred))return PTR_ERR (cred);
@@ -1885,6 +1888,7 @@ static int nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, int flags, struct nameidata *nd) { + struct cred *acred = current->cred; struct path path = { .mnt = nd->mnt, .dentry = dentry,
@@ -1893,7 +1897,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,struct rpc_cred *cred;int status =0 ; - cred =rpcauth_lookupcred (NFS_CLIENT (dir)->cl_auth,0 ); + cred =rpcauth_lookupcred (NFS_CLIENT (dir)->cl_auth,0 , acred);if (IS_ERR (cred)) { status =PTR_ERR (cred); goto out;
fs/nfs/unlink.c +2 -1
@@ -144,6 +144,7 @@ out_free:int nfs_async_unlink (struct inode *dir,struct dentry *dentry) { +struct cred *acred = current->cred;struct nfs_unlinkdata *data;int status = -ENOMEM ;
@@ -151,7 +152,7 @@ nfs_async_unlink(struct inode *dir, struct dentry *dentry)if (data ==NULL ) goto out; - data->cred =rpcauth_lookupcred (NFS_CLIENT (dir)->cl_auth,0 ); + data->cred =rpcauth_lookupcred (NFS_CLIENT (dir)->cl_auth,0 , acred);if (IS_ERR (data->cred)) { status =PTR_ERR (data->cred); goto out_free;
include/linux/sunrpc/auth.h +2 -1
@@ -129,7 +129,8 @@ struct rpc_auth * rpcauth_create(rpc_authflavor_t, struct rpc_clnt *);void rpcauth_release (struct rpc_auth *);struct rpc_cred *rpcauth_lookup_credcache (struct rpc_auth *,struct cred *,int );void rpcauth_init_cred (struct rpc_cred *,const struct cred *,struct rpc_auth *,const struct rpc_credops *); -struct rpc_cred *rpcauth_lookupcred (struct rpc_auth *,int ); +struct rpc_cred *rpcauth_lookupcred (struct rpc_auth *,int , +struct cred *);struct rpc_cred *rpcauth_bindcred (struct rpc_task *);void rpcauth_holdcred (struct rpc_task *);void put_rpccred (struct rpc_cred *);
net/sunrpc/auth.c +2 -2
@@ -334,11 +334,11 @@ out: }struct rpc_cred * -rpcauth_lookupcred (struct rpc_auth *auth,int flags) +rpcauth_lookupcred (struct rpc_auth *auth,int flags,struct cred *acred) {dprintk ("RPC: looking up %s cred\n" , auth->au_ops->au_name); -return auth->au_ops->lookup_cred (auth, current->cred, flags); +return auth->au_ops->lookup_cred (auth, acred, flags); }void
David Howells
maintainerPATCH 18/52 CRED: Make rpcauth_bindcred() take a credentials pointer
In reply to David HowellsMake rpcauth_bindcred() take a credentials pointer.
---
fs/nfs/nfs3proc.c | 6 +++--- fs/nfs/nfs4proc.c | 18 +++++++++--------- fs/nfs/proc.c | 4 ++-- fs/nfs/unlink.c | 2 +- include/linux/sunrpc/auth.h | 2 +- include/linux/sunrpc/clnt.h | 3 ++- net/sunrpc/auth.c | 4 ++-- net/sunrpc/clnt.c | 7 ++++--- net/sunrpc/rpcb_clnt.c | 2 +- 9 files changed, 25 insertions(+), 23 deletions(-)
fs/nfs/nfs3proc.c +3 -3
@@ -739,7 +739,7 @@ static void nfs3_proc_read_setup(struct nfs_read_data *data) .rpc_cred = data->cred, }; -rpc_call_setup (&data->task, &msg,0 ); +rpc_call_setup (&data->task, &msg,0 , current->cred); }static int nfs3_write_done (struct rpc_task *task,struct nfs_write_data *data)
@@ -768,7 +768,7 @@ static void nfs3_proc_write_setup(struct nfs_write_data *data, int how) }/* Finalize the task. */ -rpc_call_setup (&data->task, &msg,0 ); +rpc_call_setup (&data->task, &msg,0 , current->cred); }static int nfs3_commit_done (struct rpc_task *task,struct nfs_write_data *data)
@@ -789,7 +789,7 @@ static void nfs3_proc_commit_setup(struct nfs_write_data *data, int how) .rpc_cred = data->cred, }; -rpc_call_setup (&data->task, &msg,0 ); +rpc_call_setup (&data->task, &msg,0 , current->cred); } static int
fs/nfs/nfs4proc.c +9 -9
@@ -729,7 +729,7 @@ static void nfs4_open_confirm_prepare(struct rpc_task *task, void *calldata) .rpc_cred = data->owner->so_cred, }; data->timestamp = jiffies; -rpc_call_setup (task, &msg,0 ); +rpc_call_setup (task, &msg,0 , current->cred); }static void nfs4_open_confirm_done (struct rpc_task *task,void *calldata)
@@ -838,7 +838,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)nfs_copy_fh (&data->o_res.fh, data->o_arg.fh); } data->timestamp = jiffies; -rpc_call_setup (task, &msg,0 ); +rpc_call_setup (task, &msg,0 , current->cred);return ; out_no_action: task->tk_action =NULL ;
@@ -1316,7 +1316,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data) calldata->arg.open_flags =FMODE_WRITE ; } calldata->timestamp = jiffies; -rpc_call_setup (task, &msg,0 ); +rpc_call_setup (task, &msg,0 , current->cred); }static const struct rpc_call_ops nfs4_close_ops = {
@@ -2434,7 +2434,7 @@ static void nfs4_proc_read_setup(struct nfs_read_data *data) data->timestamp = jiffies; -rpc_call_setup (&data->task, &msg,0 ); +rpc_call_setup (&data->task, &msg,0 , current->cred); }static int nfs4_write_done (struct rpc_task *task,struct nfs_write_data *data)
@@ -2478,7 +2478,7 @@ static void nfs4_proc_write_setup(struct nfs_write_data *data, int how) data->timestamp = jiffies;/* Finalize the task. */ -rpc_call_setup (&data->task, &msg,0 ); +rpc_call_setup (&data->task, &msg,0 , current->cred); }static int nfs4_commit_done (struct rpc_task *task,struct nfs_write_data *data)
@@ -2507,7 +2507,7 @@ static void nfs4_proc_commit_setup(struct nfs_write_data *data, int how) data->args.bitmask = server->attr_bitmask; data->res.server = server; -rpc_call_setup (&data->task, &msg,0 ); +rpc_call_setup (&data->task, &msg,0 , current->cred); }/*
@@ -3007,7 +3007,7 @@ static void nfs4_delegreturn_prepare(struct rpc_task *task, void *calldata) .rpc_cred = data->cred, };nfs_fattr_init (data->res.fattr); -rpc_call_setup (task, &msg,0 ); +rpc_call_setup (task, &msg,0 , current->cred); }static void nfs4_delegreturn_done (struct rpc_task *task,void *calldata)
@@ -3255,7 +3255,7 @@ static void nfs4_locku_prepare(struct rpc_task *task, void *data)return ; } calldata->timestamp = jiffies; -rpc_call_setup (task, &msg,0 ); +rpc_call_setup (task, &msg,0 , current->cred); }static const struct rpc_call_ops nfs4_locku_ops = {
@@ -3384,7 +3384,7 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata) data->arg.new_lock_owner =1 ; } data->timestamp = jiffies; -rpc_call_setup (task, &msg,0 ); +rpc_call_setup (task, &msg,0 , current->cred); out:dprintk ("%s: done!, ret = %d\n" , __FUNCTION__, data->rpc_status); }
fs/nfs/proc.c +2 -2
@@ -570,7 +570,7 @@ static void nfs_proc_read_setup(struct nfs_read_data *data) .rpc_cred = data->cred, }; -rpc_call_setup (&data->task, &msg,0 ); +rpc_call_setup (&data->task, &msg,0 , current->cred); }static int nfs_write_done (struct rpc_task *task,struct nfs_write_data *data)
@@ -593,7 +593,7 @@ static void nfs_proc_write_setup(struct nfs_write_data *data, int how) data->args.stable =NFS_FILE_SYNC ;/* Finalize the task. */ -rpc_call_setup (&data->task, &msg,0 ); +rpc_call_setup (&data->task, &msg,0 , current->cred); } static void
fs/nfs/unlink.c +1 -1
@@ -68,7 +68,7 @@ static void nfs_async_unlink_init(struct rpc_task *task, void *calldata)nfs_begin_data_update (dir);NFS_PROTO (dir)->unlink_setup (&msg, dir); -rpc_call_setup (task, &msg,0 ); +rpc_call_setup (task, &msg,0 , current->cred); }/**
include/linux/sunrpc/auth.h +1 -1
@@ -131,7 +131,7 @@ struct rpc_cred * rpcauth_lookup_credcache(struct rpc_auth *, struct cred *, intvoid rpcauth_init_cred (struct rpc_cred *,const struct cred *,struct rpc_auth *,const struct rpc_credops *);struct rpc_cred *rpcauth_lookupcred (struct rpc_auth *,int ,struct cred *); -struct rpc_cred *rpcauth_bindcred (struct rpc_task *); +struct rpc_cred *rpcauth_bindcred (struct rpc_task *,struct cred *);void rpcauth_holdcred (struct rpc_task *);void put_rpccred (struct rpc_cred *);void rpcauth_unbindcred (struct rpc_task *);
include/linux/sunrpc/clnt.h +2 -1
@@ -126,7 +126,8 @@ int rpcb_register(u32, u32, int, unsigned short, int *);int rpcb_getport_sync (struct sockaddr_in *,__u32 ,__u32 ,int );void rpcb_getport_async (struct rpc_task *); -void rpc_call_setup (struct rpc_task *,struct rpc_message *,int ); +void rpc_call_setup (struct rpc_task *,struct rpc_message *,int , +struct cred *); int rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags, const struct rpc_call_ops *tk_ops,
net/sunrpc/auth.c +2 -2
@@ -359,7 +359,7 @@ rpcauth_init_cred(struct rpc_cred *cred, const struct cred *acred,EXPORT_SYMBOL (rpcauth_init_cred);struct rpc_cred * -rpcauth_bindcred (struct rpc_task *task) +rpcauth_bindcred (struct rpc_task *task,struct cred *acred) {struct rpc_auth *auth = task->tk_client->cl_auth;struct rpc_cred *ret;
@@ -369,7 +369,7 @@ rpcauth_bindcred(struct rpc_task *task) task->tk_pid, task->tk_client->cl_auth->au_ops->au_name);if (task->tk_flags &RPC_TASK_ROOTCREDS ) flags |=RPCAUTH_LOOKUP_ROOTCREDS ; - ret = auth->au_ops->lookup_cred (auth, current->cred, flags); + ret = auth->au_ops->lookup_cred (auth, acred, flags);if (!IS_ERR (ret)) task->tk_msg.rpc_cred = ret;else
net/sunrpc/clnt.c +4 -3
@@ -534,7 +534,7 @@ struct rpc_task *rpc_do_run_task(struct rpc_clnt *clnt,/* Mask signals on synchronous RPC calls and RPCSEC_GSS upcalls */ rpc_task_sigmask (task, &oldset);if (msg !=NULL ) { -rpc_call_setup (task, msg,0 ); +rpc_call_setup (task, msg,0 , current->cred);if (task->tk_status !=0 ) { ret =ERR_PTR (task->tk_status);rpc_put_task (task);
@@ -607,7 +607,8 @@ struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags,EXPORT_SYMBOL (rpc_run_task);void -rpc_call_setup (struct rpc_task *task,struct rpc_message *msg,int flags) +rpc_call_setup (struct rpc_task *task,struct rpc_message *msg,int flags, +struct cred *acred) { task->tk_msg = *msg; task->tk_flags |= flags;
@@ -615,7 +616,7 @@ rpc_call_setup(struct rpc_task *task, struct rpc_message *msg, int flags)if (task->tk_msg.rpc_cred !=NULL )rpcauth_holdcred (task);else -rpcauth_bindcred (task); +rpcauth_bindcred (task, acred);if (task->tk_status ==0 ) task->tk_action = call_start;
net/sunrpc/rpcb_clnt.c +1 -1
@@ -152,7 +152,7 @@ static void rpcb_getport_prepare(struct rpc_task *task, void *calldata) .rpc_resp = &map->r_port, }; -rpc_call_setup (task, &msg,0 ); +rpc_call_setup (task, &msg,0 , current->cred); }static void rpcb_map_release (void *data)
David Howells
maintainerPATCH 19/52 CRED: Add a credentials pointer to struct rpc_task
In reply to David HowellsAdd a credentials pointer to struct rpc_task and make use of it in the rpc_call_prepare() operation.
---
fs/nfs/nfs4proc.c | 12 ++++++------ fs/nfs/unlink.c | 2 +- include/linux/sunrpc/sched.h | 1 + net/sunrpc/rpcb_clnt.c | 2 +- net/sunrpc/sched.c | 4 ++++ 5 files changed, 13 insertions(+), 8 deletions(-)
fs/nfs/nfs4proc.c +6 -6
@@ -729,7 +729,7 @@ static void nfs4_open_confirm_prepare(struct rpc_task *task, void *calldata) .rpc_cred = data->owner->so_cred, }; data->timestamp = jiffies; -rpc_call_setup (task, &msg,0 , current->cred); +rpc_call_setup (task, &msg,0 , task->tk_acred); }static void nfs4_open_confirm_done (struct rpc_task *task,void *calldata)
@@ -838,7 +838,7 @@ static void nfs4_open_prepare(struct rpc_task *task, void *calldata)nfs_copy_fh (&data->o_res.fh, data->o_arg.fh); } data->timestamp = jiffies; -rpc_call_setup (task, &msg,0 , current->cred); +rpc_call_setup (task, &msg,0 , task->tk_acred);return ; out_no_action: task->tk_action =NULL ;
@@ -1316,7 +1316,7 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data) calldata->arg.open_flags =FMODE_WRITE ; } calldata->timestamp = jiffies; -rpc_call_setup (task, &msg,0 , current->cred); +rpc_call_setup (task, &msg,0 , task->tk_acred); }static const struct rpc_call_ops nfs4_close_ops = {
@@ -3007,7 +3007,7 @@ static void nfs4_delegreturn_prepare(struct rpc_task *task, void *calldata) .rpc_cred = data->cred, };nfs_fattr_init (data->res.fattr); -rpc_call_setup (task, &msg,0 , current->cred); +rpc_call_setup (task, &msg,0 , task->tk_acred); }static void nfs4_delegreturn_done (struct rpc_task *task,void *calldata)
@@ -3255,7 +3255,7 @@ static void nfs4_locku_prepare(struct rpc_task *task, void *data)return ; } calldata->timestamp = jiffies; -rpc_call_setup (task, &msg,0 , current->cred); +rpc_call_setup (task, &msg,0 , task->tk_acred); }static const struct rpc_call_ops nfs4_locku_ops = {
@@ -3384,7 +3384,7 @@ static void nfs4_lock_prepare(struct rpc_task *task, void *calldata) data->arg.new_lock_owner =1 ; } data->timestamp = jiffies; -rpc_call_setup (task, &msg,0 , current->cred); +rpc_call_setup (task, &msg,0 , task->tk_acred); out:dprintk ("%s: done!, ret = %d\n" , __FUNCTION__, data->rpc_status); }
fs/nfs/unlink.c +1 -1
@@ -68,7 +68,7 @@ static void nfs_async_unlink_init(struct rpc_task *task, void *calldata)nfs_begin_data_update (dir);NFS_PROTO (dir)->unlink_setup (&msg, dir); -rpc_call_setup (task, &msg,0 , current->cred); +rpc_call_setup (task, &msg,0 , task->tk_acred); }/**
include/linux/sunrpc/sched.h +1 -0
@@ -69,6 +69,7 @@ struct rpc_task {void (*tk_action)(struct rpc_task *);const struct rpc_call_ops *tk_ops;void * tk_calldata; +struct cred * tk_acred;/* * tk_timer is used for async processing by the RPC scheduling
net/sunrpc/rpcb_clnt.c +1 -1
@@ -152,7 +152,7 @@ static void rpcb_getport_prepare(struct rpc_task *task, void *calldata) .rpc_resp = &map->r_port, }; -rpc_call_setup (task, &msg,0 , current->cred); +rpc_call_setup (task, &msg,0 , task->tk_acred); }static void rpcb_map_release (void *data)
net/sunrpc/sched.c +4 -0
@@ -808,6 +808,8 @@ void rpc_free(void *buffer)*/ void rpc_init_task (struct rpc_task *task,struct rpc_clnt *clnt,int flags,const struct rpc_call_ops *tk_ops,void *calldata) { +struct cred *acred = current->cred; +memset (task,0 ,sizeof (*task));init_timer (&task->tk_timer); task->tk_timer.data = (unsigned long ) task;
@@ -819,6 +821,7 @@ void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, consif (tk_ops->rpc_call_prepare !=NULL ) task->tk_action = rpc_prepare_task; task->tk_calldata = calldata; + task->tk_acred =get_cred (acred);INIT_LIST_HEAD (&task->tk_task);/* Initialize retry counters */
@@ -897,6 +900,7 @@ void rpc_put_task(struct rpc_task *task)rpc_release_client (task->tk_client); task->tk_client =NULL ; } +put_cred (task->tk_acred);if (task->tk_flags &RPC_TASK_DYNAMIC )call_rcu_bh (&task->u.tk_rcu, rpc_free_task);rpc_release_calldata (tk_ops, calldata);
David Howells
maintainerPATCH 20/52 CRED: Pass credentials into rpc_init_task()
In reply to David HowellsPass credentials into rpc_init_task().
---
fs/lockd/clntlock.c | 2 fs/lockd/clntproc.c | 34 ++- fs/lockd/host.c | 6 fs/lockd/mon.c | 21 +- fs/lockd/svc.c | 2 fs/lockd/svc4proc.c | 6 fs/lockd/svclock.c | 13 + fs/lockd/svcproc.c | 7 - fs/nfs/callback.c | 2 fs/nfs/callback.h | 2 fs/nfs/client.c | 103 +++++--- fs/nfs/delegation.c | 24 +- fs/nfs/delegation.h | 10 + fs/nfs/dir.c | 111 ++++++--- fs/nfs/direct.c | 29 +- fs/nfs/file.c | 14 + fs/nfs/getroot.c | 22 +- fs/nfs/inode.c | 45 +++- fs/nfs/internal.h | 24 +- fs/nfs/mount_clnt.c | 7 - fs/nfs/namespace.c | 5 fs/nfs/nfs3acl.c | 43 ++- fs/nfs/nfs3proc.c | 130 ++++++---- fs/nfs/nfs4_fs.h | 30 ++ fs/nfs/nfs4namespace.c | 7 - fs/nfs/nfs4proc.c | 496 ++++++++++++++++++++++++---------------- fs/nfs/nfs4renewd.c | 2 fs/nfs/nfs4state.c | 16 + fs/nfs/proc.c | 99 ++++---- fs/nfs/read.c | 7 - fs/nfs/super.c | 41 ++- fs/nfs/symlink.c | 24 ++ fs/nfs/unlink.c | 18 + fs/nfs/write.c | 17 + include/linux/lockd/bind.h | 5 include/linux/lockd/lockd.h | 5 include/linux/lockd/sm_inter.h | 4 include/linux/nfs_fs.h | 38 ++- include/linux/nfs_xdr.h | 54 +++- include/linux/sunrpc/clnt.h | 10 - include/linux/sunrpc/sched.h | 13 + net/sunrpc/auth_gss/auth_gss.c | 2 net/sunrpc/clnt.c | 50 +++- net/sunrpc/rpcb_clnt.c | 14 + net/sunrpc/sched.c | 22 +- net/sunrpc/svc.c | 5 46 files changed, 980 insertions(+), 661 deletions(-)
fs/lockd/clntlock.c +1 -1
@@ -174,7 +174,7 @@ reclaimer(void *ptr)/* This one ensures that our parent doesn't terminate while the * reclaim is in progress */ lock_kernel (); -lockd_up (0 );/* note: this cannot fail as lockd is already running */ +lockd_up (0 , &init_cred);/* note: this cannot fail as lockd is already running */ dprintk ("lockd: reclaiming locks for host %s\n" , host->h_name);
fs/lockd/clntproc.c +20 -14
@@ -28,7 +28,8 @@ static int nlmclnt_lock(struct nlm_rqst *, struct file_lock *);static int nlmclnt_unlock (struct nlm_rqst *,struct file_lock *);static int nlm_stat_to_errno (__be32 stat);static void nlmclnt_locks_init_private (struct file_lock *fl,struct nlm_host *host); -static int nlmclnt_cancel (struct nlm_host *,int ,struct file_lock *); +static int nlmclnt_cancel (struct nlm_host *,int ,struct file_lock *, +struct cred *);static const struct rpc_call_ops nlmclnt_unlock_ops;static const struct rpc_call_ops nlmclnt_cancel_ops;
@@ -149,7 +150,8 @@ static void nlmclnt_release_lockargs(struct nlm_rqst *req)* This is the main entry point for the NLM client. */ int -nlmclnt_proc (struct inode *inode,int cmd,struct file_lock *fl) +nlmclnt_proc (struct inode *inode,int cmd,struct file_lock *fl, +struct cred *acred) {struct rpc_clnt *client =NFS_CLIENT (inode);struct sockaddr_in addr;
@@ -173,7 +175,7 @@ nlmclnt_proc(struct inode *inode, int cmd, struct file_lock *fl)if (host ==NULL )return -ENOLCK ; - call =nlm_alloc_call (host); + call =nlm_alloc_call (host, acred);if (call ==NULL )return -ENOMEM ;
@@ -227,7 +229,7 @@ EXPORT_SYMBOL(nlmclnt_proc);* Note: the caller must hold a reference to host. In case of failure, * this reference will be released. */ -struct nlm_rqst *nlm_alloc_call (struct nlm_host *host) +struct nlm_rqst *nlm_alloc_call (struct nlm_host *host,struct cred *acred) {struct nlm_rqst *call;
@@ -237,6 +239,7 @@ struct nlm_rqst *nlm_alloc_call(struct nlm_host *host)locks_init_lock (&call->a_args.lock.fl);locks_init_lock (&call->a_res.lock.fl); call->a_host = host; + call->a_acred =get_cred (acred);return call; }if (signalled ())
@@ -252,10 +255,11 @@ void nlm_release_call(struct nlm_rqst *call) {nlm_release_host (call->a_host);nlmclnt_release_lockargs (call); +put_cred (call->a_acred);kfree (call); } -static void nlmclnt_rpc_release (void *data) +static void nlmclnt_rpc_release (struct cred *acred,void *data) {return nlm_release_call (data); }
@@ -300,12 +304,12 @@ nlmclnt_call(struct nlm_rqst *req, u32 proc) goto in_grace_period;/* If we have no RPC client yet, create one. */ -if ((clnt =nlm_bind_host (host)) ==NULL ) +if ((clnt =nlm_bind_host (host, req->a_acred)) ==NULL )return -ENOLCK ; msg.rpc_proc = &clnt->cl_procinfo[proc];/* Perform the RPC call. If an error occurs, try again */ -if ((status =rpc_call_sync (clnt, &msg,0 )) <0 ) { +if ((status =rpc_call_sync (clnt, &msg,0 , req->a_acred)) <0 ) {dprintk ("lockd: rpc_call returned error %d\n" , -status);switch (status) {case -EPROTONOSUPPORT :
@@ -365,15 +369,16 @@ static int __nlm_async_call(struct nlm_rqst *req, u32 proc, struct rpc_message * (int)proc, host->h_name);/* If we have no RPC client yet, create one. */ - clnt =nlm_bind_host (host); + clnt =nlm_bind_host (host, req->a_acred);if (clnt ==NULL ) goto out_err; msg->rpc_proc = &clnt->cl_procinfo[proc];/* bootstrap and kick off the async RPC call */ -return rpc_call_async (clnt, msg,RPC_TASK_ASYNC , tk_ops, req); +return rpc_call_async (clnt, msg,RPC_TASK_ASYNC , tk_ops, req, + req->a_acred); out_err: - tk_ops->rpc_release (req); + tk_ops->rpc_release (req->a_acred, req);return -ENOLCK ; }
@@ -499,7 +504,7 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)unsigned char fl_flags = fl->fl_flags;int status = -ENOLCK ; -if (nsm_monitor (host) <0 ) { +if (nsm_monitor (host, req->a_acred) <0 ) {printk (KERN_NOTICE "lockd: failed to monitor %s\n" , host->h_name); goto out;
@@ -553,7 +558,7 @@ out_unblock:nlmclnt_finish_block (block);/* Cancel the blocked request if it is still pending */ if (resp->status == nlm_lck_blocked) -nlmclnt_cancel (host, req->a_args.block, fl); +nlmclnt_cancel (host, req->a_args.block, fl, req->a_acred); out:nlm_release_call (req); fl->fl_flags = fl_flags;
@@ -681,7 +686,8 @@ static const struct rpc_call_ops nlmclnt_unlock_ops = {* We always use an async RPC call for this in order not to hang a * process that has been Ctrl-C'ed. */ -static int nlmclnt_cancel (struct nlm_host *host,int block,struct file_lock *fl) +static int nlmclnt_cancel (struct nlm_host *host,int block, +struct file_lock *fl,struct cred *acred) {struct nlm_rqst *req;unsigned long flags;
@@ -695,7 +701,7 @@ static int nlmclnt_cancel(struct nlm_host *host, int block, struct file_lock *flrecalc_sigpending ();spin_unlock_irqrestore (¤t->sighand->siglock, flags); - req =nlm_alloc_call (nlm_get_host (host)); + req =nlm_alloc_call (nlm_get_host (host), acred);if (!req)return -ENOMEM ; req->a_flags =RPC_TASK_ASYNC ;
fs/lockd/host.c +3 -3
@@ -163,7 +163,7 @@ nlm_destroy_host(struct nlm_host *host)/* * Release NSM handle and unmonitor host. */ -nsm_unmonitor (host); +nsm_unmonitor (host, current->cred); clnt = host->h_rpcclnt;if (clnt !=NULL )
@@ -203,7 +203,7 @@ nlmsvc_lookup_host(struct svc_rqst *rqstp,* Create the NLM RPC client for an NLM peer */ struct rpc_clnt * -nlm_bind_host (struct nlm_host *host) +nlm_bind_host (struct nlm_host *host,struct cred *acred) {struct rpc_clnt *clnt;
@@ -246,7 +246,7 @@ nlm_bind_host(struct nlm_host *host) RPC_CLNT_CREATE_AUTOBIND), }; - clnt =rpc_create (&args); + clnt =rpc_create (&args, acred);if (!IS_ERR (clnt)) host->h_rpcclnt = clnt;else {
fs/lockd/mon.c +11 -10
@@ -17,7 +17,7 @@#define NLMDBG_FACILITY NLMDBG_MONITOR -static struct rpc_clnt *nsm_create (void ); +static struct rpc_clnt *nsm_create (struct cred *);static struct rpc_program nsm_program;
@@ -30,7 +30,8 @@ int nsm_local_state;* Common procedure for SM_MON/SM_UNMON calls */ static int -nsm_mon_unmon (struct nsm_handle *nsm,u32 proc,struct nsm_res *res) +nsm_mon_unmon (struct nsm_handle *nsm,u32 proc,struct nsm_res *res, +struct cred *acred) {struct rpc_clnt *clnt;int status;
@@ -40,7 +41,7 @@ nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res) .rpc_resp = res, }; - clnt =nsm_create (); + clnt =nsm_create (acred);if (IS_ERR (clnt)) { status =PTR_ERR (clnt); goto out;
@@ -55,7 +56,7 @@ nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res)memset (res,0 ,sizeof (*res)); msg.rpc_proc = &clnt->cl_procinfo[proc]; - status =rpc_call_sync (clnt, &msg,0 ); + status =rpc_call_sync (clnt, &msg,0 , acred);if (status <0 )printk (KERN_DEBUG "nsm_mon_unmon: rpc failed, status=%d\n" , status);
@@ -70,7 +71,7 @@ nsm_mon_unmon(struct nsm_handle *nsm, u32 proc, struct nsm_res *res)* Set up monitoring of a remote host */ int -nsm_monitor (struct nlm_host *host) +nsm_monitor (struct nlm_host *host,struct cred *acred) {struct nsm_handle *nsm = host->h_nsmhandle;struct nsm_res res;
@@ -82,7 +83,7 @@ nsm_monitor(struct nlm_host *host)if (nsm->sm_monitored)return 0 ; - status =nsm_mon_unmon (nsm,SM_MON , &res); + status =nsm_mon_unmon (nsm,SM_MON , &res, acred);if (status <0 || res.status !=0 )printk (KERN_NOTICE "lockd: cannot monitor %s\n" , host->h_name);
@@ -95,7 +96,7 @@ nsm_monitor(struct nlm_host *host)* Cease to monitor remote host */ int -nsm_unmonitor (struct nlm_host *host) +nsm_unmonitor (struct nlm_host *host,struct cred *acred) {struct nsm_handle *nsm = host->h_nsmhandle;struct nsm_res res;
@@ -109,7 +110,7 @@ nsm_unmonitor(struct nlm_host *host) && nsm->sm_monitored && !nsm->sm_sticky) {dprintk ("lockd: nsm_unmonitor(%s)\n" , host->h_name); - status =nsm_mon_unmon (nsm,SM_UNMON , &res); + status =nsm_mon_unmon (nsm,SM_UNMON , &res, acred);if (status <0 )printk (KERN_NOTICE "lockd: cannot unmonitor %s\n" , host->h_name);
@@ -124,7 +125,7 @@ nsm_unmonitor(struct nlm_host *host)* Create NSM client for the local host */ static struct rpc_clnt * -nsm_create (void ) +nsm_create (struct cred *acred) {struct sockaddr_in sin = { .sin_family =AF_INET ,
@@ -141,7 +142,7 @@ nsm_create(void) .authflavor = RPC_AUTH_NULL, }; -return rpc_create (&args); +return rpc_create (&args, acred); }/*
fs/lockd/svc.c +1 -1
@@ -264,7 +264,7 @@ static int make_socks(struct svc_serv *serv, int proto)* Bring up the lockd process if it's not already up. */ int -lockd_up (int proto)/* Maybe add a 'family' option when IPv6 is supported ?? */ +lockd_up (int proto,struct cred *acred)/* Maybe add a 'family' option when IPv6 is supported ?? */ {struct svc_serv * serv;int error =0 ;
fs/lockd/svc4proc.c +3 -3
@@ -39,7 +39,7 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,/* Obtain host handle */ if (!(host =nlmsvc_lookup_host (rqstp, lock->caller, lock->len)) - || (argp->monitor &&nsm_monitor (host) <0 )) + || (argp->monitor &&nsm_monitor (host, current->cred) <0 )) goto no_locks; *hostp = host;
@@ -242,7 +242,7 @@ static void nlm4svc_callback_exit(struct rpc_task *task, void *data) -task->tk_status); } -static void nlm4svc_callback_release (void *data) +static void nlm4svc_callback_release (struct cred *acred,void *data) {nlm_release_call (data); }
@@ -270,7 +270,7 @@ static __be32 nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_argsif (host ==NULL )return rpc_system_err; - call =nlm_alloc_call (host); + call =nlm_alloc_call (host, current->cred);if (call ==NULL )return rpc_system_err;
fs/lockd/svclock.c +8 -5
@@ -174,12 +174,12 @@ found:static struct nlm_block *nlmsvc_create_block (struct svc_rqst *rqstp,struct nlm_host *host,struct nlm_file *file,struct nlm_lock *lock, -struct nlm_cookie *cookie) +struct nlm_cookie *cookie,struct cred *acred) {struct nlm_block *block;struct nlm_rqst *call =NULL ; - call =nlm_alloc_call (host); + call =nlm_alloc_call (host, acred);if (call ==NULL )return NULL ;
@@ -360,6 +360,7 @@ __be32 nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, struct nlm_lock *lock, int wait, struct nlm_cookie *cookie) { + struct cred *acred = current->cred;struct nlm_block *block =NULL ;struct nlm_host *host;int error;
@@ -386,7 +387,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, block =nlmsvc_lookup_block (file, lock);if (block ==NULL ) { block =nlmsvc_create_block (rqstp,nlm_get_host (host), file, - lock, cookie); + lock, cookie, acred); ret = nlm_lck_denied_nolocks;if (block ==NULL ) goto out;
@@ -463,6 +464,7 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, struct nlm_lock *lock, struct nlm_lock *conflock, struct nlm_cookie *cookie) { + struct cred *acred = current->cred;struct nlm_block *block =NULL ;int error;__be32 ret;
@@ -489,7 +491,8 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,kfree (conf);return nlm_lck_denied_nolocks; } - block =nlmsvc_create_block (rqstp, host, file, lock, cookie); + block =nlmsvc_create_block (rqstp, host, file, lock, cookie, + acred);if (block ==NULL ) {kfree (conf);return nlm_granted;
@@ -796,7 +799,7 @@ static void nlmsvc_grant_callback(struct rpc_task *task, void *data)svc_wake_up (block->b_daemon); } -static void nlmsvc_grant_release (void *data) +static void nlmsvc_grant_release (struct cred *acred,void *data) {struct nlm_rqst *call = data;
fs/lockd/svcproc.c +4 -3
@@ -68,7 +68,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,/* Obtain host handle */ if (!(host =nlmsvc_lookup_host (rqstp, lock->caller, lock->len)) - || (argp->monitor &&nsm_monitor (host) <0 )) + || (argp->monitor &&nsm_monitor (host, current->cred) <0 )) goto no_locks; *hostp = host;
@@ -272,7 +272,7 @@ static void nlmsvc_callback_exit(struct rpc_task *task, void *data) -task->tk_status); } -static void nlmsvc_callback_release (void *data) +static void nlmsvc_callback_release (struct cred *acred,void *data) {nlm_release_call (data); }
@@ -290,6 +290,7 @@ static const struct rpc_call_ops nlmsvc_callback_ops = {static __be32 nlmsvc_callback (struct svc_rqst *rqstp,u32 proc,struct nlm_args *argp,__be32 (*func)(struct svc_rqst *,struct nlm_args *,struct nlm_res *)) { +struct cred *acred = current->cred;struct nlm_host *host;struct nlm_rqst *call;__be32 stat;
@@ -300,7 +301,7 @@ static __be32 nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_argsif (host ==NULL )return rpc_system_err; - call =nlm_alloc_call (host); + call =nlm_alloc_call (host, acred);if (call ==NULL )return rpc_system_err;
fs/nfs/callback.c +1 -1
@@ -107,7 +107,7 @@ static void nfs_callback_svc(struct svc_rqst *rqstp)/* * Bring up the server process if it is not already up. */ -int nfs_callback_up (void ) +int nfs_callback_up (struct cred *acred) {struct svc_serv *serv;int ret =0 ;
fs/nfs/callback.h +1 -1
@@ -63,7 +63,7 @@ extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getatextern __be32 nfs4_callback_recall (struct cb_recallargs *args,void *dummy);#ifdef CONFIG_NFS_V4 -extern int nfs_callback_up (void ); +extern int nfs_callback_up (struct cred *acred);extern void nfs_callback_down (void );#else #define nfs_callback_up () (0)
fs/nfs/client.c +61 -42
346 lines not on this page · raw message
fs/nfs/delegation.c +17 -7
@@ -29,6 +29,7 @@ static void nfs_free_delegation_callback(struct rcu_head *head) { struct nfs_delegation *delegation = container_of(head, struct nfs_delegation, rcu); +put_cred (delegation->acred);nfs_do_free_delegation (delegation); }
@@ -106,7 +107,8 @@ again:/* * Set up a delegation on an inode */ -void nfs_inode_reclaim_delegation (struct inode *inode,struct rpc_cred *cred,struct nfs_openres *res) +void nfs_inode_reclaim_delegation (struct inode *inode,struct rpc_cred *cred, +struct nfs_openres *res,struct cred *acred) {struct nfs_delegation *delegation =NFS_I (inode)->delegation;
@@ -118,6 +120,8 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, st delegation->maxsize = res->maxsize;put_rpccred (cred); delegation->cred =get_rpccred (cred); +put_cred (delegation->acred); + delegation->acred =get_cred (acred); delegation->flags &= ~NFS_DELEGATION_NEED_RECLAIM ;NFS_I (inode)->delegation_state = delegation->type;smp_wmb ();
@@ -126,7 +130,8 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, st/* * Set up a delegation on an inode */ -int nfs_inode_set_delegation (struct inode *inode,struct rpc_cred *cred,struct nfs_openres *res) +int nfs_inode_set_delegation (struct inode *inode,struct rpc_cred *cred, +struct nfs_openres *res,struct cred *acred) {struct nfs_client *clp =NFS_SERVER (inode)->nfs_client;struct nfs_inode *nfsi =NFS_I (inode);
@@ -142,6 +147,7 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct delegation->maxsize = res->maxsize; delegation->change_attr = nfsi->change_attr; delegation->cred =get_rpccred (cred); + delegation->acred =get_cred (acred); delegation->inode = inode;spin_lock (&clp->cl_lock);
@@ -170,11 +176,14 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, structreturn status; } -static int nfs_do_return_delegation (struct inode *inode,struct nfs_delegation *delegation) +static int nfs_do_return_delegation (struct inode *inode, +struct nfs_delegation *delegation, +struct cred *acred) {int res =0 ; - res =nfs4_proc_delegreturn (inode, delegation->cred, &delegation->stateid); + res =nfs4_proc_delegreturn (inode, delegation->cred, + &delegation->stateid, acred);nfs_free_delegation (delegation);return res; }
@@ -190,7 +199,8 @@ static void nfs_msync_inode(struct inode *inode)/* * Basic procedure for returning a delegation to the server */ -static int __nfs_inode_return_delegation (struct inode *inode,struct nfs_delegation *delegation) +static int __nfs_inode_return_delegation (struct inode *inode, +struct nfs_delegation *delegation) {struct nfs_client *clp =NFS_SERVER (inode)->nfs_client;struct nfs_inode *nfsi =NFS_I (inode);
@@ -204,7 +214,7 @@ static int __nfs_inode_return_delegation(struct inode *inode, struct nfs_delegatup_read (&clp->cl_sem);nfs_msync_inode (inode); -return nfs_do_return_delegation (inode, delegation); +return nfs_do_return_delegation (inode, delegation, delegation->acred); }static struct nfs_delegation *nfs_detach_delegation_locked (struct nfs_inode *nfsi,const nfs4_stateid *stateid)
@@ -383,7 +393,7 @@ static int recall_thread(void *data)nfs_msync_inode (inode);if (delegation !=NULL ) -nfs_do_return_delegation (inode, delegation); +nfs_do_return_delegation (inode, delegation, &init_cred);iput (inode);module_put_and_exit (0 ); }
fs/nfs/delegation.h +7 -3
@@ -15,6 +15,7 @@struct nfs_delegation {struct list_head super_list;struct rpc_cred *cred; +struct cred *acred;struct inode *inode;nfs4_stateid stateid;int type;
@@ -25,8 +26,10 @@ struct nfs_delegation {struct rcu_head rcu; }; -int nfs_inode_set_delegation (struct inode *inode,struct rpc_cred *cred,struct nfs_openres *res); -void nfs_inode_reclaim_delegation (struct inode *inode,struct rpc_cred *cred,struct nfs_openres *res); +int nfs_inode_set_delegation (struct inode *inode,struct rpc_cred *cred, +struct nfs_openres *res,struct cred *acred); +void nfs_inode_reclaim_delegation (struct inode *inode,struct rpc_cred *cred, +struct nfs_openres *res,struct cred *acred);int nfs_inode_return_delegation (struct inode *inode);int nfs_async_inode_return_delegation (struct inode *inode,const nfs4_stateid *stateid);
@@ -39,7 +42,8 @@ void nfs_delegation_mark_reclaim(struct nfs_client *clp);void nfs_delegation_reap_unclaimed (struct nfs_client *clp);/* NFSv4 delegation-related procedures */ -int nfs4_proc_delegreturn (struct inode *inode,struct rpc_cred *cred,const nfs4_stateid *stateid); +int nfs4_proc_delegreturn (struct inode *inode,struct rpc_cred *cred, +const nfs4_stateid *stateid,struct cred *acred);int nfs4_open_delegation_recall (struct nfs_open_context *ctx,struct nfs4_state *state,const nfs4_stateid *stateid);int nfs4_lock_delegation_recall (struct nfs4_state *state,struct file_lock *fl);int nfs4_copy_delegation_stateid (nfs4_stateid *dst,struct inode *inode);
fs/nfs/dir.c +69 -42
438 lines not on this page · raw message
fs/nfs/direct.c +15 -14
@@ -291,14 +291,14 @@ static ssize_t nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned lo data->npages, 1, 0, data->pagevec, NULL);up_read (¤t->mm->mmap_sem);if (result <0 ) { -nfs_readdata_release (data); +nfs_readdata_release (ctx->acred, data);break ; }if ((unsigned )result < data->npages) { bytes = result *PAGE_SIZE ;if (bytes <= pgbase) {nfs_direct_release_pages (data->pagevec, result); -nfs_readdata_release (data); +nfs_readdata_release (ctx->acred, data);break ; } bytes -= pgbase;
@@ -321,8 +321,8 @@ static ssize_t nfs_direct_read_schedule(struct nfs_direct_req *dreq, unsigned lo data->res.count = bytes;rpc_init_task (&data->task,NFS_CLIENT (inode),RPC_TASK_ASYNC , - &nfs_read_direct_ops, data); -NFS_PROTO (inode)->read_setup (data); + &nfs_read_direct_ops, data, ctx->acred); +NFS_PROTO (inode)->read_setup (data, ctx->acred); data->task.tk_cookie = (unsigned long ) inode;
@@ -389,7 +389,7 @@ static void nfs_direct_free_writedata(struct nfs_direct_req *dreq) struct nfs_write_data *data = list_entry(dreq->rewrite_list.next, struct nfs_write_data, pages);list_del (&data->pages);nfs_direct_release_pages (data->pagevec, data->npages); -nfs_writedata_release (data); +nfs_writedata_release (dreq->ctx->acred, data); } }
@@ -420,8 +420,9 @@ static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)* since the original request was sent. */ rpc_init_task (&data->task,NFS_CLIENT (inode),RPC_TASK_ASYNC , - &nfs_write_direct_ops, data); -NFS_PROTO (inode)->write_setup (data,FLUSH_STABLE ); + &nfs_write_direct_ops, data, dreq->ctx->acred); +NFS_PROTO (inode)->write_setup (data,FLUSH_STABLE , + dreq->ctx->acred); data->task.tk_priority =RPC_PRIORITY_NORMAL ; data->task.tk_cookie = (unsigned long ) inode;
@@ -484,8 +485,8 @@ static void nfs_direct_commit_schedule(struct nfs_direct_req *dreq) data->res.verf = &data->verf;rpc_init_task (&data->task,NFS_CLIENT (dreq->inode),RPC_TASK_ASYNC , - &nfs_commit_direct_ops, data); -NFS_PROTO (data->inode)->commit_setup (data,0 ); + &nfs_commit_direct_ops, data, dreq->ctx->acred); +NFS_PROTO (data->inode)->commit_setup (data,0 , dreq->ctx->acred); data->task.tk_priority =RPC_PRIORITY_NORMAL ; data->task.tk_cookie = (unsigned long )data->inode;
@@ -582,7 +583,7 @@ out_unlock:* NB: Return the value of the first error return code. Subsequent * errors after the first one are ignored. */ -static void nfs_direct_write_release (void *calldata) +static void nfs_direct_write_release (struct cred *acred,void *calldata) {struct nfs_write_data *data = calldata;struct nfs_direct_req *dreq = (struct nfs_direct_req *) data->req;
@@ -631,14 +632,14 @@ static ssize_t nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned l data->npages, 0, 0, data->pagevec, NULL);up_read (¤t->mm->mmap_sem);if (result <0 ) { -nfs_writedata_release (data); +nfs_writedata_release (ctx->acred, data);break ; }if ((unsigned )result < data->npages) { bytes = result *PAGE_SIZE ;if (bytes <= pgbase) {nfs_direct_release_pages (data->pagevec, result); -nfs_writedata_release (data); +nfs_writedata_release (ctx->acred, data);break ; } bytes -= pgbase;
@@ -663,8 +664,8 @@ static ssize_t nfs_direct_write_schedule(struct nfs_direct_req *dreq, unsigned l data->res.verf = &data->verf;rpc_init_task (&data->task,NFS_CLIENT (inode),RPC_TASK_ASYNC , - &nfs_write_direct_ops, data); -NFS_PROTO (inode)->write_setup (data, sync); + &nfs_write_direct_ops, data, ctx->acred); +NFS_PROTO (inode)->write_setup (data, sync, ctx->acred); data->task.tk_priority =RPC_PRIORITY_NORMAL ; data->task.tk_cookie = (unsigned long ) inode;
fs/nfs/file.c +9 -5
@@ -158,7 +158,7 @@ static int nfs_revalidate_file_size(struct inode *inode, struct file *filp)if (!(nfsi->cache_validity &NFS_INO_REVAL_PAGECACHE ) && !nfs_attribute_timeout (inode))return 0 ; force_reval: -return __nfs_revalidate_inode (server, inode); +return __nfs_revalidate_inode (server, inode, filp->f_cred); }static loff_t nfs_file_llseek (struct file *filp,loff_t offset,int origin)
@@ -196,7 +196,8 @@ nfs_file_flush(struct file *file, fl_owner_t id) status = ctx->error; ctx->error =0 ;if (!status) -nfs_revalidate_inode (NFS_SERVER (inode), inode); +nfs_revalidate_inode (NFS_SERVER (inode), inode, + ctx->acred); }unlock_kernel ();return status;
@@ -208,6 +209,7 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov, {struct dentry * dentry = iocb->ki_filp->f_path.dentry;struct inode * inode = dentry->d_inode; +struct cred *acred = iocb->ki_filp->f_cred;ssize_t result;size_t count =iov_length (iov, nr_segs);
@@ -220,7 +222,7 @@ nfs_file_read(struct kiocb *iocb, const struct iovec *iov, dentry->d_parent->d_name.name, dentry->d_name.name, (unsigned long) count, (unsigned long) pos); - result =nfs_revalidate_mapping (inode, iocb->ki_filp->f_mapping); + result =nfs_revalidate_mapping (inode, iocb->ki_filp->f_mapping, acred);nfs_add_stats (inode,NFSIOS_NORMALREADBYTES , count);if (!result) result =generic_file_aio_read (iocb, iov, nr_segs, pos);
@@ -234,13 +236,14 @@ nfs_file_splice_read(struct file *filp, loff_t *ppos, {struct dentry *dentry = filp->f_path.dentry;struct inode *inode = dentry->d_inode; +struct cred *acred = filp->f_cred;ssize_t res;dfprintk (VFS ,"nfs: splice_read(%s/%s, %lu@%Lu)\n" , dentry->d_parent->d_name.name, dentry->d_name.name, (unsigned long ) count, (unsigned long long ) *ppos); - res =nfs_revalidate_mapping (inode, filp->f_mapping); + res =nfs_revalidate_mapping (inode, filp->f_mapping, acred);if (!res) res =generic_file_splice_read (filp, ppos, pipe, count, flags);return res;
@@ -251,12 +254,13 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma) {struct dentry *dentry = file->f_path.dentry;struct inode *inode = dentry->d_inode; +struct cred *acred = file->f_cred;int status;dfprintk (VFS ,"nfs: mmap(%s/%s)\n" , dentry->d_parent->d_name.name, dentry->d_name.name); - status =nfs_revalidate_mapping (inode, file->f_mapping); + status =nfs_revalidate_mapping (inode, file->f_mapping, acred);if (!status) status =generic_file_mmap (file, vma);return status;
fs/nfs/getroot.c +14 -8
@@ -45,7 +45,8 @@/* * get an NFS2/NFS3 root dentry from the root filehandle */ -struct dentry *nfs_get_root (struct super_block *sb,struct nfs_fh *mntfh) +struct dentry *nfs_get_root (struct super_block *sb,struct nfs_fh *mntfh, +struct cred *acred) {struct nfs_server *server =NFS_SB (sb);struct nfs_fsinfo fsinfo;
@@ -84,7 +85,8 @@ struct dentry *nfs_get_root(struct super_block *sb, struct nfs_fh *mntfh)/* get the actual root for this mount */ fsinfo.fattr = &fattr; - error = server->nfs_client->rpc_ops->getroot (server, mntfh, &fsinfo); + error = server->nfs_client->rpc_ops->getroot (server, mntfh, &fsinfo, + acred);if (error <0 ) {dprintk ("nfs_get_root: getattr error = %d\n" , -error);return ERR_PTR (error);
@@ -126,7 +128,8 @@ struct dentry *nfs_get_root(struct super_block *sb, struct nfs_fh *mntfh)*/ int nfs4_path_walk (struct nfs_server *server,struct nfs_fh *mntfh, -const char *path) +const char *path, +struct cred *acred) {struct nfs_fsinfo fsinfo;struct nfs_fattr fattr;
@@ -144,7 +147,8 @@ int nfs4_path_walk(struct nfs_server *server, path++;/* Start by getting the root filehandle from the server */ - ret = server->nfs_client->rpc_ops->getroot (server, mntfh, &fsinfo); + ret = server->nfs_client->rpc_ops->getroot (server, mntfh, &fsinfo, + acred);if (ret <0 ) {dprintk ("nfs4_get_root: getroot error = %d\n" , -ret);return ret;
@@ -201,7 +205,7 @@ eat_dot_dir:dprintk ("LookupFH: %*.*s [%s]\n" , name.len, name.len, name.name, path); ret = server->nfs_client->rpc_ops->lookupfh (server, &lastfh, &name, - mntfh, &fattr); + mntfh, &fattr, acred);if (ret <0 ) {dprintk ("nfs4_get_root: getroot error = %d\n" , -ret);return ret;
@@ -231,7 +235,8 @@ path_walk_complete:/* * get an NFS4 root dentry from the root filehandle */ -struct dentry *nfs4_get_root (struct super_block *sb,struct nfs_fh *mntfh) +struct dentry *nfs4_get_root (struct super_block *sb,struct nfs_fh *mntfh, +struct cred *acred) {struct nfs_server *server =NFS_SB (sb);struct nfs_fattr fattr;
@@ -269,7 +274,7 @@ struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh) }/* get the info about the server and filesystem */ - error =nfs4_server_capabilities (server, mntfh); + error =nfs4_server_capabilities (server, mntfh, acred);if (error <0 ) {dprintk ("nfs_get_root: getcaps error = %d\n" , -error);
@@ -277,7 +282,8 @@ struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh) }/* get the actual root for this mount */ - error = server->nfs_client->rpc_ops->getattr (server, mntfh, &fattr); + error = server->nfs_client->rpc_ops->getattr (server, mntfh, &fattr, + acred);if (error <0 ) {dprintk ("nfs_get_root: getattr error = %d\n" , -error);return ERR_PTR (error);
fs/nfs/inode.c +31 -14
149 lines not on this page · raw message
fs/nfs/internal.h +16 -8
@@ -33,20 +33,23 @@ extern struct rpc_program nfs_program;extern void nfs_put_client (struct nfs_client *);extern struct nfs_client *nfs_find_client (const struct sockaddr_in *,int );extern struct nfs_server *nfs_create_server (const struct nfs_mount_data *, -struct nfs_fh *); +struct nfs_fh *,struct cred *);extern struct nfs_server *nfs4_create_server (const struct nfs4_mount_data *,const char *,const struct sockaddr_in *,const char *,const char *,rpc_authflavor_t , -struct nfs_fh *); +struct nfs_fh *, +struct cred *);extern struct nfs_server *nfs4_create_referral_server (struct nfs_clone_mount *, -struct nfs_fh *); +struct nfs_fh *, +struct cred *);extern void nfs_free_server (struct nfs_server *server);extern struct nfs_server *nfs_clone_server (struct nfs_server *,struct nfs_fh *, -struct nfs_fattr *); +struct nfs_fattr *, +struct cred *);#ifdef CONFIG_PROC_FS extern int __init nfs_fs_proc_init (void );extern void nfs_fs_proc_exit (void );
@@ -62,7 +65,9 @@ static inline void nfs_fs_proc_exit(void)/* nfs4namespace.c */ #ifdef CONFIG_NFS_V4 -extern struct vfsmount *nfs_do_refmount (const struct vfsmount *mnt_parent,struct dentry *dentry); +extern struct vfsmount *nfs_do_refmount (const struct vfsmount *mnt_parent, +struct dentry *dentry, +struct cred *acred);#else static inline struct vfsmount *nfs_do_refmount (const struct vfsmount *mnt_parent,struct dentry *dentry)
@@ -140,13 +145,16 @@ extern char *nfs_path(const char *base, char *buffer, ssize_t buflen);/* getroot.c */ -extern struct dentry *nfs_get_root (struct super_block *,struct nfs_fh *); +extern struct dentry *nfs_get_root (struct super_block *,struct nfs_fh *, +struct cred *);#ifdef CONFIG_NFS_V4 -extern struct dentry *nfs4_get_root (struct super_block *,struct nfs_fh *); +extern struct dentry *nfs4_get_root (struct super_block *,struct nfs_fh *, +struct cred *);extern int nfs4_path_walk (struct nfs_server *server,struct nfs_fh *mntfh, -const char *path); +const char *path, +struct cred *acred);#endif /*
fs/nfs/mount_clnt.c +4 -3
@@ -35,11 +35,12 @@ struct mnt_fhstatus {* @version: mount version to use for this request * @protocol: transport protocol to use for thie request * @fh: pointer to location to place returned file handle +* @cred: the credentials to use * * Uses default timeout parameters specified by underlying transport. */ int nfs_mount (struct sockaddr *addr,size_t len,char *hostname,char *path, -int version,int protocol,struct nfs_fh *fh) +int version,int protocol,struct nfs_fh *fh,struct cred *acred) {struct mnt_fhstatus result = { .fh = fh
@@ -64,7 +65,7 @@ int nfs_mount(struct sockaddr *addr, size_t len, char *hostname, char *path,dprintk ("NFS: sending MNT request for %s:%s\n" , (hostname ? hostname :"server" ), path); - mnt_clnt =rpc_create (&args); + mnt_clnt =rpc_create (&args, acred);if (IS_ERR (mnt_clnt)) goto out_clnt_err;
@@ -73,7 +74,7 @@ int nfs_mount(struct sockaddr *addr, size_t len, char *hostname, char *path,else msg.rpc_proc = &mnt_clnt->cl_procinfo[MNTPROC_MNT ]; - status =rpc_call_sync (mnt_clnt, &msg,0 ); + status =rpc_call_sync (mnt_clnt, &msg,0 , acred);rpc_shutdown_client (mnt_clnt);if (status <0 )
fs/nfs/namespace.c +3 -2
@@ -96,6 +96,7 @@ Elong:*/ static void *nfs_follow_mountpoint (struct dentry *dentry,struct nameidata *nd) { +struct cred *acred = current->cred;struct vfsmount *mnt;struct nfs_server *server =NFS_SERVER (dentry->d_inode);struct dentry *parent;
@@ -114,13 +115,13 @@ static void * nfs_follow_mountpoint(struct dentry *dentry, struct nameidata *nd) parent =dget_parent (nd->dentry); err = server->nfs_client->rpc_ops->lookup (parent->d_inode, &nd->dentry->d_name, - &fh, &fattr); + &fh, &fattr, acred);dput (parent);if (err !=0 ) goto out_err;if (fattr.valid &NFS_ATTR_FATTR_V4_REFERRAL ) - mnt =nfs_do_refmount (nd->mnt, nd->dentry); + mnt =nfs_do_refmount (nd->mnt, nd->dentry, acred);else mnt =nfs_do_submount (nd->mnt, nd->dentry, &fh, &fattr); err =PTR_ERR (mnt);
fs/nfs/nfs3acl.c +25 -18
167 lines not on this page · raw message
fs/nfs/nfs3proc.c +71 -59
452 lines not on this page · raw message
fs/nfs/nfs4_fs.h +20 -10
@@ -174,16 +174,25 @@ extern ssize_t nfs4_listxattr(struct dentry *, char *, size_t);/* nfs4proc.c */ extern int nfs4_map_errors (int err); -extern int nfs4_proc_setclientid (struct nfs_client *,u32 ,unsigned short ,struct rpc_cred *); -extern int nfs4_proc_setclientid_confirm (struct nfs_client *,struct rpc_cred *); -extern int nfs4_proc_async_renew (struct nfs_client *,struct rpc_cred *); -extern int nfs4_proc_renew (struct nfs_client *,struct rpc_cred *); -extern int nfs4_do_close (struct path *path,struct nfs4_state *state); -extern struct dentry *nfs4_atomic_open (struct inode *,struct dentry *,struct nameidata *); -extern int nfs4_open_revalidate (struct inode *,struct dentry *,int ,struct nameidata *); -extern int nfs4_server_capabilities (struct nfs_server *server,struct nfs_fh *fhandle); +extern int nfs4_proc_setclientid (struct nfs_client *,u32 ,unsigned short , +struct rpc_cred *,struct cred *); +extern int nfs4_proc_setclientid_confirm (struct nfs_client *,struct rpc_cred *, +struct cred *); +extern int nfs4_proc_async_renew (struct nfs_client *,struct rpc_cred *, +struct cred *); +extern int nfs4_proc_renew (struct nfs_client *,struct rpc_cred *, +struct cred *); +extern int nfs4_do_close (struct path *path,struct nfs4_state *state, +struct cred *acred); +extern struct dentry *nfs4_atomic_open (struct inode *,struct dentry *, +struct nameidata *,struct cred *); +extern int nfs4_open_revalidate (struct inode *,struct dentry *,int , +struct nameidata *,struct cred *); +extern int nfs4_server_capabilities (struct nfs_server *server,struct nfs_fh *fhandle, +struct cred *acred);extern int nfs4_proc_fs_locations (struct inode *dir,const struct qstr *name, -struct nfs4_fs_locations *fs_locations,struct page *page); +struct nfs4_fs_locations *fs_locations,struct page *page, +struct cred *acred);extern struct nfs4_state_recovery_ops nfs4_reboot_recovery_ops;extern struct nfs4_state_recovery_ops nfs4_network_partition_recovery_ops;
@@ -208,7 +217,8 @@ extern void nfs4_put_state_owner(struct nfs4_state_owner *);extern void nfs4_drop_state_owner (struct nfs4_state_owner *);extern struct nfs4_state *nfs4_get_open_state (struct inode *,struct nfs4_state_owner *);extern void nfs4_put_open_state (struct nfs4_state *); -extern void nfs4_close_state (struct path *,struct nfs4_state *,mode_t ); +extern void nfs4_close_state (struct path *,struct nfs4_state *,mode_t , +struct cred *);extern void nfs4_state_set_mode_locked (struct nfs4_state *,mode_t );extern void nfs4_schedule_state_recovery (struct nfs_client *);extern void nfs4_put_lock_state (struct nfs4_lock_state *lsp);
fs/nfs/nfs4namespace.c +5 -2
@@ -212,9 +212,11 @@ out:* nfs_do_refmount - handle crossing a referral on server * @dentry - dentry of referral * @nd - nameidata info +* @acred - the credentials to use * */ -struct vfsmount *nfs_do_refmount (const struct vfsmount *mnt_parent,struct dentry *dentry) +struct vfsmount *nfs_do_refmount (const struct vfsmount *mnt_parent, +struct dentry *dentry,struct cred *acred) {struct vfsmount *mnt =ERR_PTR (-ENOMEM );struct dentry *parent;
@@ -240,7 +242,8 @@ struct vfsmount *nfs_do_refmount(const struct vfsmount *mnt_parent, struct dentrdprintk ("%s: getting locations for %s/%s\n" , __FUNCTION__, parent->d_name.name, dentry->d_name.name); - err =nfs4_proc_fs_locations (parent->d_inode, &dentry->d_name, fs_locations, page); + err =nfs4_proc_fs_locations (parent->d_inode, &dentry->d_name, + fs_locations, page, acred);dput (parent); if (err != 0 || fs_locations->nlocations <= 0 ||
fs/nfs/nfs4proc.c +295 -201
584 lines not on this page · raw message
fs/nfs/proc.c +54 -45
99 lines not on this page · raw message
fs/nfs/super.c +25 -16
41 lines not on this page · raw message
include/linux/nfs_xdr.h +31 -23
54 lines not on this page · raw message
net/sunrpc/clnt.c +31 -19
50 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
David Howells
maintainerPATCH 21/52 CRED: Pass credentials through the truncate() inode operation
In reply to David HowellsPass credentials through the truncate() inode operation.
---
fs/attr.c | 3 ++- fs/buffer.c | 3 ++- fs/ext3/inode.c | 6 +++--- fs/ext3/super.c | 3 ++- fs/fat/file.c | 2 +- fs/fat/inode.c | 4 +++- fs/nfs/inode.c | 4 +++- fs/splice.c | 2 +- include/linux/ext3_fs.h | 2 +- include/linux/fs.h | 2 +- include/linux/mm.h | 3 ++- include/linux/msdos_fs.h | 2 +- mm/filemap.c | 3 ++- mm/memory.c | 5 +++-- mm/shmem.c | 4 ++-- 15 files changed, 29 insertions(+), 19 deletions(-)
fs/attr.c +2 -1
@@ -68,11 +68,12 @@ EXPORT_SYMBOL(inode_change_ok);int inode_setattr (struct inode * inode,struct iattr * attr) { +struct cred *cred = current->cred;unsigned int ia_valid = attr->ia_valid;if (ia_valid &ATTR_SIZE && attr->ia_size !=i_size_read (inode)) { -int error =vmtruncate (inode, attr->ia_size); +int error =vmtruncate (inode, attr->ia_size, cred);if (error)return error; }
fs/buffer.c +2 -1
@@ -2013,6 +2013,7 @@ int block_read_full_page(struct page *page, get_block_t *get_block)static int __generic_cont_expand (struct inode *inode,loff_t size,pgoff_t index,unsigned int offset) { +struct cred *cred = current->cred;struct address_space *mapping = inode->i_mapping;struct page *page;unsigned long limit;
@@ -2039,7 +2040,7 @@ static int __generic_cont_expand(struct inode *inode, loff_t size,*/ unlock_page (page);page_cache_release (page); -vmtruncate (inode, inode->i_size); +vmtruncate (inode, inode->i_size, cred); goto out; }
fs/ext3/inode.c +3 -3
@@ -181,6 +181,7 @@ static int ext3_journal_test_restart(handle_t *handle, struct inode *inode)*/ void ext3_delete_inode (struct inode * inode) { +struct cred *cred = &writeback_cred;handle_t *handle;truncate_inode_pages (&inode->i_data,0 );
@@ -203,7 +204,7 @@ void ext3_delete_inode (struct inode * inode) handle->h_sync =1 ; inode->i_size =0 ;if (inode->i_blocks) -ext3_truncate (inode); +ext3_truncate (inode, cred);/* * Kill off the orphan record which ext3_truncate created. * AKPM: I think this can be inside the above `if'.
@@ -2227,9 +2228,8 @@ static void ext3_free_branches(handle_t *handle, struct inode *inode,* that's fine - as long as they are linked from the inode, the post-crash * ext3_truncate() run will find them and release them. */ -void ext3_truncate (struct inode *inode) +void ext3_truncate (struct inode *inode,struct cred *cred) { -struct cred *cred = current->cred;handle_t *handle;struct ext3_inode_info *ei =EXT3_I (inode);__le32 *i_data = ei->i_data;
fs/ext3/super.c +2 -1
@@ -1259,6 +1259,7 @@ static int ext3_check_descriptors (struct super_block * sb)static void ext3_orphan_cleanup (struct super_block * sb,struct ext3_super_block * es) { +struct cred *cred = current->cred;unsigned int s_flags = sb->s_flags;int nr_orphans =0 , nr_truncates =0 ;#ifdef CONFIG_QUOTA
@@ -1321,7 +1322,7 @@ static void ext3_orphan_cleanup (struct super_block * sb, __FUNCTION__, inode->i_ino, inode->i_size);jbd_debug (2 ,"truncating inode %lu to %Ld bytes\n" , inode->i_ino, inode->i_size); -ext3_truncate (inode); +ext3_truncate (inode, cred); nr_truncates++; }else { printk(KERN_DEBUG
fs/fat/file.c +1 -1
@@ -282,7 +282,7 @@ static int fat_free(struct inode *inode, int skip)return fat_free_clusters (inode, free_start); } -void fat_truncate (struct inode *inode) +void fat_truncate (struct inode *inode,struct cred *cred) {struct msdos_sb_info *sbi =MSDOS_SB (inode->i_sb);const unsigned int cluster_size = sbi->cluster_size;
fs/fat/inode.c +3 -1
@@ -430,11 +430,13 @@ EXPORT_SYMBOL_GPL(fat_build_inode);static void fat_delete_inode (struct inode *inode) { +struct cred *cred = &writeback_cred; +truncate_inode_pages (&inode->i_data,0 );if (!is_bad_inode (inode)) { inode->i_size =0 ; -fat_truncate (inode); +fat_truncate (inode, cred); }clear_inode (inode); }
fs/nfs/inode.c +3 -1
@@ -368,6 +368,8 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)*/ void nfs_setattr_update_inode (struct inode *inode,struct iattr *attr) { +struct cred *acred = current->cred; +if ((attr->ia_valid & (ATTR_MODE |ATTR_UID |ATTR_GID )) !=0 ) {if ((attr->ia_valid &ATTR_MODE ) !=0 ) {int mode = attr->ia_mode &S_IALLUGO ;
@@ -385,7 +387,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr)if ((attr->ia_valid &ATTR_SIZE ) !=0 ) {nfs_inc_stats (inode,NFSIOS_SETATTRTRUNC ); inode->i_size = attr->ia_size; -vmtruncate (inode, attr->ia_size); +vmtruncate (inode, attr->ia_size, acred); } }
fs/splice.c +1 -1
@@ -612,7 +612,7 @@ find_page:* outside i_size. Trim these off again. */ if (sd->pos + this_len > isize) -vmtruncate (mapping->host, isize); +vmtruncate (mapping->host, isize, file->f_cred); goto out_ret; }
include/linux/ext3_fs.h +1 -1
@@ -827,7 +827,7 @@ extern void ext3_discard_reservation (struct inode *);extern void ext3_dirty_inode (struct inode *);extern int ext3_change_inode_journal_flag (struct inode *,int );extern int ext3_get_inode_loc (struct inode *,struct ext3_iloc *); -extern void ext3_truncate (struct inode *); +extern void ext3_truncate (struct inode *,struct cred *);extern void ext3_set_inode_flags (struct inode *);extern void ext3_get_inode_flags (struct ext3_inode_info *);extern void ext3_set_aops (struct inode *inode);
include/linux/fs.h +1 -1
@@ -1148,7 +1148,7 @@ struct inode_operations {int (*readlink) (struct dentry *,char __user *,int );void * (*follow_link) (struct dentry *,struct nameidata *);void (*put_link) (struct dentry *,struct nameidata *,void *); -void (*truncate) (struct inode *); +void (*truncate) (struct inode *,struct cred *);int (*permission) (struct inode *,int ,struct nameidata *);int (*setattr) (struct dentry *,struct iattr *);int (*getattr) (struct vfsmount *mnt,struct dentry *,struct kstat *);
include/linux/mm.h +2 -1
@@ -20,6 +20,7 @@ struct anon_vma;struct file_ra_state ;struct user_struct ;struct writeback_control ; +struct cred ;#ifndef CONFIG_DISCONTIGMEM /* Don't use mapnrs, do it properly */ extern unsigned long max_mapnr;
@@ -790,7 +791,7 @@ static inline void unmap_shared_mapping_range(struct address_space *mapping,unmap_mapping_range (mapping, holebegin, holelen,0 ); } -extern int vmtruncate (struct inode * inode,loff_t offset); +extern int vmtruncate (struct inode * inode,loff_t offset,struct cred *cred);extern int vmtruncate_range (struct inode * inode,loff_t offset,loff_t end);#ifdef CONFIG_MMU
include/linux/msdos_fs.h +1 -1
@@ -402,7 +402,7 @@ extern int fat_generic_ioctl(struct inode *inode, struct file *filp,extern const struct file_operations fat_file_operations;extern const struct inode_operations fat_file_inode_operations;extern int fat_notify_change (struct dentry * dentry,struct iattr * attr); -extern void fat_truncate (struct inode *inode); +extern void fat_truncate (struct inode *inode,struct cred *cred);extern int fat_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat);
mm/filemap.c +2 -1
@@ -1841,6 +1841,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov, size_t count, ssize_t written) {struct file *file = iocb->ki_filp; +struct cred *cred = file->f_cred;struct address_space * mapping = file->f_mapping;const struct address_space_operations *a_ops = mapping->a_ops;struct inode *inode = mapping->host;
@@ -1924,7 +1925,7 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,* outside i_size. Trim these off again. */ if (pos + bytes > isize) -vmtruncate (inode, isize); +vmtruncate (inode, isize, cred);break ; }if (likely (nr_segs ==1 ))
mm/memory.c +3 -2
@@ -1999,12 +1999,13 @@ EXPORT_SYMBOL(unmap_mapping_range);* vmtruncate - unmap mappings "freed" by truncate() syscall * @inode: inode of the file used * @offset: file offset to start truncating +* @cred: the credentials to use * * NOTE! We have to be ready to update the memory sharing * between the file and the memory map for a potential last * incomplete page. Ugly, but necessary. */ -int vmtruncate (struct inode * inode,loff_t offset) +int vmtruncate (struct inode * inode,loff_t offset,struct cred *cred) {struct address_space *mapping = inode->i_mapping;unsigned long limit;
@@ -2042,7 +2043,7 @@ do_expand: out_truncate:if (inode->i_op && inode->i_op->truncate) - inode->i_op->truncate (inode); + inode->i_op->truncate (inode, cred);return 0 ; out_sig:send_sig (SIGXFSZ , current,0 );
mm/shmem.c +2 -2
@@ -708,7 +708,7 @@ done2: } } -static void shmem_truncate (struct inode *inode) +static void shmem_truncate (struct inode *inode,struct cred *cred) {shmem_truncate_range (inode, inode->i_size, (loff_t)-1 ); }
@@ -770,7 +770,7 @@ static void shmem_delete_inode(struct inode *inode)truncate_inode_pages (inode->i_mapping,0 );shmem_unacct_size (info->flags, inode->i_size); inode->i_size =0 ; -shmem_truncate (inode); +shmem_truncate (inode, &writeback_cred);if (!list_empty (&info->swaplist)) {spin_lock (&shmem_swaplist_lock);list_del_init (&info->swaplist);
David Howells
maintainerPATCH 22/52 CRED: Pass credentials to nfs_setattr_update_inode()
In reply to David HowellsPass credentials to nfs_setattr_update_inode().
---
fs/nfs/inode.c | 6 +++--- fs/nfs/nfs3proc.c | 2 +- fs/nfs/nfs4proc.c | 4 ++-- fs/nfs/proc.c | 2 +- include/linux/nfs_fs.h | 3 ++- 5 files changed, 9 insertions(+), 8 deletions(-)
fs/nfs/inode.c +3 -3
@@ -362,14 +362,14 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)* nfs_setattr_update_inode - Update inode metadata after a setattr call. * @inode: pointer to struct inode * @attr: pointer to struct iattr +* @acred: the credentials to use * * Note: we do this in the *proc.c in order to ensure that * it works for things like exclusive creates too. */ -void nfs_setattr_update_inode (struct inode *inode,struct iattr *attr) +void nfs_setattr_update_inode (struct inode *inode,struct iattr *attr, +struct cred *acred) { -struct cred *acred = current->cred; -if ((attr->ia_valid & (ATTR_MODE |ATTR_UID |ATTR_GID )) !=0 ) {if ((attr->ia_valid &ATTR_MODE ) !=0 ) {int mode = attr->ia_mode &S_IALLUGO ;
fs/nfs/nfs3proc.c +1 -1
@@ -138,7 +138,7 @@ nfs3_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,nfs_fattr_init (fattr); status =rpc_call_sync (NFS_CLIENT (inode), &msg,0 , acred);if (status ==0 ) -nfs_setattr_update_inode (inode, sattr); +nfs_setattr_update_inode (inode, sattr, acred);dprintk ("NFS reply setattr: %d\n" , status);return status; }
fs/nfs/nfs4proc.c +2 -2
@@ -1725,7 +1725,7 @@ nfs4_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr, status =nfs4_do_setattr (inode, fattr, sattr, state, acred);if (status ==0 ) -nfs_setattr_update_inode (inode, sattr); +nfs_setattr_update_inode (inode, sattr, acred);if (ctx !=NULL )put_nfs_open_context (ctx);put_rpccred (cred);
@@ -1967,7 +1967,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, status =nfs4_do_setattr (state->inode, &fattr, sattr, state, acred);if (status ==0 ) -nfs_setattr_update_inode (state->inode, sattr); +nfs_setattr_update_inode (state->inode, sattr, acred);nfs_post_op_update_inode (state->inode, &fattr); }if (status ==0 && (nd->flags &LOOKUP_OPEN ) !=0 )
fs/nfs/proc.c +1 -1
@@ -134,7 +134,7 @@ nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,nfs_fattr_init (fattr); status =rpc_call_sync (NFS_CLIENT (inode), &msg,0 , acred);if (status ==0 ) -nfs_setattr_update_inode (inode, sattr); +nfs_setattr_update_inode (inode, sattr, acred);dprintk ("NFS reply setattr: %d\n" , status);return status; }
include/linux/nfs_fs.h +2 -1
@@ -307,7 +307,8 @@ extern int nfs_revalidate_mapping_nolock(struct inode *inode,struct address_space *mapping, struct cred *acred);extern int nfs_setattr (struct dentry *,struct iattr *); -extern void nfs_setattr_update_inode (struct inode *inode,struct iattr *attr); +extern void nfs_setattr_update_inode (struct inode *inode,struct iattr *attr, +struct cred *acred);extern void nfs_begin_attr_update (struct inode *);extern void nfs_end_attr_update (struct inode *);extern void nfs_begin_data_update (struct inode *);
David Howells
maintainerPATCH 23/52 CRED: Pass credentials to the setattr() inode operation
In reply to David HowellsPass credentials to the setattr() inode operation.
---
fs/afs/inode.c | 2 +- fs/afs/internal.h | 2 +- fs/attr.c | 3 ++- fs/bad_inode.c | 3 ++- fs/ext3/inode.c | 3 +-- fs/fat/file.c | 3 ++- fs/nfs/inode.c | 5 ++--- fs/proc/base.c | 3 ++- fs/proc/generic.c | 3 ++- fs/proc/proc_net.c | 5 +++-- fs/proc/proc_sysctl.c | 3 ++- fs/sysfs/inode.c | 3 ++- fs/sysfs/sysfs.h | 3 ++- include/linux/ext3_fs.h | 2 +- include/linux/fs.h | 2 +- include/linux/msdos_fs.h | 3 ++- include/linux/nfs_fs.h | 2 +- mm/shmem.c | 3 ++- 18 files changed, 31 insertions(+), 22 deletions(-)
fs/afs/inode.c +1 -1
@@ -357,7 +357,7 @@ void afs_clear_inode(struct inode *inode)/* * set the attributes of an inode */ -int afs_setattr (struct dentry *dentry,struct iattr *attr) +int afs_setattr (struct dentry *dentry,struct iattr *attr,struct cred *cred) {struct afs_vnode *vnode =AFS_FS_I (dentry->d_inode);struct key *key;
fs/afs/internal.h +1 -1
@@ -549,7 +549,7 @@ extern struct inode *afs_iget(struct super_block *, struct key *,extern void afs_zap_data (struct afs_vnode *);extern int afs_validate (struct afs_vnode *,struct key *);extern int afs_getattr (struct vfsmount *,struct dentry *,struct kstat *); -extern int afs_setattr (struct dentry *,struct iattr *); +extern int afs_setattr (struct dentry *,struct iattr *,struct cred *);extern void afs_clear_inode (struct inode *);/*
fs/attr.c +2 -1
@@ -107,6 +107,7 @@ EXPORT_SYMBOL(inode_setattr);int notify_change (struct dentry * dentry,struct iattr * attr) { +struct cred *cred = current->cred;struct inode *inode = dentry->d_inode;mode_t mode;int error;
@@ -150,7 +151,7 @@ int notify_change(struct dentry * dentry, struct iattr * attr)if (inode->i_op && inode->i_op->setattr) { error =security_inode_setattr (dentry, attr);if (!error) - error = inode->i_op->setattr (dentry, attr); + error = inode->i_op->setattr (dentry, attr, cred); }else { error =inode_change_ok (inode, attr);if (!error)
fs/bad_inode.c +2 -1
@@ -255,7 +255,8 @@ static int bad_inode_getattr(struct vfsmount *mnt, struct dentry *dentry,return -EIO ; } -static int bad_inode_setattr (struct dentry *direntry,struct iattr *attrs) +static int bad_inode_setattr (struct dentry *direntry,struct iattr *attrs, +struct cred *cred) {return -EIO ; }
fs/ext3/inode.c +1 -2
@@ -2941,9 +2941,8 @@ int ext3_write_inode(struct inode *inode, int wait)* * Called with inode->sem down. */ -int ext3_setattr (struct dentry *dentry,struct iattr *attr) +int ext3_setattr (struct dentry *dentry,struct iattr *attr,struct cred *cred) { -struct cred *cred = current->cred;struct inode *inode = dentry->d_inode;int error, rc =0 ;const unsigned int ia_valid = attr->ia_valid;
fs/fat/file.c +2 -1
@@ -155,7 +155,8 @@ out:return err; } -int fat_notify_change (struct dentry *dentry,struct iattr *attr) +int fat_notify_change (struct dentry *dentry,struct iattr *attr, +struct cred *cred) {struct msdos_sb_info *sbi =MSDOS_SB (dentry->d_sb);struct inode *inode = dentry->d_inode;
fs/nfs/inode.c +2 -3
@@ -319,9 +319,8 @@ out_no_inode:#define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET)int -nfs_setattr (struct dentry *dentry,struct iattr *attr) -{ -struct cred *acred = current->cred; +nfs_setattr (struct dentry *dentry,struct iattr *attr,struct cred *acred) +{struct inode *inode = dentry->d_inode;struct nfs_fattr fattr;int error;
fs/proc/base.c +2 -1
@@ -343,7 +343,8 @@ static int proc_fd_access_allowed(struct inode *inode)return allowed; } -static int proc_setattr (struct dentry *dentry,struct iattr *attr) +static int proc_setattr (struct dentry *dentry,struct iattr *attr, +struct cred *cred) {int error;struct inode *inode = dentry->d_inode;
fs/proc/generic.c +2 -1
@@ -233,7 +233,8 @@ proc_file_lseek(struct file *file, loff_t offset, int orig)return retval; } -static int proc_notify_change (struct dentry *dentry,struct iattr *iattr) +static int proc_notify_change (struct dentry *dentry,struct iattr *iattr, +struct cred *cred) {struct inode *inode = dentry->d_inode;struct proc_dir_entry *de =PDE (inode);
fs/proc/proc_net.c +3 -2
@@ -116,7 +116,8 @@ static struct dentry *proc_net_lookup(struct inode *dir, struct dentry *dentry,return shadow->d_inode->i_op->lookup (shadow->d_inode, dentry, nd); } -static int proc_net_setattr (struct dentry *dentry,struct iattr *iattr) +static int proc_net_setattr (struct dentry *dentry,struct iattr *iattr, +struct cred *cred) {struct net *net = current->nsproxy->net_ns;struct dentry *shadow;
@@ -125,7 +126,7 @@ static int proc_net_setattr(struct dentry *dentry, struct iattr *iattr) shadow =proc_net_shadow_dentry (dentry->d_parent, net->proc_net);if (!shadow)return -ENOENT ; - ret = shadow->d_inode->i_op->setattr (shadow, iattr); + ret = shadow->d_inode->i_op->setattr (shadow, iattr, cred);dput (shadow);return ret; }
fs/proc/proc_sysctl.c +2 -1
@@ -420,7 +420,8 @@ out:return error; } -static int proc_sys_setattr (struct dentry *dentry,struct iattr *attr) +static int proc_sys_setattr (struct dentry *dentry,struct iattr *attr, +struct cred *cred) {struct inode *inode = dentry->d_inode;int error;
fs/sysfs/inode.c +2 -1
@@ -44,7 +44,8 @@ void sysfs_delete_inode(struct inode *inode)return generic_delete_inode (inode); } -int sysfs_setattr (struct dentry * dentry,struct iattr * iattr) +int sysfs_setattr (struct dentry * dentry,struct iattr * iattr, +struct cred *cred) {struct inode * inode = dentry->d_inode;struct sysfs_dirent * sd = dentry->d_fsdata;
fs/sysfs/sysfs.h +2 -1
@@ -91,7 +91,8 @@ extern int sysfs_create_subdir(struct kobject *kobj, const char *name, struct sysfs_dirent **p_sd);extern void sysfs_remove_subdir (struct sysfs_dirent *sd); -extern int sysfs_setattr (struct dentry *dentry,struct iattr *iattr); +extern int sysfs_setattr (struct dentry *dentry,struct iattr *iattr, +struct cred *cred);extern spinlock_t sysfs_assoc_lock;extern struct mutex sysfs_mutex;
include/linux/ext3_fs.h +1 -1
@@ -820,7 +820,7 @@ int ext3_get_blocks_handle(handle_t *handle, struct inode *inode,extern struct inode *ext3_iget (struct super_block *,unsigned long );extern int ext3_write_inode (struct inode *,int ); -extern int ext3_setattr (struct dentry *,struct iattr *); +extern int ext3_setattr (struct dentry *,struct iattr *,struct cred *);extern void ext3_delete_inode (struct inode *);extern int ext3_sync_inode (handle_t *,struct inode *);extern void ext3_discard_reservation (struct inode *);
include/linux/fs.h +1 -1
@@ -1150,7 +1150,7 @@ struct inode_operations {void (*put_link) (struct dentry *,struct nameidata *,void *);void (*truncate) (struct inode *,struct cred *);int (*permission) (struct inode *,int ,struct nameidata *); -int (*setattr) (struct dentry *,struct iattr *); +int (*setattr) (struct dentry *,struct iattr *,struct cred *);int (*getattr) (struct vfsmount *mnt,struct dentry *,struct kstat *);int (*setxattr) (struct dentry *,const char *,const void *,size_t ,int );ssize_t (*getxattr) (struct dentry *,const char *,void *,size_t );
include/linux/msdos_fs.h +2 -1
@@ -401,7 +401,8 @@ extern int fat_generic_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);extern const struct file_operations fat_file_operations;extern const struct inode_operations fat_file_inode_operations; -extern int fat_notify_change (struct dentry * dentry,struct iattr * attr); +extern int fat_notify_change (struct dentry * dentry,struct iattr * attr, +struct cred *cred);extern void fat_truncate (struct inode *inode,struct cred *cred);extern int fat_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat);
include/linux/nfs_fs.h +1 -1
@@ -306,7 +306,7 @@ extern int nfs_revalidate_mapping(struct inode *inode,extern int nfs_revalidate_mapping_nolock (struct inode *inode,struct address_space *mapping,struct cred *acred); -extern int nfs_setattr (struct dentry *,struct iattr *); +extern int nfs_setattr (struct dentry *,struct iattr *,struct cred *);extern void nfs_setattr_update_inode (struct inode *inode,struct iattr *attr,struct cred *acred);extern void nfs_begin_attr_update (struct inode *);
mm/shmem.c +2 -1
@@ -713,7 +713,8 @@ static void shmem_truncate(struct inode *inode, struct cred *cred)shmem_truncate_range (inode, inode->i_size, (loff_t)-1 ); } -static int shmem_notify_change (struct dentry *dentry,struct iattr *attr) +static int shmem_notify_change (struct dentry *dentry,struct iattr *attr, +struct cred *cred) {struct inode *inode = dentry->d_inode;struct page *page =NULL ;
David Howells
maintainerPATCH 24/52 CRED: Pass credentials through inode_setattr()
In reply to David HowellsPass credentials through the inode_setattr() function.
---
fs/attr.c | 5 ++--- fs/ext3/inode.c | 2 +- fs/fat/file.c | 2 +- fs/proc/base.c | 2 +- fs/proc/generic.c | 2 +- fs/proc/proc_sysctl.c | 2 +- fs/sysfs/inode.c | 2 +- include/linux/fs.h | 3 ++- mm/shmem.c | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-)
fs/attr.c +2 -3
@@ -66,9 +66,8 @@ error:EXPORT_SYMBOL (inode_change_ok); -int inode_setattr (struct inode * inode,struct iattr * attr) +int inode_setattr (struct inode * inode,struct iattr * attr,struct cred *cred) { -struct cred *cred = current->cred;unsigned int ia_valid = attr->ia_valid; if (ia_valid & ATTR_SIZE &&
@@ -161,7 +160,7 @@ int notify_change(struct dentry * dentry, struct iattr * attr) (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) error =DQUOT_TRANSFER (inode, attr) ? -EDQUOT :0 ;if (!error) - error =inode_setattr (inode, attr); + error =inode_setattr (inode, attr, cred); } }
fs/ext3/inode.c +1 -1
@@ -2996,7 +2996,7 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr, struct cred *cred)ext3_journal_stop (handle); } - rc =inode_setattr (inode, attr); + rc =inode_setattr (inode, attr, cred);/* If inode_setattr's call to ext3_truncate failed to get a * transaction handle at all, we need to clean up the in-core
fs/fat/file.c +1 -1
@@ -197,7 +197,7 @@ int fat_notify_change(struct dentry *dentry, struct iattr *attr, error =0 ; goto out; } - error =inode_setattr (inode, attr); + error =inode_setattr (inode, attr, cred);if (error) goto out;
fs/proc/base.c +1 -1
@@ -354,7 +354,7 @@ static int proc_setattr(struct dentry *dentry, struct iattr *attr, error =inode_change_ok (inode, attr);if (!error) - error =inode_setattr (inode, attr); + error =inode_setattr (inode, attr, cred);return error; }
fs/proc/generic.c +1 -1
@@ -244,7 +244,7 @@ static int proc_notify_change(struct dentry *dentry, struct iattr *iattr,if (error) goto out; - error =inode_setattr (inode, iattr); + error =inode_setattr (inode, iattr, cred);if (error) goto out;
fs/proc/proc_sysctl.c +1 -1
@@ -431,7 +431,7 @@ static int proc_sys_setattr(struct dentry *dentry, struct iattr *attr, error =inode_change_ok (inode, attr);if (!error) - error =inode_setattr (inode, attr); + error =inode_setattr (inode, attr, cred);return error; }
fs/sysfs/inode.c +1 -1
@@ -62,7 +62,7 @@ int sysfs_setattr(struct dentry * dentry, struct iattr * iattr,if (error)return error; - error =inode_setattr (inode, iattr); + error =inode_setattr (inode, iattr, cred);if (error)return error;
include/linux/fs.h +2 -1
@@ -1825,7 +1825,8 @@ extern int buffer_migrate_page(struct address_space *,#endif extern int inode_change_ok (struct inode *,struct iattr *); -extern int __must_check inode_setattr (struct inode *,struct iattr *); +extern int __must_check inode_setattr (struct inode *,struct iattr *, +struct cred *);extern void file_update_time (struct file *file);
mm/shmem.c +1 -1
@@ -752,7 +752,7 @@ static int shmem_notify_change(struct dentry *dentry, struct iattr *attr, error =inode_change_ok (inode, attr);if (!error) - error =inode_setattr (inode, attr); + error =inode_setattr (inode, attr, cred);#ifdef CONFIG_TMPFS_POSIX_ACL if (!error && (attr->ia_valid &ATTR_MODE )) error =generic_acl_chmod (inode, &shmem_acl_ops);
David Howells
maintainerPATCH 25/52 CRED: Give the mknod() inode op a credentials pointer
In reply to David HowellsGive the mknod() inode op a credentials pointer.
---
fs/bad_inode.c | 2 +- fs/ext2/namei.c | 4 ++-- fs/ext3/namei.c | 3 +-- fs/ext4/namei.c | 3 +-- fs/namei.c | 3 ++- fs/nfs/dir.c | 7 ++++--- fs/ramfs/inode.c | 10 ++++++---- include/linux/fs.h | 2 +- mm/shmem.c | 10 ++++++---- 9 files changed, 24 insertions(+), 20 deletions(-)
fs/bad_inode.c +1 -1
@@ -226,7 +226,7 @@ static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry) }static int bad_inode_mknod (struct inode *dir,struct dentry *dentry, -int mode,dev_t rdev) +int mode,dev_t rdev,struct cred *cred) {return -EIO ; }
fs/ext2/namei.c +2 -2
@@ -126,9 +126,9 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, streturn err; } -static int ext2_mknod (struct inode * dir,struct dentry *dentry,int mode,dev_t rdev) +static int ext2_mknod (struct inode * dir,struct dentry *dentry,int mode, +dev_t rdev,struct cred *cred) { -struct cred *cred = current->cred;struct inode * inode;int err;
fs/ext3/namei.c +1 -2
@@ -1752,9 +1752,8 @@ retry: }static int ext3_mknod (struct inode * dir,struct dentry *dentry, -int mode,dev_t rdev) +int mode,dev_t rdev,struct cred *cred) { -struct cred *cred = current->cred;handle_t *handle;struct inode *inode;int err, retries =0 ;
fs/ext4/namei.c +1 -2
@@ -1781,9 +1781,8 @@ retry: }static int ext4_mknod (struct inode * dir,struct dentry *dentry, -int mode,dev_t rdev) +int mode,dev_t rdev,struct cred *cred) { -struct cred *cred = current->cred;handle_t *handle;struct inode *inode;int err, retries =0 ;
fs/namei.c +2 -1
@@ -1889,6 +1889,7 @@ EXPORT_SYMBOL_GPL(lookup_create);int vfs_mknod (struct inode *dir,struct dentry *dentry,int mode,dev_t dev) { +struct cred *cred = current->cred;int error =may_create (dir, dentry,NULL );if (error)
@@ -1905,7 +1906,7 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)return error;DQUOT_INIT (dir); - error = dir->i_op->mknod (dir, dentry, mode, dev); + error = dir->i_op->mknod (dir, dentry, mode, dev, cred);if (!error)fsnotify_create (dir, dentry);return error;
fs/nfs/dir.c +4 -3
@@ -50,7 +50,8 @@ static int nfs_rmdir(struct inode *, struct dentry *);static int nfs_unlink (struct inode *,struct dentry *);static int nfs_symlink (struct inode *,struct dentry *,const char *);static int nfs_link (struct dentry *,struct inode *,struct dentry *); -static int nfs_mknod (struct inode *,struct dentry *,int ,dev_t ); +static int nfs_mknod (struct inode *,struct dentry *,int ,dev_t , +struct cred *);static int nfs_rename (struct inode *,struct dentry *,struct inode *,struct dentry *);static int nfs_fsync_dir (struct file *,struct dentry *,int );
@@ -1284,9 +1285,9 @@ out_err:* See comments for nfs_proc_create regarding failed operations. */ static int -nfs_mknod (struct inode *dir,struct dentry *dentry,int mode,dev_t rdev) +nfs_mknod (struct inode *dir,struct dentry *dentry,int mode,dev_t rdev, +struct cred *acred) { -struct cred *acred = current->cred;struct iattr attr;int status;
fs/ramfs/inode.c +6 -4
@@ -91,9 +91,9 @@ struct inode *ramfs_get_inode(struct super_block *sb, int mode, dev_t dev,*/ /* SMP-safe */ static int -ramfs_mknod (struct inode *dir,struct dentry *dentry,int mode,dev_t dev) +ramfs_mknod (struct inode *dir,struct dentry *dentry,int mode,dev_t dev, +struct cred *cred) { -struct cred *cred = current->cred;struct inode * inode =ramfs_get_inode (dir->i_sb, mode, dev, cred);int error = -ENOSPC ;
@@ -113,7 +113,8 @@ ramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)static int ramfs_mkdir (struct inode * dir,struct dentry * dentry,int mode) { -int retval =ramfs_mknod (dir, dentry, mode |S_IFDIR ,0 ); +struct cred *cred = current->cred; +int retval =ramfs_mknod (dir, dentry, mode |S_IFDIR ,0 , cred);if (!retval)inc_nlink (dir);return retval;
@@ -121,7 +122,8 @@ static int ramfs_mkdir(struct inode * dir, struct dentry * dentry, int mode)static int ramfs_create (struct inode *dir,struct dentry *dentry,int mode,struct nameidata *nd) { -return ramfs_mknod (dir, dentry, mode |S_IFREG ,0 ); +struct cred *cred = current->cred; +return ramfs_mknod (dir, dentry, mode |S_IFREG ,0 , cred); }static int ramfs_symlink (struct inode * dir,struct dentry *dentry,const char * symname)
include/linux/fs.h +1 -1
@@ -1142,7 +1142,7 @@ struct inode_operations {int (*symlink) (struct inode *,struct dentry *,const char *);int (*mkdir) (struct inode *,struct dentry *,int );int (*rmdir) (struct inode *,struct dentry *); -int (*mknod) (struct inode *,struct dentry *,int ,dev_t ); +int (*mknod) (struct inode *,struct dentry *,int ,dev_t ,struct cred *);int (*rename) (struct inode *,struct dentry *,struct inode *,struct dentry *);int (*readlink) (struct dentry *,char __user *,int );
mm/shmem.c +6 -4
@@ -1707,9 +1707,9 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf)* File creation. Allocate an inode, and we're done.. */ static int -shmem_mknod (struct inode *dir,struct dentry *dentry,int mode,dev_t dev) +shmem_mknod (struct inode *dir,struct dentry *dentry,int mode,dev_t dev, +struct cred *cred) { -struct cred *cred = current->cred;struct inode *inode =shmem_get_inode (dir->i_sb, mode, dev, cred);int error = -ENOSPC ;
@@ -1742,9 +1742,10 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)static int shmem_mkdir (struct inode *dir,struct dentry *dentry,int mode) { +struct cred *cred = current->cred;int error; -if ((error =shmem_mknod (dir, dentry, mode |S_IFDIR ,0 ))) +if ((error =shmem_mknod (dir, dentry, mode |S_IFDIR ,0 , cred)))return error;inc_nlink (dir);return 0 ;
@@ -1753,7 +1754,8 @@ static int shmem_mkdir(struct inode *dir, struct dentry *dentry, int mode)static int shmem_create (struct inode *dir,struct dentry *dentry,int mode,struct nameidata *nd) { -return shmem_mknod (dir, dentry, mode |S_IFREG ,0 ); +struct cred *cred = current->cred; +return shmem_mknod (dir, dentry, mode |S_IFREG ,0 , cred); }/*
David Howells
maintainerPATCH 26/52 CRED: Give the mkdir() inode op a credentials pointer
In reply to David HowellsGive the mkdir() inode op a credentials pointer.
---
fs/afs/dir.c | 6 ++++-- fs/autofs4/root.c | 5 +++-- fs/bad_inode.c | 2 +- fs/ext2/namei.c | 4 ++-- fs/ext3/namei.c | 4 ++-- fs/ext4/namei.c | 4 ++-- fs/namei.c | 3 ++- fs/nfs/dir.c | 6 +++--- fs/ramfs/inode.c | 4 ++-- fs/vfat/namei.c | 3 ++- include/linux/fs.h | 2 +- mm/shmem.c | 4 ++-- 12 files changed, 26 insertions(+), 21 deletions(-)
fs/afs/dir.c +4 -2
@@ -30,7 +30,8 @@ static int afs_lookup_filldir(void *_cookie, const char *name, int nlen, loff_t fpos, u64 ino, unsigned dtype);static int afs_create (struct inode *dir,struct dentry *dentry,int mode,struct nameidata *nd); -static int afs_mkdir (struct inode *dir,struct dentry *dentry,int mode); +static int afs_mkdir (struct inode *dir,struct dentry *dentry,int mode, +struct cred *cred);static int afs_rmdir (struct inode *dir,struct dentry *dentry);static int afs_unlink (struct inode *dir,struct dentry *dentry); static int afs_link(struct dentry *from, struct inode *dir,
@@ -721,7 +722,8 @@ static void afs_d_release(struct dentry *dentry)/* * create a directory on an AFS filesystem */ -static int afs_mkdir (struct inode *dir,struct dentry *dentry,int mode) +static int afs_mkdir (struct inode *dir,struct dentry *dentry,int mode, +struct cred *cred) {struct afs_file_status status;struct afs_callback cb;
fs/autofs4/root.c +3 -2
@@ -22,7 +22,7 @@static int autofs4_dir_symlink (struct inode *,struct dentry *,const char *);static int autofs4_dir_unlink (struct inode *,struct dentry *);static int autofs4_dir_rmdir (struct inode *,struct dentry *); -static int autofs4_dir_mkdir (struct inode *,struct dentry *,int ); +static int autofs4_dir_mkdir (struct inode *,struct dentry *,int ,struct cred *);static int autofs4_root_ioctl (struct inode *,struct file *,unsigned int ,unsigned long );static int autofs4_dir_open (struct inode *inode,struct file *file);static int autofs4_dir_close (struct inode *inode,struct file *file);
@@ -829,7 +829,8 @@ static int autofs4_dir_rmdir(struct inode *dir, struct dentry *dentry)return 0 ; } -static int autofs4_dir_mkdir (struct inode *dir,struct dentry *dentry,int mode) +static int autofs4_dir_mkdir (struct inode *dir,struct dentry *dentry,int mode, +struct cred *cred) {struct autofs_sb_info *sbi =autofs4_sbi (dir->i_sb);struct autofs_info *ino =autofs4_dentry_ino (dentry);
fs/bad_inode.c +1 -1
@@ -215,7 +215,7 @@ static int bad_inode_symlink (struct inode *dir, struct dentry *dentry, }static int bad_inode_mkdir (struct inode *dir,struct dentry *dentry, -int mode) +int mode,struct cred *cred) {return -EIO ; }
fs/ext2/namei.c +2 -2
@@ -208,9 +208,9 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,return ext2_add_nondir (dentry, inode); } -static int ext2_mkdir (struct inode * dir,struct dentry * dentry,int mode) +static int ext2_mkdir (struct inode * dir,struct dentry * dentry,int mode, +struct cred *cred) { -struct cred *cred = current->cred;struct inode * inode;int err = -EMLINK ;
fs/ext3/namei.c +2 -2
@@ -1787,9 +1787,9 @@ retry:return err; } -static int ext3_mkdir (struct inode * dir,struct dentry * dentry,int mode) +static int ext3_mkdir (struct inode * dir,struct dentry * dentry,int mode, +struct cred *cred) { -struct cred *cred = current->cred;handle_t *handle;struct inode * inode;struct buffer_head * dir_block;
fs/ext4/namei.c +2 -2
@@ -1816,9 +1816,9 @@ retry:return err; } -static int ext4_mkdir (struct inode * dir,struct dentry * dentry,int mode) +static int ext4_mkdir (struct inode * dir,struct dentry * dentry,int mode, +struct cred *cred) { -struct cred *cred = current->cred;handle_t *handle;struct inode * inode;struct buffer_head * dir_block;
fs/namei.c +2 -1
@@ -1969,6 +1969,7 @@ asmlinkage long sys_mknod(const char __user *filename, int mode, unsigned dev)int vfs_mkdir (struct inode *dir,struct dentry *dentry,int mode) { +struct cred *cred = current->cred;int error =may_create (dir, dentry,NULL );if (error)
@@ -1983,7 +1984,7 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)return error;DQUOT_INIT (dir); - error = dir->i_op->mkdir (dir, dentry, mode); + error = dir->i_op->mkdir (dir, dentry, mode, cred);if (!error)fsnotify_mkdir (dir, dentry);return error;
fs/nfs/dir.c +3 -3
@@ -45,7 +45,7 @@ static int nfs_opendir(struct inode *, struct file *);static int nfs_readdir (struct file *,void *,filldir_t );static struct dentry *nfs_lookup (struct inode *,struct dentry *,struct nameidata *);static int nfs_create (struct inode *,struct dentry *,int ,struct nameidata *); -static int nfs_mkdir (struct inode *,struct dentry *,int ); +static int nfs_mkdir (struct inode *,struct dentry *,int ,struct cred *);static int nfs_rmdir (struct inode *,struct dentry *);static int nfs_unlink (struct inode *,struct dentry *);static int nfs_symlink (struct inode *,struct dentry *,const char *);
@@ -1319,9 +1319,9 @@ out_err:/* * See comments for nfs_proc_create regarding failed operations. */ -static int nfs_mkdir (struct inode *dir,struct dentry *dentry,int mode) +static int nfs_mkdir (struct inode *dir,struct dentry *dentry,int mode, +struct cred *acred) { -struct cred *acred = current->cred;struct iattr attr;int error;
fs/ramfs/inode.c +2 -2
@@ -111,9 +111,9 @@ ramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev,return error; } -static int ramfs_mkdir (struct inode * dir,struct dentry * dentry,int mode) +static int ramfs_mkdir (struct inode * dir,struct dentry * dentry,int mode, +struct cred *cred) { -struct cred *cred = current->cred;int retval =ramfs_mknod (dir, dentry, mode |S_IFDIR ,0 , cred);if (!retval)inc_nlink (dir);
fs/vfat/namei.c +2 -1
@@ -817,7 +817,8 @@ out:return err; } -static int vfat_mkdir (struct inode *dir,struct dentry *dentry,int mode) +static int vfat_mkdir (struct inode *dir,struct dentry *dentry,int mode, +struct cred *cred) {struct super_block *sb = dir->i_sb;struct inode *inode;
include/linux/fs.h +1 -1
@@ -1140,7 +1140,7 @@ struct inode_operations {int (*link) (struct dentry *,struct inode *,struct dentry *);int (*unlink) (struct inode *,struct dentry *);int (*symlink) (struct inode *,struct dentry *,const char *); -int (*mkdir) (struct inode *,struct dentry *,int ); +int (*mkdir) (struct inode *,struct dentry *,int ,struct cred *);int (*rmdir) (struct inode *,struct dentry *);int (*mknod) (struct inode *,struct dentry *,int ,dev_t ,struct cred *); int (*rename) (struct inode *, struct dentry *,
mm/shmem.c +2 -2
@@ -1740,9 +1740,9 @@ shmem_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev,return error; } -static int shmem_mkdir (struct inode *dir,struct dentry *dentry,int mode) +static int shmem_mkdir (struct inode *dir,struct dentry *dentry,int mode, +struct cred *cred) { -struct cred *cred = current->cred;int error;if ((error =shmem_mknod (dir, dentry, mode |S_IFDIR ,0 , cred)))
David Howells
maintainerPATCH 27/52 CRED: Give the create() inode op a credentials pointer
In reply to David HowellsGive the create() inode op a credentials pointer.
---
fs/afs/dir.c | 4 ++-- fs/bad_inode.c | 2 +- fs/ext3/namei.c | 3 +-- fs/namei.c | 3 ++- fs/nfs/dir.c | 6 +++--- fs/ramfs/inode.c | 4 ++-- fs/vfat/namei.c | 2 +- include/linux/fs.h | 3 ++- mm/shmem.c | 3 +-- 9 files changed, 15 insertions(+), 15 deletions(-)
fs/afs/dir.c +2 -2
@@ -29,7 +29,7 @@ static void afs_d_release(struct dentry *dentry);static int afs_lookup_filldir (void *_cookie,const char *name,int nlen,loff_t fpos,u64 ino,unsigned dtype);static int afs_create (struct inode *dir,struct dentry *dentry,int mode, -struct nameidata *nd); +struct nameidata *nd,struct cred *cred);static int afs_mkdir (struct inode *dir,struct dentry *dentry,int mode,struct cred *cred);static int afs_rmdir (struct inode *dir,struct dentry *dentry);
@@ -908,7 +908,7 @@ error:* create a regular file on an AFS filesystem */ static int afs_create (struct inode *dir,struct dentry *dentry,int mode, -struct nameidata *nd) +struct nameidata *nd,struct cred *cred) {struct afs_file_status status;struct afs_callback cb;
fs/bad_inode.c +1 -1
@@ -186,7 +186,7 @@ static const struct file_operations bad_file_ops = };static int bad_inode_create (struct inode *dir,struct dentry *dentry, -int mode,struct nameidata *nd) +int mode,struct nameidata *nd,struct cred *cred) {return -EIO ; }
fs/ext3/namei.c +1 -2
@@ -1720,9 +1720,8 @@ static int ext3_add_nondir(handle_t *handle,* with d_instantiate(). */ static int ext3_create (struct inode * dir,struct dentry * dentry,int mode, -struct nameidata *nd) +struct nameidata *nd,struct cred *cred) { -struct cred *cred = current->cred;handle_t *handle;struct inode * inode;int err, retries =0 ;
fs/namei.c +2 -1
@@ -1545,6 +1545,7 @@ void unlock_rename(struct dentry *p1, struct dentry *p2)int vfs_create (struct inode *dir,struct dentry *dentry,int mode,struct nameidata *nd) { +struct cred *cred = current->cred;int error =may_create (dir, dentry, nd);if (error)
@@ -1558,7 +1559,7 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode,if (error)return error;DQUOT_INIT (dir); - error = dir->i_op->create (dir, dentry, mode, nd); + error = dir->i_op->create (dir, dentry, mode, nd, cred);if (!error)fsnotify_create (dir, dentry);return error;
fs/nfs/dir.c +3 -3
@@ -44,7 +44,8 @@static int nfs_opendir (struct inode *,struct file *);static int nfs_readdir (struct file *,void *,filldir_t );static struct dentry *nfs_lookup (struct inode *,struct dentry *,struct nameidata *); -static int nfs_create (struct inode *,struct dentry *,int ,struct nameidata *); +static int nfs_create (struct inode *,struct dentry *,int ,struct nameidata *, +struct cred *);static int nfs_mkdir (struct inode *,struct dentry *,int ,struct cred *);static int nfs_rmdir (struct inode *,struct dentry *);static int nfs_unlink (struct inode *,struct dentry *);
@@ -1248,9 +1249,8 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,* reply path made it appear to have failed. */ static int nfs_create (struct inode *dir,struct dentry *dentry,int mode, -struct nameidata *nd) +struct nameidata *nd,struct cred *acred) { -struct cred *acred = current->cred;struct iattr attr;int error;int open_flags =0 ;
fs/ramfs/inode.c +2 -2
@@ -120,9 +120,9 @@ static int ramfs_mkdir(struct inode * dir, struct dentry * dentry, int mode,return retval; } -static int ramfs_create (struct inode *dir,struct dentry *dentry,int mode,struct nameidata *nd) +static int ramfs_create (struct inode *dir,struct dentry *dentry,int mode, +struct nameidata *nd,struct cred *cred) { -struct cred *cred = current->cred;return ramfs_mknod (dir, dentry, mode |S_IFREG ,0 , cred); }
fs/vfat/namei.c +1 -1
@@ -731,7 +731,7 @@ error: }static int vfat_create (struct inode *dir,struct dentry *dentry,int mode, -struct nameidata *nd) +struct nameidata *nd,struct cred *cred) {struct super_block *sb = dir->i_sb;struct inode *inode;
include/linux/fs.h +2 -1
@@ -1135,7 +1135,8 @@ struct file_operations { };struct inode_operations { -int (*create) (struct inode *,struct dentry *,int ,struct nameidata *); +int (*create) (struct inode *,struct dentry *,int ,struct nameidata *, +struct cred *);struct dentry * (*lookup) (struct inode *,struct dentry *,struct nameidata *);int (*link) (struct dentry *,struct inode *,struct dentry *);int (*unlink) (struct inode *,struct dentry *);
mm/shmem.c +1 -2
@@ -1752,9 +1752,8 @@ static int shmem_mkdir(struct inode *dir, struct dentry *dentry, int mode, }static int shmem_create (struct inode *dir,struct dentry *dentry,int mode, -struct nameidata *nd) +struct nameidata *nd,struct cred *cred) { -struct cred *cred = current->cred;return shmem_mknod (dir, dentry, mode |S_IFREG ,0 , cred); }
David Howells
maintainerPATCH 28/52 CRED: Give the link() inode op a credentials pointer
In reply to David HowellsGive the link() inode op a credentials pointer.
---
fs/afs/dir.c | 4 ++-- fs/bad_inode.c | 2 +- fs/ext3/namei.c | 3 +-- fs/libfs.c | 3 ++- fs/namei.c | 3 ++- fs/nfs/dir.c | 7 ++++--- include/linux/fs.h | 6 ++++-- mm/shmem.c | 3 ++- 8 files changed, 18 insertions(+), 13 deletions(-)
fs/afs/dir.c +2 -2
@@ -35,7 +35,7 @@ static int afs_mkdir(struct inode *dir, struct dentry *dentry, int mode,static int afs_rmdir (struct inode *dir,struct dentry *dentry);static int afs_unlink (struct inode *dir,struct dentry *dentry);static int afs_link (struct dentry *from,struct inode *dir, -struct dentry *dentry); +struct dentry *dentry,struct cred *cred);static int afs_symlink (struct inode *dir,struct dentry *dentry,const char *content); static int afs_rename(struct inode *old_dir, struct dentry *old_dentry,
@@ -979,7 +979,7 @@ error:* create a hard link between files in an AFS filesystem */ static int afs_link (struct dentry *from,struct inode *dir, -struct dentry *dentry) +struct dentry *dentry,struct cred *cred) {struct afs_vnode *dvnode, *vnode;struct key *key;
fs/bad_inode.c +1 -1
@@ -198,7 +198,7 @@ static struct dentry *bad_inode_lookup(struct inode *dir, }static int bad_inode_link (struct dentry *old_dentry,struct inode *dir, -struct dentry *dentry) +struct dentry *dentry,struct cred *cred) {return -EIO ; }
fs/ext3/namei.c +1 -2
@@ -2254,9 +2254,8 @@ out_stop: }static int ext3_link (struct dentry * old_dentry, -struct inode * dir,struct dentry *dentry) +struct inode * dir,struct dentry *dentry,struct cred *cred) { -struct cred *cred = current->cred;handle_t *handle;struct inode *inode = old_dentry->d_inode;int err, retries =0 ;
fs/libfs.c +2 -1
@@ -250,7 +250,8 @@ Enomem:return -ENOMEM ; } -int simple_link (struct dentry *old_dentry,struct inode *dir,struct dentry *dentry) +int simple_link (struct dentry *old_dentry,struct inode *dir, +struct dentry *dentry,struct cred *cred) {struct inode *inode = old_dentry->d_inode;
fs/namei.c +2 -1
@@ -2300,6 +2300,7 @@ asmlinkage long sys_symlink(const char __user *oldname, const char __user *newnaint vfs_link (struct dentry *old_dentry,struct inode *dir,struct dentry *new_dentry) { +struct cred *cred = current->cred;struct inode *inode = old_dentry->d_inode;int error;
@@ -2329,7 +2330,7 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_demutex_lock (&old_dentry->d_inode->i_mutex);DQUOT_INIT (dir); - error = dir->i_op->link (old_dentry, dir, new_dentry); + error = dir->i_op->link (old_dentry, dir, new_dentry, cred);mutex_unlock (&old_dentry->d_inode->i_mutex);if (!error)fsnotify_create (dir, new_dentry);
fs/nfs/dir.c +4 -3
@@ -50,7 +50,8 @@ static int nfs_mkdir(struct inode *, struct dentry *, int, struct cred *);static int nfs_rmdir (struct inode *,struct dentry *);static int nfs_unlink (struct inode *,struct dentry *);static int nfs_symlink (struct inode *,struct dentry *,const char *); -static int nfs_link (struct dentry *,struct inode *,struct dentry *); +static int nfs_link (struct dentry *,struct inode *,struct dentry *, +struct cred *);static int nfs_mknod (struct inode *,struct dentry *,int ,dev_t ,struct cred *); static int nfs_rename(struct inode *, struct dentry *,
@@ -1604,9 +1605,9 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym }static int -nfs_link (struct dentry *old_dentry,struct inode *dir,struct dentry *dentry) +nfs_link (struct dentry *old_dentry,struct inode *dir,struct dentry *dentry, +struct cred *acred) { -struct cred *acred = current->cred;struct inode *inode = old_dentry->d_inode;int error;
include/linux/fs.h +4 -2
@@ -1138,7 +1138,8 @@ struct inode_operations {int (*create) (struct inode *,struct dentry *,int ,struct nameidata *,struct cred *);struct dentry * (*lookup) (struct inode *,struct dentry *,struct nameidata *); -int (*link) (struct dentry *,struct inode *,struct dentry *); +int (*link) (struct dentry *,struct inode *,struct dentry *, +struct cred *);int (*unlink) (struct inode *,struct dentry *);int (*symlink) (struct inode *,struct dentry *,const char *);int (*mkdir) (struct inode *,struct dentry *,int ,struct cred *);
@@ -1794,7 +1795,8 @@ extern loff_t dcache_dir_lseek(struct file *, loff_t, int);extern int dcache_readdir (struct file *,void *,filldir_t );extern int simple_getattr (struct vfsmount *,struct dentry *,struct kstat *);extern int simple_statfs (struct dentry *,struct kstatfs *); -extern int simple_link (struct dentry *,struct inode *,struct dentry *); +extern int simple_link (struct dentry *,struct inode *,struct dentry *, +struct cred *);extern int simple_unlink (struct inode *,struct dentry *);extern int simple_rmdir (struct inode *,struct dentry *);extern int simple_rename (struct inode *,struct dentry *,struct inode *,struct dentry *);
mm/shmem.c +2 -1
@@ -1760,7 +1760,8 @@ static int shmem_create(struct inode *dir, struct dentry *dentry, int mode,/* * Link a file.. */ -static int shmem_link (struct dentry *old_dentry,struct inode *dir,struct dentry *dentry) +static int shmem_link (struct dentry *old_dentry,struct inode *dir, +struct dentry *dentry,struct cred *cred) {struct inode *inode = old_dentry->d_inode;struct shmem_sb_info *sbinfo =SHMEM_SB (inode->i_sb);
David Howells
maintainerPATCH 29/52 CRED: Give the unlink() inode op a credentials pointer
In reply to David HowellsGive the unlink() inode op a credentials pointer.
---
fs/afs/dir.c | 6 ++++-- fs/autofs4/root.c | 5 +++-- fs/bad_inode.c | 3 ++- fs/ext3/namei.c | 4 ++-- fs/libfs.c | 10 +++++++--- fs/namei.c | 3 ++- fs/nfs/dir.c | 6 +++--- fs/vfat/namei.c | 3 ++- include/linux/fs.h | 4 ++-- mm/shmem.c | 9 ++++++--- net/sunrpc/rpc_pipe.c | 6 ++++-- security/inode.c | 3 ++- security/selinux/selinuxfs.c | 3 ++- 13 files changed, 41 insertions(+), 24 deletions(-)
fs/afs/dir.c +4 -2
@@ -33,7 +33,8 @@ static int afs_create(struct inode *dir, struct dentry *dentry, int mode,static int afs_mkdir (struct inode *dir,struct dentry *dentry,int mode,struct cred *cred);static int afs_rmdir (struct inode *dir,struct dentry *dentry); -static int afs_unlink (struct inode *dir,struct dentry *dentry); +static int afs_unlink (struct inode *dir,struct dentry *dentry, +struct cred *cred);static int afs_link (struct dentry *from,struct inode *dir,struct dentry *dentry,struct cred *cred); static int afs_symlink(struct inode *dir, struct dentry *dentry,
@@ -839,7 +840,8 @@ error:/* * remove a file from an AFS filesystem */ -static int afs_unlink (struct inode *dir,struct dentry *dentry) +static int afs_unlink (struct inode *dir,struct dentry *dentry, +struct cred *cred) {struct afs_vnode *dvnode, *vnode;struct key *key;
fs/autofs4/root.c +3 -2
@@ -20,7 +20,7 @@#include "autofs_i.h" static int autofs4_dir_symlink (struct inode *,struct dentry *,const char *); -static int autofs4_dir_unlink (struct inode *,struct dentry *); +static int autofs4_dir_unlink (struct inode *,struct dentry *,struct cred *);static int autofs4_dir_rmdir (struct inode *,struct dentry *);static int autofs4_dir_mkdir (struct inode *,struct dentry *,int ,struct cred *);static int autofs4_root_ioctl (struct inode *,struct file *,unsigned int ,unsigned long );
@@ -755,7 +755,8 @@ static int autofs4_dir_symlink(struct inode *dir,* * Also see autofs4_dir_rmdir().. */ -static int autofs4_dir_unlink (struct inode *dir,struct dentry *dentry) +static int autofs4_dir_unlink (struct inode *dir,struct dentry *dentry, +struct cred *cred) {struct autofs_sb_info *sbi =autofs4_sbi (dir->i_sb);struct autofs_info *ino =autofs4_dentry_ino (dentry);
fs/bad_inode.c +2 -1
@@ -203,7 +203,8 @@ static int bad_inode_link (struct dentry *old_dentry, struct inode *dir,return -EIO ; } -static int bad_inode_unlink (struct inode *dir,struct dentry *dentry) +static int bad_inode_unlink (struct inode *dir,struct dentry *dentry, +struct cred *cred) {return -EIO ; }
fs/ext3/namei.c +2 -2
@@ -2140,9 +2140,9 @@ end_rmdir:return retval; } -static int ext3_unlink (struct inode * dir,struct dentry *dentry) +static int ext3_unlink (struct inode * dir,struct dentry *dentry, +struct cred *cred) { -struct cred *cred = current->cred;int retval;struct inode * inode;struct buffer_head * bh;
fs/libfs.c +7 -3
@@ -8,6 +8,7 @@#include <linux/mount.h> #include <linux/vfs.h> #include <linux/mutex.h> +#include <linux/sched.h> #include <asm/uaccess.h>
@@ -283,7 +284,7 @@ out:return ret; } -int simple_unlink (struct inode *dir,struct dentry *dentry) +int simple_unlink (struct inode *dir,struct dentry *dentry,struct cred *cred) {struct inode *inode = dentry->d_inode;
@@ -295,11 +296,13 @@ int simple_unlink(struct inode *dir, struct dentry *dentry)int simple_rmdir (struct inode *dir,struct dentry *dentry) { +struct cred *cred = current->cred; +if (!simple_empty (dentry))return -ENOTEMPTY ;drop_nlink (dentry->d_inode); -simple_unlink (dir, dentry); +simple_unlink (dir, dentry, cred);drop_nlink (dir);return 0 ; }
@@ -307,6 +310,7 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry)int simple_rename (struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry) { +struct cred *cred = current->cred;struct inode *inode = old_dentry->d_inode;int they_are_dirs =S_ISDIR (old_dentry->d_inode->i_mode);
@@ -314,7 +318,7 @@ int simple_rename(struct inode *old_dir, struct dentry *old_dentry,return -ENOTEMPTY ;if (new_dentry->d_inode) { -simple_unlink (new_dir, new_dentry); +simple_unlink (new_dir, new_dentry, cred);if (they_are_dirs)drop_nlink (old_dir); }else if (they_are_dirs) {
fs/namei.c +2 -1
@@ -2138,6 +2138,7 @@ asmlinkage long sys_rmdir(const char __user *pathname)int vfs_unlink (struct inode *dir,struct dentry *dentry) { +struct cred *cred = current->cred;int error =may_delete (dir, dentry,0 );if (error)
@@ -2154,7 +2155,7 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)else { error =security_inode_unlink (dir, dentry);if (!error) - error = dir->i_op->unlink (dir, dentry); + error = dir->i_op->unlink (dir, dentry, cred); }mutex_unlock (&dentry->d_inode->i_mutex);
fs/nfs/dir.c +3 -3
@@ -48,7 +48,7 @@ static int nfs_create(struct inode *, struct dentry *, int, struct nameidata *, struct cred *);static int nfs_mkdir (struct inode *,struct dentry *,int ,struct cred *);static int nfs_rmdir (struct inode *,struct dentry *); -static int nfs_unlink (struct inode *,struct dentry *); +static int nfs_unlink (struct inode *,struct dentry *,struct cred *);static int nfs_symlink (struct inode *,struct dentry *,const char *);static int nfs_link (struct dentry *,struct inode *,struct dentry *,struct cred *);
@@ -1487,9 +1487,9 @@ out:* * If sillyrename() returns 0, we do nothing, otherwise we unlink. */ -static int nfs_unlink (struct inode *dir,struct dentry *dentry) +static int nfs_unlink (struct inode *dir,struct dentry *dentry, +struct cred *acred) { -struct cred *acred = current->cred;int error;int need_rehash =0 ;
fs/vfat/namei.c +2 -1
@@ -793,7 +793,8 @@ out:return err; } -static int vfat_unlink (struct inode *dir,struct dentry *dentry) +static int vfat_unlink (struct inode *dir,struct dentry *dentry, +struct cred *cred) {struct inode *inode = dentry->d_inode;struct fat_slot_info sinfo;
include/linux/fs.h +2 -2
@@ -1140,7 +1140,7 @@ struct inode_operations {struct dentry * (*lookup) (struct inode *,struct dentry *,struct nameidata *);int (*link) (struct dentry *,struct inode *,struct dentry *,struct cred *); -int (*unlink) (struct inode *,struct dentry *); +int (*unlink) (struct inode *,struct dentry *,struct cred *);int (*symlink) (struct inode *,struct dentry *,const char *);int (*mkdir) (struct inode *,struct dentry *,int ,struct cred *);int (*rmdir) (struct inode *,struct dentry *);
@@ -1797,7 +1797,7 @@ extern int simple_getattr(struct vfsmount *, struct dentry *, struct kstat *);extern int simple_statfs (struct dentry *,struct kstatfs *);extern int simple_link (struct dentry *,struct inode *,struct dentry *,struct cred *); -extern int simple_unlink (struct inode *,struct dentry *); +extern int simple_unlink (struct inode *,struct dentry *,struct cred *);extern int simple_rmdir (struct inode *,struct dentry *);extern int simple_rename (struct inode *,struct dentry *,struct inode *,struct dentry *);extern int simple_sync_file (struct file *,struct dentry *,int );
mm/shmem.c +6 -3
@@ -1790,7 +1790,8 @@ static int shmem_link(struct dentry *old_dentry, struct inode *dir,return 0 ; } -static int shmem_unlink (struct inode *dir,struct dentry *dentry) +static int shmem_unlink (struct inode *dir,struct dentry *dentry, +struct cred *cred) {struct inode *inode = dentry->d_inode;
@@ -1812,12 +1813,13 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry)static int shmem_rmdir (struct inode *dir,struct dentry *dentry) { +struct cred *cred = current->cred;if (!simple_empty (dentry))return -ENOTEMPTY ;drop_nlink (dentry->d_inode);drop_nlink (dir); -return shmem_unlink (dir, dentry); +return shmem_unlink (dir, dentry, cred); }/*
@@ -1828,6 +1830,7 @@ static int shmem_rmdir(struct inode *dir, struct dentry *dentry)*/ static int shmem_rename (struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry) { +struct cred *cred = current->cred;struct inode *inode = old_dentry->d_inode;int they_are_dirs =S_ISDIR (inode->i_mode);
@@ -1835,7 +1838,7 @@ static int shmem_rename(struct inode *old_dir, struct dentry *old_dentry, structreturn -ENOTEMPTY ;if (new_dentry->d_inode) { - (void )shmem_unlink (new_dir, new_dentry); + (void )shmem_unlink (new_dir, new_dentry, cred);if (they_are_dirs)drop_nlink (old_dir); }else if (they_are_dirs) {
net/sunrpc/rpc_pipe.c +4 -2
@@ -514,6 +514,7 @@ rpc_get_inode(struct super_block *sb, int mode)static void rpc_depopulate (struct dentry *parent,int start,int eof) { +struct cred *cred = current->cred;struct inode *dir = parent->d_inode;struct list_head *pos, *next;struct dentry *dentry, *dvec[10 ];
@@ -544,7 +545,7 @@ repeat: do { dentry = dvec[--n]; if (S_ISREG(dentry->d_inode->i_mode)) - simple_unlink(dir, dentry); + simple_unlink(dir, dentry, cred); else if (S_ISDIR(dentry->d_inode->i_mode)) simple_rmdir(dir, dentry); d_delete(dentry);
@@ -765,6 +766,7 @@ err_dput:int rpc_unlink (struct dentry *dentry) { +struct cred *cred = current->cred;struct dentry *parent;struct inode *dir;int error =0 ;
@@ -774,7 +776,7 @@ rpc_unlink(struct dentry *dentry)mutex_lock_nested (&dir->i_mutex,I_MUTEX_PARENT );if (--RPC_I (dentry->d_inode)->nkern_readwriters ==0 ) {rpc_close_pipes (dentry->d_inode); - error =simple_unlink (dir, dentry); + error =simple_unlink (dir, dentry, cred);if (!error)d_delete (dentry); }
security/inode.c +2 -1
@@ -292,6 +292,7 @@ EXPORT_SYMBOL_GPL(securityfs_create_dir);void securityfs_remove (struct dentry *dentry) {struct dentry *parent; +struct cred *cred = current->cred;if (!dentry)return ;
@@ -306,7 +307,7 @@ void securityfs_remove(struct dentry *dentry)if (S_ISDIR (dentry->d_inode->i_mode))simple_rmdir (parent->d_inode, dentry);else -simple_unlink (parent->d_inode, dentry); +simple_unlink (parent->d_inode, dentry, cred);dput (dentry); } }
security/selinux/selinuxfs.c +2 -1
@@ -963,6 +963,7 @@ static void sel_remove_entries(struct dentry *de) {struct list_head *p, *node;struct super_block *sb = de->d_sb; +struct cred *cred = current->cred;spin_lock (&dcache_lock); node = de->d_subdirs.next;
@@ -974,7 +975,7 @@ static void sel_remove_entries(struct dentry *de) d =dget_locked (d);spin_unlock (&dcache_lock);d_delete (d); -simple_unlink (de->d_inode, d); +simple_unlink (de->d_inode, d, cred);dput (d);spin_lock (&dcache_lock); }
David Howells
maintainerPATCH 30/52 CRED: Give the rmdir() inode op a credentials pointer
In reply to David HowellsGive the rmdir() inode op a credentials pointer.
---
fs/afs/dir.c | 6 ++++-- fs/autofs4/root.c | 5 +++-- fs/bad_inode.c | 3 ++- fs/ext3/namei.c | 4 ++-- fs/libfs.c | 4 +--- fs/namei.c | 3 ++- fs/nfs/dir.c | 6 +++--- fs/vfat/namei.c | 3 ++- include/linux/fs.h | 4 ++-- mm/shmem.c | 4 ++-- net/sunrpc/rpc_pipe.c | 6 ++++-- security/inode.c | 2 +- 12 files changed, 28 insertions(+), 22 deletions(-)
fs/afs/dir.c +4 -2
@@ -32,7 +32,8 @@ static int afs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *nd, struct cred *cred);static int afs_mkdir (struct inode *dir,struct dentry *dentry,int mode,struct cred *cred); -static int afs_rmdir (struct inode *dir,struct dentry *dentry); +static int afs_rmdir (struct inode *dir,struct dentry *dentry, +struct cred *cred);static int afs_unlink (struct inode *dir,struct dentry *dentry,struct cred *cred); static int afs_link(struct dentry *from, struct inode *dir,
@@ -794,7 +795,8 @@ error:/* * remove a directory from an AFS filesystem */ -static int afs_rmdir (struct inode *dir,struct dentry *dentry) +static int afs_rmdir (struct inode *dir,struct dentry *dentry, +struct cred *cred) {struct afs_vnode *dvnode, *vnode;struct key *key;
fs/autofs4/root.c +3 -2
@@ -21,7 +21,7 @@static int autofs4_dir_symlink (struct inode *,struct dentry *,const char *);static int autofs4_dir_unlink (struct inode *,struct dentry *,struct cred *); -static int autofs4_dir_rmdir (struct inode *,struct dentry *); +static int autofs4_dir_rmdir (struct inode *,struct dentry *,struct cred *);static int autofs4_dir_mkdir (struct inode *,struct dentry *,int ,struct cred *);static int autofs4_root_ioctl (struct inode *,struct file *,unsigned int ,unsigned long );static int autofs4_dir_open (struct inode *inode,struct file *file);
@@ -790,7 +790,8 @@ static int autofs4_dir_unlink(struct inode *dir, struct dentry *dentry,return 0 ; } -static int autofs4_dir_rmdir (struct inode *dir,struct dentry *dentry) +static int autofs4_dir_rmdir (struct inode *dir,struct dentry *dentry, +struct cred *cred) {struct autofs_sb_info *sbi =autofs4_sbi (dir->i_sb);struct autofs_info *ino =autofs4_dentry_ino (dentry);
fs/bad_inode.c +2 -1
@@ -221,7 +221,8 @@ static int bad_inode_mkdir(struct inode *dir, struct dentry *dentry,return -EIO ; } -static int bad_inode_rmdir (struct inode *dir,struct dentry *dentry) +static int bad_inode_rmdir (struct inode *dir,struct dentry *dentry, +struct cred *cred) {return -EIO ; }
fs/ext3/namei.c +2 -2
@@ -2080,9 +2080,9 @@ out_brelse: goto out_err; } -static int ext3_rmdir (struct inode * dir,struct dentry *dentry) +static int ext3_rmdir (struct inode * dir,struct dentry *dentry, +struct cred *cred) { -struct cred *cred = current->cred;int retval;struct inode * inode;struct buffer_head * bh;
fs/libfs.c +1 -3
@@ -294,10 +294,8 @@ int simple_unlink(struct inode *dir, struct dentry *dentry, struct cred *cred)return 0 ; } -int simple_rmdir (struct inode *dir,struct dentry *dentry) +int simple_rmdir (struct inode *dir,struct dentry *dentry,struct cred *cred) { -struct cred *cred = current->cred; -if (!simple_empty (dentry))return -ENOTEMPTY ;
fs/namei.c +2 -1
@@ -2058,6 +2058,7 @@ void dentry_unhash(struct dentry *dentry)int vfs_rmdir (struct inode *dir,struct dentry *dentry) { +struct cred *cred = current->cred;int error =may_delete (dir, dentry,1 );if (error)
@@ -2075,7 +2076,7 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)else { error =security_inode_rmdir (dir, dentry);if (!error) { - error = dir->i_op->rmdir (dir, dentry); + error = dir->i_op->rmdir (dir, dentry, cred);if (!error) dentry->d_inode->i_flags |=S_DEAD ; }
fs/nfs/dir.c +3 -3
@@ -47,7 +47,7 @@ static struct dentry *nfs_lookup(struct inode *, struct dentry *, struct nameidastatic int nfs_create (struct inode *,struct dentry *,int ,struct nameidata *,struct cred *);static int nfs_mkdir (struct inode *,struct dentry *,int ,struct cred *); -static int nfs_rmdir (struct inode *,struct dentry *); +static int nfs_rmdir (struct inode *,struct dentry *,struct cred *);static int nfs_unlink (struct inode *,struct dentry *,struct cred *);static int nfs_symlink (struct inode *,struct dentry *,const char *); static int nfs_link(struct dentry *, struct inode *, struct dentry *,
@@ -1348,9 +1348,9 @@ out_err:return error; } -static int nfs_rmdir (struct inode *dir,struct dentry *dentry) +static int nfs_rmdir (struct inode *dir,struct dentry *dentry, +struct cred *acred) { -struct cred *acred = current->cred;int error; dfprintk(VFS, "NFS: rmdir(%s/%ld), %s\n",
fs/vfat/namei.c +2 -1
@@ -764,7 +764,8 @@ out:return err; } -static int vfat_rmdir (struct inode *dir,struct dentry *dentry) +static int vfat_rmdir (struct inode *dir,struct dentry *dentry, +struct cred *cred) {struct inode *inode = dentry->d_inode;struct fat_slot_info sinfo;
include/linux/fs.h +2 -2
@@ -1143,7 +1143,7 @@ struct inode_operations {int (*unlink) (struct inode *,struct dentry *,struct cred *);int (*symlink) (struct inode *,struct dentry *,const char *);int (*mkdir) (struct inode *,struct dentry *,int ,struct cred *); -int (*rmdir) (struct inode *,struct dentry *); +int (*rmdir) (struct inode *,struct dentry *,struct cred *);int (*mknod) (struct inode *,struct dentry *,int ,dev_t ,struct cred *);int (*rename) (struct inode *,struct dentry *,struct inode *,struct dentry *);
@@ -1798,7 +1798,7 @@ extern int simple_statfs(struct dentry *, struct kstatfs *);extern int simple_link (struct dentry *,struct inode *,struct dentry *,struct cred *);extern int simple_unlink (struct inode *,struct dentry *,struct cred *); -extern int simple_rmdir (struct inode *,struct dentry *); +extern int simple_rmdir (struct inode *,struct dentry *,struct cred *);extern int simple_rename (struct inode *,struct dentry *,struct inode *,struct dentry *);extern int simple_sync_file (struct file *,struct dentry *,int );extern int simple_empty (struct dentry *);
mm/shmem.c +2 -2
@@ -1811,9 +1811,9 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry,return 0 ; } -static int shmem_rmdir (struct inode *dir,struct dentry *dentry) +static int shmem_rmdir (struct inode *dir,struct dentry *dentry, +struct cred *cred) { -struct cred *cred = current->cred;if (!simple_empty (dentry))return -ENOTEMPTY ;
net/sunrpc/rpc_pipe.c +4 -2
@@ -547,7 +547,7 @@ repeat:if (S_ISREG (dentry->d_inode->i_mode))simple_unlink (dir, dentry, cred);else if (S_ISDIR (dentry->d_inode->i_mode)) -simple_rmdir (dir, dentry); +simple_rmdir (dir, dentry, cred);d_delete (dentry);dput (dentry); }while (n);
@@ -618,8 +618,10 @@ out_err:static int __rpc_rmdir (struct inode *dir,struct dentry *dentry) { +struct cred *cred = current->cred;int error; - error =simple_rmdir (dir, dentry); + + error =simple_rmdir (dir, dentry, cred);if (!error)d_delete (dentry);return error;
security/inode.c +1 -1
@@ -305,7 +305,7 @@ void securityfs_remove(struct dentry *dentry)if (positive (dentry)) {if (dentry->d_inode) {if (S_ISDIR (dentry->d_inode->i_mode)) -simple_rmdir (parent->d_inode, dentry); +simple_rmdir (parent->d_inode, dentry, cred);else simple_unlink (parent->d_inode, dentry, cred);dput (dentry);
David Howells
maintainerPATCH 31/52 CRED: Give the rename() inode op a credentials pointer
In reply to David HowellsGive the rename() inode op a credentials pointer.
---
fs/afs/dir.c | 6 ++++-- fs/bad_inode.c | 3 ++- fs/ext3/namei.c | 4 ++-- fs/libfs.c | 5 ++--- fs/namei.c | 8 ++++++-- fs/nfs/dir.c | 6 +++--- fs/vfat/namei.c | 3 ++- include/linux/fs.h | 6 ++++-- mm/shmem.c | 5 +++-- 9 files changed, 28 insertions(+), 18 deletions(-)
fs/afs/dir.c +4 -2
@@ -41,7 +41,8 @@ static int afs_link(struct dentry *from, struct inode *dir,static int afs_symlink (struct inode *dir,struct dentry *dentry,const char *content);static int afs_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry); +struct inode *new_dir,struct dentry *new_dentry, +struct cred *cred);const struct file_operations afs_dir_file_operations = { .open = afs_dir_open,
@@ -1103,7 +1104,8 @@ error:* rename a file in an AFS filesystem and/or move it between directories */ static int afs_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry) +struct inode *new_dir,struct dentry *new_dentry, +struct cred *cred) {struct afs_vnode *orig_dvnode, *new_dvnode, *vnode;struct key *key;
fs/bad_inode.c +2 -1
@@ -234,7 +234,8 @@ static int bad_inode_mknod (struct inode *dir, struct dentry *dentry, }static int bad_inode_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry) +struct inode *new_dir,struct dentry *new_dentry, +struct cred *cred) {return -EIO ; }
fs/ext3/namei.c +2 -2
@@ -2299,9 +2299,9 @@ retry:* higher-level routines. */ static int ext3_rename (struct inode * old_dir,struct dentry *old_dentry, -struct inode * new_dir,struct dentry *new_dentry) +struct inode * new_dir,struct dentry *new_dentry, +struct cred *cred) { -struct cred *cred = current->cred;handle_t *handle;struct inode * old_inode, * new_inode;struct buffer_head * old_bh, * new_bh, * dir_bh;
fs/libfs.c +2 -3
@@ -8,7 +8,6 @@#include <linux/mount.h> #include <linux/vfs.h> #include <linux/mutex.h> -#include <linux/sched.h> #include <asm/uaccess.h>
@@ -306,9 +305,9 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry, struct cred *cred) }int simple_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry) +struct inode *new_dir,struct dentry *new_dentry, +struct cred *cred) { -struct cred *cred = current->cred;struct inode *inode = old_dentry->d_inode;int they_are_dirs =S_ISDIR (old_dentry->d_inode->i_mode);
fs/namei.c +6 -2
@@ -2433,6 +2433,7 @@ asmlinkage long sys_link(const char __user *oldname, const char __user *newname)static int vfs_rename_dir (struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry) { +struct cred *cred = current->cred;int error =0 ;struct inode *target;
@@ -2458,7 +2459,8 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,if (d_mountpoint (old_dentry)||d_mountpoint (new_dentry)) error = -EBUSY ;else - error = old_dir->i_op->rename (old_dir, old_dentry, new_dir, new_dentry); + error = old_dir->i_op->rename (old_dir, old_dentry, + new_dir, new_dentry, cred);if (target) {if (!error) target->i_flags |=S_DEAD ;
@@ -2476,6 +2478,7 @@ static int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,static int vfs_rename_other (struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry) { +struct cred *cred = current->cred;struct inode *target;int error;
@@ -2490,7 +2493,8 @@ static int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,if (d_mountpoint (old_dentry)||d_mountpoint (new_dentry)) error = -EBUSY ;else - error = old_dir->i_op->rename (old_dir, old_dentry, new_dir, new_dentry); + error = old_dir->i_op->rename (old_dir, old_dentry, + new_dir, new_dentry, cred);if (!error) {if (!(old_dir->i_sb->s_type->fs_flags &FS_RENAME_DOES_D_MOVE ))d_move (old_dentry, new_dentry);
fs/nfs/dir.c +3 -3
@@ -55,7 +55,7 @@ static int nfs_link(struct dentry *, struct inode *, struct dentry *,static int nfs_mknod (struct inode *,struct dentry *,int ,dev_t ,struct cred *);static int nfs_rename (struct inode *,struct dentry *, -struct inode *,struct dentry *); +struct inode *,struct dentry *,struct cred *);static int nfs_fsync_dir (struct file *,struct dentry *,int );static loff_t nfs_llseek_dir (struct file *,loff_t ,int );
@@ -1654,9 +1654,9 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry,* the rename. */ static int nfs_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry) +struct inode *new_dir,struct dentry *new_dentry, +struct cred *acred) { -struct cred *acred = current->cred;struct inode *old_inode = old_dentry->d_inode;struct inode *new_inode = new_dentry->d_inode;struct dentry *dentry =NULL , *rehash =NULL ;
fs/vfat/namei.c +2 -1
@@ -868,7 +868,8 @@ out: }static int vfat_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry) +struct inode *new_dir,struct dentry *new_dentry, +struct cred *cred) {struct buffer_head *dotdot_bh;struct msdos_dir_entry *dotdot_de;
include/linux/fs.h +4 -2
@@ -1146,7 +1146,8 @@ struct inode_operations {int (*rmdir) (struct inode *,struct dentry *,struct cred *);int (*mknod) (struct inode *,struct dentry *,int ,dev_t ,struct cred *);int (*rename) (struct inode *,struct dentry *, -struct inode *,struct dentry *); +struct inode *,struct dentry *, +struct cred *);int (*readlink) (struct dentry *,char __user *,int );void * (*follow_link) (struct dentry *,struct nameidata *);void (*put_link) (struct dentry *,struct nameidata *,void *);
@@ -1799,7 +1800,8 @@ extern int simple_link(struct dentry *, struct inode *, struct dentry *, struct cred *);extern int simple_unlink (struct inode *,struct dentry *,struct cred *);extern int simple_rmdir (struct inode *,struct dentry *,struct cred *); -extern int simple_rename (struct inode *,struct dentry *,struct inode *,struct dentry *); +extern int simple_rename (struct inode *,struct dentry *, +struct inode *,struct dentry *,struct cred *);extern int simple_sync_file (struct file *,struct dentry *,int );extern int simple_empty (struct dentry *);extern int simple_readpage (struct file *file,struct page *page);
mm/shmem.c +3 -2
@@ -1828,9 +1828,10 @@ static int shmem_rmdir(struct inode *dir, struct dentry *dentry,* it exists so that the VFS layer correctly free's it when it * gets overwritten. */ -static int shmem_rename (struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry) +static int shmem_rename (struct inode *old_dir,struct dentry *old_dentry, +struct inode *new_dir,struct dentry *new_dentry, +struct cred *cred) { -struct cred *cred = current->cred;struct inode *inode = old_dentry->d_inode;int they_are_dirs =S_ISDIR (inode->i_mode);
David Howells
maintainerPATCH 32/52 CRED: Give the symlink() inode op a credentials pointer
In reply to David HowellsGive the symlink() inode op a credentials pointer.
---
fs/afs/dir.c | 4 ++-- fs/autofs4/root.c | 6 ++++-- fs/bad_inode.c | 2 +- fs/ext3/namei.c | 3 +-- fs/namei.c | 3 ++- fs/nfs/dir.c | 7 ++++--- fs/ramfs/inode.c | 4 ++-- include/linux/fs.h | 3 ++- mm/shmem.c | 4 ++-- 9 files changed, 20 insertions(+), 16 deletions(-)
fs/afs/dir.c +2 -2
@@ -39,7 +39,7 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry,static int afs_link (struct dentry *from,struct inode *dir,struct dentry *dentry,struct cred *cred);static int afs_symlink (struct inode *dir,struct dentry *dentry, -const char *content); +const char *content,struct cred *cred);static int afs_rename (struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry,struct cred *cred);
@@ -1030,7 +1030,7 @@ error:* create a symlink in an AFS filesystem */ static int afs_symlink (struct inode *dir,struct dentry *dentry, -const char *content) +const char *content,struct cred *cred) {struct afs_file_status status;struct afs_server *server;
fs/autofs4/root.c +4 -2
@@ -19,7 +19,8 @@#include <linux/time.h> #include "autofs_i.h" -static int autofs4_dir_symlink (struct inode *,struct dentry *,const char *); +static int autofs4_dir_symlink (struct inode *,struct dentry *,const char *, +struct cred *);static int autofs4_dir_unlink (struct inode *,struct dentry *,struct cred *);static int autofs4_dir_rmdir (struct inode *,struct dentry *,struct cred *);static int autofs4_dir_mkdir (struct inode *,struct dentry *,int ,struct cred *);
@@ -690,7 +691,8 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry, sstatic int autofs4_dir_symlink (struct inode *dir,struct dentry *dentry, -const char *symname) +const char *symname, +struct cred *cred) {struct autofs_sb_info *sbi =autofs4_sbi (dir->i_sb);struct autofs_info *ino =autofs4_dentry_ino (dentry);
fs/bad_inode.c +1 -1
@@ -210,7 +210,7 @@ static int bad_inode_unlink(struct inode *dir, struct dentry *dentry, }static int bad_inode_symlink (struct inode *dir,struct dentry *dentry, -const char *symname) +const char *symname,struct cred *cred) {return -EIO ; }
fs/ext3/namei.c +1 -2
@@ -2196,9 +2196,8 @@ end_unlink: }static int ext3_symlink (struct inode * dir, -struct dentry *dentry,const char * symname) +struct dentry *dentry,const char * symname,struct cred *cred) { -struct cred *cred = current->cred;handle_t *handle;struct inode * inode;int l, err, retries =0 ;
fs/namei.c +2 -1
@@ -2239,6 +2239,7 @@ asmlinkage long sys_unlink(const char __user *pathname)int vfs_symlink (struct inode *dir,struct dentry *dentry,const char *oldname,int mode) { +struct cred *cred = current->cred;int error =may_create (dir, dentry,NULL );if (error)
@@ -2252,7 +2253,7 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname, ireturn error;DQUOT_INIT (dir); - error = dir->i_op->symlink (dir, dentry, oldname); + error = dir->i_op->symlink (dir, dentry, oldname, cred);if (!error)fsnotify_create (dir, dentry);return error;
fs/nfs/dir.c +4 -3
@@ -49,7 +49,8 @@ static int nfs_create(struct inode *, struct dentry *, int, struct nameidata *,static int nfs_mkdir (struct inode *,struct dentry *,int ,struct cred *);static int nfs_rmdir (struct inode *,struct dentry *,struct cred *);static int nfs_unlink (struct inode *,struct dentry *,struct cred *); -static int nfs_symlink (struct inode *,struct dentry *,const char *); +static int nfs_symlink (struct inode *,struct dentry *,const char *, +struct cred *);static int nfs_link (struct dentry *,struct inode *,struct dentry *,struct cred *); static int nfs_mknod(struct inode *, struct dentry *, int, dev_t,
@@ -1539,9 +1540,9 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry,* now have a new file handle and can instantiate an in-core NFS inode * and move the raw page into its mapping. */ -static int nfs_symlink (struct inode *dir,struct dentry *dentry,const char *symname) +static int nfs_symlink (struct inode *dir,struct dentry *dentry, +const char *symname,struct cred *acred) { -struct cred *acred = current->cred;struct pagevec lru_pvec;struct page *page;char *kaddr;
fs/ramfs/inode.c +2 -2
@@ -126,9 +126,9 @@ static int ramfs_create(struct inode *dir, struct dentry *dentry, int mode,return ramfs_mknod (dir, dentry, mode |S_IFREG ,0 , cred); } -static int ramfs_symlink (struct inode * dir,struct dentry *dentry,const char * symname) +static int ramfs_symlink (struct inode * dir,struct dentry *dentry, +const char * symname,struct cred *cred) { -struct cred *cred = current->cred;struct inode *inode;int error = -ENOSPC ;
include/linux/fs.h +2 -1
@@ -1141,7 +1141,8 @@ struct inode_operations {int (*link) (struct dentry *,struct inode *,struct dentry *,struct cred *);int (*unlink) (struct inode *,struct dentry *,struct cred *); -int (*symlink) (struct inode *,struct dentry *,const char *); +int (*symlink) (struct inode *,struct dentry *,const char *, +struct cred *);int (*mkdir) (struct inode *,struct dentry *,int ,struct cred *);int (*rmdir) (struct inode *,struct dentry *,struct cred *);int (*mknod) (struct inode *,struct dentry *,int ,dev_t ,struct cred *);
mm/shmem.c +2 -2
@@ -1855,9 +1855,9 @@ static int shmem_rename(struct inode *old_dir, struct dentry *old_dentry,return 0 ; } -static int shmem_symlink (struct inode *dir,struct dentry *dentry,const char *symname) +static int shmem_symlink (struct inode *dir,struct dentry *dentry, +const char *symname,struct cred *cred) { -struct cred *cred = current->cred;int error;int len;struct inode *inode;
David Howells
maintainerPATCH 33/52 CRED: Make the get_parent() export op take a credential pointer
In reply to David HowellsMake the get_parent() export op take a credential pointer.
---
fs/ext3/namei.c | 3 +-- fs/ext3/namei.h | 2 +- fs/fat/inode.c | 2 +- include/linux/exportfs.h | 5 +++-- mm/shmem.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-)
fs/ext3/namei.c +1 -2
@@ -1072,9 +1072,8 @@ static struct dentry *ext3_lookup(struct inode * dir, struct dentry *dentry, str } -struct dentry *ext3_get_parent (struct dentry *child) +struct dentry *ext3_get_parent (struct dentry *child,struct cred *cred) { -struct cred *cred = current->cred;unsigned long ino;struct dentry *parent;struct inode *inode;
fs/ext3/namei.h +1 -1
@@ -5,4 +5,4 @@* */ -extern struct dentry *ext3_get_parent (struct dentry *child); +extern struct dentry *ext3_get_parent (struct dentry *child,struct cred *cred);
fs/fat/inode.c +1 -1
@@ -748,7 +748,7 @@ fat_encode_fh(struct dentry *de, __u32 *fh, int *lenp, int connectable)return 3 ; } -static struct dentry *fat_get_parent (struct dentry *child) +static struct dentry *fat_get_parent (struct dentry *child,struct cred *cred) {struct buffer_head *bh;struct msdos_dir_entry *de;
include/linux/exportfs.h +3 -2
@@ -73,7 +73,8 @@ struct vfsmount;* get_parent: * @get_parent should find the parent directory for the given @child which * is also a directory. In the event that it cannot be found, or storage -* space cannot be allocated, a %ERR_PTR should be returned. +* space cannot be allocated, a %ERR_PTR should be returned. @cred indicates +* the credentials to be used for the lookup. * * get_dentry: * Given a &super_block (@sb) and a pointer to a file-system specific inode
@@ -103,7 +104,7 @@ struct export_operations { int connectable);int (*get_name)(struct dentry *parent,char *name,struct dentry *child); -struct dentry * (*get_parent)(struct dentry *child); +struct dentry * (*get_parent)(struct dentry *child,struct cred *cred);struct dentry * (*get_dentry)(struct super_block *sb,void *inump);/* This is set by the exporting module to a standard helper */
mm/shmem.c +1 -1
@@ -1994,7 +1994,7 @@ static struct xattr_handler *shmem_xattr_handlers[] = { };#endif -static struct dentry *shmem_get_parent (struct dentry *child) +static struct dentry *shmem_get_parent (struct dentry *child,struct cred *cred) {return ERR_PTR (-ESTALE ); }
David Howells
maintainerPATCH 34/52 CRED: Make Ext3 ACL set handlers pass credentials down
In reply to David HowellsMake Ext3 ACL set handlers pass credentials down to lower functions.
---
fs/ext3/acl.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
fs/ext3/acl.c +5 -4
@@ -483,9 +483,8 @@ ext3_xattr_get_acl_default(struct inode *inode, const char *name,static int ext3_xattr_set_acl (struct inode *inode,int type,const void *value, -size_t size) +size_t size,struct cred *cred) { -struct cred *cred = current->cred;handle_t *handle;struct posix_acl *acl;int error, retries =0 ;
@@ -526,18 +525,20 @@ static int ext3_xattr_set_acl_access(struct inode *inode, const char *name, const void *value, size_t size, int flags) { + struct cred *cred = current->cred;if (strcmp (name,"" ) !=0 )return -EINVAL ; - return ext3_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); +return ext3_xattr_set_acl (inode,ACL_TYPE_ACCESS , value, size, cred); }static int ext3_xattr_set_acl_default (struct inode *inode,const char *name,const void *value,size_t size,int flags) { +struct cred *cred = current->cred;if (strcmp (name,"" ) !=0 )return -EINVAL ; -return ext3_xattr_set_acl (inode,ACL_TYPE_DEFAULT , value, size); +return ext3_xattr_set_acl (inode,ACL_TYPE_DEFAULT , value, size, cred); } struct xattr_handler ext3_xattr_acl_access_handler = {
David Howells
maintainerPATCH 35/52 CRED: Make the ACL set() handler take a credentials pointer
In reply to David HowellsMake the ACL set() handler take a credentials pointer.
---
fs/ext3/acl.c | 8 ++++---- fs/ext3/xattr_security.c | 5 ++--- fs/ext3/xattr_trusted.c | 5 ++--- fs/ext3/xattr_user.c | 5 ++--- fs/xattr.c | 6 ++++-- include/linux/xattr.h | 2 +- mm/shmem.c | 3 ++- mm/shmem_acl.c | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-)
fs/ext3/acl.c +4 -4
@@ -523,9 +523,9 @@ release_and_out:static int ext3_xattr_set_acl_access (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +const void *value,size_t size,int flags, +struct cred *cred) { -struct cred *cred = current->cred;if (strcmp (name,"" ) !=0 )return -EINVAL ;return ext3_xattr_set_acl (inode,ACL_TYPE_ACCESS , value, size, cred);
@@ -533,9 +533,9 @@ ext3_xattr_set_acl_access(struct inode *inode, const char *name,static int ext3_xattr_set_acl_default (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +const void *value,size_t size,int flags, +struct cred *cred) { -struct cred *cred = current->cred;if (strcmp (name,"" ) !=0 )return -EINVAL ;return ext3_xattr_set_acl (inode,ACL_TYPE_DEFAULT , value, size, cred);
fs/ext3/xattr_security.c +2 -3
@@ -39,10 +39,9 @@ ext3_xattr_security_get(struct inode *inode, const char *name,static int ext3_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +const void *value,size_t size,int flags, +struct cred *cred) { -struct cred *cred = current->cred; -if (strcmp (name,"" ) ==0 )return -EINVAL ; return ext3_xattr_set(inode, EXT3_XATTR_INDEX_SECURITY, name,
fs/ext3/xattr_trusted.c +2 -3
@@ -45,10 +45,9 @@ ext3_xattr_trusted_get(struct inode *inode, const char *name,static int ext3_xattr_trusted_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +const void *value,size_t size,int flags, +struct cred *cred) { -struct cred *cred = current->cred; -if (strcmp (name,"" ) ==0 )return -EINVAL ; return ext3_xattr_set(inode, EXT3_XATTR_INDEX_TRUSTED, name,
fs/ext3/xattr_user.c +2 -3
@@ -45,10 +45,9 @@ ext3_xattr_user_get(struct inode *inode, const char *name,static int ext3_xattr_user_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +const void *value,size_t size,int flags, +struct cred *cred) { -struct cred *cred = current->cred; -if (strcmp (name,"" ) ==0 )return -EINVAL ;if (!test_opt (inode->i_sb,XATTR_USER ))
fs/xattr.c +4 -2
@@ -587,6 +587,7 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)int generic_setxattr (struct dentry *dentry,const char *name,const void *value,size_t size,int flags) { +struct cred *cred = current->cred;struct xattr_handler *handler;struct inode *inode = dentry->d_inode;
@@ -595,7 +596,7 @@ generic_setxattr(struct dentry *dentry, const char *name, const void *value, siz handler =xattr_resolve_name (inode->i_sb->s_xattr, &name);if (!handler)return -EOPNOTSUPP ; -return handler->set (inode, name, value, size, flags); +return handler->set (inode, name, value, size, flags, cred); }/*
@@ -605,13 +606,14 @@ generic_setxattr(struct dentry *dentry, const char *name, const void *value, sizint generic_removexattr (struct dentry *dentry,const char *name) { +struct cred *cred = current->cred;struct xattr_handler *handler;struct inode *inode = dentry->d_inode; handler =xattr_resolve_name (inode->i_sb->s_xattr, &name);if (!handler)return -EOPNOTSUPP ; -return handler->set (inode, name,NULL ,0 ,XATTR_REPLACE ); +return handler->set (inode, name,NULL ,0 ,XATTR_REPLACE , cred); }EXPORT_SYMBOL (generic_getxattr);
include/linux/xattr.h +1 -1
@@ -43,7 +43,7 @@ struct xattr_handler {int (*get)(struct inode *inode,const char *name,void *buffer,size_t size);int (*set)(struct inode *inode,const char *name,const void *buffer, -size_t size,int flags); +size_t size,int flags,struct cred *cred); };ssize_t vfs_getxattr (struct dentry *,char *,void *,size_t );
mm/shmem.c +2 -1
@@ -1972,7 +1972,8 @@ static int shmem_xattr_security_get(struct inode *inode, const char *name, }static int shmem_xattr_security_set (struct inode *inode,const char *name, -const void *value,size_t size,int flags) +const void *value,size_t size,int flags, +struct cred *cred) {if (strcmp (name,"" ) ==0 )return -EINVAL ;
mm/shmem_acl.c +2 -2
@@ -89,7 +89,7 @@ shmem_get_acl_access(struct inode *inode, const char *name, void *buffer,static int shmem_set_acl_access (struct inode *inode,const char *name,const void *value, -size_t size,int flags) +size_t size,int flags,struct cred *cred) {if (strcmp (name,"" ) !=0 )return -EINVAL ;
@@ -130,7 +130,7 @@ shmem_get_acl_default(struct inode *inode, const char *name, void *buffer,static int shmem_set_acl_default (struct inode *inode,const char *name,const void *value, -size_t size,int flags) +size_t size,int flags,struct cred *cred) {if (strcmp (name,"" ) !=0 )return -EINVAL ;
David Howells
maintainerPATCH 36/52 CRED: Make ext3_fill_super() pass credentials down
In reply to David HowellsMake ext3_fill_super() pass credentials down to the functions that it calls.
---
fs/ext3/super.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-)
fs/ext3/super.c +4 -3
@@ -1257,9 +1257,9 @@ static int ext3_check_descriptors (struct super_block * sb)* inode cleanup for us, so we can safely abort without any further action. */ static void ext3_orphan_cleanup (struct super_block * sb, -struct ext3_super_block * es) +struct ext3_super_block * es, +struct cred *cred) { -struct cred *cred = current->cred;unsigned int s_flags = sb->s_flags;int nr_orphans =0 , nr_truncates =0 ;#ifdef CONFIG_QUOTA
@@ -1398,6 +1398,7 @@ static ext3_fsblk_t descriptor_loc(struct super_block *sb,static int ext3_fill_super (struct super_block *sb,void *data,int silent) { +struct cred *cred = current->cred;struct buffer_head * bh;struct ext3_super_block *es =NULL ;struct ext3_sb_info *sbi;
@@ -1799,7 +1800,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)* superblock lock. */ EXT3_SB (sb)->s_mount_state |=EXT3_ORPHAN_FS ; -ext3_orphan_cleanup (sb, es); +ext3_orphan_cleanup (sb, es, cred);EXT3_SB (sb)->s_mount_state &= ~EXT3_ORPHAN_FS ;if (needs_recovery)printk (KERN_INFO "EXT3-fs: recovery complete.\n" );
David Howells
maintainerPATCH 37/52 CRED: Pass credentials to the get_sb() op and various fill_super() ops
In reply to David HowellsPass credentials to the get_sb() filesystem operation and various fill_super() operations required by get_sb_*() helpers.
---
fs/afs/super.c | 3 ++- fs/anon_inodes.c | 2 +- fs/autofs4/autofs_i.h | 2 +- fs/autofs4/init.c | 6 ++++-- fs/autofs4/inode.c | 3 ++- fs/binfmt_misc.c | 8 +++++--- fs/block_dev.c | 3 ++- fs/devpts/inode.c | 7 ++++--- fs/ext3/super.c | 10 ++++++---- fs/inotify_user.c | 3 ++- fs/nfs/super.c | 32 +++++++++++++++++--------------- fs/pipe.c | 2 +- fs/proc/inode.c | 3 ++- fs/proc/root.c | 5 +++-- fs/ramfs/inode.c | 14 ++++++++------ fs/super.c | 15 ++++++++------- fs/sysfs/mount.c | 8 +++++--- fs/vfat/namei.c | 7 ++++--- include/linux/fs.h | 9 +++++---- include/linux/proc_fs.h | 2 +- include/linux/ramfs.h | 3 ++- kernel/futex.c | 2 +- mm/shmem.c | 9 +++++---- net/socket.c | 2 +- net/sunrpc/rpc_pipe.c | 8 +++++--- security/inode.c | 7 ++++--- security/selinux/selinuxfs.c | 7 ++++--- 27 files changed, 105 insertions(+), 77 deletions(-)
fs/afs/super.c +2 -1
@@ -31,7 +31,7 @@ static void afs_i_init_once(void *foo, struct kmem_cache *cachep, unsigned long flags);static int afs_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name, -void *data,struct vfsmount *mnt); +void *data,struct cred *cred,struct vfsmount *mnt);static struct inode *afs_alloc_inode (struct super_block *sb);static void afs_put_super (struct super_block *sb);static void afs_destroy_inode (struct inode *inode);
@@ -352,6 +352,7 @@ static int afs_get_sb(struct file_system_type *fs_type,int flags, const char *dev_name, void *options, + struct cred *cred, struct vfsmount *mnt) { struct afs_mount_params params;
fs/anon_inodes.c +1 -1
@@ -27,7 +27,7 @@ static const struct file_operations anon_inode_fops;static int anon_inodefs_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name,void *data, -struct vfsmount *mnt) +struct cred *cred,struct vfsmount *mnt) {return get_sb_pseudo (fs_type,"anon_inode:" ,NULL ,ANON_INODE_FS_MAGIC , mnt);
fs/autofs4/autofs_i.h +1 -1
@@ -182,7 +182,7 @@ extern const struct file_operations autofs4_root_operations;/* Initializing function */ -int autofs4_fill_super (struct super_block *,void *,int ); +int autofs4_fill_super (struct super_block *,void *,int ,struct cred *);struct autofs_info *autofs4_init_ino (struct autofs_info *,struct autofs_sb_info *sbi,mode_t mode);/* Queue management functions */
fs/autofs4/init.c +4 -2
@@ -15,9 +15,11 @@#include "autofs_i.h" static int autofs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data,struct vfsmount *mnt) +int flags,const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, data, autofs4_fill_super, mnt); +return get_sb_nodev (fs_type, flags, data, autofs4_fill_super, cred, + mnt); }static struct file_system_type autofs_fs_type = {
fs/autofs4/inode.c +2 -1
@@ -303,7 +303,8 @@ static struct dentry_operations autofs4_sb_dentry_operations = { .d_release = autofs4_dentry_release, }; -int autofs4_fill_super (struct super_block *s,void *data,int silent) +int autofs4_fill_super (struct super_block *s,void *data,int silent, +struct cred *cred) {struct inode * root_inode;struct dentry * root;
fs/binfmt_misc.c +5 -3
@@ -715,7 +715,8 @@ static const struct super_operations s_ops = { .clear_inode = bm_clear_inode, }; -static int bm_fill_super (struct super_block * sb,void * data,int silent) +static int bm_fill_super (struct super_block * sb,void * data,int silent, +struct cred *cred) {static struct tree_descr bm_files[] = { [2 ] = {"status" , &bm_status_operations,S_IWUSR |S_IRUGO },
@@ -729,9 +730,10 @@ static int bm_fill_super(struct super_block * sb, void * data, int silent) }static int bm_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data,struct vfsmount *mnt) +int flags,const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, bm_fill_super, mnt); +return get_sb_single (fs_type, flags, data, bm_fill_super, cred, mnt); }static struct linux_binfmt misc_format = {
fs/block_dev.c +2 -1
@@ -499,7 +499,8 @@ static const struct super_operations bdev_sops = { };static int bd_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data,struct vfsmount *mnt) +int flags,const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt) {return get_sb_pseudo (fs_type,"bdev:" , &bdev_sops,0x62646576 , mnt); }
fs/devpts/inode.c +4 -3
@@ -98,7 +98,7 @@ static const struct super_operations devpts_sops = { };static int -devpts_fill_super (struct super_block *s,void *data,int silent) +devpts_fill_super (struct super_block *s,void *data,int silent,struct cred *cred) {struct inode * inode;
@@ -131,9 +131,10 @@ fail: }static int devpts_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data,struct vfsmount *mnt) +int flags,const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, devpts_fill_super, mnt); +return get_sb_single (fs_type, flags, data, devpts_fill_super, cred, mnt); }static struct file_system_type devpts_fs_type = {
fs/ext3/super.c +6 -4
@@ -1396,9 +1396,9 @@ static ext3_fsblk_t descriptor_loc(struct super_block *sb, } -static int ext3_fill_super (struct super_block *sb,void *data,int silent) +static int ext3_fill_super (struct super_block *sb,void *data,int silent, +struct cred *cred) { -struct cred *cred = current->cred;struct buffer_head * bh;struct ext3_super_block *es =NULL ;struct ext3_sb_info *sbi;
@@ -2779,9 +2779,11 @@ out:#endif static int ext3_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data,struct vfsmount *mnt) +int flags,const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt) { -return get_sb_bdev (fs_type, flags, dev_name, data, ext3_fill_super, mnt); +return get_sb_bdev (fs_type, flags, dev_name, data, ext3_fill_super, + cred, mnt); }static struct file_system_type ext3_fs_type = {
fs/inotify_user.c +2 -1
@@ -682,7 +682,8 @@ out:static int inotify_get_sb (struct file_system_type *fs_type,int flags, -const char *dev_name,void *data,struct vfsmount *mnt) +const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt) {return get_sb_pseudo (fs_type,"inotify" ,NULL ,0xBAD1DEA , mnt); }
fs/nfs/super.c +17 -15
@@ -223,9 +223,11 @@ static void nfs_umount_begin(struct vfsmount *, int);static int nfs_statfs (struct dentry *,struct kstatfs *);static int nfs_show_options (struct seq_file *,struct vfsmount *);static int nfs_show_stats (struct seq_file *,struct vfsmount *); -static int nfs_get_sb (struct file_system_type *,int ,const char *,void *,struct vfsmount *); +static int nfs_get_sb (struct file_system_type *,int ,const char *,void *, +struct cred *,struct vfsmount *);static int nfs_xdev_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *raw_data,struct vfsmount *mnt); +int flags,const char *dev_name,void *raw_data, +struct cred *acred,struct vfsmount *mnt);static void nfs_kill_super (struct super_block *);static struct file_system_type nfs_fs_type = {
@@ -257,11 +259,14 @@ static const struct super_operations nfs_sops = {#ifdef CONFIG_NFS_V4 static int nfs4_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *raw_data,struct vfsmount *mnt); +int flags,const char *dev_name,void *raw_data,struct cred *acred, +struct vfsmount *mnt);static int nfs4_xdev_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *raw_data,struct vfsmount *mnt); +int flags,const char *dev_name,void *raw_data,struct cred *acred, +struct vfsmount *mnt);static int nfs4_referral_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *raw_data,struct vfsmount *mnt); +int flags,const char *dev_name,void *raw_data,struct cred *acred, +struct vfsmount *mnt);static void nfs4_kill_super (struct super_block *sb); static struct file_system_type nfs4_fs_type = {
@@ -1377,9 +1382,9 @@ static int nfs_compare_super(struct super_block *sb, void *data) }static int nfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *raw_data,struct vfsmount *mnt) +int flags,const char *dev_name,void *raw_data,struct cred *acred, +struct vfsmount *mnt) { -struct cred *acred = current->cred;struct nfs_server *server =NULL ;struct super_block *s;struct nfs_fh mntfh;
@@ -1466,9 +1471,8 @@ static void nfs_kill_super(struct super_block *s)*/ static int nfs_xdev_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name,void *raw_data, -struct vfsmount *mnt) +struct cred *acred,struct vfsmount *mnt) { -struct cred *acred = current->cred;struct nfs_clone_mount *data = raw_data;struct super_block *s;struct nfs_server *server;
@@ -1732,9 +1736,9 @@ out_no_client_address:* Get the superblock for an NFS4 mountpoint */ static int nfs4_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *raw_data,struct vfsmount *mnt) +int flags,const char *dev_name,void *raw_data,struct cred *acred, +struct vfsmount *mnt) { -struct cred *acred = current->cred;struct nfs4_mount_data *data = raw_data;struct super_block *s;struct nfs_server *server;
@@ -1827,9 +1831,8 @@ static void nfs4_kill_super(struct super_block *sb)*/ static int nfs4_xdev_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name,void *raw_data, -struct vfsmount *mnt) +struct cred *acred,struct vfsmount *mnt) { -struct cred *acred = current->cred;struct nfs_clone_mount *data = raw_data;struct super_block *s;struct nfs_server *server;
@@ -1902,9 +1905,8 @@ error_splat_super:*/ static int nfs4_referral_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name,void *raw_data, -struct vfsmount *mnt) +struct cred *acred,struct vfsmount *mnt) { -struct cred *acred = current->cred;struct nfs_clone_mount *data = raw_data;struct super_block *s;struct nfs_server *server;
fs/pipe.c +1 -1
@@ -1084,7 +1084,7 @@ int do_pipe(int *fd)*/ static int pipefs_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name,void *data, -struct vfsmount *mnt) +struct cred *cred,struct vfsmount *mnt) {return get_sb_pseudo (fs_type,"pipe:" ,NULL ,PIPEFS_MAGIC , mnt); }
fs/proc/inode.c +2 -1
@@ -446,7 +446,8 @@ out_mod:return NULL ; } -int proc_fill_super (struct super_block *s,void *data,int silent) +int proc_fill_super (struct super_block *s,void *data,int silent, +struct cred *cred) {struct inode * root_inode;
fs/proc/root.c +3 -2
@@ -24,7 +24,8 @@struct proc_dir_entry *proc_bus, *proc_root_fs, *proc_root_driver;static int proc_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data,struct vfsmount *mnt) +int flags,const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt) {if (proc_mnt) {/* Seed the root directory with a pid so it doesn't need
@@ -37,7 +38,7 @@ static int proc_get_sb(struct file_system_type *fs_type,if (!ei->pid) ei->pid =find_get_pid (1 ); } -return get_sb_single (fs_type, flags, data, proc_fill_super, mnt); +return get_sb_single (fs_type, flags, data, proc_fill_super, cred, mnt); }static struct file_system_type proc_fs_type = {
fs/ramfs/inode.c +8 -6
@@ -165,9 +165,9 @@ static const struct super_operations ramfs_ops = { .drop_inode = generic_delete_inode, }; -static int ramfs_fill_super (struct super_block * sb,void * data,int silent) +static int ramfs_fill_super (struct super_block * sb,void * data,int silent, +struct cred *cred) { -struct cred *cred = current->cred;struct inode * inode;struct dentry * root;
@@ -191,16 +191,18 @@ static int ramfs_fill_super(struct super_block * sb, void * data, int silent) }int ramfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data,struct vfsmount *mnt) +int flags,const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, data, ramfs_fill_super, mnt); +return get_sb_nodev (fs_type, flags, data, ramfs_fill_super, cred, mnt); }static int rootfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data,struct vfsmount *mnt) +int flags,const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt) {return get_sb_nodev (fs_type, flags|MS_NOUSER , data, ramfs_fill_super, - mnt); + cred, mnt); }static struct file_system_type ramfs_fs_type = {
fs/super.c +8 -7
@@ -728,7 +728,7 @@ static int test_bdev_super(struct super_block *s, void *data)int get_sb_bdev (struct file_system_type *fs_type,int flags,const char *dev_name,void *data, -int (*fill_super)(struct super_block *,void *,int ), +fill_super_t fill_super,struct cred *cred,struct vfsmount *mnt) {struct block_device *bdev;
@@ -765,7 +765,7 @@ int get_sb_bdev(struct file_system_type *fs_type, s->s_flags = flags;strlcpy (s->s_id,bdevname (bdev, b),sizeof (s->s_id));sb_set_blocksize (s,block_size (bdev)); - error =fill_super (s, data, flags &MS_SILENT ?1 :0 ); + error =fill_super (s, data, flags &MS_SILENT ?1 :0 , cred);if (error) {up_write (&s->s_umount);deactivate_super (s);
@@ -801,7 +801,7 @@ EXPORT_SYMBOL(kill_block_super);int get_sb_nodev (struct file_system_type *fs_type,int flags,void *data, -int (*fill_super)(struct super_block *,void *,int ), +fill_super_t fill_super,struct cred *cred,struct vfsmount *mnt) {int error;
@@ -812,7 +812,7 @@ int get_sb_nodev(struct file_system_type *fs_type, s->s_flags = flags; - error =fill_super (s, data, flags &MS_SILENT ?1 :0 ); + error =fill_super (s, data, flags &MS_SILENT ?1 :0 , cred);if (error) {up_write (&s->s_umount);deactivate_super (s);
@@ -831,7 +831,7 @@ static int compare_single(struct super_block *s, void *p)int get_sb_single (struct file_system_type *fs_type,int flags,void *data, -int (*fill_super)(struct super_block *,void *,int ), +fill_super_t fill_super,struct cred *cred,struct vfsmount *mnt) {struct super_block *s;
@@ -842,7 +842,7 @@ int get_sb_single(struct file_system_type *fs_type,return PTR_ERR (s);if (!s->s_root) { s->s_flags = flags; - error =fill_super (s, data, flags &MS_SILENT ?1 :0 ); + error =fill_super (s, data, flags &MS_SILENT ?1 :0 , cred);if (error) {up_write (&s->s_umount);deactivate_super (s);
@@ -859,6 +859,7 @@ EXPORT_SYMBOL(get_sb_single);struct vfsmount *vfs_kern_mount (struct file_system_type *type,int flags,const char *name,void *data) { +struct cred *cred = current->cred;struct vfsmount *mnt;char *secdata =NULL ;int error;
@@ -881,7 +882,7 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void goto out_free_secdata; } - error = type->get_sb (type, flags, name, data, mnt); + error = type->get_sb (type, flags, name, data, cred, mnt);if (error <0 ) goto out_free_secdata;BUG_ON (!mnt->mnt_sb);
fs/sysfs/mount.c +5 -3
@@ -31,7 +31,8 @@ struct sysfs_dirent sysfs_root = { .s_ino = 1, }; -static int sysfs_fill_super (struct super_block *sb,void *data,int silent) +static int sysfs_fill_super (struct super_block *sb,void *data,int silent, +struct cred *cred) {struct inode *inode;struct dentry *root;
@@ -69,9 +70,10 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent) }static int sysfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data,struct vfsmount *mnt) +int flags,const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, sysfs_fill_super, mnt); +return get_sb_single (fs_type, flags, data, sysfs_fill_super, cred, mnt); }static struct file_system_type sysfs_fs_type = {
fs/vfat/namei.c +4 -3
@@ -1011,7 +1011,8 @@ static const struct inode_operations vfat_dir_inode_operations = { .getattr = fat_getattr, }; -static int vfat_fill_super (struct super_block *sb,void *data,int silent) +static int vfat_fill_super (struct super_block *sb,void *data,int silent, +struct cred *cred) {int res;
@@ -1029,10 +1030,10 @@ static int vfat_fill_super(struct super_block *sb, void *data, int silent)static int vfat_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name, -void *data,struct vfsmount *mnt) +void *data,struct cred *cred,struct vfsmount *mnt) {return get_sb_bdev (fs_type, flags, dev_name, data, vfat_fill_super, - mnt); + cred, mnt); }static struct file_system_type vfat_fs_type = {
include/linux/fs.h +5 -4
@@ -1301,7 +1301,7 @@ struct file_system_type {const char *name;int fs_flags;int (*get_sb) (struct file_system_type *,int , -const char *,void *,struct vfsmount *); +const char *,void *,struct cred *,struct vfsmount *);void (*kill_sb) (struct super_block *);struct module *owner;struct file_system_type * next;
@@ -1310,17 +1310,18 @@ struct file_system_type {struct lock_class_key s_umount_key; }; +typedef int (*fill_super_t )(struct super_block *,void *,int ,struct cred *);extern int get_sb_bdev (struct file_system_type *fs_type,int flags,const char *dev_name,void *data, -int (*fill_super)(struct super_block *,void *,int ), +fill_super_t fill_super,struct cred *cred,struct vfsmount *mnt);extern int get_sb_single (struct file_system_type *fs_type,int flags,void *data, -int (*fill_super)(struct super_block *,void *,int ), +fill_super_t fill_super,struct cred *cred,struct vfsmount *mnt);extern int get_sb_nodev (struct file_system_type *fs_type,int flags,void *data, -int (*fill_super)(struct super_block *,void *,int ), +fill_super_t fill_super,struct cred *cred,struct vfsmount *mnt);void generic_shutdown_super (struct super_block *sb);void kill_block_super (struct super_block *sb);
include/linux/proc_fs.h +1 -1
@@ -125,7 +125,7 @@ extern struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,extern void remove_proc_entry (const char *name,struct proc_dir_entry *parent);extern struct vfsmount *proc_mnt; -extern int proc_fill_super (struct super_block *,void *,int ); +extern int proc_fill_super (struct super_block *,void *,int ,struct cred *);extern struct inode *proc_get_inode (struct super_block *,unsigned int ,struct proc_dir_entry *);/*
include/linux/ramfs.h +2 -1
@@ -4,7 +4,8 @@struct inode *ramfs_get_inode (struct super_block *sb,int mode,dev_t dev,struct cred *cred);extern int ramfs_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data,struct vfsmount *mnt); +int flags,const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt);#ifndef CONFIG_MMU extern unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
kernel/futex.c +1 -1
@@ -2078,7 +2078,7 @@ asmlinkage long sys_futex(u32 __user *uaddr, int op, u32 val,static int futexfs_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name,void *data, -struct vfsmount *mnt) +struct cred *cred,struct vfsmount *mnt) {return get_sb_pseudo (fs_type,"futex" ,NULL ,0xBAD1DEA , mnt); }
mm/shmem.c +5 -4
@@ -2217,9 +2217,9 @@ static void shmem_put_super(struct super_block *sb) }static int shmem_fill_super (struct super_block *sb, -void *data,int silent) +void *data,int silent, +struct cred *cred) { -struct cred *cred = current->cred;struct inode *inode;struct dentry *root;int mode =S_IRWXUGO |S_ISVTX ;
@@ -2436,9 +2436,10 @@ static struct vm_operations_struct shmem_vm_ops = {static int shmem_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data,struct vfsmount *mnt) +int flags,const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt) { -return get_sb_nodev (fs_type, flags, data, shmem_fill_super, mnt); +return get_sb_nodev (fs_type, flags, data, shmem_fill_super, cred, mnt); }static struct file_system_type tmpfs_fs_type = {
net/socket.c +1 -1
@@ -287,7 +287,7 @@ static struct super_operations sockfs_ops = {static int sockfs_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name,void *data, -struct vfsmount *mnt) +struct cred *cred,struct vfsmount *mnt) {return get_sb_pseudo (fs_type,"socket:" , &sockfs_ops,SOCKFS_MAGIC , mnt);
net/sunrpc/rpc_pipe.c +5 -3
@@ -800,7 +800,8 @@ static struct super_operations s_ops = {#define RPCAUTH_GSSMAGIC 0x67596969static int -rpc_fill_super (struct super_block *sb,void *data,int silent) +rpc_fill_super (struct super_block *sb,void *data,int silent, +struct cred *cred) {struct inode *inode;struct dentry *root;
@@ -831,9 +832,10 @@ out:static int rpc_get_sb (struct file_system_type *fs_type, -int flags,const char *dev_name,void *data,struct vfsmount *mnt) +int flags,const char *dev_name,void *data,struct cred *cred, +struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, rpc_fill_super, mnt); +return get_sb_single (fs_type, flags, data, rpc_fill_super, cred, mnt); }static struct file_system_type rpc_pipe_fs_type = {
security/inode.c +4 -3
@@ -126,7 +126,8 @@ static inline int positive(struct dentry *dentry)return dentry->d_inode && !d_unhashed (dentry); } -static int fill_super (struct super_block *sb,void *data,int silent) +static int fill_super (struct super_block *sb,void *data,int silent, +struct cred *cred) {static struct tree_descr files[] = {{"" }};
@@ -135,9 +136,9 @@ static int fill_super(struct super_block *sb, void *data, int silent)static int get_sb (struct file_system_type *fs_type,int flags,const char *dev_name, -void *data,struct vfsmount *mnt) +void *data,struct cred *cred,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, fill_super, mnt); +return get_sb_single (fs_type, flags, data, fill_super, cred, mnt); }static struct file_system_type fs_type = {
security/selinux/selinuxfs.c +4 -3
@@ -1554,7 +1554,8 @@ out:return ret; } -static int sel_fill_super (struct super_block * sb,void * data,int silent) +static int sel_fill_super (struct super_block * sb,void * data,int silent, +struct cred *cred) {int ret;struct dentry *dentry;
@@ -1666,9 +1667,9 @@ err:static int sel_get_sb (struct file_system_type *fs_type,int flags,const char *dev_name,void *data, -struct vfsmount *mnt) +struct cred *cred,struct vfsmount *mnt) { -return get_sb_single (fs_type, flags, data, sel_fill_super, mnt); +return get_sb_single (fs_type, flags, data, sel_fill_super, cred, mnt); }static struct file_system_type sel_fs_type = {
David Howells
maintainerPATCH 38/52 CRED: Pass credentials through the quota_read() op
In reply to David HowellsPass credentials through the quota_read() op.
---
fs/ext3/super.c | 5 ++--- fs/quota_v2.c | 13 +++++++++---- include/linux/fs.h | 3 ++- 3 files changed, 13 insertions(+), 8 deletions(-)
fs/ext3/super.c +2 -3
@@ -615,7 +615,7 @@ static int ext3_write_info(struct super_block *sb, int type);static int ext3_quota_on (struct super_block *sb,int type,int format_id,char *path);static int ext3_quota_on_mount (struct super_block *sb,int type);static ssize_t ext3_quota_read (struct super_block *sb,int type,char *data, -size_t len,loff_t off); +size_t len,loff_t off,struct cred *cred);static ssize_t ext3_quota_write (struct super_block *sb,int type,const char *data,size_t len,loff_t off);
@@ -2671,9 +2671,8 @@ static int ext3_quota_on(struct super_block *sb, int type, int format_id,* itself serializes the operations (and noone else should touch the files) * we don't have to be afraid of races */ static ssize_t ext3_quota_read (struct super_block *sb,int type,char *data, -size_t len,loff_t off) +size_t len,loff_t off,struct cred *cred) { -struct cred *cred = current->cred;struct inode *inode =sb_dqopt (sb)->files[type];sector_t blk = off >>EXT3_BLOCK_SIZE_BITS (sb);int err =0 ;
fs/quota_v2.c +9 -4
@@ -28,12 +28,14 @@ typedef char *dqbuf_t;/* Check whether given file is really vfsv0 quotafile */ static int v2_check_quota_file (struct super_block *sb,int type) { +struct cred *cred = &init_cred;struct v2_disk_dqheader dqhead;ssize_t size;static const uint quota_magics[] =V2_INITQMAGICS ;static const uint quota_versions[] =V2_INITQVERSIONS ; - size = sb->s_op->quota_read (sb, type, (char *)&dqhead,sizeof (struct v2_disk_dqheader ),0 ); + size = sb->s_op->quota_read (sb, type, (char *)&dqhead, +sizeof (struct v2_disk_dqheader ),0 , cred);if (size !=sizeof (struct v2_disk_dqheader )) {printk ("quota_v2: failed read expected=%zd got=%zd\n" ,sizeof (struct v2_disk_dqheader ), size);
@@ -48,12 +50,13 @@ static int v2_check_quota_file(struct super_block *sb, int type)/* Read information header from quota file */ static int v2_read_file_info (struct super_block *sb,int type) { +struct cred *cred = &init_cred;struct v2_disk_dqinfo dinfo;struct mem_dqinfo *info =sb_dqopt (sb)->info+type;ssize_t size; size = sb->s_op->quota_read (sb, type, (char *)&dinfo, -sizeof (struct v2_disk_dqinfo ),V2_DQINFOOFF ); +sizeof (struct v2_disk_dqinfo ),V2_DQINFOOFF , cred);if (size !=sizeof (struct v2_disk_dqinfo )) {printk (KERN_WARNING "Can't read info structure on device %s.\n" , sb->s_id);
@@ -134,9 +137,10 @@ static inline void freedqbuf(dqbuf_t buf)static inline ssize_t read_blk (struct super_block *sb,int type,uint blk,dqbuf_t buf) { +struct cred *cred = &init_cred;memset (buf,0 ,V2_DQBLKSIZE );return sb->s_op->quota_read (sb, type, (char *)buf, -V2_DQBLKSIZE , blk <<V2_DQBLKSIZE_BITS ); +V2_DQBLKSIZE , blk <<V2_DQBLKSIZE_BITS , cred); }static inline ssize_t write_blk (struct super_block *sb,int type,uint blk,dqbuf_t buf)
@@ -603,6 +607,7 @@ static inline loff_t find_dqentry(struct dquot *dquot)static int v2_read_dquot (struct dquot *dquot) { +struct cred *cred = &init_cred;int type = dquot->dq_type;loff_t offset;struct v2_disk_dqblk ddquot, empty;
@@ -628,7 +633,7 @@ static int v2_read_dquot(struct dquot *dquot)else { dquot->dq_off = offset;if ((ret = dquot->dq_sb->s_op->quota_read (dquot->dq_sb, type, - (char *)&ddquot,sizeof (struct v2_disk_dqblk ), offset)) + (char *)&ddquot,sizeof (struct v2_disk_dqblk ), offset, cred)) !=sizeof (struct v2_disk_dqblk )) {if (ret >=0 ) ret = -EIO ;
include/linux/fs.h +2 -1
@@ -1205,7 +1205,8 @@ struct super_operations {int (*show_options)(struct seq_file *,struct vfsmount *);int (*show_stats)(struct seq_file *,struct vfsmount *);#ifdef CONFIG_QUOTA -ssize_t (*quota_read)(struct super_block *,int ,char *,size_t ,loff_t ); +ssize_t (*quota_read)(struct super_block *,int ,char *,size_t ,loff_t , +struct cred *);ssize_t (*quota_write)(struct super_block *,int ,const char *,size_t ,loff_t );#endif };
David Howells
maintainerPATCH 39/52 CRED: Pass credentials through the quota_write() op
In reply to David HowellsPass credentials through the quota_write() op.
---
fs/ext3/super.c | 7 ++++--- fs/quota_v2.c | 9 ++++++--- include/linux/fs.h | 3 ++- 3 files changed, 12 insertions(+), 7 deletions(-)
fs/ext3/super.c +4 -3
@@ -617,7 +617,8 @@ static int ext3_quota_on_mount(struct super_block *sb, int type);static ssize_t ext3_quota_read (struct super_block *sb,int type,char *data,size_t len,loff_t off,struct cred *cred);static ssize_t ext3_quota_write (struct super_block *sb,int type, -const char *data,size_t len,loff_t off); +const char *data,size_t len,loff_t off, +struct cred *cred);static struct dquot_operations ext3_quota_operations = { .initialize = ext3_dquot_initialize,
@@ -2709,9 +2710,9 @@ static ssize_t ext3_quota_read(struct super_block *sb, int type, char *data,/* Write to quotafile (we know the transaction is already started and has * enough credits) */ static ssize_t ext3_quota_write (struct super_block *sb,int type, -const char *data,size_t len,loff_t off) +const char *data,size_t len,loff_t off, +struct cred *cred) { -struct cred *cred = current->cred;struct inode *inode =sb_dqopt (sb)->files[type];sector_t blk = off >>EXT3_BLOCK_SIZE_BITS (sb);int err =0 ;
fs/quota_v2.c +6 -3
@@ -74,6 +74,7 @@ static int v2_read_file_info(struct super_block *sb, int type)/* Write information header to quota file */ static int v2_write_file_info (struct super_block *sb,int type) { +struct cred *cred = &init_cred;struct v2_disk_dqinfo dinfo;struct mem_dqinfo *info =sb_dqopt (sb)->info+type;ssize_t size;
@@ -88,7 +89,7 @@ static int v2_write_file_info(struct super_block *sb, int type) dinfo.dqi_free_blk =cpu_to_le32 (info->u.v2_i.dqi_free_blk); dinfo.dqi_free_entry =cpu_to_le32 (info->u.v2_i.dqi_free_entry); size = sb->s_op->quota_write (sb, type, (char *)&dinfo, -sizeof (struct v2_disk_dqinfo ),V2_DQINFOOFF ); +sizeof (struct v2_disk_dqinfo ),V2_DQINFOOFF , cred);if (size !=sizeof (struct v2_disk_dqinfo )) {printk (KERN_WARNING "Can't write info structure on device %s.\n" , sb->s_id);
@@ -145,8 +146,9 @@ static inline ssize_t read_blk(struct super_block *sb, int type, uint blk, dqbufstatic inline ssize_t write_blk (struct super_block *sb,int type,uint blk,dqbuf_t buf) { +struct cred *cred = &init_cred;return sb->s_op->quota_write (sb, type, (char *)buf, -V2_DQBLKSIZE , blk <<V2_DQBLKSIZE_BITS ); +V2_DQBLKSIZE , blk <<V2_DQBLKSIZE_BITS , cred); }/* Remove empty block from list and return it */
@@ -394,6 +396,7 @@ static inline int dq_insert_tree(struct dquot *dquot)*/ static int v2_write_dquot (struct dquot *dquot) { +struct cred *cred = &init_cred;int type = dquot->dq_type;ssize_t ret;struct v2_disk_dqblk ddquot, empty;
@@ -414,7 +417,7 @@ static int v2_write_dquot(struct dquot *dquot) ddquot.dqb_itime =cpu_to_le64 (1 );spin_unlock (&dq_data_lock); ret = dquot->dq_sb->s_op->quota_write (dquot->dq_sb, type, - (char *)&ddquot,sizeof (struct v2_disk_dqblk ), dquot->dq_off); + (char *)&ddquot,sizeof (struct v2_disk_dqblk ), dquot->dq_off, cred);if (ret !=sizeof (struct v2_disk_dqblk )) {printk (KERN_WARNING "VFS: dquota write failed on dev %s\n" , dquot->dq_sb->s_id);if (ret >=0 )
include/linux/fs.h +2 -1
@@ -1207,7 +1207,8 @@ struct super_operations {#ifdef CONFIG_QUOTA ssize_t (*quota_read)(struct super_block *,int ,char *,size_t ,loff_t ,struct cred *); -ssize_t (*quota_write)(struct super_block *,int ,const char *,size_t ,loff_t ); +ssize_t (*quota_write)(struct super_block *,int ,const char *,size_t , +loff_t ,struct cred *);#endif };
David Howells
maintainerPATCH 40/52 CRED: Give the lookup() inode op a credentials pointer
In reply to David HowellsGive the lookup() inode op a credentials pointer.
---
fs/afs/dir.c | 4 ++-- fs/afs/mntpt.c | 6 ++++-- fs/autofs4/root.c | 6 ++++-- fs/bad_inode.c | 3 ++- fs/ext3/namei.c | 4 ++-- fs/libfs.c | 3 ++- fs/namei.c | 6 ++++-- fs/nfs/dir.c | 18 +++++++++++------- fs/proc/base.c | 23 +++++++++++++++++------ fs/proc/generic.c | 3 ++- fs/proc/proc_net.c | 4 ++-- fs/proc/proc_sysctl.c | 2 +- fs/proc/root.c | 6 +++--- fs/sysfs/dir.c | 2 +- fs/vfat/namei.c | 2 +- include/linux/fs.h | 6 ++++-- include/linux/proc_fs.h | 3 ++- 17 files changed, 64 insertions(+), 37 deletions(-)
fs/afs/dir.c +2 -2
@@ -20,7 +20,7 @@#include "internal.h" static struct dentry *afs_lookup (struct inode *dir,struct dentry *dentry, -struct nameidata *nd); +struct nameidata *nd,struct cred *cred);static int afs_dir_open (struct inode *inode,struct file *file);static int afs_readdir (struct file *file,void *dirent,filldir_t filldir);static int afs_d_revalidate (struct dentry *dentry,struct nameidata *nd);
@@ -488,7 +488,7 @@ static int afs_do_lookup(struct inode *dir, struct dentry *dentry,* look up an entry in a directory */ static struct dentry *afs_lookup (struct inode *dir,struct dentry *dentry, -struct nameidata *nd) +struct nameidata *nd,struct cred *cred) {struct afs_vnode *vnode;struct afs_fid fid;
fs/afs/mntpt.c +4 -2
@@ -23,7 +23,8 @@static struct dentry *afs_mntpt_lookup (struct inode *dir,struct dentry *dentry, -struct nameidata *nd); +struct nameidata *nd, +struct cred *cred);static int afs_mntpt_open (struct inode *inode,struct file *file);static void *afs_mntpt_follow_link (struct dentry *dentry,struct nameidata *nd);static void afs_mntpt_expiry_timed_out (struct work_struct *work);
@@ -103,7 +104,8 @@ out:*/ static struct dentry *afs_mntpt_lookup (struct inode *dir,struct dentry *dentry, -struct nameidata *nd) +struct nameidata *nd, +struct cred *cred) { _enter("%p,%p{%p{%s},%s}", dir,
fs/autofs4/root.c +4 -2
@@ -29,7 +29,8 @@ static int autofs4_dir_open(struct inode *inode, struct file *file);static int autofs4_dir_close (struct inode *inode,struct file *file);static int autofs4_dir_readdir (struct file * filp,void * dirent,filldir_t filldir);static int autofs4_root_readdir (struct file * filp,void * dirent,filldir_t filldir); -static struct dentry *autofs4_lookup (struct inode *,struct dentry *,struct nameidata *); +static struct dentry *autofs4_lookup (struct inode *,struct dentry *, +struct nameidata *,struct cred *);static void *autofs4_follow_link (struct dentry *,struct nameidata *);const struct file_operations autofs4_root_operations = {
@@ -566,7 +567,8 @@ next: }/* Lookups in the root directory */ -static struct dentry *autofs4_lookup (struct inode *dir,struct dentry *dentry,struct nameidata *nd) +static struct dentry *autofs4_lookup (struct inode *dir,struct dentry *dentry, +struct nameidata *nd,struct cred *cred) {struct autofs_sb_info *sbi;struct dentry *unhashed;
fs/bad_inode.c +2 -1
@@ -192,7 +192,8 @@ static int bad_inode_create (struct inode *dir, struct dentry *dentry, }static struct dentry *bad_inode_lookup (struct inode *dir, -struct dentry *dentry,struct nameidata *nd) +struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {return ERR_PTR (-EIO ); }
fs/ext3/namei.c +2 -2
@@ -1044,9 +1044,9 @@ errout: }#endif -static struct dentry *ext3_lookup (struct inode * dir,struct dentry *dentry,struct nameidata *nd) +static struct dentry *ext3_lookup (struct inode * dir,struct dentry *dentry, +struct nameidata *nd,struct cred *cred) { -struct cred *cred = current->cred;struct inode * inode;struct ext3_dir_entry_2 * de;struct buffer_head * bh;
fs/libfs.c +2 -1
@@ -41,7 +41,8 @@ static int simple_delete_dentry(struct dentry *dentry)* Lookup the data. This is trivial - if the dentry didn't already * exist, we know it is negative. Set d_op to delete negative dentries. */ -struct dentry *simple_lookup (struct inode *dir,struct dentry *dentry,struct nameidata *nd) +struct dentry *simple_lookup (struct inode *dir,struct dentry *dentry, +struct nameidata *nd,struct cred *cred) {static struct dentry_operations simple_dentry_operations = { .d_delete = simple_delete_dentry,
fs/namei.c +4 -2
@@ -469,6 +469,7 @@ ok:*/ static struct dentry *real_lookup (struct dentry * parent,struct qstr * name,struct nameidata *nd) { +struct cred *cred = current->cred;struct dentry * result;struct inode *dir = parent->d_inode;
@@ -492,7 +493,7 @@ static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, sstruct dentry * dentry =d_alloc (parent, name); result =ERR_PTR (-ENOMEM );if (dentry) { - result = dir->i_op->lookup (dir, dentry, nd); + result = dir->i_op->lookup (dir, dentry, nd, cred);if (result)dput (dentry);else
@@ -1275,6 +1276,7 @@ int __user_path_lookup_open(const char __user *name, unsigned int lookup_flags,static inline struct dentry *__lookup_hash_kern (struct qstr *name,struct dentry *base,struct nameidata *nd) { +struct cred *cred = current->cred;struct dentry *dentry;struct inode *inode;int err;
@@ -1298,7 +1300,7 @@ static inline struct dentry *__lookup_hash_kern(struct qstr *name, struct dentry dentry =ERR_PTR (-ENOMEM );if (!new) goto out; - dentry = inode->i_op->lookup (inode, new, nd); + dentry = inode->i_op->lookup (inode, new, nd, cred);if (!dentry) dentry = new;else
fs/nfs/dir.c +11 -7
@@ -43,7 +43,8 @@static int nfs_opendir (struct inode *,struct file *);static int nfs_readdir (struct file *,void *,filldir_t ); -static struct dentry *nfs_lookup (struct inode *,struct dentry *,struct nameidata *); +static struct dentry *nfs_lookup (struct inode *,struct dentry *, +struct nameidata *,struct cred *);static int nfs_create (struct inode *,struct dentry *,int ,struct nameidata *,struct cred *);static int nfs_mkdir (struct inode *,struct dentry *,int ,struct cred *);
@@ -107,7 +108,8 @@ const struct inode_operations nfs3_dir_inode_operations = {#ifdef CONFIG_NFS_V4 -static struct dentry *nfs_atomic_lookup (struct inode *,struct dentry *,struct nameidata *); +static struct dentry *nfs_atomic_lookup (struct inode *,struct dentry *, +struct nameidata *,struct cred *);const struct inode_operations nfs4_dir_inode_operations = { .create = nfs_create, .lookup = nfs_atomic_lookup,
@@ -919,9 +921,9 @@ static inline int nfs_reval_fsid(struct inode *dir, const struct nfs_fattr *fattreturn 0 ; } -static struct dentry *nfs_lookup (struct inode *dir,struct dentry * dentry,struct nameidata *nd) +static struct dentry *nfs_lookup (struct inode *dir,struct dentry * dentry, +struct nameidata *nd,struct cred *acred) { -struct cred *acred = current->cred;struct dentry *res;struct inode *inode =NULL ;int error;
@@ -1016,9 +1018,11 @@ static int is_atomic_open(struct inode *dir, struct nameidata *nd)return 1 ; } -static struct dentry *nfs_atomic_lookup (struct inode *dir,struct dentry *dentry,struct nameidata *nd) +static struct dentry *nfs_atomic_lookup (struct inode *dir, +struct dentry *dentry, +struct nameidata *nd, +struct cred *acred) { -struct cred *acred = current->cred;struct dentry *res =NULL ;int error;
@@ -1083,7 +1087,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry out:return res; no_open: -return nfs_lookup (dir, dentry, nd); +return nfs_lookup (dir, dentry, nd, acred); }static int nfs_open_revalidate (struct dentry *dentry,struct nameidata *nd)
fs/proc/base.c +17 -6
@@ -1445,7 +1445,7 @@ out_no_task: }static struct dentry *proc_lookupfd (struct inode *dir,struct dentry *dentry, -struct nameidata *nd) +struct nameidata *nd,struct cred *cred) {return proc_lookupfd_common (dir, dentry, proc_fd_instantiate); }
@@ -1528,7 +1528,8 @@ static struct dentry *proc_fdinfo_instantiate(struct inode *dir,static struct dentry *proc_lookupfdinfo (struct inode *dir,struct dentry *dentry, -struct nameidata *nd) +struct nameidata *nd, +struct cred *cred) {return proc_lookupfd_common (dir, dentry, proc_fdinfo_instantiate); }
@@ -1773,7 +1774,8 @@ static const struct file_operations proc_attr_dir_operations = { };static struct dentry *proc_attr_dir_lookup (struct inode *dir, -struct dentry *dentry,struct nameidata *nd) +struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {return proc_pident_lookup (dir, dentry, attr_dir_stuff,ARRAY_SIZE (attr_dir_stuff));
@@ -2112,7 +2114,11 @@ static const struct file_operations proc_tgid_base_operations = { .readdir = proc_tgid_base_readdir, }; -static struct dentry *proc_tgid_base_lookup (struct inode *dir,struct dentry *dentry,struct nameidata *nd){ +static struct dentry *proc_tgid_base_lookup (struct inode *dir, +struct dentry *dentry, +struct nameidata *nd, +struct cred *cred) +{return proc_pident_lookup (dir, dentry, tgid_base_stuff,ARRAY_SIZE (tgid_base_stuff)); }
@@ -2387,7 +2393,11 @@ static int proc_tid_base_readdir(struct file * filp, tid_base_stuff,ARRAY_SIZE(tid_base_stuff)); } -static struct dentry *proc_tid_base_lookup (struct inode *dir,struct dentry *dentry,struct nameidata *nd){ +static struct dentry *proc_tid_base_lookup (struct inode *dir, +struct dentry *dentry, +struct nameidata *nd, +struct cred *cred) +{return proc_pident_lookup (dir, dentry, tid_base_stuff,ARRAY_SIZE (tid_base_stuff)); }
@@ -2431,7 +2441,8 @@ out:return error; } -static struct dentry *proc_task_lookup (struct inode *dir,struct dentry * dentry,struct nameidata *nd) +static struct dentry *proc_task_lookup (struct inode *dir,struct dentry *dentry, +struct nameidata *nd,struct cred *cred) {struct dentry *result =ERR_PTR (-ENOENT );struct task_struct *task;
fs/proc/generic.c +2 -1
@@ -384,7 +384,8 @@ static struct dentry_operations proc_dentry_operations =* Don't create negative dentries here, return -ENOENT by hand * instead. */ -struct dentry *proc_lookup (struct inode * dir,struct dentry *dentry,struct nameidata *nd) +struct dentry *proc_lookup (struct inode * dir,struct dentry *dentry, +struct nameidata *nd,struct cred *cred) {struct inode *inode =NULL ;struct proc_dir_entry * de;
fs/proc/proc_net.c +2 -2
@@ -101,7 +101,7 @@ static void *proc_net_follow_link(struct dentry *parent, struct nameidata *nd) }static struct dentry *proc_net_lookup (struct inode *dir,struct dentry *dentry, -struct nameidata *nd) +struct nameidata *nd,struct cred *cred) {struct net *net = current->nsproxy->net_ns;struct dentry *shadow;
@@ -113,7 +113,7 @@ static struct dentry *proc_net_lookup(struct inode *dir, struct dentry *dentry,dput (nd->dentry); nd->dentry = shadow; -return shadow->d_inode->i_op->lookup (shadow->d_inode, dentry, nd); +return shadow->d_inode->i_op->lookup (shadow->d_inode, dentry, nd, cred); } static int proc_net_setattr(struct dentry *dentry, struct iattr *iattr,
fs/proc/proc_sysctl.c +1 -1
@@ -139,7 +139,7 @@ static struct ctl_table *do_proc_sys_lookup(struct dentry *parent, }static struct dentry *proc_sys_lookup (struct inode *dir,struct dentry *dentry, -struct nameidata *nd) +struct nameidata *nd,struct cred *cred) {struct ctl_table_header *head;struct inode *inode;
fs/proc/root.c +3 -3
@@ -91,11 +91,11 @@ static int proc_root_getattr(struct vfsmount *mnt, struct dentry *dentry, structreturn 0 ; } -static struct dentry *proc_root_lookup (struct inode * dir,struct dentry * dentry,struct nameidata *nd) +static struct dentry *proc_root_lookup (struct inode * dir,struct dentry * dentry, +struct nameidata *nd,struct cred *cred) { -if (!proc_lookup (dir, dentry, nd)) { +if (!proc_lookup (dir, dentry, nd, cred))return NULL ; - }return proc_pid_lookup (dir, dentry, nd); }
fs/sysfs/dir.c +1 -1
@@ -760,7 +760,7 @@ static int sysfs_count_nlink(struct sysfs_dirent *sd) }static struct dentry *sysfs_lookup (struct inode *dir,struct dentry *dentry, -struct nameidata *nd) +struct nameidata *nd,struct cred *cred) {struct dentry *ret =NULL ;struct sysfs_dirent * parent_sd = dentry->d_parent->d_fsdata;
fs/vfat/namei.c +1 -1
@@ -684,7 +684,7 @@ static int vfat_find(struct inode *dir, struct qstr *qname, }static struct dentry *vfat_lookup (struct inode *dir,struct dentry *dentry, -struct nameidata *nd) +struct nameidata *nd,struct cred *cred) {struct super_block *sb = dir->i_sb;struct fat_slot_info sinfo;
include/linux/fs.h +4 -2
@@ -1137,7 +1137,8 @@ struct file_operations {struct inode_operations {int (*create) (struct inode *,struct dentry *,int ,struct nameidata *,struct cred *); -struct dentry * (*lookup) (struct inode *,struct dentry *,struct nameidata *); +struct dentry * (*lookup) (struct inode *,struct dentry *, +struct nameidata *,struct cred *);int (*link) (struct dentry *,struct inode *,struct dentry *,struct cred *);int (*unlink) (struct inode *,struct dentry *,struct cred *);
@@ -1814,7 +1815,8 @@ extern int simple_prepare_write(struct file *file, struct page *page,extern int simple_commit_write (struct file *file,struct page *page,unsigned offset,unsigned to); -extern struct dentry *simple_lookup (struct inode *,struct dentry *,struct nameidata *); +extern struct dentry *simple_lookup (struct inode *,struct dentry *, +struct nameidata *,struct cred *);extern ssize_t generic_read_dir (struct file *,char __user *,size_t ,loff_t *);extern const struct file_operations simple_dir_operations;extern const struct inode_operations simple_dir_inode_operations;
include/linux/proc_fs.h +2 -1
@@ -136,7 +136,8 @@ extern struct inode *proc_get_inode(struct super_block *, unsigned int, struct p* of the /proc/<pid> subdirectories. */ extern int proc_readdir (struct file *,void *,filldir_t ); -extern struct dentry *proc_lookup (struct inode *,struct dentry *,struct nameidata *); +extern struct dentry *proc_lookup (struct inode *,struct dentry *, +struct nameidata *,struct cred *);extern const struct file_operations proc_kcore_operations;extern const struct file_operations proc_kmsg_operations;
David Howells
maintainerPATCH 41/52 CRED: Pass credentials through d_revalidate()
In reply to David HowellsPass credentials through d_revalidate().
---
fs/afs/dir.c | 6 ++- fs/autofs4/root.c | 8 +++- fs/namei.c | 7 +++- fs/nfs/dir.c | 13 ++++--- fs/proc/base.c | 88 +++++++++++++++++++++++++++++------------------ fs/proc/proc_sysctl.c | 3 +- fs/proc/root.c | 2 + fs/vfat/namei.c | 3 +- include/linux/dcache.h | 3 +- include/linux/proc_fs.h | 3 +- 10 files changed, 84 insertions(+), 52 deletions(-)
fs/afs/dir.c +4 -2
@@ -23,7 +23,8 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd, struct cred *cred);static int afs_dir_open (struct inode *inode,struct file *file);static int afs_readdir (struct file *file,void *dirent,filldir_t filldir); -static int afs_d_revalidate (struct dentry *dentry,struct nameidata *nd); +static int afs_d_revalidate (struct dentry *dentry,struct nameidata *nd, +struct cred *cred);static int afs_d_delete (struct dentry *dentry);static void afs_d_release (struct dentry *dentry); static int afs_lookup_filldir(void *_cookie, const char *name, int nlen,
@@ -564,7 +565,8 @@ static struct dentry *afs_lookup(struct inode *dir, struct dentry *dentry,* - NOTE! the hit can be a negative hit too, so we can't assume we have an * inode */ -static int afs_d_revalidate (struct dentry *dentry,struct nameidata *nd) +static int afs_d_revalidate (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {struct afs_vnode *vnode, *dir;struct afs_fid fid;
fs/autofs4/root.c +5 -3
@@ -98,6 +98,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file) {struct dentry *dentry = file->f_path.dentry;struct vfsmount *mnt = file->f_path.mnt; +struct cred *cred = file->f_cred;struct autofs_sb_info *sbi =autofs4_sbi (dentry->d_sb);struct dentry *cursor;int status;
@@ -136,7 +137,7 @@ static int autofs4_dir_open(struct inode *inode, struct file *file)d_invalidate (dentry); nd.flags =LOOKUP_DIRECTORY ; - ret = (dentry->d_op->d_revalidate)(dentry, &nd); + ret = (dentry->d_op->d_revalidate)(dentry, &nd, cred);if (ret <=0 ) {if (ret <0 )
@@ -394,7 +395,8 @@ out_error:* yet completely filled in, and revalidate has to delay such * lookups.. */ -static int autofs4_revalidate (struct dentry *dentry,struct nameidata *nd) +static int autofs4_revalidate (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {struct inode *dir = dentry->d_parent->d_inode;struct autofs_sb_info *sbi =autofs4_sbi (dir->i_sb);
@@ -633,7 +635,7 @@ static struct dentry *autofs4_lookup(struct inode *dir, struct dentry *dentry,if (dentry->d_op && dentry->d_op->d_revalidate) {mutex_unlock (&dir->i_mutex); - (dentry->d_op->d_revalidate)(dentry, nd); + (dentry->d_op->d_revalidate)(dentry, nd, cred);mutex_lock (&dir->i_mutex); }
fs/namei.c +5 -2
@@ -378,7 +378,8 @@ void release_open_intent(struct nameidata *nd)static inline struct dentry *do_revalidate (struct dentry *dentry,struct nameidata *nd) { -int status = dentry->d_op->d_revalidate (dentry, nd); +struct cred *cred = current->cred; +int status = dentry->d_op->d_revalidate (dentry, nd, cred);if (unlikely (status <=0 )) {/* * The dentry failed validation.
@@ -811,6 +812,7 @@ fail:*/ static fastcall int __link_path_walk(const char * name, struct nameidata *nd) { +struct cred *cred = current->cred;struct path next;struct inode *inode;int err;
@@ -980,7 +982,8 @@ return_reval: (nd->dentry->d_sb->s_type->fs_flags & FS_REVAL_DOT)) { err = -ESTALE ;/* Note: we do not d_invalidate() */ -if (!nd->dentry->d_op->d_revalidate (nd->dentry, nd)) +if (!nd->dentry->d_op->d_revalidate (nd->dentry, nd, + cred))break ; } return_base:
fs/nfs/dir.c +7 -6
@@ -762,9 +762,9 @@ int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry,* If the parent directory is seen to have changed, we throw out the * cached dentry and do a new lookup. */ -static int nfs_lookup_revalidate (struct dentry * dentry,struct nameidata *nd) +static int nfs_lookup_revalidate (struct dentry * dentry,struct nameidata *nd, +struct cred *acred) { -struct cred *acred = current->cred;struct inode *dir;struct inode *inode;struct dentry *parent;
@@ -993,7 +993,8 @@ out: }#ifdef CONFIG_NFS_V4 -static int nfs_open_revalidate (struct dentry *,struct nameidata *); +static int nfs_open_revalidate (struct dentry *,struct nameidata *, +struct cred *);struct dentry_operations nfs4_dentry_operations = { .d_revalidate = nfs_open_revalidate,
@@ -1090,9 +1091,9 @@ no_open:return nfs_lookup (dir, dentry, nd, acred); } -static int nfs_open_revalidate (struct dentry *dentry,struct nameidata *nd) +static int nfs_open_revalidate (struct dentry *dentry,struct nameidata *nd, +struct cred *acred) { -struct cred *acred = current->cred;struct dentry *parent =NULL ;struct inode *inode = dentry->d_inode;struct inode *dir;
@@ -1138,7 +1139,7 @@ no_open:dput (parent);if (inode !=NULL &&nfs_have_delegation (inode,FMODE_READ ))return 1 ; - return nfs_lookup_revalidate(dentry, nd); + return nfs_lookup_revalidate(dentry, nd, acred); }#endif /* CONFIG_NFSV4 */
fs/proc/base.c +54 -34
290 lines not on this page · raw message
fs/proc/proc_sysctl.c +2 -1
@@ -451,7 +451,8 @@ static struct inode_operations proc_sys_inode_operations = { .setattr = proc_sys_setattr, }; -static int proc_sys_revalidate (struct dentry *dentry,struct nameidata *nd) +static int proc_sys_revalidate (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {struct ctl_table_header *head;struct ctl_table *table;
fs/proc/root.c +1 -1
@@ -97,7 +97,7 @@ static struct dentry *proc_root_lookup(struct inode * dir, struct dentry * dentrif (!proc_lookup (dir, dentry, nd, cred))return NULL ; -return proc_pid_lookup (dir, dentry, nd); +return proc_pid_lookup (dir, dentry, nd, cred); } static int proc_root_readdir(struct file * filp,
fs/vfat/namei.c +2 -1
@@ -25,7 +25,8 @@#include <linux/buffer_head.h> #include <linux/namei.h> -static int vfat_revalidate (struct dentry *dentry,struct nameidata *nd) +static int vfat_revalidate (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {int ret =1 ;
include/linux/dcache.h +2 -1
@@ -11,6 +11,7 @@struct nameidata ;struct vfsmount ; +struct cred ;/* * linux/include/linux/dcache.h
@@ -127,7 +128,7 @@ enum dentry_d_lock_class };struct dentry_operations { -int (*d_revalidate)(struct dentry *,struct nameidata *); +int (*d_revalidate)(struct dentry *,struct nameidata *,struct cred *);int (*d_hash) (struct dentry *,struct qstr *);int (*d_compare) (struct dentry *,struct qstr *,struct qstr *);int (*d_delete)(struct dentry *);
include/linux/proc_fs.h +2 -1
@@ -110,7 +110,8 @@ extern void proc_misc_init(void);struct mm_struct ;void proc_flush_task (struct task_struct *task); -struct dentry *proc_pid_lookup (struct inode *dir,struct dentry * dentry,struct nameidata *); +struct dentry *proc_pid_lookup (struct inode *,struct dentry *, +struct nameidata *,struct cred *);int proc_pid_readdir (struct file * filp,void * dirent,filldir_t filldir);unsigned long task_vsize (struct mm_struct *);int task_statm (struct mm_struct *,int *,int *,int *,int *);
David Howells
maintainerPATCH 42/52 CRED: Pass credentials through the permission() inode op
In reply to David HowellsPass credentials through the permission() inode operation.
---
fs/afs/internal.h | 5 ++--- fs/afs/security.c | 5 +++-- fs/bad_inode.c | 2 +- fs/ext3/acl.c | 5 +++-- fs/ext3/acl.h | 3 ++- fs/namei.c | 14 ++++++++------ fs/nfs/dir.c | 6 +++--- fs/proc/base.c | 4 ++-- fs/proc/proc_sysctl.c | 5 +++-- include/linux/fs.h | 7 ++++--- include/linux/nfs_fs.h | 3 ++- include/linux/shmem_fs.h | 2 +- mm/shmem_acl.c | 5 +++-- 13 files changed, 37 insertions(+), 29 deletions(-)
fs/afs/internal.h +2 -3
@@ -469,8 +469,6 @@ extern bool afs_cm_incoming_call(struct afs_call *);extern const struct inode_operations afs_dir_inode_operations;extern const struct file_operations afs_dir_file_operations; -extern int afs_permission (struct inode *,int ,struct nameidata *); -/* * file.c */
@@ -607,7 +605,8 @@ extern void afs_clear_permits(struct afs_vnode *);extern void afs_cache_permit (struct afs_vnode *,struct key *,long );extern void afs_zap_permits (struct rcu_head *);extern struct key *afs_request_key (struct afs_cell *); -extern int afs_permission (struct inode *,int ,struct nameidata *); +extern int afs_permission (struct inode *,int ,struct nameidata *, +struct cred *);/* * server.c
fs/afs/security.c +3 -2
@@ -284,7 +284,8 @@ static int afs_check_permit(struct afs_vnode *vnode, struct key *key,* - AFS ACLs are attached to directories only, and a file is controlled by its * parent directory's ACL */ -int afs_permission (struct inode *inode,int mask,struct nameidata *nd) +int afs_permission (struct inode *inode,int mask,struct nameidata *nd, +struct cred *cred) {struct afs_vnode *vnode =AFS_FS_I (inode);afs_access_t access;
@@ -346,7 +347,7 @@ int afs_permission(struct inode *inode, int mask, struct nameidata *nd) }key_put (key); - ret =generic_permission (inode, mask,NULL ); + ret =generic_permission (inode, mask,NULL , cred);_leave (" = %d" , ret);return ret;
fs/bad_inode.c +1 -1
@@ -248,7 +248,7 @@ static int bad_inode_readlink(struct dentry *dentry, char __user *buffer, }static int bad_inode_permission (struct inode *inode,int mask, -struct nameidata *nd) +struct nameidata *nd,struct cred *cred) {return -EIO ; }
fs/ext3/acl.c +3 -2
@@ -299,9 +299,10 @@ ext3_check_acl(struct inode *inode, int mask) }int -ext3_permission (struct inode *inode,int mask,struct nameidata *nd) +ext3_permission (struct inode *inode,int mask,struct nameidata *nd, +struct cred *cred) { -return generic_permission (inode, mask, ext3_check_acl); +return generic_permission (inode, mask, ext3_check_acl, cred); }/*
fs/ext3/acl.h +2 -1
@@ -58,7 +58,8 @@ static inline int ext3_acl_count(size_t size)#define EXT3_ACL_NOT_CACHED ((void *)-1)/* acl.c */ -extern int ext3_permission (struct inode *,int ,struct nameidata *); +extern int ext3_permission (struct inode *,int ,struct nameidata *, +struct cred *);extern int ext3_acl_chmod (struct inode *,struct cred *);extern int ext3_init_acl (handle_t *,struct inode *,struct inode *,struct cred *);
fs/namei.c +8 -6
@@ -174,18 +174,19 @@ EXPORT_SYMBOL(putname);* @inode: inode to check access rights for * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC) * @check_acl: optional callback to check for Posix ACLs +* @cred: the credentials to use * * Used to check for read/write/execute permissions on a file. * We use "fsuid" for this, letting us set arbitrary permissions * for filesystem access without changing the "normal" uids which * are used for other things.. */ -int generic_permission (struct inode *inode,int mask, -int (*check_acl)(struct inode *inode,int mask)) +int generic_permission (struct inode *inode,int mask,check_acl_t check_acl, +struct cred *cred) {umode_t mode = inode->i_mode; -if (current->cred->uid == inode->i_uid) +if (cred->uid == inode->i_uid) mode >>=6 ;else {if (IS_POSIXACL (inode) && (mode &S_IRWXG ) && check_acl) {
@@ -196,7 +197,7 @@ int generic_permission(struct inode *inode, int mask,return error; } -if (in_group_p (current->cred, inode->i_gid)) +if (in_group_p (cred, inode->i_gid)) mode >>=3 ; }
@@ -228,6 +229,7 @@ int generic_permission(struct inode *inode, int mask,int permission (struct inode *inode,int mask,struct nameidata *nd) { +struct cred *cred = current->cred;umode_t mode = inode->i_mode;int retval, submask;
@@ -260,9 +262,9 @@ int permission(struct inode *inode, int mask, struct nameidata *nd)/* Ordinary permission routines do not understand MAY_APPEND. */ submask = mask & ~MAY_APPEND ;if (inode->i_op && inode->i_op->permission) - retval = inode->i_op->permission (inode, submask, nd); + retval = inode->i_op->permission (inode, submask, nd, cred);else - retval =generic_permission (inode, submask,NULL ); + retval =generic_permission (inode, submask,NULL , cred);if (retval)return retval;
fs/nfs/dir.c +3 -3
@@ -1992,9 +1992,9 @@ out:return -EACCES ; } -int nfs_permission (struct inode *inode,int mask,struct nameidata *nd) +int nfs_permission (struct inode *inode,int mask,struct nameidata *nd, +struct cred *acred) { -struct cred *acred = current->cred;struct rpc_cred *cred;int res =0 ;
@@ -2045,7 +2045,7 @@ out: out_notsup: res =nfs_revalidate_inode (NFS_SERVER (inode), inode, acred);if (res ==0 ) - res =generic_permission (inode, mask,NULL ); + res =generic_permission (inode, mask,NULL , acred);unlock_kernel (); goto out; }
fs/proc/base.c +2 -2
@@ -1486,11 +1486,11 @@ static const struct file_operations proc_fd_operations = {* access /proc/self/fd after it has executed a setuid(). */ static int proc_fd_permission (struct inode *inode,int mask, -struct nameidata *nd) +struct nameidata *nd,struct cred *cred) {int rv; - rv =generic_permission (inode, mask,NULL ); + rv =generic_permission (inode, mask,NULL , cred);if (rv ==0 )return 0 ;if (task_pid (current) ==proc_pid (inode))
fs/proc/proc_sysctl.c +3 -2
@@ -369,7 +369,8 @@ out:return ret; } -static int proc_sys_permission (struct inode *inode,int mask,struct nameidata *nd) +static int proc_sys_permission (struct inode *inode,int mask, +struct nameidata *nd,struct cred *cred) {/* * sysctl entries that are not writeable,
@@ -393,7 +394,7 @@ static int proc_sys_permission(struct inode *inode, int mask, struct nameidata *if (current->euid ==0 ) mode >>=6 ; -else if (in_group_p (current->cred,0 )) +else if (in_group_p (cred,0 )) mode >>=3 ;if ((mode & mask & (MAY_READ |MAY_WRITE |MAY_EXEC )) == mask)
include/linux/fs.h +4 -3
@@ -1154,7 +1154,8 @@ struct inode_operations {void * (*follow_link) (struct dentry *,struct nameidata *);void (*put_link) (struct dentry *,struct nameidata *,void *);void (*truncate) (struct inode *,struct cred *); -int (*permission) (struct inode *,int ,struct nameidata *); +int (*permission) (struct inode *,int ,struct nameidata *, +struct cred *);int (*setattr) (struct dentry *,struct iattr *,struct cred *);int (*getattr) (struct vfsmount *mnt,struct dentry *,struct kstat *);int (*setxattr) (struct dentry *,const char *,const void *,size_t ,int );
@@ -1571,8 +1572,8 @@ extern sector_t bmap(struct inode *, sector_t);#endif extern int notify_change (struct dentry *,struct iattr *);extern int permission (struct inode *,int ,struct nameidata *); -extern int generic_permission (struct inode *,int , -int (*check_acl)(struct inode *,int )); +typedef int (*check_acl_t )(struct inode *,int ); +extern int generic_permission (struct inode *,int ,check_acl_t ,struct cred *);extern int get_write_access (struct inode *);extern int deny_write_access (struct file *);
include/linux/nfs_fs.h +2 -1
@@ -289,7 +289,8 @@ extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *,extern int nfs_refresh_inode (struct inode *,struct nfs_fattr *);extern int nfs_post_op_update_inode (struct inode *inode,struct nfs_fattr *fattr);extern int nfs_getattr (struct vfsmount *,struct dentry *,struct kstat *); -extern int nfs_permission (struct inode *,int ,struct nameidata *); +extern int nfs_permission (struct inode *,int ,struct nameidata *, +struct cred *);extern int nfs_access_get_cached (struct inode *,struct rpc_cred *,struct nfs_access_entry *);extern void nfs_access_add_cache (struct inode *,struct nfs_access_entry *);extern void nfs_access_zap_cache (struct inode *inode);
include/linux/shmem_fs.h +1 -1
@@ -41,7 +41,7 @@ static inline struct shmem_inode_info *SHMEM_I(struct inode *inode) }#ifdef CONFIG_TMPFS_POSIX_ACL -int shmem_permission (struct inode *,int ,struct nameidata *); +int shmem_permission (struct inode *,int ,struct nameidata *,struct cred *);int shmem_acl_init (struct inode *,struct inode *);void shmem_acl_destroy_inode (struct inode *);
mm/shmem_acl.c +3 -2
@@ -191,7 +191,8 @@ shmem_check_acl(struct inode *inode, int mask)* shmem_permission - permission() inode operation */ int -shmem_permission (struct inode *inode,int mask,struct nameidata *nd) +shmem_permission (struct inode *inode,int mask,struct nameidata *nd, +struct cred *cred) { -return generic_permission (inode, mask, shmem_check_acl); +return generic_permission (inode, mask, shmem_check_acl, cred); }
David Howells
maintainerPATCH 43/52 CRED: Pass credentials through the statfs() superblock op
In reply to David HowellsPass credentials through the statfs() superblock operation.
---
fs/afs/super.c | 6 ++++-- fs/ext3/super.c | 6 ++++-- fs/fat/inode.c | 3 ++- fs/libfs.c | 2 +- fs/nfs/super.c | 6 +++--- fs/open.c | 3 ++- include/linux/fs.h | 4 ++-- mm/shmem.c | 3 ++- 8 files changed, 20 insertions(+), 13 deletions(-)
fs/afs/super.c +4 -2
@@ -35,7 +35,8 @@ static int afs_get_sb(struct file_system_type *fs_type,static struct inode *afs_alloc_inode (struct super_block *sb);static void afs_put_super (struct super_block *sb);static void afs_destroy_inode (struct inode *inode); -static int afs_statfs (struct dentry *dentry,struct kstatfs *buf); +static int afs_statfs (struct dentry *dentry,struct kstatfs *buf, +struct cred *cred);struct file_system_type afs_fs_type = { .owner =THIS_MODULE ,
@@ -511,7 +512,8 @@ static void afs_destroy_inode(struct inode *inode)/* * return information about an AFS volume */ -static int afs_statfs (struct dentry *dentry,struct kstatfs *buf) +static int afs_statfs (struct dentry *dentry,struct kstatfs *buf, +struct cred *cred) {struct afs_volume_status vs;struct afs_vnode *vnode =AFS_FS_I (dentry->d_inode);
fs/ext3/super.c +4 -2
@@ -59,7 +59,8 @@ static int ext3_sync_fs(struct super_block *sb, int wait);static const char *ext3_decode_error (struct super_block * sb,int errno,char nbuf[16 ]);static int ext3_remount (struct super_block * sb,int * flags,char * data); -static int ext3_statfs (struct dentry * dentry,struct kstatfs * buf); +static int ext3_statfs (struct dentry * dentry,struct kstatfs * buf, +struct cred *cred);static void ext3_unlockfs (struct super_block *sb);static void ext3_write_super (struct super_block * sb);static void ext3_write_super_lockfs (struct super_block *sb);
@@ -2429,7 +2430,8 @@ restore_opts:return err; } -static int ext3_statfs (struct dentry * dentry,struct kstatfs * buf) +static int ext3_statfs (struct dentry * dentry,struct kstatfs * buf, +struct cred *cred) {struct super_block *sb = dentry->d_sb;struct ext3_sb_info *sbi =EXT3_SB (sb);
fs/fat/inode.c +2 -1
@@ -537,7 +537,8 @@ static int fat_remount(struct super_block *sb, int *flags, char *data)return 0 ; } -static int fat_statfs (struct dentry *dentry,struct kstatfs *buf) +static int fat_statfs (struct dentry *dentry,struct kstatfs *buf, +struct cred *cred) {struct msdos_sb_info *sbi =MSDOS_SB (dentry->d_sb);
fs/libfs.c +1 -1
@@ -20,7 +20,7 @@ int simple_getattr(struct vfsmount *mnt, struct dentry *dentry,return 0 ; } -int simple_statfs (struct dentry *dentry,struct kstatfs *buf) +int simple_statfs (struct dentry *dentry,struct kstatfs *buf,struct cred *cred) { buf->f_type = dentry->d_sb->s_magic; buf->f_bsize =PAGE_CACHE_SIZE ;
fs/nfs/super.c +3 -3
@@ -220,7 +220,7 @@ static match_table_t nfs_secflavor_tokens = {static void nfs_umount_begin (struct vfsmount *,int ); -static int nfs_statfs (struct dentry *,struct kstatfs *); +static int nfs_statfs (struct dentry *,struct kstatfs *,struct cred *);static int nfs_show_options (struct seq_file *,struct vfsmount *);static int nfs_show_stats (struct seq_file *,struct vfsmount *); static int nfs_get_sb(struct file_system_type *, int, const char *, void *,
@@ -358,9 +358,9 @@ void __exit unregister_nfs_fs(void)/* * Deliver file system statistics to userspace */ -static int nfs_statfs (struct dentry *dentry,struct kstatfs *buf) +static int nfs_statfs (struct dentry *dentry,struct kstatfs *buf, +struct cred *acred) { -struct cred *acred = current->cred;struct nfs_server *server =NFS_SB (dentry->d_sb);unsigned char blockbits;unsigned long blockres;
fs/open.c +2 -1
@@ -30,6 +30,7 @@int vfs_statfs (struct dentry *dentry,struct kstatfs *buf) { +struct cred *cred = current->cred;int retval = -ENODEV ;if (dentry) {
@@ -39,7 +40,7 @@ int vfs_statfs(struct dentry *dentry, struct kstatfs *buf) retval =security_sb_statfs (dentry);if (retval)return retval; - retval = dentry->d_sb->s_op->statfs (dentry, buf); + retval = dentry->d_sb->s_op->statfs (dentry, buf, cred);if (retval ==0 && buf->f_frsize ==0 ) buf->f_frsize = buf->f_bsize; }
include/linux/fs.h +2 -2
@@ -1199,7 +1199,7 @@ struct super_operations {int (*sync_fs)(struct super_block *sb,int wait);void (*write_super_lockfs) (struct super_block *);void (*unlockfs) (struct super_block *); -int (*statfs) (struct dentry *,struct kstatfs *); +int (*statfs) (struct dentry *,struct kstatfs *,struct cred *);int (*remount_fs) (struct super_block *,int *,char *);void (*clear_inode) (struct inode *);void (*umount_begin) (struct vfsmount *,int );
@@ -1801,7 +1801,7 @@ extern int dcache_dir_close(struct inode *, struct file *);extern loff_t dcache_dir_lseek (struct file *,loff_t ,int );extern int dcache_readdir (struct file *,void *,filldir_t );extern int simple_getattr (struct vfsmount *,struct dentry *,struct kstat *); -extern int simple_statfs (struct dentry *,struct kstatfs *); +extern int simple_statfs (struct dentry *,struct kstatfs *,struct cred *);extern int simple_link (struct dentry *,struct inode *,struct dentry *,struct cred *);extern int simple_unlink (struct inode *,struct dentry *,struct cred *);
mm/shmem.c +2 -1
@@ -1682,7 +1682,8 @@ static ssize_t shmem_file_read(struct file *filp, char __user *buf, size_t countreturn desc.error; } -static int shmem_statfs (struct dentry *dentry,struct kstatfs *buf) +static int shmem_statfs (struct dentry *dentry,struct kstatfs *buf, +struct cred *cred) {struct shmem_sb_info *sbinfo =SHMEM_SB (dentry->d_sb);
David Howells
maintainerPATCH 44/52 CRED: Pass credentials through the follow_link() inode op
In reply to David HowellsPass credentials through the follow_link() inode operation.
---
fs/afs/mntpt.c | 6 ++++-- fs/autofs4/root.c | 6 ++++-- fs/autofs4/symlink.c | 3 ++- fs/ext3/symlink.c | 3 ++- fs/namei.c | 9 ++++++--- fs/nfs/namespace.c | 5 +++-- fs/nfs/symlink.c | 4 ++-- fs/proc/base.c | 6 ++++-- fs/proc/generic.c | 3 ++- fs/proc/proc_net.c | 3 ++- fs/sysfs/dir.c | 2 +- fs/sysfs/symlink.c | 3 ++- include/linux/fs.h | 6 ++++-- include/linux/sysfs.h | 6 ++++-- mm/shmem.c | 7 +++++-- 15 files changed, 47 insertions(+), 25 deletions(-)
fs/afs/mntpt.c +4 -2
@@ -26,7 +26,8 @@ static struct dentry *afs_mntpt_lookup(struct inode *dir,struct nameidata *nd, struct cred *cred);static int afs_mntpt_open (struct inode *inode,struct file *file); -static void *afs_mntpt_follow_link (struct dentry *dentry,struct nameidata *nd); +static void *afs_mntpt_follow_link (struct dentry *dentry,struct nameidata *nd, +struct cred *cred);static void afs_mntpt_expiry_timed_out (struct work_struct *work);const struct file_operations afs_mntpt_file_operations = {
@@ -212,7 +213,8 @@ error:/* * follow a link from a mountpoint directory, thus causing it to be mounted */ -static void *afs_mntpt_follow_link (struct dentry *dentry,struct nameidata *nd) +static void *afs_mntpt_follow_link (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {struct vfsmount *newmnt;int err;
fs/autofs4/root.c +4 -2
@@ -31,7 +31,8 @@ static int autofs4_dir_readdir(struct file * filp, void * dirent, filldir_t fillstatic int autofs4_root_readdir (struct file * filp,void * dirent,filldir_t filldir);static struct dentry *autofs4_lookup (struct inode *,struct dentry *,struct nameidata *,struct cred *); -static void *autofs4_follow_link (struct dentry *,struct nameidata *); +static void *autofs4_follow_link (struct dentry *,struct nameidata *, +struct cred *);const struct file_operations autofs4_root_operations = { .open = dcache_dir_open,
@@ -325,7 +326,8 @@ static int try_to_fill_dentry(struct dentry *dentry, int flags) }/* For autofs direct mounts the follow link triggers the mount */ -static void *autofs4_follow_link (struct dentry *dentry,struct nameidata *nd) +static void *autofs4_follow_link (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {struct autofs_sb_info *sbi =autofs4_sbi (dentry->d_sb);struct autofs_info *ino =autofs4_dentry_ino (dentry);
fs/autofs4/symlink.c +2 -1
@@ -12,7 +12,8 @@#include "autofs_i.h" -static void *autofs4_follow_link (struct dentry *dentry,struct nameidata *nd) +static void *autofs4_follow_link (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {struct autofs_info *ino =autofs4_dentry_ino (dentry);nd_set_link (nd, (char *)ino->u.symlink);
fs/ext3/symlink.c +2 -1
@@ -23,7 +23,8 @@#include <linux/namei.h> #include "xattr.h" -static void *ext3_follow_link (struct dentry *dentry,struct nameidata *nd) +static void *ext3_follow_link (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {struct ext3_inode_info *ei =EXT3_I (dentry->d_inode);nd_set_link (nd, (char *)ei->i_data);
fs/namei.c +6 -3
@@ -595,6 +595,7 @@ static inline void path_to_nameidata(struct path *path, struct nameidata *nd) static __always_inline int __do_follow_link(struct path *path, struct nameidata *nd) { +struct cred *cred = current->cred;int error;void *cookie;struct dentry *dentry = path->dentry;
@@ -607,7 +608,7 @@ static __always_inline int __do_follow_link(struct path *path, struct nameidatadget (dentry); }mntget (path->mnt); - cookie = dentry->d_inode->i_op->follow_link (dentry, nd); + cookie = dentry->d_inode->i_op->follow_link (dentry, nd, cred); error =PTR_ERR (cookie);if (!IS_ERR (cookie)) {char *s =nd_get_link (nd);
@@ -2682,11 +2683,12 @@ out:*/ int generic_readlink (struct dentry *dentry,char __user *buffer,int buflen) { +struct cred *cred = current->cred;struct nameidata nd;void *cookie; nd.depth =0 ; - cookie = dentry->d_inode->i_op->follow_link (dentry, &nd); + cookie = dentry->d_inode->i_op->follow_link (dentry, &nd, cred);if (!IS_ERR (cookie)) {int res =vfs_readlink (dentry, buffer, buflen,nd_get_link (&nd));if (dentry->d_inode->i_op->put_link)
@@ -2725,7 +2727,8 @@ int page_readlink(struct dentry *dentry, char __user *buffer, int buflen)return res; } -void *page_follow_link_light (struct dentry *dentry,struct nameidata *nd) +void *page_follow_link_light (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {struct page *page =NULL ;nd_set_link (nd,page_getlink (dentry, &page));
fs/nfs/namespace.c +3 -2
@@ -85,6 +85,7 @@ Elong:* nfs_follow_mountpoint - handle crossing a mountpoint on the server * @dentry - dentry of mountpoint * @nd - nameidata info +* @acred - the credentials to use * * When we encounter a mountpoint on the server, we want to set up * a mountpoint on the client too, to prevent inode numbers from
@@ -94,9 +95,9 @@ Elong:* situation, and that different filesystems may want to use * different security flavours. */ -static void *nfs_follow_mountpoint (struct dentry *dentry,struct nameidata *nd) +static void *nfs_follow_mountpoint (struct dentry *dentry,struct nameidata *nd, +struct cred *acred) { -struct cred *acred = current->cred;struct vfsmount *mnt;struct nfs_server *server =NFS_SERVER (dentry->d_inode);struct dentry *parent;
fs/nfs/symlink.c +2 -2
@@ -53,10 +53,10 @@ error:return -EIO ; } -static void *nfs_follow_link (struct dentry *dentry,struct nameidata *nd) +static void *nfs_follow_link (struct dentry *dentry,struct nameidata *nd, +struct cred *acred) {struct inode *inode = dentry->d_inode; -struct cred *acred = current->cred;struct page *page;void *err;
fs/proc/base.c +4 -2
@@ -933,7 +933,8 @@ static const struct file_operations proc_pid_sched_operations = {#endif -static void *proc_pid_follow_link (struct dentry *dentry,struct nameidata *nd) +static void *proc_pid_follow_link (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {struct inode *inode = dentry->d_inode;int error = -EACCES ;
@@ -1896,7 +1897,8 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer,return vfs_readlink (dentry,buffer,buflen,tmp); } -static void *proc_self_follow_link (struct dentry *dentry,struct nameidata *nd) +static void *proc_self_follow_link (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {char tmp[PROC_NUMBUF ];sprintf (tmp,"%d" , current->tgid);
fs/proc/generic.c +2 -1
@@ -353,7 +353,8 @@ static void release_inode_number(unsigned int inum)spin_unlock (&proc_inum_lock); } -static void *proc_follow_link (struct dentry *dentry,struct nameidata *nd) +static void *proc_follow_link (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {nd_set_link (nd,PDE (dentry->d_inode)->data);return NULL ;
fs/proc/proc_net.c +2 -1
@@ -84,7 +84,8 @@ out_de_put: goto out; } -static void *proc_net_follow_link (struct dentry *parent,struct nameidata *nd) +static void *proc_net_follow_link (struct dentry *parent,struct nameidata *nd, +struct cred *cred) {struct net *net = current->nsproxy->net_ns;struct dentry *shadow;
fs/sysfs/dir.c +1 -1
@@ -1199,7 +1199,7 @@ static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)*/ int sysfs_make_shadowed_dir (struct kobject *kobj, -void * (*follow_link)(struct dentry *,struct nameidata *)) +sysfs_follow_link_t follow_link) {struct dentry *dentry;struct inode *inode;
fs/sysfs/symlink.c +2 -1
@@ -158,7 +158,8 @@ static int sysfs_getlink(struct dentry *dentry, char * path)return error; } -static void *sysfs_follow_link (struct dentry *dentry,struct nameidata *nd) +static void *sysfs_follow_link (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {int error = -ENOMEM ;unsigned long page =get_zeroed_page (GFP_KERNEL );
include/linux/fs.h +4 -2
@@ -1151,7 +1151,8 @@ struct inode_operations { struct inode *, struct dentry *, struct cred *);int (*readlink) (struct dentry *,char __user *,int ); -void * (*follow_link) (struct dentry *,struct nameidata *); +void * (*follow_link) (struct dentry *,struct nameidata *, +struct cred *);void (*put_link) (struct dentry *,struct nameidata *,void *);void (*truncate) (struct inode *,struct cred *); int (*permission) (struct inode *, int, struct nameidata *,
@@ -1767,7 +1768,8 @@ extern const struct file_operations generic_ro_fops;extern int vfs_readlink (struct dentry *,char __user *,int ,const char *);extern int vfs_follow_link (struct nameidata *,const char *);extern int page_readlink (struct dentry *,char __user *,int ); -extern void *page_follow_link_light (struct dentry *,struct nameidata *); +extern void *page_follow_link_light (struct dentry *,struct nameidata *, +struct cred *);extern void page_put_link (struct dentry *,struct nameidata *,void *);extern int __page_symlink (struct inode *inode,const char *symname,int len,gfp_t gfp_mask);
include/linux/sysfs.h +4 -2
@@ -20,6 +20,7 @@ struct module;struct nameidata ;struct dentry ;struct sysfs_dirent ; +struct cred ;/* FIXME * The *owner field is no longer used, but leave around
@@ -138,9 +139,10 @@ void sysfs_remove_file_from_group(struct kobject *kobj,void sysfs_notify (struct kobject * k,char *dir,char *attr); - +typedef void *(*sysfs_follow_link_t )(struct dentry *,struct nameidata *, +struct cred *);extern int sysfs_make_shadowed_dir (struct kobject *kobj, -void * (*follow_link)(struct dentry *,struct nameidata *)); +sysfs_follow_link_t follow_link);extern struct sysfs_dirent *sysfs_create_shadow_dir (struct kobject *kobj);extern void sysfs_remove_shadow_dir (struct sysfs_dirent *shadow_sd);
mm/shmem.c +5 -2
@@ -1912,13 +1912,16 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry,return 0 ; } -static void *shmem_follow_link_inline (struct dentry *dentry,struct nameidata *nd) +static void *shmem_follow_link_inline (struct dentry *dentry, +struct nameidata *nd, +struct cred *cred) {nd_set_link (nd, (char *)SHMEM_I (dentry->d_inode));return NULL ; } -static void *shmem_follow_link (struct dentry *dentry,struct nameidata *nd) +static void *shmem_follow_link (struct dentry *dentry,struct nameidata *nd, +struct cred *cred) {struct page *page =NULL ;int res =shmem_getpage (dentry->d_inode,0 , &page,SGP_READ ,NULL );
David Howells
maintainerPATCH 45/52 CRED: Pass credentials through the getattr() inode op
In reply to David HowellsPass credentials through the getattr() inode operation.
---
fs/afs/inode.c | 2 +- fs/afs/internal.h | 3 ++- fs/bad_inode.c | 2 +- fs/fat/file.c | 3 ++- fs/libfs.c | 2 +- fs/nfs/inode.c | 4 ++-- fs/proc/base.c | 6 ++++-- fs/proc/generic.c | 2 +- fs/proc/root.c | 4 ++-- fs/stat.c | 3 ++- include/linux/fs.h | 6 ++++-- include/linux/msdos_fs.h | 2 +- include/linux/nfs_fs.h | 3 ++- 13 files changed, 25 insertions(+), 17 deletions(-)
fs/afs/inode.c +1 -1
@@ -292,7 +292,7 @@ error_unlock:* read the attributes of an inode */ int afs_getattr (struct vfsmount *mnt,struct dentry *dentry, -struct kstat *stat) +struct kstat *stat,struct cred *cred) {struct inode *inode;
fs/afs/internal.h +2 -1
@@ -546,7 +546,8 @@ extern struct inode *afs_iget(struct super_block *, struct key *, struct afs_callback *);extern void afs_zap_data (struct afs_vnode *);extern int afs_validate (struct afs_vnode *,struct key *); -extern int afs_getattr (struct vfsmount *,struct dentry *,struct kstat *); +extern int afs_getattr (struct vfsmount *,struct dentry *,struct kstat *, +struct cred *);extern int afs_setattr (struct dentry *,struct iattr *,struct cred *);extern void afs_clear_inode (struct inode *);
fs/bad_inode.c +1 -1
@@ -254,7 +254,7 @@ static int bad_inode_permission(struct inode *inode, int mask, }static int bad_inode_getattr (struct vfsmount *mnt,struct dentry *dentry, -struct kstat *stat) +struct kstat *stat,struct cred *cred) {return -EIO ; }
fs/fat/file.c +2 -1
@@ -304,7 +304,8 @@ void fat_truncate(struct inode *inode, struct cred *cred)fat_flush_inodes (inode->i_sb, inode,NULL ); } -int fat_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat) +int fat_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat, +struct cred *cred) {struct inode *inode = dentry->d_inode;generic_fillattr (inode, stat);
fs/libfs.c +1 -1
@@ -12,7 +12,7 @@#include <asm/uaccess.h> int simple_getattr (struct vfsmount *mnt,struct dentry *dentry, -struct kstat *stat) +struct kstat *stat,struct cred *cred) {struct inode *inode = dentry->d_inode;generic_fillattr (inode, stat);
fs/nfs/inode.c +2 -2
@@ -425,9 +425,9 @@ static void nfs_wake_up_inode(struct inode *inode)wake_up_bit (&nfsi->flags,NFS_INO_REVALIDATING ); } -int nfs_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat) +int nfs_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat, +struct cred *acred) { -struct cred *acred = current->cred;struct inode *inode = dentry->d_inode;int need_atime =NFS_I (inode)->cache_validity &NFS_INO_INVALID_ATIME ;int err;
fs/proc/base.c +4 -2
@@ -1064,7 +1064,8 @@ out_unlock:return NULL ; } -static int pid_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat) +static int pid_getattr (struct vfsmount *mnt,struct dentry *dentry, +struct kstat *stat,struct cred *cred) {struct inode *inode = dentry->d_inode;struct task_struct *task;
@@ -2640,7 +2641,8 @@ out_no_task:return retval; } -static int proc_task_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat) +static int proc_task_getattr (struct vfsmount *mnt,struct dentry *dentry, +struct kstat *stat,struct cred *cred) {struct inode *inode = dentry->d_inode;struct task_struct *p =get_proc_task (inode);
fs/proc/generic.c +1 -1
@@ -256,7 +256,7 @@ out: }static int proc_getattr (struct vfsmount *mnt,struct dentry *dentry, -struct kstat *stat) +struct kstat *stat,struct cred *cred) {struct inode *inode = dentry->d_inode;struct proc_dir_entry *de =PROC_I (inode)->pde;
fs/proc/root.c +2 -2
@@ -83,8 +83,8 @@ void __init proc_root_init(void)proc_sys_init (); } -static int proc_root_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat -) +static int proc_root_getattr (struct vfsmount *mnt,struct dentry *dentry, +struct kstat *stat,struct cred *cred) {generic_fillattr (dentry->d_inode, stat); stat->nlink = proc_root.nlink +nr_processes ();
fs/stat.c +2 -1
@@ -39,6 +39,7 @@ EXPORT_SYMBOL(generic_fillattr);int vfs_getattr (struct vfsmount *mnt,struct dentry *dentry,struct kstat *stat) { +struct cred *cred = current->cred;struct inode *inode = dentry->d_inode;int retval;
@@ -47,7 +48,7 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)return retval;if (inode->i_op->getattr) -return inode->i_op->getattr (mnt, dentry, stat); +return inode->i_op->getattr (mnt, dentry, stat, cred);generic_fillattr (inode, stat);return 0 ;
include/linux/fs.h +4 -2
@@ -1158,7 +1158,8 @@ struct inode_operations {int (*permission) (struct inode *,int ,struct nameidata *,struct cred *);int (*setattr) (struct dentry *,struct iattr *,struct cred *); -int (*getattr) (struct vfsmount *mnt,struct dentry *,struct kstat *); +int (*getattr) (struct vfsmount *,struct dentry *,struct kstat *, +struct cred *);int (*setxattr) (struct dentry *,const char *,const void *,size_t ,int );ssize_t (*getxattr) (struct dentry *,const char *,void *,size_t );ssize_t (*listxattr) (struct dentry *,char *,size_t );
@@ -1802,7 +1803,8 @@ extern int dcache_dir_open(struct inode *, struct file *);extern int dcache_dir_close (struct inode *,struct file *);extern loff_t dcache_dir_lseek (struct file *,loff_t ,int );extern int dcache_readdir (struct file *,void *,filldir_t ); -extern int simple_getattr (struct vfsmount *,struct dentry *,struct kstat *); +extern int simple_getattr (struct vfsmount *,struct dentry *,struct kstat *, +struct cred *);extern int simple_statfs (struct dentry *,struct kstatfs *,struct cred *);extern int simple_link (struct dentry *,struct inode *,struct dentry *,struct cred *);
include/linux/msdos_fs.h +1 -1
@@ -405,7 +405,7 @@ extern int fat_notify_change(struct dentry * dentry, struct iattr * attr, struct cred *cred);extern void fat_truncate (struct inode *inode,struct cred *cred);extern int fat_getattr (struct vfsmount *mnt,struct dentry *dentry, -struct kstat *stat); +struct kstat *statm,struct cred *cred);/* fat/inode.c */ extern void fat_attach (struct inode *inode,loff_t i_pos);
include/linux/nfs_fs.h +2 -1
@@ -288,7 +288,8 @@ extern struct inode *nfs_fhget(struct super_block *, struct nfs_fh *, struct nfs_fattr *);extern int nfs_refresh_inode (struct inode *,struct nfs_fattr *);extern int nfs_post_op_update_inode (struct inode *inode,struct nfs_fattr *fattr); -extern int nfs_getattr (struct vfsmount *,struct dentry *,struct kstat *); +extern int nfs_getattr (struct vfsmount *,struct dentry *,struct kstat *, +struct cred *);extern int nfs_permission (struct inode *,int ,struct nameidata *,struct cred *);extern int nfs_access_get_cached (struct inode *,struct rpc_cred *,struct nfs_access_entry *);