Re: [[PATCH V4]] audit: trigger accompanying records when no rules present

2020-09-22 Thread Richard Guy Briggs
On 2020-09-21 19:31, Paul Moore wrote:
> On Mon, Sep 21, 2020 at 3:57 PM Richard Guy Briggs  wrote:
> > On 2020-09-15 12:18, Paul Moore wrote:
> > > On Thu, Sep 10, 2020 at 11:03 AM Richard Guy Briggs  
> > > wrote:
> > > >
> > > > When there are no audit rules registered, mandatory records (config,
> > > > etc.) are missing their accompanying records (syscall, proctitle, etc.).
> > > >
> > > > This is due to audit context dummy set on syscall entry based on absence
> > > > of rules that signals that no other records are to be printed.
> > > >
> > > > Clear the dummy bit if any record is generated.
> > > >
> > > > The proctitle context and dummy checks are pointless since the
> > > > proctitle record will not be printed if no syscall records are printed.
> > > >
> > > > The fds array is reset to -1 after the first syscall to indicate it
> > > > isn't valid any more, but was never set to -1 when the context was
> > > > allocated to indicate it wasn't yet valid.
> > > >
> > > > The audit_inode* functions can be called without going through
> > > > getname_flags() or getname_kernel() that sets audit_names and cwd, so
> > > > set the cwd if it has not already been done so due to audit_names being
> > > > valid.
> > > >
> > > > The LSM dump_common_audit_data() LSM_AUDIT_DATA_NET:AF_UNIX case was
> > > > missed with the ghak96 patch, so add that case here.
> > > >
> > > > Thanks to bauen1  for reporting LSM situations in
> > > > which context->cwd is not valid, inadvertantly fixed by the ghak96 
> > > > patch.
> > > >
> > > > Please see upstream github issue
> > > > https://github.com/linux-audit/audit-kernel/issues/120
> > > > This is also related to upstream github issue
> > > > https://github.com/linux-audit/audit-kernel/issues/96
> > > >
> > > > Signed-off-by: Richard Guy Briggs 
> > > > ---
> > > > Passes audit-testsuite.
> > > >
> > > > Chagelog:
> > > > v4:
> > > > - rebase on audit/next v5.9-rc1
> > > > - squash v2+v3fix
> > > > - add pwd NULL check in audit_log_name()
> > > > - resubmit after revert
> > > >
> > > > v3:
> > > > - initialize fds[0] to -1
> > > > - init cwd for ghak96 LSM_AUDIT_DATA_NET:AF_UNIX case
> > > > - init cwd for audit_inode{,_child}
> > > >
> > > > v2:
> > > > - unconditionally clear dummy
> > > > - create audit_clear_dummy accessor function
> > > > - remove proctitle context and dummy checks
> > > >
> > > >  kernel/audit.c   |  1 +
> > > >  kernel/audit.h   |  8 
> > > >  kernel/auditsc.c | 11 +++
> > > >  security/lsm_audit.c |  1 +
> > > >  4 files changed, 17 insertions(+), 4 deletions(-)
> > >
> > > Comments below, but can you elaborate on if any testing was done
> > > beyond the audit-testsuite?
> >
> > Yes, it was tested with audit-testsuite and bauen1's reproducer
> >
> > > > diff --git a/kernel/audit.h b/kernel/audit.h
> > > > index 3b9c0945225a..abcfef58435b 100644
> > > > --- a/kernel/audit.h
> > > > +++ b/kernel/audit.h
> > > > @@ -290,6 +290,13 @@ extern int audit_signal_info_syscall(struct 
> > > > task_struct *t);
> > > >  extern void audit_filter_inodes(struct task_struct *tsk,
> > > > struct audit_context *ctx);
> > > >  extern struct list_head *audit_killed_trees(void);
> > > > +
> > > > +static inline void audit_clear_dummy(struct audit_context *ctx)
> > > > +{
> > > > +   if (ctx)
> > > > +   ctx->dummy = 0;
> > > > +}
> > >
> > > With the only caller being audit_log_start(), should this be moved to
> > > kernel/audit.c?  I'm just not sure this is something we would ever
> > > need (or want) to call from elsewhere, thoughts?
> >
> > Yes, move it, or better yet just open code it.
> 
> Sure.  It might also help to put a one-liner comment in there about why.

No problem.

> > > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > > > index 8dba8f0983b5..9d2de93f40b3 100644
> > > > --- a/kernel/auditsc.c
> > > > +++ b/kernel/auditsc.c
> > > > @@ -1367,7 +1368,10 @@ static void audit_log_name(struct audit_context 
> > > > *context, struct audit_names *n,
> > > > /* name was specified as a relative path and the
> > > >  * directory component is the cwd
> > > >  */
> > > > -   audit_log_d_path(ab, " name=", >pwd);
> > > > +   if (>pwd)
> > >
> > > Hmm, I don't think this is going to work the way you are intending; I
> > > believe this will always evaluate to true regardless of the state of
> > > context->pwd.  If you look elsewhere in kernel/auditsc.c you will see
> > > some examples of checking to see if context->pwd is valid (e.g.
> > > _audit_getcwd() and audit_log_exit()).
> >
> > Sorry for the ctx->pwd.dentry/mnt brainfart, the compiler *did*
> > complain.
> 
> That begs the question: why did you submit the patch?  I don't want to
> dwell too much on this, but compilers are pretty smart these days,
> it's best not to ignore their warnings unless you are *really* sure
> you 

Re: [[PATCH V4]] audit: trigger accompanying records when no rules present

2020-09-21 Thread Paul Moore
On Mon, Sep 21, 2020 at 3:57 PM Richard Guy Briggs  wrote:
> On 2020-09-15 12:18, Paul Moore wrote:
> > On Thu, Sep 10, 2020 at 11:03 AM Richard Guy Briggs  wrote:
> > >
> > > When there are no audit rules registered, mandatory records (config,
> > > etc.) are missing their accompanying records (syscall, proctitle, etc.).
> > >
> > > This is due to audit context dummy set on syscall entry based on absence
> > > of rules that signals that no other records are to be printed.
> > >
> > > Clear the dummy bit if any record is generated.
> > >
> > > The proctitle context and dummy checks are pointless since the
> > > proctitle record will not be printed if no syscall records are printed.
> > >
> > > The fds array is reset to -1 after the first syscall to indicate it
> > > isn't valid any more, but was never set to -1 when the context was
> > > allocated to indicate it wasn't yet valid.
> > >
> > > The audit_inode* functions can be called without going through
> > > getname_flags() or getname_kernel() that sets audit_names and cwd, so
> > > set the cwd if it has not already been done so due to audit_names being
> > > valid.
> > >
> > > The LSM dump_common_audit_data() LSM_AUDIT_DATA_NET:AF_UNIX case was
> > > missed with the ghak96 patch, so add that case here.
> > >
> > > Thanks to bauen1  for reporting LSM situations in
> > > which context->cwd is not valid, inadvertantly fixed by the ghak96 patch.
> > >
> > > Please see upstream github issue
> > > https://github.com/linux-audit/audit-kernel/issues/120
> > > This is also related to upstream github issue
> > > https://github.com/linux-audit/audit-kernel/issues/96
> > >
> > > Signed-off-by: Richard Guy Briggs 
> > > ---
> > > Passes audit-testsuite.
> > >
> > > Chagelog:
> > > v4:
> > > - rebase on audit/next v5.9-rc1
> > > - squash v2+v3fix
> > > - add pwd NULL check in audit_log_name()
> > > - resubmit after revert
> > >
> > > v3:
> > > - initialize fds[0] to -1
> > > - init cwd for ghak96 LSM_AUDIT_DATA_NET:AF_UNIX case
> > > - init cwd for audit_inode{,_child}
> > >
> > > v2:
> > > - unconditionally clear dummy
> > > - create audit_clear_dummy accessor function
> > > - remove proctitle context and dummy checks
> > >
> > >  kernel/audit.c   |  1 +
> > >  kernel/audit.h   |  8 
> > >  kernel/auditsc.c | 11 +++
> > >  security/lsm_audit.c |  1 +
> > >  4 files changed, 17 insertions(+), 4 deletions(-)
> >
> > Comments below, but can you elaborate on if any testing was done
> > beyond the audit-testsuite?
>
> Yes, it was tested with audit-testsuite and bauen1's reproducer
>
> > > diff --git a/kernel/audit.h b/kernel/audit.h
> > > index 3b9c0945225a..abcfef58435b 100644
> > > --- a/kernel/audit.h
> > > +++ b/kernel/audit.h
> > > @@ -290,6 +290,13 @@ extern int audit_signal_info_syscall(struct 
> > > task_struct *t);
> > >  extern void audit_filter_inodes(struct task_struct *tsk,
> > > struct audit_context *ctx);
> > >  extern struct list_head *audit_killed_trees(void);
> > > +
> > > +static inline void audit_clear_dummy(struct audit_context *ctx)
> > > +{
> > > +   if (ctx)
> > > +   ctx->dummy = 0;
> > > +}
> >
> > With the only caller being audit_log_start(), should this be moved to
> > kernel/audit.c?  I'm just not sure this is something we would ever
> > need (or want) to call from elsewhere, thoughts?
>
> Yes, move it, or better yet just open code it.

Sure.  It might also help to put a one-liner comment in there about why.

> > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > > index 8dba8f0983b5..9d2de93f40b3 100644
> > > --- a/kernel/auditsc.c
> > > +++ b/kernel/auditsc.c
> > > @@ -1367,7 +1368,10 @@ static void audit_log_name(struct audit_context 
> > > *context, struct audit_names *n,
> > > /* name was specified as a relative path and the
> > >  * directory component is the cwd
> > >  */
> > > -   audit_log_d_path(ab, " name=", >pwd);
> > > +   if (>pwd)
> >
> > Hmm, I don't think this is going to work the way you are intending; I
> > believe this will always evaluate to true regardless of the state of
> > context->pwd.  If you look elsewhere in kernel/auditsc.c you will see
> > some examples of checking to see if context->pwd is valid (e.g.
> > _audit_getcwd() and audit_log_exit()).
>
> Sorry for the ctx->pwd.dentry/mnt brainfart, the compiler *did*
> complain.

That begs the question: why did you submit the patch?  I don't want to
dwell too much on this, but compilers are pretty smart these days,
it's best not to ignore their warnings unless you are *really* sure
you are right.

> > > +   audit_log_d_path(ab, " name=", 
> > > >pwd);
> > > +   else
> > > +   audit_log_format(ab, " name=(null)");
> > > break;
> > > default:
> > > 

Re: [[PATCH V4]] audit: trigger accompanying records when no rules present

2020-09-21 Thread Richard Guy Briggs
On 2020-09-15 12:18, Paul Moore wrote:
> On Thu, Sep 10, 2020 at 11:03 AM Richard Guy Briggs  wrote:
> >
> > When there are no audit rules registered, mandatory records (config,
> > etc.) are missing their accompanying records (syscall, proctitle, etc.).
> >
> > This is due to audit context dummy set on syscall entry based on absence
> > of rules that signals that no other records are to be printed.
> >
> > Clear the dummy bit if any record is generated.
> >
> > The proctitle context and dummy checks are pointless since the
> > proctitle record will not be printed if no syscall records are printed.
> >
> > The fds array is reset to -1 after the first syscall to indicate it
> > isn't valid any more, but was never set to -1 when the context was
> > allocated to indicate it wasn't yet valid.
> >
> > The audit_inode* functions can be called without going through
> > getname_flags() or getname_kernel() that sets audit_names and cwd, so
> > set the cwd if it has not already been done so due to audit_names being
> > valid.
> >
> > The LSM dump_common_audit_data() LSM_AUDIT_DATA_NET:AF_UNIX case was
> > missed with the ghak96 patch, so add that case here.
> >
> > Thanks to bauen1  for reporting LSM situations in
> > which context->cwd is not valid, inadvertantly fixed by the ghak96 patch.
> >
> > Please see upstream github issue
> > https://github.com/linux-audit/audit-kernel/issues/120
> > This is also related to upstream github issue
> > https://github.com/linux-audit/audit-kernel/issues/96
> >
> > Signed-off-by: Richard Guy Briggs 
> > ---
> > Passes audit-testsuite.
> >
> > Chagelog:
> > v4:
> > - rebase on audit/next v5.9-rc1
> > - squash v2+v3fix
> > - add pwd NULL check in audit_log_name()
> > - resubmit after revert
> >
> > v3:
> > - initialize fds[0] to -1
> > - init cwd for ghak96 LSM_AUDIT_DATA_NET:AF_UNIX case
> > - init cwd for audit_inode{,_child}
> >
> > v2:
> > - unconditionally clear dummy
> > - create audit_clear_dummy accessor function
> > - remove proctitle context and dummy checks
> >
> >  kernel/audit.c   |  1 +
> >  kernel/audit.h   |  8 
> >  kernel/auditsc.c | 11 +++
> >  security/lsm_audit.c |  1 +
> >  4 files changed, 17 insertions(+), 4 deletions(-)
> 
> Comments below, but can you elaborate on if any testing was done
> beyond the audit-testsuite?

Yes, it was tested with audit-testsuite and bauen1's reproducer

> > diff --git a/kernel/audit.h b/kernel/audit.h
> > index 3b9c0945225a..abcfef58435b 100644
> > --- a/kernel/audit.h
> > +++ b/kernel/audit.h
> > @@ -290,6 +290,13 @@ extern int audit_signal_info_syscall(struct 
> > task_struct *t);
> >  extern void audit_filter_inodes(struct task_struct *tsk,
> > struct audit_context *ctx);
> >  extern struct list_head *audit_killed_trees(void);
> > +
> > +static inline void audit_clear_dummy(struct audit_context *ctx)
> > +{
> > +   if (ctx)
> > +   ctx->dummy = 0;
> > +}
> 
> With the only caller being audit_log_start(), should this be moved to
> kernel/audit.c?  I'm just not sure this is something we would ever
> need (or want) to call from elsewhere, thoughts?

Yes, move it, or better yet just open code it.

> > diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> > index 8dba8f0983b5..9d2de93f40b3 100644
> > --- a/kernel/auditsc.c
> > +++ b/kernel/auditsc.c
> > @@ -1367,7 +1368,10 @@ static void audit_log_name(struct audit_context 
> > *context, struct audit_names *n,
> > /* name was specified as a relative path and the
> >  * directory component is the cwd
> >  */
> > -   audit_log_d_path(ab, " name=", >pwd);
> > +   if (>pwd)
> 
> Hmm, I don't think this is going to work the way you are intending; I
> believe this will always evaluate to true regardless of the state of
> context->pwd.  If you look elsewhere in kernel/auditsc.c you will see
> some examples of checking to see if context->pwd is valid (e.g.
> _audit_getcwd() and audit_log_exit()).

Sorry for the ctx->pwd.dentry/mnt brainfart, the compiler *did*
complain.

> > +   audit_log_d_path(ab, " name=", 
> > >pwd);
> > +   else
> > +   audit_log_format(ab, " name=(null)");
> > break;
> > default:
> > /* log the name's directory component */...
> 
> > @@ -2079,6 +2080,7 @@ void __audit_inode(struct filename *name, const 
> > struct dentry *dentry,
> > }
> > handle_path(dentry);
> > audit_copy_inode(n, dentry, inode, flags & AUDIT_INODE_NOEVAL);
> > +   _audit_getcwd(context);
> >  }
> >
> >  void __audit_file(const struct file *file)
> > @@ -2197,6 +2199,7 @@ void __audit_inode_child(struct inode *parent,
> > audit_copy_inode(found_child, dentry, inode, 0);
> > else
> > found_child->ino = 

Re: [[PATCH V4]] audit: trigger accompanying records when no rules present

2020-09-15 Thread Paul Moore
On Thu, Sep 10, 2020 at 11:03 AM Richard Guy Briggs  wrote:
>
> When there are no audit rules registered, mandatory records (config,
> etc.) are missing their accompanying records (syscall, proctitle, etc.).
>
> This is due to audit context dummy set on syscall entry based on absence
> of rules that signals that no other records are to be printed.
>
> Clear the dummy bit if any record is generated.
>
> The proctitle context and dummy checks are pointless since the
> proctitle record will not be printed if no syscall records are printed.
>
> The fds array is reset to -1 after the first syscall to indicate it
> isn't valid any more, but was never set to -1 when the context was
> allocated to indicate it wasn't yet valid.
>
> The audit_inode* functions can be called without going through
> getname_flags() or getname_kernel() that sets audit_names and cwd, so
> set the cwd if it has not already been done so due to audit_names being
> valid.
>
> The LSM dump_common_audit_data() LSM_AUDIT_DATA_NET:AF_UNIX case was
> missed with the ghak96 patch, so add that case here.
>
> Thanks to bauen1  for reporting LSM situations in
> which context->cwd is not valid, inadvertantly fixed by the ghak96 patch.
>
> Please see upstream github issue
> https://github.com/linux-audit/audit-kernel/issues/120
> This is also related to upstream github issue
> https://github.com/linux-audit/audit-kernel/issues/96
>
> Signed-off-by: Richard Guy Briggs 
> ---
> Passes audit-testsuite.
>
> Chagelog:
> v4:
> - rebase on audit/next v5.9-rc1
> - squash v2+v3fix
> - add pwd NULL check in audit_log_name()
> - resubmit after revert
>
> v3:
> - initialize fds[0] to -1
> - init cwd for ghak96 LSM_AUDIT_DATA_NET:AF_UNIX case
> - init cwd for audit_inode{,_child}
>
> v2:
> - unconditionally clear dummy
> - create audit_clear_dummy accessor function
> - remove proctitle context and dummy checks
>
>  kernel/audit.c   |  1 +
>  kernel/audit.h   |  8 
>  kernel/auditsc.c | 11 +++
>  security/lsm_audit.c |  1 +
>  4 files changed, 17 insertions(+), 4 deletions(-)

Comments below, but can you elaborate on if any testing was done
beyond the audit-testsuite?

> diff --git a/kernel/audit.h b/kernel/audit.h
> index 3b9c0945225a..abcfef58435b 100644
> --- a/kernel/audit.h
> +++ b/kernel/audit.h
> @@ -290,6 +290,13 @@ extern int audit_signal_info_syscall(struct task_struct 
> *t);
>  extern void audit_filter_inodes(struct task_struct *tsk,
> struct audit_context *ctx);
>  extern struct list_head *audit_killed_trees(void);
> +
> +static inline void audit_clear_dummy(struct audit_context *ctx)
> +{
> +   if (ctx)
> +   ctx->dummy = 0;
> +}

With the only caller being audit_log_start(), should this be moved to
kernel/audit.c?  I'm just not sure this is something we would ever
need (or want) to call from elsewhere, thoughts?

> diff --git a/kernel/auditsc.c b/kernel/auditsc.c
> index 8dba8f0983b5..9d2de93f40b3 100644
> --- a/kernel/auditsc.c
> +++ b/kernel/auditsc.c
> @@ -1367,7 +1368,10 @@ static void audit_log_name(struct audit_context 
> *context, struct audit_names *n,
> /* name was specified as a relative path and the
>  * directory component is the cwd
>  */
> -   audit_log_d_path(ab, " name=", >pwd);
> +   if (>pwd)

Hmm, I don't think this is going to work the way you are intending; I
believe this will always evaluate to true regardless of the state of
context->pwd.  If you look elsewhere in kernel/auditsc.c you will see
some examples of checking to see if context->pwd is valid (e.g.
_audit_getcwd() and audit_log_exit()).

> +   audit_log_d_path(ab, " name=", >pwd);
> +   else
> +   audit_log_format(ab, " name=(null)");
> break;
> default:
> /* log the name's directory component */...

> @@ -2079,6 +2080,7 @@ void __audit_inode(struct filename *name, const struct 
> dentry *dentry,
> }
> handle_path(dentry);
> audit_copy_inode(n, dentry, inode, flags & AUDIT_INODE_NOEVAL);
> +   _audit_getcwd(context);
>  }
>
>  void __audit_file(const struct file *file)
> @@ -2197,6 +2199,7 @@ void __audit_inode_child(struct inode *parent,
> audit_copy_inode(found_child, dentry, inode, 0);
> else
> found_child->ino = AUDIT_INO_UNSET;
> +   _audit_getcwd(context);
>  }
>  EXPORT_SYMBOL_GPL(__audit_inode_child);
>
> diff --git a/security/lsm_audit.c b/security/lsm_audit.c
> index 53d0d183db8f..e93077612246 100644
> --- a/security/lsm_audit.c
> +++ b/security/lsm_audit.c
> @@ -369,6 +369,7 @@ static void dump_common_audit_data(struct audit_buffer 
> *ab,
> audit_log_untrustedstring(ab, p);
> else
>  

[[PATCH V4]] audit: trigger accompanying records when no rules present

2020-09-10 Thread Richard Guy Briggs
When there are no audit rules registered, mandatory records (config,
etc.) are missing their accompanying records (syscall, proctitle, etc.).

This is due to audit context dummy set on syscall entry based on absence
of rules that signals that no other records are to be printed.

Clear the dummy bit if any record is generated.

The proctitle context and dummy checks are pointless since the
proctitle record will not be printed if no syscall records are printed.

The fds array is reset to -1 after the first syscall to indicate it
isn't valid any more, but was never set to -1 when the context was
allocated to indicate it wasn't yet valid.

The audit_inode* functions can be called without going through
getname_flags() or getname_kernel() that sets audit_names and cwd, so
set the cwd if it has not already been done so due to audit_names being
valid.

The LSM dump_common_audit_data() LSM_AUDIT_DATA_NET:AF_UNIX case was
missed with the ghak96 patch, so add that case here.

Thanks to bauen1  for reporting LSM situations in
which context->cwd is not valid, inadvertantly fixed by the ghak96 patch.

Please see upstream github issue
https://github.com/linux-audit/audit-kernel/issues/120
This is also related to upstream github issue
https://github.com/linux-audit/audit-kernel/issues/96

Signed-off-by: Richard Guy Briggs 
---
Passes audit-testsuite.

Chagelog:
v4:
- rebase on audit/next v5.9-rc1
- squash v2+v3fix
- add pwd NULL check in audit_log_name()
- resubmit after revert

v3:
- initialize fds[0] to -1
- init cwd for ghak96 LSM_AUDIT_DATA_NET:AF_UNIX case
- init cwd for audit_inode{,_child}

v2:
- unconditionally clear dummy
- create audit_clear_dummy accessor function
- remove proctitle context and dummy checks

 kernel/audit.c   |  1 +
 kernel/audit.h   |  8 
 kernel/auditsc.c | 11 +++
 security/lsm_audit.c |  1 +
 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index 68cee3bc8cfe..8604eccb348f 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1865,6 +1865,7 @@ struct audit_buffer *audit_log_start(struct audit_context 
*ctx, gfp_t gfp_mask,
}
 
audit_get_stamp(ab->ctx, , );
+   audit_clear_dummy(ab->ctx);
audit_log_format(ab, "audit(%llu.%03lu:%u): ",
 (unsigned long long)t.tv_sec, t.tv_nsec/100, 
serial);
 
diff --git a/kernel/audit.h b/kernel/audit.h
index 3b9c0945225a..abcfef58435b 100644
--- a/kernel/audit.h
+++ b/kernel/audit.h
@@ -290,6 +290,13 @@ extern int audit_signal_info_syscall(struct task_struct 
*t);
 extern void audit_filter_inodes(struct task_struct *tsk,
struct audit_context *ctx);
 extern struct list_head *audit_killed_trees(void);
+
+static inline void audit_clear_dummy(struct audit_context *ctx)
+{
+   if (ctx)
+   ctx->dummy = 0;
+}
+
 #else /* CONFIG_AUDITSYSCALL */
 #define auditsc_get_stamp(c, t, s) 0
 #define audit_put_watch(w) {}
@@ -323,6 +330,7 @@ static inline int audit_signal_info_syscall(struct 
task_struct *t)
 }
 
 #define audit_filter_inodes(t, c) AUDIT_DISABLED
+#define audit_clear_dummy(c) {}
 #endif /* CONFIG_AUDITSYSCALL */
 
 extern char *audit_unpack_string(void **bufp, size_t *remain, size_t len);
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 8dba8f0983b5..9d2de93f40b3 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -929,6 +929,7 @@ static inline struct audit_context 
*audit_alloc_context(enum audit_state state)
context->prio = state == AUDIT_RECORD_CONTEXT ? ~0ULL : 0;
INIT_LIST_HEAD(>killed_trees);
INIT_LIST_HEAD(>names_list);
+   context->fds[0] = -1;
return context;
 }
 
@@ -1367,7 +1368,10 @@ static void audit_log_name(struct audit_context 
*context, struct audit_names *n,
/* name was specified as a relative path and the
 * directory component is the cwd
 */
-   audit_log_d_path(ab, " name=", >pwd);
+   if (>pwd)
+   audit_log_d_path(ab, " name=", >pwd);
+   else
+   audit_log_format(ab, " name=(null)");
break;
default:
/* log the name's directory component */
@@ -1435,9 +1439,6 @@ static void audit_log_proctitle(void)
struct audit_context *context = audit_context();
struct audit_buffer *ab;
 
-   if (!context || context->dummy)
-   return;
-
ab = audit_log_start(context, GFP_KERNEL, AUDIT_PROCTITLE);
if (!ab)
return; /* audit_panic or being filtered */
@@ -2079,6 +2080,7 @@ void __audit_inode(struct filename *name, const struct 
dentry *dentry,
}
handle_path(dentry);
audit_copy_inode(n, dentry, inode, flags & AUDIT_INODE_NOEVAL);
+   _audit_getcwd(context);
 }
 
 void __audit_file(const struct file