public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
* [PATCH 4/4] Add the checking of key field for a watch or syscall given
@ 2008-08-02 10:16 zhangxiliang
  2008-08-05  0:06 ` Steve Grubb
  2008-08-05 13:44 ` Steve Grubb
  0 siblings, 2 replies; 7+ messages in thread
From: zhangxiliang @ 2008-08-02 10:16 UTC (permalink / raw)
  To: Steve Grubb, Linux Audit

Hello Steve, 

When field is AUDIT_FILTERKEY, it should need a watch or syscall given prior to it.
So I add checking and error message "-19" to realize it.

Do you agree with me? This is the patches for latest code in
audit SVN project. 

Signed-off-by: Zhang Xiliang <zhangxiliang@cn.fujitsu.com>
---
 lib/libaudit.c |    3 +++
 src/auditctl.c |    7 ++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/lib/libaudit.c b/lib/libaudit.c
index 4d20261..8dd5baa 100644
--- a/lib/libaudit.c
+++ b/lib/libaudit.c
@@ -75,6 +75,7 @@ static const struct nv_list failure_actions[] =
   { NULL,		0 }
 };
 
+int audit_permadded hidden = 0;
 int audit_archadded hidden = 0;
 int audit_syscalladded hidden = 0;
 unsigned int audit_elf hidden = 0U;
