* [patch] selinux: restore optimization to selinux_file_permission
@ 2009-06-22 18:54 Stephen Smalley
2009-06-22 19:34 ` Paul Moore
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stephen Smalley @ 2009-06-22 18:54 UTC (permalink / raw)
To: James Morris, Eric Paris, Paul Moore; +Cc: selinux
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.
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
---
security/selinux/hooks.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 15c2a08..d6f6478 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -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);
}
--
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 majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [patch] selinux: restore optimization to selinux_file_permission
2009-06-22 18:54 [patch] selinux: restore optimization to selinux_file_permission Stephen Smalley
@ 2009-06-22 19:34 ` Paul Moore
2009-06-22 19:43 ` Eric Paris
2009-06-22 22:23 ` James Morris
2 siblings, 0 replies; 4+ messages in thread
From: Paul Moore @ 2009-06-22 19:34 UTC (permalink / raw)
To: Stephen Smalley; +Cc: James Morris, Eric Paris, selinux
On Monday 22 June 2009 02:54:53 pm Stephen Smalley wrote:
> 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.
>
> Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Sorry, my mistake - thanks for fixing this.
Reviewed-by: Paul Moore <paul.moore@hp.com>
> ---
>
> security/selinux/hooks.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 15c2a08..d6f6478 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -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);
> }
--
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 majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch] selinux: restore optimization to selinux_file_permission
2009-06-22 18:54 [patch] selinux: restore optimization to selinux_file_permission Stephen Smalley
2009-06-22 19:34 ` Paul Moore
@ 2009-06-22 19:43 ` Eric Paris
2009-06-22 22:23 ` James Morris
2 siblings, 0 replies; 4+ messages in thread
From: Eric Paris @ 2009-06-22 19:43 UTC (permalink / raw)
To: Stephen Smalley; +Cc: James Morris, Eric Paris, Paul Moore, selinux
On Mon, 2009-06-22 at 14:54 -0400, Stephen Smalley wrote:
> 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.
>
> Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Acked-by: Eric Paris <eparis@redhat.com>
>
> ---
>
> security/selinux/hooks.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 15c2a08..d6f6478 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -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);
> }
>
>
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch] selinux: restore optimization to selinux_file_permission
2009-06-22 18:54 [patch] selinux: restore optimization to selinux_file_permission Stephen Smalley
2009-06-22 19:34 ` Paul Moore
2009-06-22 19:43 ` Eric Paris
@ 2009-06-22 22:23 ` James Morris
2 siblings, 0 replies; 4+ messages in thread
From: James Morris @ 2009-06-22 22:23 UTC (permalink / raw)
To: Stephen Smalley; +Cc: Eric Paris, Paul Moore, selinux
On Mon, 22 Jun 2009, Stephen Smalley wrote:
> 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.
>
> Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next
--
James Morris
<jmorris@namei.org>
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-06-22 22:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-22 18:54 [patch] selinux: restore optimization to selinux_file_permission Stephen Smalley
2009-06-22 19:34 ` Paul Moore
2009-06-22 19:43 ` Eric Paris
2009-06-22 22:23 ` James Morris
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.