summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-23 17:25:45 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-23 17:25:45 -0400
commite94f8ccde4710f9a3e51dd3bc6134c96e33f29b3 (patch)
tree15dd4e776cb92e486c7a0eb1168347de5a87402c
parent9f7582d15f82e86b2041ab22327b7d769e061c1f (diff)
parente5bfad3d7acc5702f32aafeb388362994f4d7bd0 (diff)
Merge tag 'smack-for-5.4-rc1' of git://github.com/cschaufler/smack-next
Pull smack updates from Casey Schaufler: "Four patches for v5.4. Nothing is major. All but one are in response to mechanically detected potential issues. The remaining patch cleans up kernel-doc notations" * tag 'smack-for-5.4-rc1' of git://github.com/cschaufler/smack-next: smack: use GFP_NOFS while holding inode_smack::smk_lock security: smack: Fix possible null-pointer dereferences in smack_socket_sock_rcv_skb() smack: fix some kernel-doc notations Smack: Don't ignore other bprm->unsafe flags if LSM_UNSAFE_PTRACE is set
-rw-r--r--security/smack/smack_access.c6
-rw-r--r--security/smack/smack_lsm.c40
2 files changed, 23 insertions, 23 deletions
diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c
index f1c93a7be9ec..38ac3da4e791 100644
--- a/security/smack/smack_access.c
+++ b/security/smack/smack_access.c
@@ -465,7 +465,7 @@ char *smk_parse_smack(const char *string, int len)
465 if (i == 0 || i >= SMK_LONGLABEL) 465 if (i == 0 || i >= SMK_LONGLABEL)
466 return ERR_PTR(-EINVAL); 466 return ERR_PTR(-EINVAL);
467 467
468 smack = kzalloc(i + 1, GFP_KERNEL); 468 smack = kzalloc(i + 1, GFP_NOFS);
469 if (smack == NULL) 469 if (smack == NULL)
470 return ERR_PTR(-ENOMEM); 470 return ERR_PTR(-ENOMEM);
471 471
@@ -500,7 +500,7 @@ int smk_netlbl_mls(int level, char *catset, struct netlbl_lsm_secattr *sap,
500 if ((m & *cp) == 0) 500 if ((m & *cp) == 0)
501 continue; 501 continue;
502 rc = netlbl_catmap_setbit(&sap->attr.mls.cat, 502 rc = netlbl_catmap_setbit(&sap->attr.mls.cat,
503 cat, GFP_KERNEL); 503 cat, GFP_NOFS);
504 if (rc < 0) { 504 if (rc < 0) {
505 netlbl_catmap_free(sap->attr.mls.cat); 505 netlbl_catmap_free(sap->attr.mls.cat);
506 return rc; 506 return rc;
@@ -536,7 +536,7 @@ struct smack_known *smk_import_entry(const char *string, int len)
536 if (skp != NULL) 536 if (skp != NULL)
537 goto freeout; 537 goto freeout;
538 538
539 skp = kzalloc(sizeof(*skp), GFP_KERNEL); 539 skp = kzalloc(sizeof(*skp), GFP_NOFS);
540 if (skp == NULL) { 540 if (skp == NULL) {
541 skp = ERR_PTR(-ENOMEM); 541 skp = ERR_PTR(-ENOMEM);
542 goto freeout; 542 goto freeout;
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 4c5e5a438f8b..abeb09c30633 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -288,7 +288,7 @@ static struct smack_known *smk_fetch(const char *name, struct inode *ip,
288 if (!(ip->i_opflags & IOP_XATTR)) 288 if (!(ip->i_opflags & IOP_XATTR))
289 return ERR_PTR(-EOPNOTSUPP); 289 return ERR_PTR(-EOPNOTSUPP);
290 290
291 buffer = kzalloc(SMK_LONGLABEL, GFP_KERNEL); 291 buffer = kzalloc(SMK_LONGLABEL, GFP_NOFS);
292 if (buffer == NULL) 292 if (buffer == NULL)
293 return ERR_PTR(-ENOMEM); 293 return ERR_PTR(-ENOMEM);
294 294
@@ -307,7 +307,7 @@ static struct smack_known *smk_fetch(const char *name, struct inode *ip,
307 307
308/** 308/**
309 * init_inode_smack - initialize an inode security blob 309 * init_inode_smack - initialize an inode security blob
310 * @isp: the blob to initialize 310 * @inode: inode to extract the info from
311 * @skp: a pointer to the Smack label entry to use in the blob 311 * @skp: a pointer to the Smack label entry to use in the blob
312 * 312 *
313 */ 313 */
@@ -509,7 +509,7 @@ static int smack_ptrace_traceme(struct task_struct *ptp)
509 509
510/** 510/**
511 * smack_syslog - Smack approval on syslog 511 * smack_syslog - Smack approval on syslog
512 * @type: message type 512 * @typefrom_file: unused
513 * 513 *
514 * Returns 0 on success, error code otherwise. 514 * Returns 0 on success, error code otherwise.
515 */ 515 */
@@ -765,7 +765,7 @@ static int smack_sb_eat_lsm_opts(char *options, void **mnt_opts)
765/** 765/**
766 * smack_set_mnt_opts - set Smack specific mount options 766 * smack_set_mnt_opts - set Smack specific mount options
767 * @sb: the file system superblock 767 * @sb: the file system superblock
768 * @opts: Smack mount options 768 * @mnt_opts: Smack mount options
769 * @kern_flags: mount option from kernel space or user space 769 * @kern_flags: mount option from kernel space or user space
770 * @set_kern_flags: where to store converted mount opts 770 * @set_kern_flags: where to store converted mount opts
771 * 771 *
@@ -937,7 +937,8 @@ static int smack_bprm_set_creds(struct linux_binprm *bprm)
937 937
938 if (rc != 0) 938 if (rc != 0)
939 return rc; 939 return rc;
940 } else if (bprm->unsafe) 940 }
941 if (bprm->unsafe & ~LSM_UNSAFE_PTRACE)
941 return -EPERM; 942 return -EPERM;
942 943
943 bsp->smk_task = isp->smk_task; 944 bsp->smk_task = isp->smk_task;
@@ -958,7 +959,7 @@ static int smack_bprm_set_creds(struct linux_binprm *bprm)
958 * smack_inode_alloc_security - allocate an inode blob 959 * smack_inode_alloc_security - allocate an inode blob
959 * @inode: the inode in need of a blob 960 * @inode: the inode in need of a blob
960 * 961 *
961 * Returns 0 if it gets a blob, -ENOMEM otherwise 962 * Returns 0
962 */ 963 */
963static int smack_inode_alloc_security(struct inode *inode) 964static int smack_inode_alloc_security(struct inode *inode)
964{ 965{
@@ -1164,7 +1165,7 @@ static int smack_inode_rename(struct inode *old_inode,
1164 * 1165 *
1165 * This is the important Smack hook. 1166 * This is the important Smack hook.
1166 * 1167 *
1167 * Returns 0 if access is permitted, -EACCES otherwise 1168 * Returns 0 if access is permitted, an error code otherwise
1168 */ 1169 */
1169static int smack_inode_permission(struct inode *inode, int mask) 1170static int smack_inode_permission(struct inode *inode, int mask)
1170{ 1171{
@@ -1222,8 +1223,7 @@ static int smack_inode_setattr(struct dentry *dentry, struct iattr *iattr)
1222 1223
1223/** 1224/**
1224 * smack_inode_getattr - Smack check for getting attributes 1225 * smack_inode_getattr - Smack check for getting attributes
1225 * @mnt: vfsmount of the object 1226 * @path: path to extract the info from
1226 * @dentry: the object
1227 * 1227 *
1228 * Returns 0 if access is permitted, an error code otherwise 1228 * Returns 0 if access is permitted, an error code otherwise
1229 */ 1229 */
@@ -1870,14 +1870,13 @@ static int smack_file_receive(struct file *file)
1870/** 1870/**
1871 * smack_file_open - Smack dentry open processing 1871 * smack_file_open - Smack dentry open processing
1872 * @file: the object 1872 * @file: the object
1873 * @cred: task credential
1874 * 1873 *
1875 * Set the security blob in the file structure. 1874 * Set the security blob in the file structure.
1876 * Allow the open only if the task has read access. There are 1875 * Allow the open only if the task has read access. There are
1877 * many read operations (e.g. fstat) that you can do with an 1876 * many read operations (e.g. fstat) that you can do with an
1878 * fd even if you have the file open write-only. 1877 * fd even if you have the file open write-only.
1879 * 1878 *
1880 * Returns 0 1879 * Returns 0 if current has access, error code otherwise
1881 */ 1880 */
1882static int smack_file_open(struct file *file) 1881static int smack_file_open(struct file *file)
1883{ 1882{
@@ -1900,7 +1899,7 @@ static int smack_file_open(struct file *file)
1900 1899
1901/** 1900/**
1902 * smack_cred_alloc_blank - "allocate" blank task-level security credentials 1901 * smack_cred_alloc_blank - "allocate" blank task-level security credentials
1903 * @new: the new credentials 1902 * @cred: the new credentials
1904 * @gfp: the atomicity of any memory allocations 1903 * @gfp: the atomicity of any memory allocations
1905 * 1904 *
1906 * Prepare a blank set of credentials for modification. This must allocate all 1905 * Prepare a blank set of credentials for modification. This must allocate all
@@ -1983,7 +1982,7 @@ static void smack_cred_transfer(struct cred *new, const struct cred *old)
1983 1982
1984/** 1983/**
1985 * smack_cred_getsecid - get the secid corresponding to a creds structure 1984 * smack_cred_getsecid - get the secid corresponding to a creds structure
1986 * @c: the object creds 1985 * @cred: the object creds
1987 * @secid: where to put the result 1986 * @secid: where to put the result
1988 * 1987 *
1989 * Sets the secid to contain a u32 version of the smack label. 1988 * Sets the secid to contain a u32 version of the smack label.
@@ -2140,8 +2139,6 @@ static int smack_task_getioprio(struct task_struct *p)
2140/** 2139/**
2141 * smack_task_setscheduler - Smack check on setting scheduler 2140 * smack_task_setscheduler - Smack check on setting scheduler
2142 * @p: the task object 2141 * @p: the task object
2143 * @policy: unused
2144 * @lp: unused
2145 * 2142 *
2146 * Return 0 if read access is permitted 2143 * Return 0 if read access is permitted
2147 */ 2144 */
@@ -2611,8 +2608,9 @@ static void smk_ipv6_port_label(struct socket *sock, struct sockaddr *address)
2611 2608
2612/** 2609/**
2613 * smk_ipv6_port_check - check Smack port access 2610 * smk_ipv6_port_check - check Smack port access
2614 * @sock: socket 2611 * @sk: socket
2615 * @address: address 2612 * @address: address
2613 * @act: the action being taken
2616 * 2614 *
2617 * Create or update the port list entry 2615 * Create or update the port list entry
2618 */ 2616 */
@@ -2782,7 +2780,7 @@ static int smack_socket_post_create(struct socket *sock, int family,
2782 * 2780 *
2783 * Cross reference the peer labels for SO_PEERSEC 2781 * Cross reference the peer labels for SO_PEERSEC
2784 * 2782 *
2785 * Returns 0 on success, and error code otherwise 2783 * Returns 0
2786 */ 2784 */
2787static int smack_socket_socketpair(struct socket *socka, 2785static int smack_socket_socketpair(struct socket *socka,
2788 struct socket *sockb) 2786 struct socket *sockb)
@@ -3014,13 +3012,13 @@ static int smack_shm_shmctl(struct kern_ipc_perm *isp, int cmd)
3014 * 3012 *
3015 * Returns 0 if current has the requested access, error code otherwise 3013 * Returns 0 if current has the requested access, error code otherwise
3016 */ 3014 */
3017static int smack_shm_shmat(struct kern_ipc_perm *ipc, char __user *shmaddr, 3015static int smack_shm_shmat(struct kern_ipc_perm *isp, char __user *shmaddr,
3018 int shmflg) 3016 int shmflg)
3019{ 3017{
3020 int may; 3018 int may;
3021 3019
3022 may = smack_flags_to_may(shmflg); 3020 may = smack_flags_to_may(shmflg);
3023 return smk_curacc_shm(ipc, may); 3021 return smk_curacc_shm(isp, may);
3024} 3022}
3025 3023
3026/** 3024/**
@@ -3925,6 +3923,8 @@ access_check:
3925 skp = smack_ipv6host_label(&sadd); 3923 skp = smack_ipv6host_label(&sadd);
3926 if (skp == NULL) 3924 if (skp == NULL)
3927 skp = smack_net_ambient; 3925 skp = smack_net_ambient;
3926 if (skb == NULL)
3927 break;
3928#ifdef CONFIG_AUDIT 3928#ifdef CONFIG_AUDIT
3929 smk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net); 3929 smk_ad_init_net(&ad, __func__, LSM_AUDIT_DATA_NET, &net);
3930 ad.a.u.net->family = family; 3930 ad.a.u.net->family = family;
@@ -4762,7 +4762,7 @@ static __init void init_smack_known_list(void)
4762/** 4762/**
4763 * smack_init - initialize the smack system 4763 * smack_init - initialize the smack system
4764 * 4764 *
4765 * Returns 0 4765 * Returns 0 on success, -ENOMEM is there's no memory
4766 */ 4766 */
4767static __init int smack_init(void) 4767static __init int smack_init(void)
4768{ 4768{