selinux: restore optimization to selinux_file_permission
PATCH 1/1 selinux: restore optimization to selinux_file_permission
Restore the optimization to skip revalidation in selinux_file_permission if nothing has changed since the dentry_open checks, accidentally removed by 389fb800. Also remove redundant test from selinux_revalidate_file_permission.
---
security/selinux/hooks.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
security/selinux/hooks.c +10 -5
@@ -2938,11 +2938,6 @@ static int selinux_revalidate_file_permission(struct file *file, int mask)const struct cred *cred =current_cred ();struct inode *inode = file->f_path.dentry->d_inode; -if (!mask) { -/* No permission to check. Existence test. */ -return 0 ; - } -/* file_mask_to_av won't add FILE__WRITE if MAY_APPEND is set */ if ((file->f_flags &O_APPEND ) && (mask &MAY_WRITE )) mask |=MAY_APPEND ;
@@ -2953,10 +2948,20 @@ static int selinux_revalidate_file_permission(struct file *file, int mask)static int selinux_file_permission (struct file *file,int mask) { +struct inode *inode = file->f_path.dentry->d_inode; +struct file_security_struct *fsec = file->f_security; +struct inode_security_struct *isec = inode->i_security; +u32 sid =current_sid (); +if (!mask)/* No permission to check. Existence test. */ return 0 ; +if (sid == fsec->sid && fsec->isid == isec->sid && + fsec->pseqno ==avc_policy_seqno ()) +/* No change since dentry_open check. */ +return 0 ; +return selinux_revalidate_file_permission (file, mask); }
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 6 lines · Stephen Smalley
Restore the optimization to skip revalidation in
selinux_file_permissionif nothing has changed since thedentry_openchecks, accidentally removed by389fb800. Also remove redundant test fromselinux_revalidate_file_permission.Signed-off-by Stephen Smalley <[email protected]>
Sorry, my mistake - thanks for fixing this.
Quoted 42 lines
---
security/selinux/hooks.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)security/selinux/hooks.c +10
-5@@ -2938,11 +2938,6 @@ static int selinux_revalidate_file_permission(struct file *file, int mask) const struct cred *cred = current_cred();struct inode *inode = file->f_path.dentry->d_inode; -if (!mask) { -/* No permission to check. Existence test. */ -return 0 ; - } -/* file_mask_to_av won't add FILE__WRITE if MAY_APPEND is set */ if ((file->f_flags &O_APPEND ) && (mask &MAY_WRITE )) mask |=MAY_APPEND ;@@ -2953,10 +2948,20 @@ static int selinux_revalidate_file_permission(struct file *file, int mask)static int selinux_file_permission (struct file *file,int mask) { +struct inode *inode = file->f_path.dentry->d_inode; +struct file_security_struct *fsec = file->f_security; +struct inode_security_struct *isec = inode->i_security; +u32 sid =current_sid (); +if (!mask)/* No permission to check. Existence test. */ return 0 ; +if (sid == fsec->sid && fsec->isid == isec->sid && + fsec->pseqno ==avc_policy_seqno ()) +/* No change since dentry_open check. */ +return 0 ; +return selinux_revalidate_file_permission (file, mask); }
Signature · 8 lines
paul moore linux @ hp -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 5 lines · Stephen Smalley
Restore the optimization to skip revalidation in
selinux_file_permissionif nothing has changed since thedentry_openchecks, accidentally removed by389fb800. Also remove redundant test fromselinux_revalidate_file_permission.Signed-off-by Stephen Smalley <[email protected]>
Quoted 34 lines
---
security/selinux/hooks.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)security/selinux/hooks.c +5
-5@@ -2938,11 +2938,6 @@ static int selinux_revalidate_file_permission(struct file *file, int mask)const struct cred *cred =current_cred ();struct inode *inode = file->f_path.dentry->d_inode; -if (!mask) { -/* No permission to check. Existence test. */ -return 0 ; - } -/* file_mask_to_av won't add FILE__WRITE if MAY_APPEND is set */ if ((file->f_flags &O_APPEND ) && (mask &MAY_WRITE )) mask |=MAY_APPEND ;@@ -2953,10 +2948,20 @@ static int selinux_revalidate_file_permission(struct file *file, int mask)static int selinux_file_permission (struct file *file,int mask) { +struct inode *inode = file->f_path.dentry->d_inode; +struct file_security_struct *fsec = file->f_security; +struct inode_security_struct *isec = inode->i_security; +u32 sid =current_sid (); +if (!mask)/* No permission to check. Existence test. */
security/selinux/hooks.c static int selinux_revalidate_file_permission(struct file *file, int mask) · line 2967
Quoted 10 lines
security/selinux/hooks.c +5
-0return 0 ; +if (sid == fsec->sid && fsec->isid == isec->sid && + fsec->pseqno ==avc_policy_seqno ()) +/* No change since dentry_open check. */ +return 0 ; +return selinux_revalidate_file_permission (file, mask); }
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 5 lines · Stephen Smalley
Restore the optimization to skip revalidation in
selinux_file_permissionif nothing has changed since thedentry_openchecks, accidentally removed by389fb800. Also remove redundant test fromselinux_revalidate_file_permission.Signed-off-by Stephen Smalley <[email protected]>
Applied togit://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next
Signature · 7 lines
James Morris <[email protected]> -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.