From: Yang Guo Date: Thu, 12 Dec 2019 02:02:24 +0000 (+0800) Subject: selinux: remove unnecessary selinux cred request X-Git-Tag: v5.10.7~3231^2~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=210a292874517782bed2e2220c7beb1608d3b05d;p=platform%2Fkernel%2Flinux-rpi.git selinux: remove unnecessary selinux cred request task_security_struct was obtained at the beginning of may_create and selinux_inode_init_security, no need to obtain again. may_create will be called very frequently when create dir and file. Cc: Paul Moore Cc: Stephen Smalley Cc: Eric Paris Signed-off-by: Yang Guo Signed-off-by: Shaokun Zhang Signed-off-by: Paul Moore --- diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 4762634..40ec866 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1833,8 +1833,8 @@ static int may_create(struct inode *dir, if (rc) return rc; - rc = selinux_determine_inode_label(selinux_cred(current_cred()), dir, - &dentry->d_name, tclass, &newsid); + rc = selinux_determine_inode_label(tsec, dir, &dentry->d_name, tclass, + &newsid); if (rc) return rc; @@ -2906,8 +2906,7 @@ static int selinux_inode_init_security(struct inode *inode, struct inode *dir, newsid = tsec->create_sid; - rc = selinux_determine_inode_label(selinux_cred(current_cred()), - dir, qstr, + rc = selinux_determine_inode_label(tsec, dir, qstr, inode_mode_to_security_class(inode->i_mode), &newsid); if (rc)