Commit 449fe968 authored by Jan Harkes's avatar Jan Harkes Committed by Linus Torvalds

[PATCH] Coda updates [3/5]

Both userspace and the kernel are testing only the fsuid part of the 
coda_creds credentials structure. Nothing else is really used, so we now
match the code with the actual usage by only passing fsuid around. The
kernel-userspace API is kept compatible (for now).
parent 64353a2b
...@@ -31,8 +31,8 @@ void coda_cache_enter(struct inode *inode, int mask) ...@@ -31,8 +31,8 @@ void coda_cache_enter(struct inode *inode, int mask)
struct coda_inode_info *cii = ITOC(inode); struct coda_inode_info *cii = ITOC(inode);
cii->c_cached_epoch = atomic_read(&permission_epoch); cii->c_cached_epoch = atomic_read(&permission_epoch);
if ( !coda_cred_ok(&cii->c_cached_cred) ) { if (cii->c_uid != current->fsuid) {
coda_load_creds(&cii->c_cached_cred); cii->c_uid = current->fsuid;
cii->c_cached_perm = mask; cii->c_cached_perm = mask;
} else } else
cii->c_cached_perm |= mask; cii->c_cached_perm |= mask;
...@@ -64,8 +64,8 @@ int coda_cache_check(struct inode *inode, int mask) ...@@ -64,8 +64,8 @@ int coda_cache_check(struct inode *inode, int mask)
int hit; int hit;
hit = (mask & cii->c_cached_perm) == mask && hit = (mask & cii->c_cached_perm) == mask &&
coda_cred_ok(&cii->c_cached_cred) && cii->c_uid == current->fsuid &&
cii->c_cached_epoch == atomic_read(&permission_epoch); cii->c_cached_epoch == atomic_read(&permission_epoch);
return hit; return hit;
} }
......
...@@ -45,30 +45,6 @@ int coda_isroot(struct inode *i) ...@@ -45,30 +45,6 @@ int coda_isroot(struct inode *i)
return ( i->i_sb->s_root->d_inode == i ); return ( i->i_sb->s_root->d_inode == i );
} }
/* put the current process credentials in the cred */
void coda_load_creds(struct coda_cred *cred)
{
cred->cr_uid = (vuid_t) current->uid;
cred->cr_euid = (vuid_t) current->euid;
cred->cr_suid = (vuid_t) current->suid;
cred->cr_fsuid = (vuid_t) current->fsuid;
cred->cr_groupid = (vgid_t) current->gid;
cred->cr_egid = (vgid_t) current->egid;
cred->cr_sgid = (vgid_t) current->sgid;
cred->cr_fsgid = (vgid_t) current->fsgid;
}
int coda_cred_ok(struct coda_cred *cred)
{
return(current->fsuid == cred->cr_fsuid);
}
int coda_cred_eq(struct coda_cred *cred1, struct coda_cred *cred2)
{
return (cred1->cr_fsuid == cred2->cr_fsuid);
}
unsigned short coda_flags_to_cflags(unsigned short flags) unsigned short coda_flags_to_cflags(unsigned short flags)
{ {
unsigned short coda_flags = 0; unsigned short coda_flags = 0;
......
...@@ -136,7 +136,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file) ...@@ -136,7 +136,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file)
cfi->cfi_magic = CODA_MAGIC; cfi->cfi_magic = CODA_MAGIC;
cfi->cfi_mapcount = 0; cfi->cfi_mapcount = 0;
cfi->cfi_container = host_file; cfi->cfi_container = host_file;
coda_load_creds(&cfi->cfi_cred);
BUG_ON(coda_file->private_data != NULL); BUG_ON(coda_file->private_data != NULL);
coda_file->private_data = cfi; coda_file->private_data = cfi;
...@@ -176,7 +175,7 @@ int coda_flush(struct file *coda_file) ...@@ -176,7 +175,7 @@ int coda_flush(struct file *coda_file)
coda_inode = coda_file->f_dentry->d_inode; coda_inode = coda_file->f_dentry->d_inode;
err = venus_store(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags, err = venus_store(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags,
&cfi->cfi_cred); coda_file->f_uid);
if (err == -EOPNOTSUPP) { if (err == -EOPNOTSUPP) {
use_coda_close = 1; use_coda_close = 1;
...@@ -214,7 +213,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file) ...@@ -214,7 +213,7 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
if (use_coda_close) if (use_coda_close)
err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode), err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode),
coda_flags, &cfi->cfi_cred); coda_flags, coda_file->f_uid);
host_inode = cfi->cfi_container->f_dentry->d_inode; host_inode = cfi->cfi_container->f_dentry->d_inode;
cii = ITOC(coda_inode); cii = ITOC(coda_inode);
......
...@@ -46,7 +46,7 @@ static struct inode *coda_alloc_inode(struct super_block *sb) ...@@ -46,7 +46,7 @@ static struct inode *coda_alloc_inode(struct super_block *sb)
return NULL; return NULL;
memset(&ei->c_fid, 0, sizeof(struct ViceFid)); memset(&ei->c_fid, 0, sizeof(struct ViceFid));
ei->c_flags = 0; ei->c_flags = 0;
memset(&ei->c_cached_cred, 0, sizeof(struct coda_cred)); ei->c_uid = 0;
ei->c_cached_perm = 0; ei->c_cached_perm = 0;
return &ei->vfs_inode; return &ei->vfs_inode;
} }
......
...@@ -55,7 +55,8 @@ static void *alloc_upcall(int opcode, int size) ...@@ -55,7 +55,8 @@ static void *alloc_upcall(int opcode, int size)
inp->ih.opcode = opcode; inp->ih.opcode = opcode;
inp->ih.pid = current->pid; inp->ih.pid = current->pid;
inp->ih.pgid = current->pgrp; inp->ih.pgid = current->pgrp;
coda_load_creds(&(inp->ih.cred)); memset(&inp->ih.cred, 0, sizeof(struct coda_cred));
inp->ih.cred.cr_fsuid = current->fsuid;
return (void*)inp; return (void*)inp;
} }
...@@ -163,16 +164,18 @@ int venus_lookup(struct super_block *sb, struct ViceFid *fid, ...@@ -163,16 +164,18 @@ int venus_lookup(struct super_block *sb, struct ViceFid *fid,
} }
int venus_store(struct super_block *sb, struct ViceFid *fid, int flags, int venus_store(struct super_block *sb, struct ViceFid *fid, int flags,
struct coda_cred *cred) vuid_t uid)
{ {
union inputArgs *inp; union inputArgs *inp;
union outputArgs *outp; union outputArgs *outp;
int insize, outsize, error; int insize, outsize, error;
struct coda_cred cred = { 0, };
cred.cr_fsuid = uid;
insize = SIZE(store); insize = SIZE(store);
UPARG(CODA_STORE); UPARG(CODA_STORE);
memcpy(&(inp->ih.cred), cred, sizeof(*cred)); memcpy(&(inp->ih.cred), &cred, sizeof(cred));
inp->coda_store.VFid = *fid; inp->coda_store.VFid = *fid;
inp->coda_store.flags = flags; inp->coda_store.flags = flags;
...@@ -202,16 +205,18 @@ int venus_release(struct super_block *sb, struct ViceFid *fid, int flags) ...@@ -202,16 +205,18 @@ int venus_release(struct super_block *sb, struct ViceFid *fid, int flags)
} }
int venus_close(struct super_block *sb, struct ViceFid *fid, int flags, int venus_close(struct super_block *sb, struct ViceFid *fid, int flags,
struct coda_cred *cred) vuid_t uid)
{ {
union inputArgs *inp; union inputArgs *inp;
union outputArgs *outp; union outputArgs *outp;
int insize, outsize, error; int insize, outsize, error;
struct coda_cred cred = { 0, };
cred.cr_fsuid = uid;
insize = SIZE(release); insize = SIZE(release);
UPARG(CODA_CLOSE); UPARG(CODA_CLOSE);
memcpy(&(inp->ih.cred), cred, sizeof(*cred)); memcpy(&(inp->ih.cred), &cred, sizeof(cred));
inp->coda_close.VFid = *fid; inp->coda_close.VFid = *fid;
inp->coda_close.flags = flags; inp->coda_close.flags = flags;
......
...@@ -21,8 +21,8 @@ struct coda_inode_info { ...@@ -21,8 +21,8 @@ struct coda_inode_info {
u_short c_flags; /* flags (see below) */ u_short c_flags; /* flags (see below) */
struct list_head c_cilist; /* list of all coda inodes */ struct list_head c_cilist; /* list of all coda inodes */
unsigned int c_mapcount; /* nr of times this inode is mapped */ unsigned int c_mapcount; /* nr of times this inode is mapped */
unsigned int c_cached_epoch; unsigned int c_cached_epoch; /* epoch for cached permissions */
struct coda_cred c_cached_cred; /* credentials of cached perms */ vuid_t c_uid; /* fsuid for cached permissions */
unsigned int c_cached_perm; /* cached access permissions */ unsigned int c_cached_perm; /* cached access permissions */
struct inode vfs_inode; struct inode vfs_inode;
}; };
...@@ -35,7 +35,6 @@ struct coda_file_info { ...@@ -35,7 +35,6 @@ struct coda_file_info {
int cfi_magic; /* magic number */ int cfi_magic; /* magic number */
struct file *cfi_container; /* container file for this cnode */ struct file *cfi_container; /* container file for this cnode */
unsigned int cfi_mapcount; /* nr of times this file is mapped */ unsigned int cfi_mapcount; /* nr of times this file is mapped */
struct coda_cred cfi_cred; /* credentials of opener */
}; };
#define CODA_FTOC(file) ((struct coda_file_info *)((file)->private_data)) #define CODA_FTOC(file) ((struct coda_file_info *)((file)->private_data))
......
...@@ -54,12 +54,9 @@ char *coda_f2s(ViceFid *f); ...@@ -54,12 +54,9 @@ char *coda_f2s(ViceFid *f);
int coda_isroot(struct inode *i); int coda_isroot(struct inode *i);
int coda_iscontrol(const char *name, size_t length); int coda_iscontrol(const char *name, size_t length);
void coda_load_creds(struct coda_cred *cred);
void coda_vattr_to_iattr(struct inode *, struct coda_vattr *); void coda_vattr_to_iattr(struct inode *, struct coda_vattr *);
void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *); void coda_iattr_to_vattr(struct iattr *, struct coda_vattr *);
unsigned short coda_flags_to_cflags(unsigned short); unsigned short coda_flags_to_cflags(unsigned short);
int coda_cred_ok(struct coda_cred *cred);
int coda_cred_eq(struct coda_cred *cred1, struct coda_cred *cred2);
/* sysctl.h */ /* sysctl.h */
void coda_sysctl_init(void); void coda_sysctl_init(void);
......
...@@ -39,11 +39,9 @@ int venus_setattr(struct super_block *, struct ViceFid *, ...@@ -39,11 +39,9 @@ int venus_setattr(struct super_block *, struct ViceFid *,
int venus_lookup(struct super_block *sb, struct ViceFid *fid, int venus_lookup(struct super_block *sb, struct ViceFid *fid,
const char *name, int length, int *type, const char *name, int length, int *type,
struct ViceFid *resfid); struct ViceFid *resfid);
int venus_store(struct super_block *sb, struct ViceFid *fid, int flags, int venus_store(struct super_block *sb, struct ViceFid *fid, int flags, vuid_t uid);
struct coda_cred *);
int venus_release(struct super_block *sb, struct ViceFid *fid, int flags); int venus_release(struct super_block *sb, struct ViceFid *fid, int flags);
int venus_close(struct super_block *sb, struct ViceFid *fid, int flags, int venus_close(struct super_block *sb, struct ViceFid *fid, int flags, vuid_t uid);
struct coda_cred *);
int venus_open(struct super_block *sb, struct ViceFid *fid, int venus_open(struct super_block *sb, struct ViceFid *fid,
int flags, struct file **f); int flags, struct file **f);
int venus_mkdir(struct super_block *sb, struct ViceFid *dirfid, int venus_mkdir(struct super_block *sb, struct ViceFid *dirfid,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment