mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] vfs: fix audit_inode call in O_CREAT case of do_last
@ 2013-04-12 19:16 Jeff Layton
  2013-04-12 21:39 ` Jeff Layton
  2013-04-17  3:02 ` Richard Guy Briggs
  0 siblings, 2 replies; 3+ messages in thread
From: Jeff Layton @ 2013-04-12 19:16 UTC (permalink / raw)
  To: viro; +Cc: rbriggs, jjaburek, linux-fsdevel, linux-audit, linux-kernel

Jiri reported a regression in auditing of open(..., O_CREAT) syscalls.
In older kernels, creating a file with open(..., O_CREAT) created
audit_name records that looked like this:

type=PATH msg=audit(1360255720.628:64): item=1 name="/abc/foo" inode=138810 dev=fd:00 mode=0100640 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
type=PATH msg=audit(1360255720.628:64): item=0 name="/abc/" inode=138635 dev=fd:00 mode=040750 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0

...in recent kernels though, they look like this:

type=PATH msg=audit(1360255402.886:12574): item=2 name=(null) inode=264599 dev=fd:00 mode=0100640 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
type=PATH msg=audit(1360255402.886:12574): item=1 name=(null) inode=264598 dev=fd:00 mode=040750 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
type=PATH msg=audit(1360255402.886:12574): item=0 name="/abc/foo" inode=264598 dev=fd:00 mode=040750 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0

Richard bisected to determine that the problems started with commit
bfcec708, but the log messages have changed with some later
audit-related patches.

The problem is that this audit_inode call is passing in the parent of
the dentry being opened, but audit_inode is being called with the parent
flag false. This causes later audit_inode and audit_inode_child calls to
match the wrong entry in the audit_names list.

This patch simply sets the flag to properly indicate that this inode
represents the parent. With this, the audit_names entries are back to
looking like they did before.