@@ -920,6 +921,8 @@ int audit_rule_fieldpair_data(struct audit_rule_data **rulep, const char *pair,
 		case AUDIT_SUBJ_SEN:
 		case AUDIT_SUBJ_CLR:
 		case AUDIT_FILTERKEY:
+			if (field == AUDIT_FILTERKEY && !(audit_syscalladded || audit_permadded))
+                                return -19;
 			vlen = strlen(v);
 			if (field == AUDIT_FILTERKEY &&
 					vlen > AUDIT_MAX_KEY_LEN)
diff --git a/src/auditctl.c b/src/auditctl.c
index 0d38ac1..2c99e09 100644
--- a/src/auditctl.c
+++ b/src/auditctl.c
@@ -67,7 +67,6 @@ enum { OLD, NEW };
 int which;
 static struct audit_rule  rule;
 static struct audit_rule_data *rule_new = NULL;
-int audit_permadded;
 static char key[AUDIT_MAX_KEY_LEN+1];
 static int keylen;
 static int printed;
@@ -77,6 +76,7 @@ static const char key_sep[2] = { AUDIT_KEY_SEPARATOR, 0 };
 extern int audit_archadded;
 extern int audit_syscalladded;
 extern unsigned int audit_elf;
+extern int audit_permadded;
 
 /*
  * This function will reset everything used for each loop when loading 
@@ -799,6 +799,11 @@ static int setopt(int count, char *vars[])
 					"Field %s can not be used with exclude filter list\n", optarg);
 				retval = -1;
 				break;
+			case -19:
+				fprintf(stderr,
+					"Key field needs a watch or syscall given prior to it\n");
+				retval = -1;
+				break;
 			default:
 				retval = -1;
 				break;

-- 
Regards
Zhang Xiliang

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

* Re: [PATCH 4/4] Add the checking of key field for a watch or syscall given
  2008-08-02 10:16 [PATCH 4/4] Add the checking of key field for a watch or syscall given zhangxiliang
@ 2008-08-05  0:06 ` Steve Grubb
  2008-08-05  0:36   ` zhangxiliang
  2008-08-05 13:44 ` Steve Grubb
  1 sibling, 1 reply; 7+ messages in thread
From: Steve Grubb @ 2008-08-05  0:06 UTC (permalink / raw)
  To: zhangxiliang; +Cc: Linux Audit

On Saturday 02 August 2008 06:16:48 zhangxiliang wrote:
> When field is AUDIT_FILTERKEY, it should need a watch or syscall given
> prior to it. So I add checking and error message "-19" to realize it.
>
> Do you agree with me?

Yes, but where does permadded get set?

Thanks,
-Steve

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

* Re: [PATCH 4/4] Add the checking of key field for a watch or syscall given
  2008-08-05  0:06 ` Steve Grubb
@ 2008-08-05  0:36   ` zhangxiliang
  2008-08-05  1:59     ` Steve Grubb
  0 siblings, 1 reply; 7+ messages in thread
From: zhangxiliang @ 2008-08-05  0:36 UTC (permalink / raw)
  To: Steve Grubb; +Cc: Linux Audit


Steve Grubb said the following on 2008-08-05 8:06:
> On Saturday 02 August 2008 06:16:48 zhangxiliang wrote:
>> When field is AUDIT_FILTERKEY, it should need a watch or syscall given
>> prior to it. So I add checking and error message "-19" to realize it.
>>
>> Do you agree with me?
> 
> Yes, but where does permadded get set?

"permadded" set in "lib/libaudit.c" as follows:
 int audit_permadded hidden = 0;
 int audit_archadded hidden = 0;
 int audit_syscalladded hidden = 0
  
 It declares in "src/auditctl.c" as follows:
 extern int audit_permadded;

> 
> Thanks,
> -Steve
> 
> 
> 

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

* Re: [PATCH 4/4] Add the checking of key field for a watch or syscall given
  2008-08-05  0:36   ` zhangxiliang
@ 2008-08-05  1:59     ` Steve Grubb
  2008-08-05  6:47       ` zhangxiliang
  0 siblings, 1 reply; 7+ messages in thread
From: Steve Grubb @ 2008-08-05  1:59 UTC (permalink / raw)
  To: zhangxiliang; +Cc: Linux Audit

On Monday 04 August 2008 20:36:37 zhangxiliang wrote:
> >> When field is AUDIT_FILTERKEY, it should need a watch or syscall given
> >> prior to it. So I add checking and error message "-19" to realize it.
> >>
> >> Do you agree with me?
> >
> > Yes, but where does permadded get set?
>
> "permadded" set in "lib/libaudit.c" as follows:
>  int audit_permadded hidden = 0;
>  int audit_archadded hidden = 0;
>  int audit_syscalladded hidden = 0

Right, but I don't see where it gets set to a 1.

Thanks,
-Steve

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

* Re: [PATCH 4/4] Add the checking of key field for a watch or syscall given
  2008-08-05  1:59     ` Steve Grubb
@ 2008-08-05  6:47       ` zhangxiliang
  2008-08-05 13:49         ` Steve Grubb
  0 siblings, 1 reply; 7+ messages in thread
From: zhangxiliang @ 2008-08-05  6:47 UTC (permalink / raw)
  To: Steve Grubb; +Cc: Linux Audit

Steve Grubb said the following on 2008-08-05 9:59:
> 
> Right, but I don't see where it gets set to a 1.
>  

Thank you for your suggestion.
I found the audit_permadded is set to 1 in audit_setup_perms() and setopt() after the AUDIT_PERM field.
But I think it is not enough.

When the watch is added and AUDIT_PERM is not added, the perm r,w,x,a should be added by kernel default.
So I think the audit_permadded should be set to 1 after a watch added.
I make a new patch for it. The "key" patch and new patch should use together.

Subject: [PATCH] When the watch is set, the audit_permadded should be set to 1

Signed-off-by: Zhang Xiliang <zhangxiliang@cn.fujitsu.com>
---
 lib/libaudit.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/lib/libaudit.c b/lib/libaudit.c
index 71267de..9a317c5 100644
--- a/lib/libaudit.c
+++ b/lib/libaudit.c
@@ -580,6 +580,8 @@ int audit_add_watch_dir(int type, struct audit_rule_data **rulep,
 	rule->fieldflags[1] = AUDIT_EQUAL;
 	rule->values[1] = AUDIT_PERM_READ | AUDIT_PERM_WRITE |
 				AUDIT_PERM_EXEC | AUDIT_PERM_ATTR;
+	
+	audit_permadded = 1;
 
 	return  0;
 }
@@ -941,6 +943,10 @@ int audit_rule_fieldpair_data(struct audit_rule_data **rulep, const char *pair,
 				rule = *rulep;
 			}
 			strncpy(&rule->buf[offset], v, vlen);
+
+			if(flags && (AUDIT_WATCH || AUDIT_DIR))
+				audit_permadded = 1;
+
 			break;
 		case AUDIT_ARCH:
 			if (audit_syscalladded)

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

* Re: [PATCH 4/4] Add the checking of key field for a watch or syscall given
  2008-08-02 10:16 [PATCH 4/4] Add the checking of key field for a watch or syscall given zhangxiliang
  2008-08-05  0:06 ` Steve Grubb
@ 2008-08-05 13:44 ` Steve Grubb
  1 sibling, 0 replies; 7+ messages in thread
From: Steve Grubb @ 2008-08-05 13:44 UTC (permalink / raw)
  To: zhangxiliang; +Cc: Linux Audit

On Saturday 02 August 2008 06:16:48 zhangxiliang wrote:
> When field is AUDIT_FILTERKEY, it should need a watch or syscall given
> prior to it. So I add checking and error message "-19" to realize it.
>
> Do you agree with me? This is the patches for latest code in
> audit SVN project.

Applied. Thanks for the patch.

-Steve

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

* Re: [PATCH 4/4] Add the checking of key field for a watch or syscall given
  2008-08-05  6:47       ` zhangxiliang
@ 2008-08-05 13:49         ` Steve Grubb
  0 siblings, 0 replies; 7+ messages in thread
From: Steve Grubb @ 2008-08-05 13:49 UTC (permalink / raw)
  To: zhangxiliang; +Cc: Linux Audit

On Tuesday 05 August 2008 02:47:26 zhangxiliang wrote:
> When the watch is added and AUDIT_PERM is not added, the perm r,w,x,a
> should be added by kernel default. So I think the audit_permadded should be
> set to 1 after a watch added. I make a new patch for it. The "key" patch
> and new patch should use together.

Applied. Thanks for the patch.

-Steve

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

end of thread, other threads:[~2008-08-05 13:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-02 10:16 [PATCH 4/4] Add the checking of key field for a watch or syscall given zhangxiliang
2008-08-05  0:06 ` Steve Grubb
2008-08-05  0:36   ` zhangxiliang
2008-08-05  1:59     ` Steve Grubb
2008-08-05  6:47       ` zhangxiliang
2008-08-05 13:49         ` Steve Grubb
2008-08-05 13:44 ` Steve Grubb

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