Commit 828dfe1d authored by Eric Paris's avatar Eric Paris Committed by James Morris

SELinux: whitespace and formating fixes for hooks.c

All whitespace and formatting.  Nothing interesting to see here.  About
the only thing to remember is that we aren't supposed to initialize
static variables to 0/NULL.  It is done for us and doing it ourselves
puts them in a different section.

With this patch running checkpatch.pl against hooks.c only gives us
complaints about busting the 80 character limit and declaring extern's
in .c files.  Apparently they don't like it, but I don't feel like going
to the trouble of moving those to .h files...
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 744ba35e
......@@ -99,11 +99,11 @@ extern struct security_operations *security_ops;
atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
#ifdef CONFIG_SECURITY_SELINUX_DEVELOP
int selinux_enforcing = 0;
int selinux_enforcing;
static int __init enforcing_setup(char *str)
{
selinux_enforcing = simple_strtol(str,NULL,0);
selinux_enforcing = simple_strtol(str, NULL, 0);
return 1;
}
__setup("enforcing=", enforcing_setup);
......@@ -123,13 +123,13 @@ int selinux_enabled = 1;
#endif
/* Original (dummy) security module. */
static struct security_operations *original_ops = NULL;
static struct security_operations *original_ops;
/* Minimal support for a secondary security module,
just to allow the use of the dummy or capability modules.
The owlsm module can alternatively be used as a secondary
module as long as CONFIG_OWLSM_FD is not enabled. */
static struct security_operations *secondary_ops = NULL;
static struct security_operations *secondary_ops;
/* Lists of inode and superblock security structures initialized
before the policy was loaded. */
......@@ -1054,7 +1054,7 @@ static int selinux_proc_get_sid(struct proc_dir_entry *de,
int buflen, rc;
char *buffer, *path, *end;
buffer = (char*)__get_free_page(GFP_KERNEL);
buffer = (char *)__get_free_page(GFP_KERNEL);
if (!buffer)
return -ENOMEM;
......@@ -1305,7 +1305,7 @@ static int task_has_capability(struct task_struct *tsk,
tsec = tsk->security;
AVC_AUDIT_DATA_INIT(&ad,CAP);
AVC_AUDIT_DATA_INIT(&ad, CAP);
ad.tsk = tsk;
ad.u.cap = cap;
......@@ -1348,7 +1348,7 @@ static int inode_has_perm(struct task_struct *tsk,
struct inode_security_struct *isec;
struct avc_audit_data ad;
if (unlikely (IS_PRIVATE (inode)))
if (unlikely(IS_PRIVATE(inode)))
return 0;
tsec = tsk->security;
......@@ -1373,7 +1373,7 @@ static inline int dentry_has_perm(struct task_struct *tsk,
{
struct inode *inode = dentry->d_inode;
struct avc_audit_data ad;
AVC_AUDIT_DATA_INIT(&ad,FS);
AVC_AUDIT_DATA_INIT(&ad, FS);
ad.u.fs.path.mnt = mnt;
ad.u.fs.path.dentry = dentry;
return inode_has_perm(tsk, inode, av, &ad);
......@@ -1676,7 +1676,7 @@ static int selinux_ptrace(struct task_struct *parent, struct task_struct *child)
{
int rc;
rc = secondary_ops->ptrace(parent,child);
rc = secondary_ops->ptrace(parent, child);
if (rc)
return rc;
......@@ -1721,7 +1721,7 @@ static int selinux_capable(struct task_struct *tsk, int cap)
if (rc)
return rc;
return task_has_capability(tsk,cap);
return task_has_capability(tsk, cap);
}
static int selinux_sysctl_get_sid(ctl_table *table, u16 tclass, u32 *sid)
......@@ -1730,7 +1730,7 @@ static int selinux_sysctl_get_sid(ctl_table *table, u16 tclass, u32 *sid)
char *buffer, *path, *end;
rc = -ENOMEM;
buffer = (char*)__get_free_page(GFP_KERNEL);
buffer = (char *)__get_free_page(GFP_KERNEL);
if (!buffer)
goto out;
......@@ -1788,7 +1788,7 @@ static int selinux_sysctl(ctl_table *table, int op)
/* The op values are "defined" in sysctl.c, thereby creating
* a bad coupling between this module and sysctl.c */
if(op == 001) {
if (op == 001) {
error = avc_has_perm(tsec->sid, tsid,
SECCLASS_DIR, DIR__SEARCH, NULL);
} else {
......@@ -1818,16 +1818,14 @@ static int selinux_quotactl(int cmds, int type, int id, struct super_block *sb)
case Q_QUOTAOFF:
case Q_SETINFO:
case Q_SETQUOTA:
rc = superblock_has_perm(current,
sb,
FILESYSTEM__QUOTAMOD, NULL);
rc = superblock_has_perm(current, sb, FILESYSTEM__QUOTAMOD,
NULL);
break;
case Q_GETFMT:
case Q_GETINFO:
case Q_GETQUOTA:
rc = superblock_has_perm(current,
sb,
FILESYSTEM__QUOTAGET, NULL);
rc = superblock_has_perm(current, sb, FILESYSTEM__QUOTAGET,
NULL);
break;
default:
rc = 0; /* let the kernel handle invalid cmds */
......@@ -2011,13 +2009,13 @@ static int selinux_bprm_set_security(struct linux_binprm *bprm)
return 0;
}
static int selinux_bprm_check_security (struct linux_binprm *bprm)
static int selinux_bprm_check_security(struct linux_binprm *bprm)
{
return secondary_ops->bprm_check_security(bprm);
}
static int selinux_bprm_secureexec (struct linux_binprm *bprm)
static int selinux_bprm_secureexec(struct linux_binprm *bprm)
{
struct task_security_struct *tsec = current->security;
int atsecure = 0;
......@@ -2044,7 +2042,7 @@ extern struct vfsmount *selinuxfs_mount;
extern struct dentry *selinux_null;
/* Derived from fs/exec.c:flush_old_files. */
static inline void flush_unauthorized_files(struct files_struct * files)
static inline void flush_unauthorized_files(struct files_struct *files)
{
struct avc_audit_data ad;
struct file *file, *devnull = NULL;
......@@ -2079,7 +2077,7 @@ static inline void flush_unauthorized_files(struct files_struct * files)
/* Revalidate access to inherited open files. */
AVC_AUDIT_DATA_INIT(&ad,FS);
AVC_AUDIT_DATA_INIT(&ad, FS);
spin_lock(&files->file_lock);
for (;;) {
......@@ -2095,7 +2093,7 @@ static inline void flush_unauthorized_files(struct files_struct * files)
if (!set)
continue;
spin_unlock(&files->file_lock);
for ( ; set ; i++,set >>= 1) {
for ( ; set ; i++, set >>= 1) {
if (set & 1) {
file = fget(i);
if (!file)
......@@ -2252,7 +2250,7 @@ static void selinux_bprm_post_apply_creds(struct linux_binprm *bprm)
for (i = 0; i < RLIM_NLIMITS; i++) {
rlim = current->signal->rlim + i;
initrlim = init_task.signal->rlim+i;
rlim->rlim_cur = min(rlim->rlim_max,initrlim->rlim_cur);
rlim->rlim_cur = min(rlim->rlim_max, initrlim->rlim_cur);
}
if (current->signal->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) {
/*
......@@ -2315,8 +2313,7 @@ static inline void take_selinux_option(char **to, char *from, int *first,
if (!*first) {
**to = '|';
*to += 1;
}
else
} else
*first = 0;
while (current_size < len) {
......@@ -2380,7 +2377,7 @@ static int selinux_sb_kern_mount(struct super_block *sb, void *data)
if (rc)
return rc;
AVC_AUDIT_DATA_INIT(&ad,FS);
AVC_AUDIT_DATA_INIT(&ad, FS);
ad.u.fs.path.dentry = sb->s_root;
return superblock_has_perm(current, sb, FILESYSTEM__MOUNT, &ad);
}
......@@ -2389,16 +2386,16 @@ static int selinux_sb_statfs(struct dentry *dentry)
{
struct avc_audit_data ad;
AVC_AUDIT_DATA_INIT(&ad,FS);
AVC_AUDIT_DATA_INIT(&ad, FS);
ad.u.fs.path.dentry = dentry->d_sb->s_root;
return superblock_has_perm(current, dentry->d_sb, FILESYSTEM__GETATTR, &ad);
}
static int selinux_mount(char * dev_name,
static int selinux_mount(char *dev_name,
struct nameidata *nd,
char * type,
char *type,
unsigned long flags,
void * data)
void *data)
{
int rc;
......@@ -2422,8 +2419,8 @@ static int selinux_umount(struct vfsmount *mnt, int flags)
if (rc)
return rc;
return superblock_has_perm(current,mnt->mnt_sb,
FILESYSTEM__UNMOUNT,NULL);
return superblock_has_perm(current, mnt->mnt_sb,
FILESYSTEM__UNMOUNT, NULL);
}
/* inode security operations */
......@@ -2509,7 +2506,7 @@ static int selinux_inode_link(struct dentry *old_dentry, struct inode *dir, stru
{
int rc;
rc = secondary_ops->inode_link(old_dentry,dir,new_dentry);
rc = secondary_ops->inode_link(old_dentry, dir, new_dentry);
if (rc)
return rc;
return may_link(dir, old_dentry, MAY_LINK);
......@@ -2566,7 +2563,7 @@ static int selinux_inode_follow_link(struct dentry *dentry, struct nameidata *na
{
int rc;
rc = secondary_ops->inode_follow_link(dentry,nameidata);
rc = secondary_ops->inode_follow_link(dentry, nameidata);
if (rc)
return rc;
return dentry_has_perm(current, NULL, dentry, FILE__READ);
......@@ -2652,7 +2649,7 @@ static int selinux_inode_setxattr(struct dentry *dentry, char *name, void *value
if (!is_owner_or_cap(inode))
return -EPERM;
AVC_AUDIT_DATA_INIT(&ad,FS);
AVC_AUDIT_DATA_INIT(&ad, FS);
ad.u.fs.path.dentry = dentry;
rc = avc_has_perm(tsec->sid, isec->sid, isec->sclass,
......@@ -2705,17 +2702,17 @@ static void selinux_inode_post_setxattr(struct dentry *dentry, char *name,
return;
}
static int selinux_inode_getxattr (struct dentry *dentry, char *name)
static int selinux_inode_getxattr(struct dentry *dentry, char *name)
{
return dentry_has_perm(current, NULL, dentry, FILE__GETATTR);
}
static int selinux_inode_listxattr (struct dentry *dentry)
static int selinux_inode_listxattr(struct dentry *dentry)
{
return dentry_has_perm(current, NULL, dentry, FILE__GETATTR);
}
static int selinux_inode_removexattr (struct dentry *dentry, char *name)
static int selinux_inode_removexattr(struct dentry *dentry, char *name)
{
if (strcmp(name, XATTR_NAME_SELINUX))
return selinux_inode_setotherxattr(dentry, name);
......@@ -2768,7 +2765,7 @@ static int selinux_inode_setsecurity(struct inode *inode, const char *name,
if (!value || !size)
return -EACCES;
rc = security_context_to_sid((void*)value, size, &newsid);
rc = security_context_to_sid((void *)value, size, &newsid);
if (rc)
return rc;
......@@ -2886,7 +2883,7 @@ static int selinux_file_ioctl(struct file *file, unsigned int cmd,
case KDSKBENT:
case KDSKBSENT:
error = task_has_capability(current,CAP_SYS_TTY_CONFIG);
error = task_has_capability(current, CAP_SYS_TTY_CONFIG);
break;
/* default case assumes that the command will go
......@@ -2894,7 +2891,6 @@ static int selinux_file_ioctl(struct file *file, unsigned int cmd,
*/
default:
error = file_has_perm(current, file, FILE__IOCTL);
}
return error;
}
......@@ -2935,7 +2931,7 @@ static int selinux_file_mmap(struct file *file, unsigned long reqprot,
unsigned long addr, unsigned long addr_only)
{
int rc = 0;
u32 sid = ((struct task_security_struct*)(current->security))->sid;
u32 sid = ((struct task_security_struct *)(current->security))->sid;
if (addr < mmap_min_addr)
rc = avc_has_perm(sid, sid, SECCLASS_MEMPROTECT,
......@@ -3011,7 +3007,7 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd,
}
if ((file->f_flags & O_APPEND) && !(arg & O_APPEND)) {
err = file_has_perm(current, file,FILE__WRITE);
err = file_has_perm(current, file, FILE__WRITE);
break;
}
/* fall through */
......@@ -3165,7 +3161,7 @@ static int selinux_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags)
static int selinux_task_post_setuid(uid_t id0, uid_t id1, uid_t id2, int flags)
{
return secondary_ops->task_post_setuid(id0,id1,id2,flags);
return secondary_ops->task_post_setuid(id0, id1, id2, flags);
}
static int selinux_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags)
......@@ -3209,7 +3205,7 @@ static int selinux_task_setnice(struct task_struct *p, int nice)
if (rc)
return rc;
return task_has_perm(current,p, PROCESS__SETSCHED);
return task_has_perm(current, p, PROCESS__SETSCHED);
}
static int selinux_task_setioprio(struct task_struct *p, int ioprio)
......@@ -3574,7 +3570,7 @@ static int socket_has_perm(struct task_struct *task, struct socket *sock,
if (isec->sid == SECINITSID_KERNEL)
goto out;
AVC_AUDIT_DATA_INIT(&ad,NET);
AVC_AUDIT_DATA_INIT(&ad, NET);
ad.u.net.sk = sock->sk;
err = avc_has_perm(tsec->sid, isec->sid, isec->sclass, perms, &ad);
......@@ -3684,7 +3680,7 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
snum, &sid);
if (err)
goto out;
AVC_AUDIT_DATA_INIT(&ad,NET);
AVC_AUDIT_DATA_INIT(&ad, NET);
ad.u.net.sport = htons(snum);
ad.u.net.family = family;
err = avc_has_perm(isec->sid, sid,
......@@ -3695,7 +3691,7 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
}
}
switch(isec->sclass) {
switch (isec->sclass) {
case SECCLASS_TCP_SOCKET:
node_perm = TCP_SOCKET__NODE_BIND;
break;
......@@ -3717,7 +3713,7 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
if (err)
goto out;
AVC_AUDIT_DATA_INIT(&ad,NET);
AVC_AUDIT_DATA_INIT(&ad, NET);
ad.u.net.sport = htons(snum);
ad.u.net.family = family;
......@@ -3776,7 +3772,7 @@ static int selinux_socket_connect(struct socket *sock, struct sockaddr *address,
perm = (isec->sclass == SECCLASS_TCP_SOCKET) ?
TCP_SOCKET__NAME_CONNECT : DCCP_SOCKET__NAME_CONNECT;
AVC_AUDIT_DATA_INIT(&ad,NET);
AVC_AUDIT_DATA_INIT(&ad, NET);
ad.u.net.dport = htons(snum);
ad.u.net.family = sk->sk_family;
err = avc_has_perm(isec->sid, sid, isec->sclass, perm, &ad);
......@@ -3841,7 +3837,7 @@ static int selinux_socket_getpeername(struct socket *sock)
return socket_has_perm(current, sock, SOCKET__GETATTR);
}
static int selinux_socket_setsockopt(struct socket *sock,int level,int optname)
static int selinux_socket_setsockopt(struct socket *sock, int level, int optname)
{
int err;
......@@ -3880,7 +3876,7 @@ static int selinux_socket_unix_stream_connect(struct socket *sock,
isec = SOCK_INODE(sock)->i_security;
other_isec = SOCK_INODE(other)->i_security;
AVC_AUDIT_DATA_INIT(&ad,NET);
AVC_AUDIT_DATA_INIT(&ad, NET);
ad.u.net.sk = other->sk;
err = avc_has_perm(isec->sid, other_isec->sid,
......@@ -3912,7 +3908,7 @@ static int selinux_socket_unix_may_send(struct socket *sock,
isec = SOCK_INODE(sock)->i_security;
other_isec = SOCK_INODE(other)->i_security;
AVC_AUDIT_DATA_INIT(&ad,NET);
AVC_AUDIT_DATA_INIT(&ad, NET);
ad.u.net.sk = other->sk;
err = avc_has_perm(isec->sid, other_isec->sid,
......@@ -4202,7 +4198,7 @@ static void selinux_sk_getsecid(struct sock *sk, u32 *secid)
}
}
static void selinux_sock_graft(struct sock* sk, struct socket *parent)
static void selinux_sock_graft(struct sock *sk, struct socket *parent)
{
struct inode_security_struct *isec = SOCK_INODE(parent)->i_security;
struct sk_security_struct *sksec = sk->sk_security;
......@@ -4723,7 +4719,7 @@ static int selinux_msg_queue_msgctl(struct msg_queue *msq, int cmd)
int err;
int perms;
switch(cmd) {
switch (cmd) {
case IPC_INFO:
case MSG_INFO:
/* No specific object, just general system-wide information. */
......@@ -4871,7 +4867,7 @@ static int selinux_shm_shmctl(struct shmid_kernel *shp, int cmd)
int perms;
int err;
switch(cmd) {
switch (cmd) {
case IPC_INFO:
case SHM_INFO:
/* No specific object, just general system-wide information. */
......@@ -4970,7 +4966,7 @@ static int selinux_sem_semctl(struct sem_array *sma, int cmd)
int err;
u32 perms;
switch(cmd) {
switch (cmd) {
case IPC_INFO:
case SEM_INFO:
/* No specific object, just general system-wide information. */
......@@ -5042,7 +5038,7 @@ static void selinux_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
}
/* module stacking operations */
static int selinux_register_security (const char *name, struct security_operations *ops)
static int selinux_register_security(const char *name, struct security_operations *ops)
{
if (secondary_ops != original_ops) {
printk(KERN_ERR "%s: There is already a secondary security "
......@@ -5059,7 +5055,7 @@ static int selinux_register_security (const char *name, struct security_operatio
return 0;
}
static void selinux_d_instantiate (struct dentry *dentry, struct inode *inode)
static void selinux_d_instantiate(struct dentry *dentry, struct inode *inode)
{
if (inode)
inode_doinit_with_dentry(inode, dentry);
......@@ -5219,8 +5215,7 @@ static int selinux_setprocattr(struct task_struct *p,
tsec->sid = sid;
task_unlock(p);
}
}
else
} else
return -EINVAL;
return size;
......@@ -5520,15 +5515,14 @@ static __init int selinux_init(void)
original_ops = secondary_ops = security_ops;
if (!secondary_ops)
panic ("SELinux: No initial security operations\n");
if (register_security (&selinux_ops))
panic("SELinux: No initial security operations\n");
if (register_security(&selinux_ops))
panic("SELinux: Unable to register with kernel.\n");
if (selinux_enforcing) {
if (selinux_enforcing)
printk(KERN_DEBUG "SELinux: Starting in enforcing mode\n");
} else {
else
printk(KERN_DEBUG "SELinux: Starting in permissive mode\n");
}
#ifdef CONFIG_KEYS
/* Add security information to initial keyrings */
......@@ -5673,10 +5667,11 @@ static void selinux_nf_ip_exit(void)
#endif /* CONFIG_NETFILTER */
#ifdef CONFIG_SECURITY_SELINUX_DISABLE
static int selinux_disabled;
int selinux_disable(void)
{
extern void exit_sel_fs(void);
static int selinux_disabled = 0;
if (ss_initialized) {
/* Not permitted after initial policy load. */
......
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