Cc: <stable@vger.kernel.org> # v3.7+
Cc: Richard Guy Briggs <rbriggs@redhat.com>
Reported-by: Jiri Jaburek <jjaburek@redhat.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 fs/namei.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 57ae9c8..85e40d1 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2740,7 +2740,7 @@ static int do_last(struct nameidata *nd, struct path *path,
 		if (error)
 			return error;
 
-		audit_inode(name, dir, 0);
+		audit_inode(name, dir, LOOKUP_PARENT);
 		error = -EISDIR;
 		/* trailing slashes? */
 		if (nd->last.name[nd->last.len])
-- 
1.7.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vfs: fix audit_inode call in O_CREAT case of do_last
  2013-04-12 19:16 [PATCH] vfs: fix audit_inode call in O_CREAT case of do_last Jeff Layton
@ 2013-04-12 21:39 ` Jeff Layton
  2013-04-17  3:02 ` Richard Guy Briggs
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Layton @ 2013-04-12 21:39 UTC (permalink / raw)
  To: viro; +Cc: rbriggs, jjaburek, linux-fsdevel, linux-audit, linux-kernel

On Fri, 12 Apr 2013 15:16:32 -0400
Jeff Layton <jlayton@redhat.com> wrote:

> Jiri reported a regression in auditing of open(..., O_CREAT) syscalls.
> In older kernels, creating a file with open(..., O_CREAT) created
> audit_name records that looked like this:
> 
> type=PATH msg=audit(1360255720.628:64): item=1 name="/abc/foo" inode=138810 dev=fd:00 mode=0100640 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
> type=PATH msg=audit(1360255720.628:64): item=0 name="/abc/" inode=138635 dev=fd:00 mode=040750 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
> 
> ...in recent kernels though, they look like this:
> 
> type=PATH msg=audit(1360255402.886:12574): item=2 name=(null) inode=264599 dev=fd:00 mode=0100640 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
> type=PATH msg=audit(1360255402.886:12574): item=1 name=(null) inode=264598 dev=fd:00 mode=040750 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
> type=PATH msg=audit(1360255402.886:12574): item=0 name="/abc/foo" inode=264598 dev=fd:00 mode=040750 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
> 
> Richard bisected to determine that the problems started with commit
> bfcec708, but the log messages have changed with some later
> audit-related patches.
> 
> The problem is that this audit_inode call is passing in the parent of
> the dentry being opened, but audit_inode is being called with the parent
> flag false. This causes later audit_inode and audit_inode_child calls to
> match the wrong entry in the audit_names list.
> 
> This patch simply sets the flag to properly indicate that this inode
> represents the parent. With this, the audit_names entries are back to
> looking like they did before.
> 
> Cc: <stable@vger.kernel.org> # v3.7+
> Cc: Richard Guy Briggs <rbriggs@redhat.com>
> Reported-by: Jiri Jaburek <jjaburek@redhat.com>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
>  fs/namei.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/namei.c b/fs/namei.c
> index 57ae9c8..85e40d1 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -2740,7 +2740,7 @@ static int do_last(struct nameidata *nd, struct path *path,
>  		if (error)
>  			return error;
>  
> -		audit_inode(name, dir, 0);
> +		audit_inode(name, dir, LOOKUP_PARENT);
>  		error = -EISDIR;
>  		/* trailing slashes? */
>  		if (nd->last.name[nd->last.len])

BTW, there are a couple of other calls to audit_inode earlier in this
function (the LAST_BIND and LAST_ROOT cases). I suspect those also need
similar treatment, but I've left them alone for now since I didn't have
a clear way to verify it. Let me know if you'd like me to respin this
with those changed as well.

Thanks,
-- 
Jeff Layton <jlayton@redhat.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] vfs: fix audit_inode call in O_CREAT case of do_last
  2013-04-12 19:16 [PATCH] vfs: fix audit_inode call in O_CREAT case of do_last Jeff Layton
  2013-04-12 21:39 ` Jeff Layton
@ 2013-04-17  3:02 ` Richard Guy Briggs
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Guy Briggs @ 2013-04-17  3:02 UTC (permalink / raw)
  To: Jeff Layton; +Cc: viro, linux-fsdevel, jjaburek, linux-audit, linux-kernel

On Fri, Apr 12, 2013 at 03:16:32PM -0400, Jeff Layton wrote:
> Jiri reported a regression in auditing of open(..., O_CREAT) syscalls.
> In older kernels, creating a file with open(..., O_CREAT) created
> audit_name records that looked like this:
> 
> type=PATH msg=audit(1360255720.628:64): item=1 name="/abc/foo" inode=138810 dev=fd:00 mode=0100640 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
> type=PATH msg=audit(1360255720.628:64): item=0 name="/abc/" inode=138635 dev=fd:00 mode=040750 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
> 
> ...in recent kernels though, they look like this:
> 
> type=PATH msg=audit(1360255402.886:12574): item=2 name=(null) inode=264599 dev=fd:00 mode=0100640 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
> type=PATH msg=audit(1360255402.886:12574): item=1 name=(null) inode=264598 dev=fd:00 mode=040750 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
> type=PATH msg=audit(1360255402.886:12574): item=0 name="/abc/foo" inode=264598 dev=fd:00 mode=040750 ouid=0 ogid=0 rdev=00:00 obj=unconfined_u:object_r:default_t:s0
> 
> Richard bisected to determine that the problems started with commit
> bfcec708, but the log messages have changed with some later
> audit-related patches.
> 
> The problem is that this audit_inode call is passing in the parent of
> the dentry being opened, but audit_inode is being called with the parent
> flag false. This causes later audit_inode and audit_inode_child calls to
> match the wrong entry in the audit_names list.
> 
> This patch simply sets the flag to properly indicate that this inode
> represents the parent. With this, the audit_names entries are back to
> looking like they did before.

This patch fixes the problem for me.

Tested-by: Richard Guy Briggs <rbriggs@redhat.com>

> Cc: <stable@vger.kernel.org> # v3.7+
> Cc: Richard Guy Briggs <rbriggs@redhat.com>
> Reported-by: Jiri Jaburek <jjaburek@redhat.com>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
>  fs/namei.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/namei.c b/fs/namei.c
> index 57ae9c8..85e40d1 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -2740,7 +2740,7 @@ static int do_last(struct nameidata *nd, struct path *path,
>  		if (error)
>  			return error;
>  
> -		audit_inode(name, dir, 0);
> +		audit_inode(name, dir, LOOKUP_PARENT);
>  		error = -EISDIR;
>  		/* trailing slashes? */
>  		if (nd->last.name[nd->last.len])
> -- 
> 1.7.1
> 
> --
> Linux-audit mailing list
> Linux-audit@redhat.com
> https://www.redhat.com/mailman/listinfo/linux-audit

- RGB

--
Richard Guy Briggs <rbriggs@redhat.com>
Senior Software Engineer
AMER ENG Base Operating Systems
Remote, Canada, Ottawa
Voice: 1.647.777.2635
Internal: (81) 32635

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-17  3:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-12 19:16 [PATCH] vfs: fix audit_inode call in O_CREAT case of do_last Jeff Layton
2013-04-12 21:39 ` Jeff Layton
2013-04-17  3:02 ` Richard Guy Briggs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®