summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <greg@kroah.com>2002-11-26 23:11:25 -0800
committerGreg Kroah-Hartman <greg@kroah.com>2002-11-26 23:11:25 -0800
commitee0990090dc3e324f878acc86eee8edabf147ec7 (patch)
tree44b0274f2b2adbcafd28eb03c6c8269fe1cb6be9
parent2e1dab7d3c33534fc1805867322c22d26c87e609 (diff)
LSM: change if statements into something more readable for the fs/* files.
-rw-r--r--fs/attr.c3
-rw-r--r--fs/dquot.c3
-rw-r--r--fs/exec.c9
-rw-r--r--fs/fcntl.c9
-rw-r--r--fs/ioctl.c3
-rw-r--r--fs/locks.c12
-rw-r--r--fs/namei.c33
-rw-r--r--fs/namespace.c12
-rw-r--r--fs/open.c3
-rw-r--r--fs/read_write.c6
-rw-r--r--fs/readdir.c3
-rw-r--r--fs/stat.c6
-rw-r--r--fs/xattr.c12
13 files changed, 76 insertions, 38 deletions
diff --git a/fs/attr.c b/fs/attr.c
index af45dd627c01..c7c414b9929c 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -157,7 +157,8 @@ int notify_change(struct dentry * dentry, struct iattr * attr)
return 0;
if (inode->i_op && inode->i_op->setattr) {
- if (!(error = security_inode_setattr(dentry, attr)))
+ error = security_inode_setattr(dentry, attr);
+ if (!error)
error = inode->i_op->setattr(dentry, attr);
} else {
error = inode_change_ok(inode, attr);
diff --git a/fs/dquot.c b/fs/dquot.c
index dca590bbd8fb..5da20a7049ce 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -1307,7 +1307,8 @@ int vfs_quota_on(struct super_block *sb, int type, int format_id, char *path)
error = -EIO;
if (!f->f_op || !f->f_op->read || !f->f_op->write)
goto out_f;
- if ((error = security_quota_on(f)))
+ error = security_quota_on(f);
+ if (error)
goto out_f;
inode = f->f_dentry->d_inode;
error = -EACCES;
diff --git a/fs/exec.c b/fs/exec.c
index 3757201478c3..a0a4aa824ae6 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -841,7 +841,8 @@ int prepare_binprm(struct linux_binprm *bprm)
}
/* fill in binprm security blob */
- if ((retval = security_bprm_set(bprm)))
+ retval = security_bprm_set(bprm);
+ if (retval)
return retval;
memset(bprm->buf,0,BINPRM_BUF_SIZE);
@@ -958,7 +959,8 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
}
}
#endif
- if ((retval = security_bprm_check(bprm)))
+ retval = security_bprm_check(bprm);
+ if (retval)
return retval;
/* kernel module loader fixup */
@@ -1054,7 +1056,8 @@ int do_execve(char * filename, char ** argv, char ** envp, struct pt_regs * regs
if ((retval = bprm.envc) < 0)
goto out_mm;
- if ((retval = security_bprm_alloc(&bprm)))
+ retval = security_bprm_alloc(&bprm);
+ if (retval)
goto out;
retval = prepare_binprm(&bprm);
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 90900d2188a0..041b84ffd0ce 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -274,7 +274,8 @@ int f_setown(struct file *filp, unsigned long arg, int force)
{
int err;
- if ((err = security_file_set_fowner(filp)))
+ err = security_file_set_fowner(filp);
+ if (err)
return err;
f_modown(filp, arg, current->uid, current->euid, force);
@@ -367,7 +368,8 @@ asmlinkage long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg)
if (!filp)
goto out;
- if ((err = security_file_fcntl(filp, cmd, arg))) {
+ err = security_file_fcntl(filp, cmd, arg);
+ if (err) {
fput(filp);
return err;
}
@@ -390,7 +392,8 @@ asmlinkage long sys_fcntl64(unsigned int fd, unsigned int cmd, unsigned long arg
if (!filp)
goto out;
- if ((err = security_file_fcntl(filp, cmd, arg))) {
+ err = security_file_fcntl(filp, cmd, arg);
+ if (err) {
fput(filp);
return err;
}
diff --git a/fs/ioctl.c b/fs/ioctl.c
index b0b6b2ed4c3b..9e16c74d67f0 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -59,7 +59,8 @@ asmlinkage long sys_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg)
goto out;
error = 0;
- if ((error = security_file_ioctl(filp, cmd, arg))) {
+ error = security_file_ioctl(filp, cmd, arg);
+ if (error) {
fput(filp);
goto out;
}
diff --git a/fs/locks.c b/fs/locks.c
index dac9a048ed35..04600003a4a0 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1185,7 +1185,8 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
return -EACCES;
if (!S_ISREG(inode->i_mode))
return -EINVAL;
- if ((error = security_file_lock(filp, arg)))
+ error = security_file_lock(filp, arg);
+ if (error)
return error;
lock_kernel();
@@ -1298,7 +1299,8 @@ asmlinkage long sys_flock(unsigned int fd, unsigned int cmd)
if (error)
goto out_putf;
- if ((error = security_file_lock(filp, cmd)))
+ error = security_file_lock(filp, cmd);
+ if (error)
goto out_free;
for (;;) {
@@ -1449,7 +1451,8 @@ int fcntl_setlk(struct file *filp, unsigned int cmd, struct flock *l)
goto out;
}
- if ((error = security_file_lock(filp, file_lock->fl_type)))
+ error = security_file_lock(filp, file_lock->fl_type);
+ if (error)
goto out;
if (filp->f_op && filp->f_op->lock != NULL) {
@@ -1588,7 +1591,8 @@ int fcntl_setlk64(struct file *filp, unsigned int cmd, struct flock64 *l)
goto out;
}
- if ((error = security_file_lock(filp, file_lock->fl_type)))
+ error = security_file_lock(filp, file_lock->fl_type);
+ if (error)
goto out;
if (filp->f_op && filp->f_op->lock != NULL) {
diff --git a/fs/namei.c b/fs/namei.c
index 8961c2eaba74..179732c79ece 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -413,7 +413,8 @@ static inline int do_follow_link(struct dentry *dentry, struct nameidata *nd)
current->state = TASK_RUNNING;
schedule();
}
- if ((err = security_inode_follow_link(dentry, nd)))
+ err = security_inode_follow_link(dentry, nd);
+ if (err)
goto loop;
current->link_count++;
current->total_link_count++;
@@ -1124,7 +1125,8 @@ int vfs_create(struct inode *dir, struct dentry *dentry, int mode)
return -EACCES; /* shouldn't it be ENOSYS? */
mode &= S_IALLUGO;
mode |= S_IFREG;
- if ((error = security_inode_create(dir, dentry, mode)))
+ error = security_inode_create(dir, dentry, mode);
+ if (error)
return error;
DQUOT_INIT(dir);
error = dir->i_op->create(dir, dentry, mode);
@@ -1343,7 +1345,8 @@ do_link:
* stored in nd->last.name and we will have to putname() it when we
* are done. Procfs-like symlinks just set LAST_BIND.
*/
- if ((error = security_inode_follow_link(dentry, nd)))
+ error = security_inode_follow_link(dentry, nd);
+ if (error)
goto exit_dput;
UPDATE_ATIME(dentry->d_inode);
error = dentry->d_inode->i_op->follow_link(dentry, nd);
@@ -1408,7 +1411,8 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
if (!dir->i_op || !dir->i_op->mknod)
return -EPERM;
- if ((error = security_inode_mknod(dir, dentry, mode, dev)))
+ error = security_inode_mknod(dir, dentry, mode, dev);
+ if (error)
return error;
DQUOT_INIT(dir);
@@ -1476,7 +1480,8 @@ int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
return -EPERM;
mode &= (S_IRWXUGO|S_ISVTX);
- if ((error = security_inode_mkdir(dir, dentry, mode)))
+ error = security_inode_mkdir(dir, dentry, mode);
+ if (error)
return error;
DQUOT_INIT(dir);
@@ -1568,7 +1573,8 @@ int vfs_rmdir(struct inode *dir, struct dentry *dentry)
if (d_mountpoint(dentry))
error = -EBUSY;
else {
- if (!(error = security_inode_rmdir(dir, dentry))) {
+ error = security_inode_rmdir(dir, dentry);
+ if (!error) {
error = dir->i_op->rmdir(dir, dentry);
if (!error)
dentry->d_inode->i_flags |= S_DEAD;
@@ -1641,7 +1647,8 @@ int vfs_unlink(struct inode *dir, struct dentry *dentry)
if (d_mountpoint(dentry))
error = -EBUSY;
else {
- if (!(error = security_inode_unlink(dir, dentry)))
+ error = security_inode_unlink(dir, dentry);
+ if (error)
error = dir->i_op->unlink(dir, dentry);
}
up(&dentry->d_inode->i_sem);
@@ -1704,7 +1711,8 @@ int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
if (!dir->i_op || !dir->i_op->symlink)
return -EPERM;
- if ((error = security_inode_symlink(dir, dentry, oldname)))
+ error = security_inode_symlink(dir, dentry, oldname);
+ if (error)
return error;
DQUOT_INIT(dir);
@@ -1774,7 +1782,8 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
if (S_ISDIR(old_dentry->d_inode->i_mode))
return -EPERM;
- if ((error = security_inode_link(old_dentry, dir, new_dentry)))
+ error = security_inode_link(old_dentry, dir, new_dentry);
+ if (error)
return error;
down(&old_dentry->d_inode->i_sem);
@@ -1882,7 +1891,8 @@ int vfs_rename_dir(struct inode *old_dir, struct dentry *old_dentry,
return error;
}
- if ((error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry)))
+ error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry);
+ if (error)
return error;
target = new_dentry->d_inode;
@@ -1916,7 +1926,8 @@ int vfs_rename_other(struct inode *old_dir, struct dentry *old_dentry,
struct inode *target;
int error;
- if ((error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry)))
+ error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry);
+ if (error)
return error;
dget(new_dentry);
diff --git a/fs/namespace.c b/fs/namespace.c
index 1841cc0bdd7b..64b4b149895f 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -289,7 +289,8 @@ static int do_umount(struct vfsmount *mnt, int flags)
struct super_block * sb = mnt->mnt_sb;
int retval = 0;
- if ((retval = security_sb_umount(mnt, flags)))
+ retval = security_sb_umount(mnt, flags);
+ if (retval)
return retval;
/*
@@ -470,7 +471,8 @@ static int graft_tree(struct vfsmount *mnt, struct nameidata *nd)
if (IS_DEADDIR(nd->dentry->d_inode))
goto out_unlock;
- if ((err = security_sb_check_sb(mnt, nd)))
+ err = security_sb_check_sb(mnt, nd);
+ if (err)
goto out_unlock;
spin_lock(&dcache_lock);
@@ -740,7 +742,8 @@ long do_mount(char * dev_name, char * dir_name, char *type_page,
if (retval)
return retval;
- if ((retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page)))
+ retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page);
+ if (retval)
goto dput_out;
if (flags & MS_REMOUNT)
@@ -985,7 +988,8 @@ asmlinkage long sys_pivot_root(const char *new_root, const char *put_old)
if (error)
goto out1;
- if ((error = security_sb_pivotroot(&old_nd, &new_nd))) {
+ error = security_sb_pivotroot(&old_nd, &new_nd);
+ if (error) {
path_release(&old_nd);
goto out1;
}
diff --git a/fs/open.c b/fs/open.c
index ecfb462a282d..e06322405948 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -31,7 +31,8 @@ int vfs_statfs(struct super_block *sb, struct statfs *buf)
retval = -ENOSYS;
if (sb->s_op && sb->s_op->statfs) {
memset(buf, 0, sizeof(struct statfs));
- if ((retval = security_sb_statfs(sb)))
+ retval = security_sb_statfs(sb);
+ if (retval)
return retval;
retval = sb->s_op->statfs(sb, buf);
}
diff --git a/fs/read_write.c b/fs/read_write.c
index f8e221b2e9ff..13af577513b9 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -193,7 +193,8 @@ ssize_t vfs_read(struct file *file, char *buf, size_t count, loff_t *pos)
ret = locks_verify_area(FLOCK_VERIFY_READ, inode, file, *pos, count);
if (!ret) {
- if (!(ret = security_file_permission (file, MAY_READ))) {
+ ret = security_file_permission (file, MAY_READ);
+ if (!ret) {
if (file->f_op->read)
ret = file->f_op->read(file, buf, count, pos);
else
@@ -232,7 +233,8 @@ ssize_t vfs_write(struct file *file, const char *buf, size_t count, loff_t *pos)
ret = locks_verify_area(FLOCK_VERIFY_WRITE, inode, file, *pos, count);
if (!ret) {
- if (!(ret = security_file_permission (file, MAY_WRITE))) {
+ ret = security_file_permission (file, MAY_WRITE);
+ if (!ret) {
if (file->f_op->write)
ret = file->f_op->write(file, buf, count, pos);
else
diff --git a/fs/readdir.c b/fs/readdir.c
index 31c6298d6202..69312c338eba 100644
--- a/fs/readdir.c
+++ b/fs/readdir.c
@@ -22,7 +22,8 @@ int vfs_readdir(struct file *file, filldir_t filler, void *buf)
if (!file->f_op || !file->f_op->readdir)
goto out;
- if ((res = security_file_permission(file, MAY_READ)))
+ res = security_file_permission(file, MAY_READ);
+ if (res)
goto out;
down(&inode->i_sem);
diff --git a/fs/stat.c b/fs/stat.c
index 9ecf6c7db0a1..375661315ecd 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -38,7 +38,8 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
struct inode *inode = dentry->d_inode;
int retval;
- if ((retval = security_inode_getattr(mnt, dentry)))
+ retval = security_inode_getattr(mnt, dentry);
+ if (retval)
return retval;
if (inode->i_op->getattr)
@@ -241,7 +242,8 @@ asmlinkage long sys_readlink(const char * path, char * buf, int bufsiz)
error = -EINVAL;
if (inode->i_op && inode->i_op->readlink) {
- if (!(error = security_inode_readlink(nd.dentry))) {
+ error = security_inode_readlink(nd.dentry);
+ if (!error) {
UPDATE_ATIME(inode);
error = inode->i_op->readlink(nd.dentry, buf, bufsiz);
}
diff --git a/fs/xattr.c b/fs/xattr.c
index 933a94031f5b..a0ad0fa76d59 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -86,7 +86,8 @@ setxattr(struct dentry *d, char *name, void *value, size_t size, int flags)
error = -EOPNOTSUPP;
if (d->d_inode->i_op && d->d_inode->i_op->setxattr) {
- if ((error = security_inode_setxattr(d, kname, kvalue, size, flags)))
+ error = security_inode_setxattr(d, kname, kvalue, size, flags);
+ if (error)
goto out;
down(&d->d_inode->i_sem);
error = d->d_inode->i_op->setxattr(d, kname, kvalue, size, flags);
@@ -162,7 +163,8 @@ getxattr(struct dentry *d, char *name, void *value, size_t size)
error = -EOPNOTSUPP;
if (d->d_inode->i_op && d->d_inode->i_op->getxattr) {
- if ((error = security_inode_getxattr(d, kname)))
+ error = security_inode_getxattr(d, kname);
+ if (error)
goto out;
down(&d->d_inode->i_sem);
error = d->d_inode->i_op->getxattr(d, kname, kvalue, size);
@@ -234,7 +236,8 @@ listxattr(struct dentry *d, char *list, size_t size)
error = -EOPNOTSUPP;
if (d->d_inode->i_op && d->d_inode->i_op->listxattr) {
- if ((error = security_inode_listxattr(d)))
+ error = security_inode_listxattr(d);
+ if (error)
goto out;
down(&d->d_inode->i_sem);
error = d->d_inode->i_op->listxattr(d, klist, size);
@@ -308,7 +311,8 @@ removexattr(struct dentry *d, char *name)
error = -EOPNOTSUPP;
if (d->d_inode->i_op && d->d_inode->i_op->removexattr) {
- if ((error = security_inode_removexattr(d, kname)))
+ error = security_inode_removexattr(d, kname);
+ if (error)
goto out;
down(&d->d_inode->i_sem);
error = d->d_inode->i_op->removexattr(d, kname);