Skip to contentSkip to conversation

Add support for loginuid_set

PATCH In review Richard Guy Briggs 3 participants 21 messages Aug 18, 2016 – Oct 18, 2016

lore
Share & tools
lore
#0 lore raw

v2 cover Add support for loginuid_set

loginuid_set support should have been added to userspace when it was added to the kernel around v3.10. Add it before we do similar for sessionID and sessionID_set.

There will be a number of users of features_bitmap within the same function (exclude filter extension, sessionID filter), so refactor audit_rule_fieldpair_data() to put audit_get_features earlier in the function.

Richard Guy Briggs (2):
get feature list only once
Add user filter option loginuid_set from uapi macro
AUDIT_LOGINUID_SET

 trunk/lib/errormsg.h |    2 ++
 trunk/lib/fieldtab.h |    2 ++
 trunk/lib/libaudit.c |   17 ++++++++++++++++-
 trunk/lib/libaudit.h |    6 ++++++
 4 files changed, 26 insertions(+), 1 deletions(-)
#1 lore raw

PATCH v2 1/2 get feature list only once

---
 trunk/lib/libaudit.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
trunk/lib/libaudit.c +1 -1
index 70b8ea8..566b89e 100644
@@ -1345,6 +1345,7 @@ int audit_rule_fieldpair_data(struct audit_rule_data **rulep, const char *pair,
 	int        vlen;
 	int        offset;
 	struct audit_rule_data *rule = *rulep;
+	uint32_t features = audit_get_features();
 
 	if (f == NULL)
 		return -1;
@@ -1508,7 +1509,6 @@ int audit_rule_fieldpair_data(struct audit_rule_data **rulep, const char *pair,
 		case AUDIT_FILTERKEY:
 		case AUDIT_EXE:
 			if (field == AUDIT_EXE) {
-				uint32_t features = audit_get_features();
 				if ((features & AUDIT_FEATURE_BITMAP_EXECUTABLE_PATH) == 0)
 					return -30;
 				if (op != AUDIT_EQUAL)
Signature · 1 line
1.7.1
#2 lore raw

PATCH v2 2/2 Add user filter option loginuid_set from uapi macro AUDIT_LOGINUID_SET

In reply to Richard Guy Briggs

Add macro if not in headers, check for version or feature bitmap. Check for user or exit list use, check for boolean.

See upstream kernel commits:

	780a7654cee8d61819512385e778e4827db4bfbc
	041d7b98ffe59c59fdd639931dea7d74f9aa9a59
---
 trunk/lib/errormsg.h |    2 ++
 trunk/lib/fieldtab.h |    2 ++
 trunk/lib/libaudit.c |   15 +++++++++++++++
 trunk/lib/libaudit.h |    6 ++++++
 4 files changed, 25 insertions(+), 0 deletions(-)
trunk/lib/errormsg.h +2 -0
index a4602d5..c678315 100644
@@ -66,5 +66,7 @@ static const struct msg_tab err_msgtab[] = {
     { -28,    2,    "Too many fields in rule:" },
     { -29,    1,    "only takes = operator" },
     { -30,    2,    "Field option not supported by kernel:" },
+    { -31,    1,    "can only be used with exit and user filter lists" },
+    { -32,    2,    "-F value should be boolean 0 or 1 for" },
 };
 #endif
trunk/lib/fieldtab.h +2 -0
index bf48c95..107157d 100644
@@ -31,6 +31,8 @@ _S(AUDIT_SGID,         "sgid"         )
 _S(AUDIT_FSGID,        "fsgid"        )
 _S(AUDIT_LOGINUID,     "auid"         )
 _S(AUDIT_LOGINUID,     "loginuid"     )
+_S(AUDIT_LOGINUID_SET, "auid_set"     )
+_S(AUDIT_LOGINUID_SET, "loginuid_set" )
 _S(AUDIT_PERS,         "pers"         )
 _S(AUDIT_ARCH,         "arch"         )
 _S(AUDIT_MSGTYPE,      "msgtype"      )
trunk/lib/libaudit.c +15 -0
index 566b89e..236f8bc 100644
@@ -1627,6 +1627,21 @@ int audit_rule_fieldpair_data(struct audit_rule_data **rulep, const char *pair,
 			else 
 				return -21;
 			break;
+		case AUDIT_LOGINUID_SET:
+			if(!features)
+				return -30;
+			if (flags != AUDIT_FILTER_USER &&
+			    flags != AUDIT_FILTER_EXIT)
+				return -31;
+			if (isdigit((char)*(v))) {
+				rule->values[rule->field_count] =
+					strtol(v, NULL, 0);
+				if (rule->values[rule->field_count] > 1)
+					return -32;
+			}
+			else
+				return -32;
+			break;
 		case AUDIT_DEVMAJOR...AUDIT_INODE:
 		case AUDIT_SUCCESS:
 			if (flags != AUDIT_FILTER_EXIT)
trunk/lib/libaudit.h +6 -0
index 9640f17..0852bcc 100644
@@ -369,6 +369,12 @@ extern "C" {
 #define AUDIT_COMPARE_SGID_TO_FSGID    25
 #endif
 
+/* Rule fields */
+#ifndef AUDIT_LOGINUID_SET
+#define AUDIT_LOGINUID_SET		24
+#endif
+
+/* Architectures */
 #ifndef EM_ARM
 #define EM_ARM  40
 #endif
Signature · 1 line
1.7.1
#3 lore raw
In reply to Richard Guy Briggs
Quoted 3 lines · EDT Richard Guy Briggs

loginuid_set support should have been added to userspace when it was added to the kernel around v3.10. Add it before we do similar for sessionID and sessionID_set.

If this were accepted, how would this change writing rules? IOW, can you give an example rule so we can see what this looks like?

Thanks,
-Steve

Quoted 15 lines

There will be a number of users of features_bitmap within the same function (exclude filter extension, sessionID filter), so refactor audit_rule_fieldpair_data() to put audit_get_features earlier in the function.

Richard Guy Briggs (2):
get feature list only once
Add user filter option loginuid_set from uapi macro
AUDIT_LOGINUID_SET

 trunk/lib/errormsg.h |    2 ++
 trunk/lib/fieldtab.h |    2 ++
 trunk/lib/libaudit.c |   17 ++++++++++++++++-
 trunk/lib/libaudit.h |    6 ++++++
 4 files changed, 26 insertions(+), 1 deletions(-)
#4 lore raw
Quoted 7 lines · Steve Grubb
Quoted 3 lines · EDT Richard Guy Briggs

loginuid_set support should have been added to userspace when it was added to the kernel around v3.10. Add it before we do similar for sessionID and sessionID_set.

If this were accepted, how would this change writing rules? IOW, can you give an example rule so we can see what this looks like?

We have a RFE feature page which documents some rule examples:

* https://github.com/linux-audit/audit-kernel/wiki/RFE-Session-ID-User-Filter

Signature · 2 lines
paul moore
security @ redhat
#5 lore raw
Quoted 6 lines · EDT Paul Moore
Quoted 5 lines · Steve Grubb
Quoted 3 lines · EDT Richard Guy Briggs

loginuid_set support should have been added to userspace when it was added to the kernel around v3.10. Add it before we do similar for sessionID and sessionID_set.

Quoted 7 lines
Quoted 2 lines

If this were accepted, how would this change writing rules? IOW, can you give an example rule so we can see what this looks like?

We have a RFE feature page which documents some rule examples:

*
https://github.com/linux-audit/audit-kernel/wiki/RFE-Session-ID-User-Filter

OK, thanks. This is helpful. So, what is the difference between these rules?

-a always,exit -F path=/tmp/sessionid_test -F loginuid=-1

-a always,exit -F path=/tmp/sessionid_set_test -F loginuid_set=0

-Steve

#6 lore raw
Quoted 17 lines · Steve Grubb
Quoted 6 lines · EDT Paul Moore
Quoted 5 lines · Steve Grubb
Quoted 3 lines · EDT Richard Guy Briggs

loginuid_set support should have been added to userspace when it was added to the kernel around v3.10. Add it before we do similar for sessionID and sessionID_set.

Quoted 7 lines
Quoted 2 lines

If this were accepted, how would this change writing rules? IOW, can you give an example rule so we can see what this looks like?

We have a RFE feature page which documents some rule examples:

*
https://github.com/linux-audit/audit-kernel/wiki/RFE-Session-ID-User-Filter

OK, thanks. This is helpful. So, what is the difference between these rules?

Review

Quoted 3 lines
(quoted diff) +0 -2
-a always,exit -F path=/tmp/sessionid_test -F loginuid=-1
 
-a always,exit -F path=/tmp/sessionid_set_test -F loginuid_set=0

The only difference is one flag in the kernel to indicate how it was invoked to be able to report when queried exactly the same way it was invoked, but there is no difference in the actual behaviour of the filter. This was added because of your report that "f24=0" was reported instead of loginuid_set=0 for backwards compatibility.

Going forward, the implementation of the sessionid_set field (which works similarly) will not allow an unset value of sessionid since these are a new addition that didn't need to accomodate backward compatibility.

Quoted 1 line

-Steve

- RGB

--
Richard Guy Briggs <[email protected]>
Kernel Security Engineering, Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635

#7 lore raw
Quoted 23 lines · EDT Richard Guy Briggs
Quoted 22 lines · Steve Grubb
Quoted 10 lines · EDT Paul Moore
Quoted 8 lines · Steve Grubb
Quoted 3 lines · EDT Richard Guy Briggs

loginuid_set support should have been added to userspace when it was added to the kernel around v3.10. Add it before we do similar for sessionID and sessionID_set.

If this were accepted, how would this change writing rules? IOW, can you
give an example rule so we can see what this looks like?

Quoted 5 lines

We have a RFE feature page which documents some rule examples:

*
https://github.com/linux-audit/audit-kernel/wiki/RFE-Session-ID-User-Fil
ter

OK, thanks. This is helpful. So, what is the difference between these rules?

-a always,exit -F path=/tmp/sessionid_test -F loginuid=-1

Quoted 7 lines
Quoted 1 line

-a always,exit -F path=/tmp/sessionid_set_test -F loginuid_set=0

The only difference is one flag in the kernel to indicate how it was invoked to be able to report when queried exactly the same way it was invoked, but there is no difference in the actual behaviour of the filter. This was added because of your report that "f24=0" was reported instead of loginuid_set=0 for backwards compatibility.

OK. Generally its bad to have 2 ways to do the same thing. People use SCAP content to check system configurations. If there's two ways to do the same thing, then someone can accidentally choose the wrong way and fail their scan. We run into this in the past where we allowed -a exit,always and -a always,exit. All the rules had to be reworked to be consistent. Therefore, I would recommend not using the loginuid_set option. We still get questions about -w /path/file -p wa vs -a always,exit -F path=/path/file -F perm=wa. But that one is so deeply embedded that it should not be fixed.

Quoted 4 lines

Going forward, the implementation of the sessionid_set field (which works similarly) will not allow an unset value of sessionid since these are a new addition that didn't need to accomodate backward compatibility.

As long as we can trigger on sessionid=-1, then we are fine.

-Steve

#8 lore raw
Quoted 41 lines · Steve Grubb
Quoted 23 lines · EDT Richard Guy Briggs
Quoted 22 lines · Steve Grubb
Quoted 10 lines · EDT Paul Moore
Quoted 8 lines · Steve Grubb
Quoted 3 lines · EDT Richard Guy Briggs

loginuid_set support should have been added to userspace when it was added to the kernel around v3.10. Add it before we do similar for sessionID and sessionID_set.

If this were accepted, how would this change writing rules? IOW, can you
give an example rule so we can see what this looks like?

Quoted 5 lines

We have a RFE feature page which documents some rule examples:

*
https://github.com/linux-audit/audit-kernel/wiki/RFE-Session-ID-User-Fil
ter

OK, thanks. This is helpful. So, what is the difference between these rules?

-a always,exit -F path=/tmp/sessionid_test -F loginuid=-1

Quoted 7 lines
Quoted 1 line

-a always,exit -F path=/tmp/sessionid_set_test -F loginuid_set=0

The only difference is one flag in the kernel to indicate how it was invoked to be able to report when queried exactly the same way it was invoked, but there is no difference in the actual behaviour of the filter. This was added because of your report that "f24=0" was reported instead of loginuid_set=0 for backwards compatibility.

OK. Generally its bad to have 2 ways to do the same thing. People use SCAP content to check system configurations. If there's two ways to do the same thing, then someone can accidentally choose the wrong way and fail their scan. We run into this in the past where we allowed -a exit,always and -a always,exit. All the rules had to be reworked to be consistent. Therefore, I would recommend not using the loginuid_set option. We still get questions about -w /path/file -p wa vs -a always,exit -F path=/path/file -F perm=wa. But that one is so deeply embedded that it should not be fixed.

Quoted 6 lines
Quoted 4 lines

Going forward, the implementation of the sessionid_set field (which works similarly) will not allow an unset value of sessionid since these are a new addition that didn't need to accomodate backward compatibility.

As long as we can trigger on sessionid=-1, then we are fine.

Wait a minute ... what happened to the loginuid_set patches? Didn't those get merged to userspace?

Signature · 2 lines
paul moore
security @ redhat
#9 lore raw
Quoted 5 lines · EDT Paul Moore
Quoted 4 lines · Steve Grubb
Quoted 3 lines · EDT Richard Guy Briggs
Quoted 2 lines · Steve Grubb
Quoted 1 line · EDT Paul Moore

On Mon, Oct 10, 2016 at 1:24 PM, Steve Grubb <[email protected]>

Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Thursday, August 18, 2016 2:18:55 PM EDT Richard Guy Briggs

Quoted 44 lines · wrote:
Quoted 44 lines
Quoted 21 lines
Quoted 21 lines
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

loginuid_set support should have been added to userspace when it was
added to the kernel around v3.10. Add it before we do similar for sessionID and sessionID_set.

If this were accepted, how would this change writing rules? IOW, can
you
give an example rule so we can see what this looks like?

Quoted 5 lines

We have a RFE feature page which documents some rule examples:

*
https://github.com/linux-audit/audit-kernel/wiki/RFE-Session-ID-User-> >> > > Fil ter

OK, thanks. This is helpful. So, what is the difference between these rules?

-a always,exit -F path=/tmp/sessionid_test -F loginuid=-1

Quoted 7 lines
Quoted 1 line

-a always,exit -F path=/tmp/sessionid_set_test -F loginuid_set=0

The only difference is one flag in the kernel to indicate how it was invoked to be able to report when queried exactly the same way it was invoked, but there is no difference in the actual behaviour of the filter. This was added because of your report that "f24=0" was reported instead of loginuid_set=0 for backwards compatibility.

OK. Generally its bad to have 2 ways to do the same thing. People use SCAP content to check system configurations. If there's two ways to do the same thing, then someone can accidentally choose the wrong way and fail their scan. We run into this in the past where we allowed -a exit,always and -a always,exit. All the rules had to be reworked to be consistent. Therefore, I would recommend not using the loginuid_set option. We still get questions about -w /path/file -p wa vs -a always,exit -F path=/path/file -F perm=wa. But that one is so deeply embedded that it should not be fixed.

Quoted 4 lines

Going forward, the implementation of the sessionid_set field (which works similarly) will not allow an unset value of sessionid since these are a new addition that didn't need to accomodate backward compatibility.

Quoted 4 lines
Quoted 1 line

As long as we can trigger on sessionid=-1, then we are fine.

Wait a minute ... what happened to the loginuid_set patches? Didn't those get merged to userspace?

I'm reviewing this patch set for merging now that we are past all the 2.6 bug fixing.

-Steve

#10 lore raw
Quoted 53 lines · Steve Grubb
Quoted 5 lines · EDT Paul Moore
Quoted 4 lines · Steve Grubb
Quoted 3 lines · EDT Richard Guy Briggs
Quoted 2 lines · Steve Grubb
Quoted 1 line · EDT Paul Moore

On Mon, Oct 10, 2016 at 1:24 PM, Steve Grubb <[email protected]>

Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Thursday, August 18, 2016 2:18:55 PM EDT Richard Guy Briggs

Quoted 44 lines · wrote:
Quoted 44 lines
Quoted 21 lines
Quoted 21 lines
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

loginuid_set support should have been added to userspace when it was
added to the kernel around v3.10. Add it before we do similar for sessionID and sessionID_set.

If this were accepted, how would this change writing rules? IOW, can
you
give an example rule so we can see what this looks like?

Quoted 5 lines

We have a RFE feature page which documents some rule examples:

*
https://github.com/linux-audit/audit-kernel/wiki/RFE-Session-ID-User-> >> > > Fil ter

OK, thanks. This is helpful. So, what is the difference between these rules?

-a always,exit -F path=/tmp/sessionid_test -F loginuid=-1

Quoted 7 lines
Quoted 1 line

-a always,exit -F path=/tmp/sessionid_set_test -F loginuid_set=0

The only difference is one flag in the kernel to indicate how it was invoked to be able to report when queried exactly the same way it was invoked, but there is no difference in the actual behaviour of the filter. This was added because of your report that "f24=0" was reported instead of loginuid_set=0 for backwards compatibility.

OK. Generally its bad to have 2 ways to do the same thing. People use SCAP content to check system configurations. If there's two ways to do the same thing, then someone can accidentally choose the wrong way and fail their scan. We run into this in the past where we allowed -a exit,always and -a always,exit. All the rules had to be reworked to be consistent. Therefore, I would recommend not using the loginuid_set option. We still get questions about -w /path/file -p wa vs -a always,exit -F path=/path/file -F perm=wa. But that one is so deeply embedded that it should not be fixed.

Quoted 4 lines

Going forward, the implementation of the sessionid_set field (which works similarly) will not allow an unset value of sessionid since these are a new addition that didn't need to accomodate backward compatibility.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

As long as we can trigger on sessionid=-1, then we are fine.

Wait a minute ... what happened to the loginuid_set patches? Didn't those get merged to userspace?

I'm reviewing this patch set for merging now that we are past all the 2.6 bug fixing.

Ah, nevermind ... I confused loginuid and sessionid, sorry about the confusion.

Anyway, I thought the desire for having a dedicated "is the loginuid value set?" filter came from userspace? If not, where did this requirement come from?

Signature · 2 lines
paul moore
security @ redhat
#11 lore raw
Quoted 74 lines · EDT Paul Moore
Quoted 65 lines · Steve Grubb
Quoted 5 lines · EDT Paul Moore
Quoted 4 lines · Steve Grubb
Quoted 3 lines · EDT Richard Guy Briggs
Quoted 2 lines · Steve Grubb
Quoted 1 line · EDT Paul Moore

On Mon, Oct 10, 2016 at 1:24 PM, Steve Grubb <[email protected]>

Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Thursday, August 18, 2016 2:18:55 PM EDT Richard Guy Briggs

Quoted 54 lines · wrote:
Quoted 54 lines
Quoted 24 lines
Quoted 24 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

loginuid_set support should have been added to userspace when it
was
added to the kernel around v3.10. Add it before we do similar for
sessionID and sessionID_set.

If this were accepted, how would this change writing rules? IOW, can
you
give an example rule so we can see what this looks like?

Quoted 5 lines

We have a RFE feature page which documents some rule examples:

*
https://github.com/linux-audit/audit-kernel/wiki/RFE-Session-ID-Us
er-> >> > > Fil ter

OK, thanks. This is helpful. So, what is the difference between these
rules?

-a always,exit -F path=/tmp/sessionid_test -F loginuid=-1

Quoted 8 lines
Quoted 1 line

-a always,exit -F path=/tmp/sessionid_set_test -F loginuid_set=0

The only difference is one flag in the kernel to indicate how it was invoked to be able to report when queried exactly the same way it was invoked, but there is no difference in the actual behaviour of the filter. This was added because of your report that "f24=0" was reported
instead of loginuid_set=0 for backwards compatibility.

OK. Generally its bad to have 2 ways to do the same thing. People use SCAP
content to check system configurations. If there's two ways to do the same
thing, then someone can accidentally choose the wrong way and fail their
scan. We run into this in the past where we allowed -a exit,always and -a
always,exit. All the rules had to be reworked to be consistent. Therefore, I would recommend not using the loginuid_set option. We still
get questions about -w /path/file -p wa vs -a always,exit -F path=/path/file -F perm=wa. But that one is so deeply embedded that it should not be fixed.

Quoted 5 lines

Going forward, the implementation of the sessionid_set field (which works similarly) will not allow an unset value of sessionid since these
are a new addition that didn't need to accomodate backward compatibility.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

As long as we can trigger on sessionid=-1, then we are fine.

Wait a minute ... what happened to the loginuid_set patches? Didn't those get merged to userspace?

I'm reviewing this patch set for merging now that we are past all the 2.6 bug fixing.

Quoted 6 lines

Ah, nevermind ... I confused loginuid and sessionid, sorry about the confusion.

Anyway, I thought the desire for having a dedicated "is the loginuid value set?" filter came from userspace? If not, where did this requirement come from?

I don't know where it came from. We have always used -1 for unset loginuid and session id.

-Steve

#12 lore raw
Quoted 78 lines · Steve Grubb
Quoted 77 lines · EDT Paul Moore
Quoted 65 lines · Steve Grubb
Quoted 5 lines · EDT Paul Moore
Quoted 4 lines · Steve Grubb
Quoted 3 lines · EDT Richard Guy Briggs
Quoted 2 lines · Steve Grubb
Quoted 1 line · EDT Paul Moore

On Mon, Oct 10, 2016 at 1:24 PM, Steve Grubb <[email protected]>

Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Thursday, August 18, 2016 2:18:55 PM EDT Richard Guy Briggs

Quoted 54 lines · wrote:
Quoted 54 lines
Quoted 24 lines
Quoted 24 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

loginuid_set support should have been added to userspace when it
was
added to the kernel around v3.10. Add it before we do similar for
sessionID and sessionID_set.

If this were accepted, how would this change writing rules? IOW, can
you
give an example rule so we can see what this looks like?

Quoted 5 lines

We have a RFE feature page which documents some rule examples:

*
https://github.com/linux-audit/audit-kernel/wiki/RFE-Session-ID-Us
er-> >> > > Fil ter

OK, thanks. This is helpful. So, what is the difference between these
rules?

-a always,exit -F path=/tmp/sessionid_test -F loginuid=-1

Quoted 8 lines
Quoted 1 line

-a always,exit -F path=/tmp/sessionid_set_test -F loginuid_set=0

The only difference is one flag in the kernel to indicate how it was invoked to be able to report when queried exactly the same way it was invoked, but there is no difference in the actual behaviour of the filter. This was added because of your report that "f24=0" was reported
instead of loginuid_set=0 for backwards compatibility.

OK. Generally its bad to have 2 ways to do the same thing. People use SCAP
content to check system configurations. If there's two ways to do the same
thing, then someone can accidentally choose the wrong way and fail their
scan. We run into this in the past where we allowed -a exit,always and -a
always,exit. All the rules had to be reworked to be consistent. Therefore, I would recommend not using the loginuid_set option. We still
get questions about -w /path/file -p wa vs -a always,exit -F path=/path/file -F perm=wa. But that one is so deeply embedded that it should not be fixed.

Quoted 5 lines

Going forward, the implementation of the sessionid_set field (which works similarly) will not allow an unset value of sessionid since these
are a new addition that didn't need to accomodate backward compatibility.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

As long as we can trigger on sessionid=-1, then we are fine.

Wait a minute ... what happened to the loginuid_set patches? Didn't those get merged to userspace?

I'm reviewing this patch set for merging now that we are past all the 2.6 bug fixing.

Ah, nevermind ... I confused loginuid and sessionid, sorry about the confusion.

Quoted 6 lines
Quoted 3 lines

Anyway, I thought the desire for having a dedicated "is the loginuid value set?" filter came from userspace? If not, where did this requirement come from?

I don't know where it came from. We have always used -1 for unset loginuid and session id.

Looking back through the git logs, it looks like it originally came out of the user namespace work by Eric Biederman.

Signature · 2 lines
paul moore
security @ redhat
#13 lore raw
Quoted 83 lines · Paul Moore
Quoted 82 lines · Steve Grubb
Quoted 80 lines · EDT Paul Moore
Quoted 65 lines · Steve Grubb
Quoted 5 lines · EDT Paul Moore
Quoted 4 lines · Steve Grubb
Quoted 3 lines · EDT Richard Guy Briggs
Quoted 2 lines · Steve Grubb
Quoted 1 line · EDT Paul Moore

On Mon, Oct 10, 2016 at 1:24 PM, Steve Grubb <[email protected]>

Quoted 1 line · wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

On Thursday, August 18, 2016 2:18:55 PM EDT Richard Guy Briggs

Quoted 54 lines · wrote:
Quoted 54 lines
Quoted 24 lines
Quoted 24 lines
Quoted 12 lines
Quoted 11 lines
Quoted 6 lines

loginuid_set support should have been added to userspace when it
was
added to the kernel around v3.10. Add it before we do similar for
sessionID and sessionID_set.

If this were accepted, how would this change writing rules? IOW, can
you
give an example rule so we can see what this looks like?

Quoted 5 lines

We have a RFE feature page which documents some rule examples:

*
https://github.com/linux-audit/audit-kernel/wiki/RFE-Session-ID-Us
er-> >> > > Fil ter

OK, thanks. This is helpful. So, what is the difference between these
rules?

-a always,exit -F path=/tmp/sessionid_test -F loginuid=-1

Quoted 8 lines
Quoted 1 line

-a always,exit -F path=/tmp/sessionid_set_test -F loginuid_set=0

The only difference is one flag in the kernel to indicate how it was invoked to be able to report when queried exactly the same way it was invoked, but there is no difference in the actual behaviour of the filter. This was added because of your report that "f24=0" was reported
instead of loginuid_set=0 for backwards compatibility.

OK. Generally its bad to have 2 ways to do the same thing. People use SCAP
content to check system configurations. If there's two ways to do the same
thing, then someone can accidentally choose the wrong way and fail their
scan. We run into this in the past where we allowed -a exit,always and -a
always,exit. All the rules had to be reworked to be consistent. Therefore, I would recommend not using the loginuid_set option. We still
get questions about -w /path/file -p wa vs -a always,exit -F path=/path/file -F perm=wa. But that one is so deeply embedded that it should not be fixed.

Quoted 5 lines

Going forward, the implementation of the sessionid_set field (which works similarly) will not allow an unset value of sessionid since these
are a new addition that didn't need to accomodate backward compatibility.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

As long as we can trigger on sessionid=-1, then we are fine.

Wait a minute ... what happened to the loginuid_set patches? Didn't those get merged to userspace?

I'm reviewing this patch set for merging now that we are past all the 2.6 bug fixing.

Ah, nevermind ... I confused loginuid and sessionid, sorry about the confusion.

Anyway, I thought the desire for having a dedicated "is the loginuid value set?" filter came from userspace? If not, where did this requirement come from?

Quoted 5 lines
Quoted 2 lines

I don't know where it came from. We have always used -1 for unset loginuid and session id.

Looking back through the git logs, it looks like it originally came out of the user namespace work by Eric Biederman.

That's exactly where it came from. Eric submitted the patch 780a7654 to fix the regression caused by e1760bd (userns: Convert the audit loginuid to be a kuid) and its set of 9 patches that were part of a 41-patch set. I notice Paul was Cc:-ed on that set... I had to work around the work around when Steve reported the "f24=..." values.

I can accept that Steve doesn't want to add more ways of doing the same thing, so I don't have an easy answer in terms of AUDIT_LOGINUID_SET being exposed in the UAPI.

Since sessionid is a new field for filter specification (but not reporting and searching), I blocked sessionid==-1 in the api for setting filters. This unfortunately makes it a different way to specify it than loginuid when it is not set.

Quoted 1 line

paul moore

- RGB

--
Richard Guy Briggs <[email protected]>
Kernel Security Engineering, Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635

#14 lore raw
Quoted 4 lines · EDT Richard Guy Briggs

Since sessionid is a new field for filter specification (but not reporting and searching), I blocked sessionid==-1 in the api for setting filters. This unfortunately makes it a different way to specify it than loginuid when it is not set.

Can we unblock that?

-Steve

#15 lore raw
Quoted 7 lines · Steve Grubb
Quoted 4 lines · EDT Richard Guy Briggs

Since sessionid is a new field for filter specification (but not reporting and searching), I blocked sessionid==-1 in the api for setting filters. This unfortunately makes it a different way to specify it than loginuid when it is not set.

Can we unblock that?

Sure, then we would have two ways to express the same thing and ends up using in-band signalling which is what Eric was trying to avoid in the first place.

Quoted 1 line

-Steve

- RGB

--
Richard Guy Briggs <[email protected]>
Kernel Security Engineering, Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635

#16 lore raw
Quoted 7 lines · EDT Richard Guy Briggs
Quoted 6 lines · Steve Grubb
Quoted 4 lines · EDT Richard Guy Briggs

Since sessionid is a new field for filter specification (but not reporting and searching), I blocked sessionid==-1 in the api for setting filters. This unfortunately makes it a different way to specify it than loginuid when it is not set.

Quoted 5 lines
Quoted 1 line

Can we unblock that?

Sure, then we would have two ways to express the same thing and ends up using in-band signalling which is what Eric was trying to avoid in the first place.

The plan would be to not use sessionid_set at all. Then we have one way to do things. I doubt anyone is using either of the set functions. Just mark them deprecated in the comments.

-Steve

#17 lore raw
In reply to Richard Guy Briggs
Quoted 8 lines · Richard Guy Briggs
Quoted 2 lines · Paul Moore

Looking back through the git logs, it looks like it originally came out of the user namespace work by Eric Biederman.

That's exactly where it came from. Eric submitted the patch 780a7654 to fix the regression caused by e1760bd (userns: Convert the audit loginuid to be a kuid) and its set of 9 patches that were part of a 41-patch set. I notice Paul was Cc:-ed on that set...

I don't have the time to dig through my mail to see what all was included in that patchset, but based on the git log that patch was from April 2013 and I didn't become responsible for the audit code until October 2014. I also don't see my Acked-by/Reviewed-by tag on that commit so it is safe to say I was busy with other things at the time. There are plenty of things you can blame me for, this ain't one of 'em.

Quoted 11 lines

I had to work around the work
around when Steve reported the "f24=..." values.

I can accept that Steve doesn't want to add more ways of doing the same thing, so I don't have an easy answer in terms of AUDIT_LOGINUID_SET being exposed in the UAPI.

Since sessionid is a new field for filter specification (but not reporting and searching), I blocked sessionid==-1 in the api for setting filters. This unfortunately makes it a different way to specify it than loginuid when it is not set.

We are not going to change the loginuid related mechanisms at this point; they aren't causing any breakage, and I don't want to break the existing kernel/user API without a good reason.

We haven't merged any of the session ID code into the kernel so changes are still possible. The logic for supporting loginuid_set (UID namespace issues) don't really apply to session IDs so I think we can drop the sessionid_set part of the API and just use the -1 sentinel. If you are all still looking to blame somebody, you can all blame me for suggesting session ID to Richard.

Richard, if we use -1 as a magic number for the session ID, we should make sure we roll the session ID value assigned to new sessions before we hit -1 in audit_set_loginuid(...).

Signature · 2 lines
paul moore
security @ redhat
#18 lore raw
Quoted 5 lines · EDT Paul Moore

We haven't merged any of the session ID code into the kernel so changes are still possible. The logic for supporting loginuid_set (UID namespace issues) don't really apply to session IDs so I think we can drop the sessionid_set part of the API and just use the -1 sentinel.

OK, that's good to hear. I'll fix up and merge the sessionid patch - no need to re-send the user space piece.

-Steve

#19 lore raw
Quoted 9 lines · Steve Grubb
Quoted 5 lines · EDT Paul Moore

We haven't merged any of the session ID code into the kernel so changes are still possible. The logic for supporting loginuid_set (UID namespace issues) don't really apply to session IDs so I think we can drop the sessionid_set part of the API and just use the -1 sentinel.

OK, that's good to hear. I'll fix up and merge the sessionid patch - no need to re-send the user space piece.

userspace patch 2 gets dropped, paches 1 and 3 need rework to not block -1 and to remove sessionid_set respectively. kernel patch 2 gets dropped and patch 1 I think needs rework to allow -1.

The test patches also need rework as does the RFE page.

Quoted 1 line

-Steve

- RGB

--
Richard Guy Briggs <[email protected]>
Kernel Security Engineering, Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635

#20 lore raw
Quoted 8 lines · Richard Guy Briggs
Quoted 7 lines · Steve Grubb
Quoted 5 lines · EDT Paul Moore

We haven't merged any of the session ID code into the kernel so changes are still possible. The logic for supporting loginuid_set (UID namespace issues) don't really apply to session IDs so I think we can drop the sessionid_set part of the API and just use the -1 sentinel.

Quoted 6 lines
Quoted 2 lines

OK, that's good to hear. I'll fix up and merge the sessionid patch - no need to re-send the user space piece.

userspace patch 2 gets dropped, paches 1 and 3 need rework to not block -1 and to remove sessionid_set respectively. kernel patch 2 gets dropped and patch 1 I think needs rework to allow -1.

Kernel patch 1 does not need rework because I properly put the positive integer check for sessionID in the sessionID_set patch that adds that.

Quoted 5 lines

The test patches also need rework as does the RFE page.

Quoted 1 line

-Steve

- RGB

- RGB

--
Richard Guy Briggs <[email protected]>
Kernel Security Engineering, Base Operating Systems, Red Hat Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635