refpolicy is missing on lots of hits with audit2allow -R.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
The reason for this is threshold, setting. I think the interfaces are getting more complicated and one AVC that is looking for read ends up being two far different from the threshold, so audit2allow does not report it.
For example.
node=(removed) type=AVC msg=audit(1271587735.632:422): avc: denied { getattr } for pid=13239 comm="openvpn" path="/home/bbaetz/.pki/vpn01_cacert.pem" dev=dm-3 ino=565334 scontext=system_u:system_r:openvpn_t:s0 tcontext=unconfined_u:object_r:home_cert_t:s0 tclass=file
node=(removed) type=SYSCALL msg=audit(1271587735.632:422): arch=c000003e syscall=5 success=yes exit=0 a0=6 a1=7fffd84f4a20 a2=7fffd84f4a20 a3=18 items=0 ppid=13235 pid=13239 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="openvpn" exe="/usr/sbin/openvpn" subj=system_u:system_r:openvpn_t:s0 key=(null)
Finds userdom_read_home_certs but it's threshold is two far off, so it reports nothing.
I think we should either eliminate the threshold and report the best interface that we have, and let the policy writer decide if he wants the match.
If you look at the interface userdom_read_home_certs.
[InterfaceVector userdom_read_home_certs $1:source ] $1,home_cert_t,file,read,lock,getattr,open,ioctl $1,home_cert_t,dir,ioctl,search,read,lock,open,getattr $1,home_cert_t,lnk_file,read,getattr $1,home_root_t,dir,getattr,open,search $1,home_root_t,lnk_file,read,getattr $1,user_home_dir_t,dir,getattr,open,search $1,user_home_dir_t,lnk_file,read,getattr
A domain that is allowed to search the homedir is always going to generate an AVC that is a long way off.
I thing we should either remove the bastards and just add all as childs, or recode it like the attachment.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvMacAACgkQrlYvE4MpobNeAgCfcoVssEQJ8mfZT/aBvAt0z7+3 CoMAnR1bOcXk7x/jIZ+0i2Kc/faUJAVk
=Uuf7
-----END PGP SIGNATURE-----
matching.py renamed from matching.py~ +4 -3
@@ -63,14 +63,15 @@ def best(self): if len(self.children): return self.children[0] - else: - return None + if len(self.bastards): + return self.bastards[0] + return None def __len__(self): # Only return the length of the matches so # that this can be used to test if there is # a match. - return len(self.children) + return len(self.children) + len(self.bastards) def __iter__(self): return iter(self.children)
Quoted 8 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1The reason for this is threshold, setting. I think the interfaces are getting more complicated and one AVC that is looking for read ends up being two far different from the threshold, so audit2allow does not report it.
Is it really that the interfaces have more access in them or is it that our measure of difference is off? See below.
[snip]
Quoted 12 lines
If you look at the interface
userdom_read_home_certs.[InterfaceVector
userdom_read_home_certs$1:source ] $1,home_cert_t,file,read,lock,getattr,open,ioctl $1,home_cert_t,dir,ioctl,search,read,lock,open,getattr $1,home_cert_t,lnk_file,read,getattr $1,home_root_t,dir,getattr,open,search $1,home_root_t,lnk_file,read,getattr $1,user_home_dir_t,dir,getattr,open,search $1,user_home_dir_t,lnk_file,read,getattr
Quoted 3 lines
A domain that is allowed to search the homedir is always going to generate an AVC that is a long way off.
Seems to me that the problem is that the read / getattr on user_home_dir_t directories and files is adding too much distance.
Quoted 3 lines
I thing we should either remove the bastards and just add all as childs, or recode it like the attachment.
I'm against removing the threshold altogether - if we do that then we'll get a match for almost everything including completely wrong interfaces. Can we start with tweaking either the perm weights or the distance calculation? For example, what happens when you drop the weight for dir read down to 5 or 1 and similar for lnk_file (they are both 10 right now)? After that we might need to tweak the threshold.
Also - I've been hacking on a patch to add in attribute access to the interface vectors. Any idea how much help we would get from that?
Karl
Quoted 9 lines
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/iEYEARECAAYFAkvMacAACgkQrlYvE4MpobNeAgCfcoVssEQJ8mfZT/aBvAt0z7+3 CoMAnR1bOcXk7x/jIZ+0i2Kc/faUJAVk
=Uuf7
-----END PGP SIGNATURE-----
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 13 lines · Karl MacMillan
Quoted 12 lines · Daniel J Walsh
If you look at the interface
userdom_read_home_certs.[InterfaceVector
userdom_read_home_certs$1:source ] $1,home_cert_t,file,read,lock,getattr,open,ioctl $1,home_cert_t,dir,ioctl,search,read,lock,open,getattr $1,home_cert_t,lnk_file,read,getattr $1,home_root_t,dir,getattr,open,search $1,home_root_t,lnk_file,read,getattr $1,user_home_dir_t,dir,getattr,open,search $1,user_home_dir_t,lnk_file,read,getattr
Quoted 7 lines
Quoted 3 lines
A domain that is allowed to search the homedir is always going to generate an AVC that is a long way off.
Seems to me that the problem is that the read / getattr on
user_home_dir_tdirectories and files is adding too much distance.
I looked at this a bit more - there are a few interesting issues:
1. The open permissions have not been added to the perm_map file (patch attached to fix that). When there is no perm map then we weight the permission at 5 and assume read and write. Since we heavily penalize providing a write interface for a read access request, this causes the return of a large distance (as I believe that it should). I'd like to find a long term home for the perm map file that increases it's likelihood of being updated with new permissions (Chris - what do you think of including this with reference policy?).
2. As I mentioned, the weighting on things like reading a symlink or directory contents is fairly high. For this use I don't think that's appropriate - the attached perm map patch also reduces these pretty drastically.
3. The bulk of the rest of the distance comes from the unrelated type/object access. We get access to 4 type/object class pairs that aren't requested. Unfortunately there is no tracking of the notion of related access or scaling of the type penalty based upon how minor the related access is. Perhaps we should scale the type penalty with the permission weighting?
4. The final issue is that this interface is a bit broad for the requested access - requesting getattr for the cert files and getting read is a pretty significant bump. Once you resolve the perm_map issue then the distance is just over the threshold - which is about where I was aiming with this algorithm (go me). Now, the reality is likely that a read would come right after this getattr - if that had have been in the audit log all would be fine. Having said that, I'm not against making the threshold a little higher to return these (another patch attached).
Long term, I wonder if we should return interfaces above the threshold but commented out with a note explaining that the interface, while providing the requested access, is potentially dangerously broad. Dan, any chance you want to add that feature?
Karl
Quoted 11 lines
Quoted 3 lines
I thing we should either remove the bastards and just add all as childs, or recode it like the attachment.
I'm against removing the threshold altogether - if we do that then we'll get a match for almost everything including completely wrong interfaces. Can we start with tweaking either the perm weights or the distance calculation? For example, what happens when you drop the weight for dir read down to 5 or 1 and similar for
lnk_file(they are both 10 right now)? After that we might need to tweak the threshold.
Quoted 15 lines
Also - I've been hacking on a patch to add in attribute access to the interface vectors. Any idea how much help we would get from that?
Karl
Quoted 9 lines
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/iEYEARECAAYFAkvMacAACgkQrlYvE4MpobNeAgCfcoVssEQJ8mfZT/aBvAt0z7+3 CoMAnR1bOcXk7x/jIZ+0i2Kc/faUJAVk
=Uuf7
-----END PGP SIGNATURE-----
From 83b22cfdc01073a378fc9d50875575d252b95003 Mon Sep 17 00:00:00 2001
Message-Id: <83b22cfdc01073a378fc9d50875575d252b95003.1271724209.git.kmacmillan@tresys.com>
From: Karl MacMillan <[email protected]>
Date: Mon, 19 Apr 2010 20:09:41 -0400
Subject: [PATCH 1/2] Update perm map with open permissions.
--- sepolgen/src/share/perm_map | 51 ++++++++++++++++++++++++------------------ 1 files changed, 29 insertions(+), 22 deletions(-)
sepolgen/src/share/perm_map +29 -22
@@ -124,7 +124,7 @@ class filesystem 10 quotamod w 1 quotaget r 1 -class file 20 +class file 21 execute_no_trans r 1 entrypoint r 1 execmod n 1
@@ -141,48 +141,50 @@ class file 20 unlink w 1 link w 1 rename w 5 - execute r 100 + execute r 10 swapon b 1 quotaon b 1 mounton b 1 + open r 1 -class dir 22 - add_name w 5 +class dir 23 + add_name w 1 remove_name w 1 reparent w 1 search r 1 rmdir b 1 ioctl n 1 - read r 10 - write w 10 + read r 1 + write w 1 create w 1 - getattr r 7 - setattr w 7 + getattr r 1 + setattr w 1 lock n 1 - relabelfrom r 10 - relabelto w 10 + relabelfrom r 1 + relabelto w 1 append w 1 unlink w 1 link w 1 - rename w 5 + rename w 1 execute r 1 swapon b 1 quotaon b 1 mounton b 1 + open r 1 class fd 1 use b 1 -class lnk_file 17 +class lnk_file 18 ioctl n 1 - read r 10 - write w 10 + read r 1 + write w 1 create w 1 - getattr r 7 - setattr w 7 + getattr r 1 + setattr w 1 lock n 1 - relabelfrom r 10 - relabelto w 10 + relabelfrom r 1 + relabelto w 1 append w 1 unlink w 1 link w 1
@@ -191,8 +193,9 @@ class lnk_file 17 swapon b 1 quotaon b 1 mounton b 1 + open r 1 -class chr_file 20 +class chr_file 21 execute_no_trans r 1 entrypoint r 1 execmod n 1
@@ -213,8 +216,9 @@ class chr_file 20 swapon b 1 quotaon b 1 mounton b 1 + open r 1 -class blk_file 17 +class blk_file 18 ioctl n 1 read r 10 write w 10
@@ -232,8 +236,9 @@ class blk_file 17 swapon b 1 quotaon b 1 mounton b 1 + open r 1 -class sock_file 17 +class sock_file 18 ioctl n 1 read r 10 write w 10
@@ -251,8 +256,9 @@ class sock_file 17 swapon b 1 quotaon b 1 mounton b 1 + open r 1 -class fifo_file 17 +class fifo_file 18 ioctl n 1 read r 10 write w 10
@@ -270,6 +276,7 @@ class fifo_file 17 swapon b 1 quotaon b 1 mounton b 1 + open r 1 class socket 22 ioctl n 1
Signature · 1 line
1.6.6.1
From f08915971be3f54acb94c931db33dc64f0c3d435 Mon Sep 17 00:00:00 2001
Message-Id: <f08915971be3f54acb94c931db33dc64f0c3d435.1271724209.git.kmacmillan@tresys.com>
In-Reply-To: <83b22cfdc01073a378fc9d50875575d252b95003.1271724209.git.kmacmillan@tresys.com>
References: <83b22cfdc01073a378fc9d50875575d252b95003.1271724209.git.kmacmillan@tresys.com>
From: Karl MacMillan <[email protected]>
Date: Mon, 19 Apr 2010 20:40:48 -0400
Subject: [PATCH 2/2] Increase the matching threshold.
--- sepolgen/src/sepolgen/matching.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
sepolgen/src/sepolgen/matching.py +1 -1
@@ -50,7 +50,7 @@ class Match: return 1 class MatchList: - DEFAULT_THRESHOLD = 120 + DEFAULT_THRESHOLD = 150 def __init__(self): # Match objects that pass the threshold self.children = []
Signature · 1 line
1.6.6.1
Quoted 25 lines · Karl MacMillan
Quoted 13 lines · Karl MacMillan
Quoted 12 lines · Daniel J Walsh
If you look at the interface
userdom_read_home_certs.[InterfaceVector
userdom_read_home_certs$1:source ] $1,home_cert_t,file,read,lock,getattr,open,ioctl $1,home_cert_t,dir,ioctl,search,read,lock,open,getattr $1,home_cert_t,lnk_file,read,getattr $1,home_root_t,dir,getattr,open,search $1,home_root_t,lnk_file,read,getattr $1,user_home_dir_t,dir,getattr,open,search $1,user_home_dir_t,lnk_file,read,getattrQuoted 7 lines
Quoted 3 lines
A domain that is allowed to search the homedir is always going to generate an AVC that is a long way off.
Seems to me that the problem is that the read / getattr on
user_home_dir_tdirectories and files is adding too much distance.I looked at this a bit more - there are a few interesting issues:
Quoted 8 lines
1. The open permissions have not been added to the
perm_mapfile (patch attached to fix that). When there is no perm map then we weight the permission at 5 and assume read and write. Since we heavily penalize providing a write interface for a read access request, this causes the return of a large distance (as I believe that it should). I'd like to find a long term home for the perm map file that increases it's likelihood of being updated with new permissions (Chris - what do you think of including this with reference policy?).
I'm fine with it, just as long as the output perm map file has a agreed-upon standard format. It looks like sepolgen has the same format as setools, so that probably won't be a problem (unless there are other tools with perm maps that I am unaware of).
Signature · 10 lines
Chris PeBenito Tresys Technology, LLC (410) 290-1411 x150 -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 56 lines · Karl MacMillan
Quoted 13 lines · Karl MacMillan
Quoted 12 lines · Daniel J Walsh
If you look at the interface
userdom_read_home_certs.[InterfaceVector
userdom_read_home_certs$1:source ] $1,home_cert_t,file,read,lock,getattr,open,ioctl $1,home_cert_t,dir,ioctl,search,read,lock,open,getattr $1,home_cert_t,lnk_file,read,getattr $1,home_root_t,dir,getattr,open,search $1,home_root_t,lnk_file,read,getattr $1,user_home_dir_t,dir,getattr,open,search $1,user_home_dir_t,lnk_file,read,getattrQuoted 7 lines
Quoted 3 lines
A domain that is allowed to search the homedir is always going to generate an AVC that is a long way off.
Seems to me that the problem is that the read / getattr on
user_home_dir_tdirectories and files is adding too much distance.I looked at this a bit more - there are a few interesting issues:
1. The open permissions have not been added to the
perm_mapfile (patch attached to fix that). When there is no perm map then we weight the permission at 5 and assume read and write. Since we heavily penalize providing a write interface for a read access request, this causes the return of a large distance (as I believe that it should). I'd like to find a long term home for the perm map file that increases it's likelihood of being updated with new permissions (Chris - what do you think of including this with reference policy?).2. As I mentioned, the weighting on things like reading a symlink or directory contents is fairly high. For this use I don't think that's appropriate - the attached perm map patch also reduces these pretty drastically.
3. The bulk of the rest of the distance comes from the unrelated type/object access. We get access to 4 type/object class pairs that aren't requested. Unfortunately there is no tracking of the notion of related access or scaling of the type penalty based upon how minor the related access is. Perhaps we should scale the type penalty with the permission weighting?
4. The final issue is that this interface is a bit broad for the requested access - requesting getattr for the cert files and getting read is a pretty significant bump. Once you resolve the
perm_mapissue then the distance is just over the threshold - which is about where I was aiming with this algorithm (go me). Now, the reality is likely that a read would come right after this getattr - if that had have been in the audit log all would be fine. Having said that, I'm not against making the threshold a little higher to return these (another patch attached).
Quoted 33 lines
Long term, I wonder if we should return interfaces above the threshold but commented out with a note explaining that the interface, while providing the requested access, is potentially dangerously broad. Dan, any chance you want to add that feature?
Karl
Quoted 26 lines
Quoted 3 lines
I thing we should either remove the bastards and just add all as childs, or recode it like the attachment.
I'm against removing the threshold altogether - if we do that then we'll get a match for almost everything including completely wrong interfaces. Can we start with tweaking either the perm weights or the distance calculation? For example, what happens when you drop the weight for dir read down to 5 or 1 and similar for
lnk_file(they are both 10 right now)? After that we might need to tweak the threshold.Also - I've been hacking on a patch to add in attribute access to the interface vectors. Any idea how much help we would get from that?
Karl
Quoted 9 lines
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/iEYEARECAAYFAkvMacAACgkQrlYvE4MpobNeAgCfcoVssEQJ8mfZT/aBvAt0z7+3 CoMAnR1bOcXk7x/jIZ+0i2Kc/faUJAVk
=Uuf7
-----END PGP SIGNATURE-----
Ok that works, but If we move to a more general case. or openvn_t getattr on etc_t
#============= openvpn_t ==============
# src="openvpn_t" tgt="etc_t" class="file", perms="getattr" # comm="openvpn" exe="" path=""
# Interface options:
# automount_exec_config(openvpn_t) # [51] # files_exec_etc_files(openvpn_t) # [51] # files_delete_etc_files(openvpn_t) # [118] # files_relabel_etc_files(openvpn_t) # [136] # files_rw_etc_files(openvpn_t) # [161] # files_read_etc_files(openvpn_t) # [171] # files_manage_etc_files(openvpn_t) # [179] # auth_use_nsswitch(openvpn_t) # [1342] # seutil_semanage_policy(openvpn_t) # [3489] # auth_login_pgm_domain(openvpn_t) # [3717] # portage_compile_domain(openvpn_t) # [4004]
I would have expected files_read_etc_files(openvpn_t) to be the closest/best match.
The tool is getting confused by attributes. Since attributes are not currently interpretable, they should be eliminated from the calculation. Best way to do this is just eliminate any types that don't end in a _t. -----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvPBdMACgkQrlYvE4MpobP9IQCePlmwSbiO94NTCiu1mHwUzdkI 8YsAn3tlgDQljeLLLhJmMaUGRHFkrBVp
=8OfI
-----END PGP SIGNATURE-----
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 19 lines · Daniel J Walsh
Ok that works, but If we move to a more general case. or
openvn_tgetattr onetc_t#=============
openvpn_t==============
# src="openvpn_t" tgt="etc_t" class="file", perms="getattr" # comm="openvpn" exe="" path=""
# Interface options:
#automount_exec_config(openvpn_t)# [51]
#files_exec_etc_files(openvpn_t)# [51]
#files_delete_etc_files(openvpn_t)# [118]
#files_relabel_etc_files(openvpn_t)# [136]
#files_rw_etc_files(openvpn_t)# [161]
#files_read_etc_files(openvpn_t)# [171]
#files_manage_etc_files(openvpn_t)# [179]
#auth_use_nsswitch(openvpn_t)# [1342]
#seutil_semanage_policy(openvpn_t)# [3489]
#auth_login_pgm_domain(openvpn_t)# [3717]
#portage_compile_domain(openvpn_t)# [4004]
Quoted 3 lines
I would have expected
files_read_etc_files(openvpn_t)to be the closest/best match.
Can you send me the audit messages for this?
Quoted 3 lines
The tool is getting confused by attributes. Since attributes are not currently interpretable, they should be eliminated from the calculation. Best way to do this is just eliminate any types that don't end in a _t.
I'm not certain what you mean by this - confused in what way? The only thing I know about is the lack of typattribute statements. The attached patch adds attribute handling to sepolgen. It's only lightly tested but I wanted you to get it sooner rather than later.
Karl
Quoted 9 lines
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/iEYEARECAAYFAkvPBdMACgkQrlYvE4MpobP9IQCePlmwSbiO94NTCiu1mHwUzdkI 8YsAn3tlgDQljeLLLhJmMaUGRHFkrBVp
=8OfI
-----END PGP SIGNATURE-----
Quoted 5 lines
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
From 6192cbf8ea0e7bf7e7fb9e1857f2da781fb378fc Mon Sep 17 00:00:00 2001
From: Karl MacMillan <[email protected]>
Date: Wed, 21 Apr 2010 21:16:26 -0400
Subject: [PATCH] Add attribute handling to sepolgen.
Sepolgen currently cannot resolve typeattribute statements in interfaces, meaning that much of the access allowed by some attributes is missed. This patch adds a helper application to extract attribute access from the current binary policy file, changes sepolgen-ifgen to use that helper, and changes the core code to add in the access from those tools.
I also move sepolgen-ifgen to its own directory under policycoreutils.
--- policycoreutils/Makefile | 2 +- policycoreutils/audit2allow/Makefile | 1 - policycoreutils/audit2allow/sepolgen-ifgen | 89 -------- policycoreutils/sepolgen-ifgen/Makefile | 26 +++ policycoreutils/sepolgen-ifgen/sepolgen-ifgen | 126 +++++++++++ .../sepolgen-ifgen/sepolgen-ifgen-attr-helper.c | 230 ++++++++++++++++++++ sepolgen/src/sepolgen/defaults.py | 3 + sepolgen/src/sepolgen/interfaces.py | 72 ++++++- 8 files changed, 450 insertions(+), 99 deletions(-) delete mode 100644 policycoreutils/audit2allow/sepolgen-ifgen create mode 100644 policycoreutils/sepolgen-ifgen/Makefile create mode 100644 policycoreutils/sepolgen-ifgen/sepolgen-ifgen create mode 100644 policycoreutils/sepolgen-ifgen/sepolgen-ifgen-attr-helper.c
policycoreutils/Makefile +1 -1
@@ -1,4 +1,4 @@ -SUBDIRS = setfiles semanage load_policy newrole run_init secon audit2allow audit2why scripts sestatus semodule_package semodule semodule_link semodule_expand semodule_deps setsebool po +SUBDIRS = setfiles semanage load_policy newrole run_init secon audit2allow audit2why scripts sestatus semodule_package semodule semodule_link semodule_expand semodule_deps setsebool sepolgen-ifgen po INOTIFYH = $(shell ls /usr/include/sys/inotify.h 2>/dev/null)
policycoreutils/audit2allow/Makefile +0 -1
@@ -10,7 +10,6 @@ all: ; install: all -mkdir -p $(BINDIR) install -m 755 audit2allow $(BINDIR) - install -m 755 sepolgen-ifgen $(BINDIR) -mkdir -p $(MANDIR)/man1 install -m 644 audit2allow.1 $(MANDIR)/man1/
policycoreutils/audit2allow/sepolgen-ifgen deleted +0 -89
89 lines not on this page · raw message
policycoreutils/sepolgen-ifgen/Makefile new file +26 -0
@@ -0,0 +1,26 @@ +# Installation directories. +PREFIX ?= ${DESTDIR}/usr +BINDIR ?= $(PREFIX)/bin +LIBDIR ?= ${PREFIX}/lib +INCLUDEDIR ?= $(PREFIX)/include + +CFLAGS ?= -Wall -W +override CFLAGS += -I$(INCLUDEDIR) +LDLIBS = $(LIBDIR)/libsepol.a + +all: sepolgen-ifgen-attr-helper + +sepolgen-ifgen-attr-helper: sepolgen-ifgen-attr-helper.o + +install: all + -mkdir -p $(BINDIR) + install -m 755 sepolgen-ifgen $(BINDIR) + install -m 755 sepolgen-ifgen-attr-helper $(BINDIR) + +clean: + rm -f *~ *.o + +indent: + ../../scripts/Lindent $(wildcard *.[ch]) + +relabel: ;
policycoreutils/sepolgen-ifgen/sepolgen-ifgen new file +126 -0
126 lines not on this page · raw message
policycoreutils/sepolgen-ifgen/sepolgen-ifgen-attr-helper.c new file +230 -0
230 lines not on this page · raw message
sepolgen/src/sepolgen/defaults.py +3 -0
@@ -30,6 +30,9 @@ def perm_map(): def interface_info(): return data_dir() + "/interface_info" +def attribute_info(): + return data_dir() + "/attribute_info" + def refpolicy_devel(): return "/usr/share/selinux/devel"
sepolgen/src/sepolgen/interfaces.py +64 -8
109 lines not on this page · raw message
Signature · 1 line
1.6.6.1
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 30 lines · Karl MacMillan
Quoted 19 lines · Daniel J Walsh
Ok that works, but If we move to a more general case. or
openvn_tgetattr onetc_t#=============
openvpn_t==============
# src="openvpn_t" tgt="etc_t" class="file", perms="getattr" # comm="openvpn" exe="" path=""
# Interface options:# automount_exec_config(openvpn_t) # [51] # files_exec_etc_files(openvpn_t) # [51] # files_delete_etc_files(openvpn_t) # [118] # files_relabel_etc_files(openvpn_t) # [136] # files_rw_etc_files(openvpn_t) # [161] # files_read_etc_files(openvpn_t) # [171] # files_manage_etc_files(openvpn_t) # [179] # auth_use_nsswitch(openvpn_t) # [1342] # seutil_semanage_policy(openvpn_t) # [3489] # auth_login_pgm_domain(openvpn_t) # [3717] # portage_compile_domain(openvpn_t) # [4004]Quoted 3 lines
I would have expected
files_read_etc_files(openvpn_t)to be the closest/best match.Can you send me the audit messages for this?
Quoted 3 lines
The tool is getting confused by attributes. Since attributes are not currently interpretable, they should be eliminated from the calculation. Best way to do this is just eliminate any types that don't end in a _t.
Quoted 21 lines
I'm not certain what you mean by this - confused in what way? The only thing I know about is the lack of typattribute statements. The attached patch adds attribute handling to sepolgen. It's only lightly tested but I wanted you to get it sooner rather than later.
Karl
Quoted 14 lines
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/iEYEARECAAYFAkvPBdMACgkQrlYvE4MpobP9IQCePlmwSbiO94NTCiu1mHwUzdkI 8YsAn3tlgDQljeLLLhJmMaUGRHFkrBVp
=8OfI
-----END PGP SIGNATURE-------
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
First let me get rid of these ^M all over the patch.pwd
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvQSWwACgkQrlYvE4MpobPjqQCgkQAXldyncbGkD5KgOI49vVRQ b0sAoJ2wSfzsPELFd9efh4XRtKdBACR1
=Pkv1
-----END PGP SIGNATURE-----
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 2 lines · Daniel J Walsh
First let me get rid of these ^M all over the patch.pwd
Oops - I'll take care of that in the next patch.
Karl
Quoted 9 lines
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/iEYEARECAAYFAkvQSWwACgkQrlYvE4MpobPjqQCgkQAXldyncbGkD5KgOI49vVRQ b0sAoJ2wSfzsPELFd9efh4XRtKdBACR1
=Pkv1
-----END PGP SIGNATURE-----
Quoted 5 lines
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I have not fully examined this patch but I don't believe it will do what I need.
If I define an interface that ends up looking like this:
[InterfaceVector files_read_etc_files $1:source ] $1,configfile,dir,ioctl,search,read,lock,open,getattr $1,configfile,file,read,lock,getattr,open,ioctl $1,configfile,lnk_file,read,getattr
And have and avc that looks like this:
node=(removed) type=AVC msg=audit(1271587735.632:422): avc: denied { getattr } for pid=13239 comm="openvpn" path="/home/bbaetz/.pki/vpn01_cacert.pem" dev=dm-3 ino=565334 scontext=system_u:system_r:openvpn_t:s0 tcontext=unconfined_u:object_r:etc_t:s0 tclass=file
This will never match.
What we need is a way to expand out configfile into etc_t, or to realize that etc_t is a configfile.
The tool you added does not do the equivalent of
seinfo -aconfigfile -x
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvQUTwACgkQrlYvE4MpobMfWwCfbg6t/396jHWHCpasqosqf8Mw 7qkAoNiXMi8+RK5/4mBu8WbnGLvxlb7+
=EDEY
-----END PGP SIGNATURE-----
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 25 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1I have not fully examined this patch but I don't believe it will do what I need.
If I define an interface that ends up looking like this:
[InterfaceVector
files_read_etc_files$1:source ] $1,configfile,dir,ioctl,search,read,lock,open,getattr $1,configfile,file,read,lock,getattr,open,ioctl $1,configfile,lnk_file,read,getattrAnd have and avc that looks like this:
node=(removed) type=AVC msg=audit(1271587735.632:422): avc: denied { getattr } for pid=13239 comm="openvpn" path="/home/bbaetz/.pki/vpn01_cacert.pem" dev=dm-3 ino=565334 scontext=system_u:system_r:openvpn_t:s0 tcontext=unconfined_u:object_r:etc_t:s0 tclass=file
Quoted 8 lines
This will never match.
What we need is a way to expand out configfile into
etc_t, or to realize thatetc_tis a configfile.The tool you added does not do the equivalent of
seinfo -aconfigfile -x
No, it doesn't do that yet, but I'll get to that soon. Now that I have the infrastructure for digging through the binary policy for attribute information it won't be too hard.
Karl
Quoted 9 lines
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/iEYEARECAAYFAkvQUTwACgkQrlYvE4MpobMfWwCfbg6t/396jHWHCpasqosqf8Mw 7qkAoNiXMi8+RK5/4mBu8WbnGLvxlb7+
=EDEY
-----END PGP SIGNATURE-----
Quoted 5 lines
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 31 lines · Karl MacMillan
Quoted 30 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1I have not fully examined this patch but I don't believe it will do what I need.
If I define an interface that ends up looking like this:
[InterfaceVector
files_read_etc_files$1:source ] $1,configfile,dir,ioctl,search,read,lock,open,getattr $1,configfile,file,read,lock,getattr,open,ioctl $1,configfile,lnk_file,read,getattrAnd have and avc that looks like this:
node=(removed) type=AVC msg=audit(1271587735.632:422): avc: denied { getattr } for pid=13239 comm="openvpn" path="/home/bbaetz/.pki/vpn01_cacert.pem" dev=dm-3 ino=565334 scontext=system_u:system_r:openvpn_t:s0 tcontext=unconfined_u:object_r:etc_t:s0 tclass=file
This will never match.
What we need is a way to expand out configfile into
etc_t, or to realize thatetc_tis a configfile.
Quoted 8 lines
Quoted 3 lines
The tool you added does not do the equivalent of
seinfo -aconfigfile -x
No, it doesn't do that yet, but I'll get to that soon. Now that I have the infrastructure for digging through the binary policy for attribute information it won't be too hard.
So it wasn't hard - I built a version that gets all of the attributes out of the binary policy and expands them in the interfaces. Running your denial now gives:
#============= openvpn_t ==============
# audit(1271587735.632:422):
# scontext="system_u:system_r:openvpn_t:s0"
tcontext="unconfined_u:object_r:etc_t:s0"
# class="file" perms="getattr"
# comm="openvpn" exe="" path=""
# message=" node=(removed) type=AVC msg=audit(1271587735.632:422): avc: denied
# { getattr } for pid=13239 comm="openvpn"
# path="/home/bbaetz/.pki/vpn01_cacert.pem" dev=dm-3 ino=565334
# scontext=system_u:system_r:openvpn_t:s0
# tcontext=unconfined_u:object_r:etc_t:s0 tclass=file "
# Interface options:
# automount_exec_config(openvpn_t) # [51]
# files_exec_etc_files(openvpn_t) # [51]
# files_delete_etc_files(openvpn_t) # [118]
# files_relabel_etc_files(openvpn_t) # [136]
# files_rw_etc_files(openvpn_t) # [161]
# files_manage_etc_files(openvpn_t) # [179]
# files_read_etc_files(openvpn_t) # [1702]
# auth_use_nsswitch(openvpn_t) # [2893]
# auth_login_pgm_domain(openvpn_t) # [32016]
# seutil_semanage_policy(openvpn_t) # [41089]
# portage_compile_domain(openvpn_t) # [59755]automount_exec_config(openvpn_t)
I was surprised by the 1702 distance for files_read_etc_files, but because of calling files_read_config_files and the configfile attribute this interface now allows access to ~60 additional types. So the distance calculation here is right I think (Chris mentioned that the upstream refpol does not have this interface call in files_read_config_files).
So I'm at a loss for what to do here. Adding the attribute expansion for rules makes audit2allow _very_ slow and it seems that it will only allow us to match very broad interfaces. I'm not convinced we really want that. Eventually it might be nice to notice that we got denials for many types and coalesce those into one broad interface call, but that will be hard (I do some of that already but this case would be harder) and doesn't seem worth it.
What do you think? Any chance you can just revert your change to files_read_etc_files?
Karl
Quoted 17 lines
Karl
Quoted 14 lines
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/iEYEARECAAYFAkvQUTwACgkQrlYvE4MpobMfWwCfbg6t/396jHWHCpasqosqf8Mw 7qkAoNiXMi8+RK5/4mBu8WbnGLvxlb7+
=EDEY
-----END PGP SIGNATURE-------
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I do not totally understand your matching, but I thought if you looked for
allow TYPE etc_t:file getattr;
You could get extra matches.
I was thinking in terms of sepolgen-ifgen would take every type and expand the attributes for the type then if you find attribute that matches, not add weight.
seinfo -tetc_t -x
etc_t
file_type
non_security_file_type
configfile
If my target was etc_t then I would get the same weight as if I substituted the attrbute with etc_t.
[InterfaceVector files_read_etc_files $1:source ] $1,etc_t,file,read,lock,getattr,open,ioctl $1,etc_t,dir,ioctl,search,read,lock,open,getattr $1,etc_t,lnk_file,read,getattr $1,configfile,dir,ioctl,search,read,lock,open,getattr $1,configfile,file,read,lock,getattr,open,ioctl $1,configfile,lnk_file,read,getattr
Would get translated at
[InterfaceVector files_read_etc_files $1:source ]
$1,etc_t,file,read,lock,getattr,open,ioctl
$1,etc_t,dir,ioctl,search,read,lock,open,getattr
$1,etc_t,lnk_file,read,getattr
$1,etc_t,dir,ioctl,search,read,lock,open,getattr
$1,etc_t,file,read,lock,getattr,open,ioctl
$1,etc_t,lnk_file,read,getattr
If I am looking for a target of etc_t
Which would then get boiled down to.
[InterfaceVector files_read_etc_files $1:source ]
$1,etc_t,file,read,lock,getattr,open,ioctl
$1,etc_t,dir,ioctl,search,read,lock,open,getattr
$1,etc_t,lnk_file,read,getattr
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvRuEMACgkQrlYvE4MpobPKzwCg3T0NUD5u1dQV6DmFHmPd22V1 uqYAnj/ytX750LXS6Um5izsloK4jhO7w
=oSpR
-----END PGP SIGNATURE-----
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 9 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1I do not totally understand your matching, but I thought if you looked for
allow TYPE etc_t:file getattr;
You could get extra matches.
That's essentially what I do.
Quoted 4 lines
I was thinking in terms of sepolgen-ifgen would take every type and expand the attributes for the type then if you find attribute that matches, not add weight.
I think you are missing what the core problem is - it's easy to find interfaces that match this access. Many interfaces (including files_read_etc_files) include a rule that directly matches getattr on etc_t files. So I don't really need to do attribute expansion to get enough matches.
The key problem is finding the _best_ match, which I define as the interface that allows the requested access with the least amount of "extra" access. That's what the distance measure is for - it is a measure of extra access. So I add extra distance for access to unrelated types, extra permissions, returning a write interface when a read was requested, etc. So when you add access to a broad attribute in files_read_etc_files the distance measure - as currently shipped - adds more distance for 1 type (the attribute). However, when I expand the attribute the distance goes up because it becomes clear that the interface is in fact allowing a _lot_ of access.
This seems correct to me, hence my request to return what was intended to be a narrow interface back to that narrow definition.
However, there are some things that I can do to make this distance algorithm better:
1. Don't penalize as much for access that involves container object classes, such as directory, in an attempt to not penalize for access that is actually related.
2. Detect execute and add a big penalty for interfaces that allow execute when it wasn't requested (similar to what I do with write).
I'm also open to other suggestions. I don't think that what I have is perfect. However, none of this will fix the fact that the files_read_etc_files shipped in Fedora grants broad access. If everyone agrees that we want that interface to match regardless then I think we are going to have to add some other mechanism to the matching algorithm. Perhaps some "hinting" mechanism to let the policy author to tell sepolgen to prefer certain interfaces. I might even be able to automatically derive this from how popular the interface is in current policies.
Karl
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 58 lines · Karl MacMillan
Quoted 9 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1I do not totally understand your matching, but I thought if you looked for
allow TYPE etc_t:file getattr;
You could get extra matches.
That's essentially what I do.
Quoted 4 lines
I was thinking in terms of sepolgen-ifgen would take every type and expand the attributes for the type then if you find attribute that matches, not add weight.
I think you are missing what the core problem is - it's easy to find interfaces that match this access. Many interfaces (including
files_read_etc_files) include a rule that directly matches getattr onetc_tfiles. So I don't really need to do attribute expansion to get enough matches.The key problem is finding the _best_ match, which I define as the interface that allows the requested access with the least amount of "extra" access. That's what the distance measure is for - it is a measure of extra access. So I add extra distance for access to unrelated types, extra permissions, returning a write interface when a read was requested, etc. So when you add access to a broad attribute in
files_read_etc_filesthe distance measure - as currently shipped - adds more distance for 1 type (the attribute). However, when I expand the attribute the distance goes up because it becomes clear that the interface is in fact allowing a _lot_ of access.This seems correct to me, hence my request to return what was intended to be a narrow interface back to that narrow definition.
However, there are some things that I can do to make this distance algorithm better:
1. Don't penalize as much for access that involves container object classes, such as directory, in an attempt to not penalize for access that is actually related.
2. Detect execute and add a big penalty for interfaces that allow execute when it wasn't requested (similar to what I do with write).
I'm also open to other suggestions. I don't think that what I have is perfect. However, none of this will fix the fact that the
files_read_etc_filesshipped in Fedora grants broad access. If everyone agrees that we want that interface to match regardless then I think we are going to have to add some other mechanism to the matching algorithm. Perhaps some "hinting" mechanism to let the policy author to tell sepolgen to prefer certain interfaces. I might even be able to automatically derive this from how popular the interface is in current policies.
Quoted 1 line
Karl
I understand, although I don't agree with penalizying because you match
on an attribute, Currently if I wrote this interface the way I want,
with just the attribute your algorithm would not find it at all.
files_read_etc_files to me means match all config files in the /etc directory, just because some random application decides to change the context of /etc/hostname to etc_runtime_t or net_conf_t, we should not need to change all domains that are supposed to read generic files in /etc. Especially when I don't even need to read them.
I would argue that
allow X etc_t:file read;
allow X configfile:file read;
Should be weighted equivalently if etc_t is a configfile or only slightly heavier, and just because etc_runtime_t or some other random types are configfile does not mean we need to add weight.
But when the attribute adds more weight then "write" does, I think the algorithm is broken.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvYVZEACgkQrlYvE4MpobPf6QCfY6wAi3VqF9s3do7QwAoQ8UrA PZwAoN5L0WvquabGFHNfINoJq4MkOy8S
=l2u0
-----END PGP SIGNATURE-----
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 62 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 58 lines · Karl MacMillan
Quoted 9 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1I do not totally understand your matching, but I thought if you looked for
allow TYPE etc_t:file getattr;
You could get extra matches.
That's essentially what I do.
Quoted 4 lines
I was thinking in terms of sepolgen-ifgen would take every type and expand the attributes for the type then if you find attribute that matches, not add weight.
I think you are missing what the core problem is - it's easy to find interfaces that match this access. Many interfaces (including
files_read_etc_files) include a rule that directly matches getattr onetc_tfiles. So I don't really need to do attribute expansion to get enough matches.The key problem is finding the _best_ match, which I define as the interface that allows the requested access with the least amount of "extra" access. That's what the distance measure is for - it is a measure of extra access. So I add extra distance for access to unrelated types, extra permissions, returning a write interface when a read was requested, etc. So when you add access to a broad attribute in
files_read_etc_filesthe distance measure - as currently shipped - adds more distance for 1 type (the attribute). However, when I expand the attribute the distance goes up because it becomes clear that the interface is in fact allowing a _lot_ of access.This seems correct to me, hence my request to return what was intended to be a narrow interface back to that narrow definition.
However, there are some things that I can do to make this distance algorithm better:
1. Don't penalize as much for access that involves container object classes, such as directory, in an attempt to not penalize for access that is actually related.
2. Detect execute and add a big penalty for interfaces that allow execute when it wasn't requested (similar to what I do with write).
I'm also open to other suggestions. I don't think that what I have is perfect. However, none of this will fix the fact that the
files_read_etc_filesshipped in Fedora grants broad access. If everyone agrees that we want that interface to match regardless then I think we are going to have to add some other mechanism to the matching algorithm. Perhaps some "hinting" mechanism to let the policy author to tell sepolgen to prefer certain interfaces. I might even be able to automatically derive this from how popular the interface is in current policies.
Quoted 6 lines
Quoted 1 line
Karl
I understand, although I don't agree with penalizying because you match on an attribute, Currently if I wrote this interface the way I want, with just the attribute your algorithm would not find it at all.
I'm not penalizing because it's an attribute, it's just that the penalty is for every extra type so attributes are going to tend to add a lot of weight.
Quoted 7 lines
files_read_etc_filesto me means match all config files in the /etc directory, just because some random application decides to change the context of/etc/hostnametoetc_runtime_tornet_conf_t, we should not need to change all domains that are supposed to read generic files in /etc. Especially when I don't even need to read them.
Quoted 9 lines
I would argue that
allow X etc_t:file read;
allow X configfile:file read;Should be weighted equivalently if
etc_tis a configfile or only slightly heavier, and just becauseetc_runtime_tor some other random types are configfile does not mean we need to add weight.
This seems like mostly a policy design question and I'd be curious to hear what others think as well. I agree that broad read access to configuration files is not much of a risk for general Linux systems. However, if I change the weighting algorithm to not worry about broad read access my concern is for matching interfaces that allow broad read access to files when the concern is confidentiality. Currently there is no clear way to infer security goals beyond read, write, and maybe exec so there is no way to categorize types as mainly for integrity vs. confidentiality.
Thoughts? What about creating some hints based upon attributes? Or what about favoring the most commonly used interfaces?
Quoted 2 lines
But when the attribute adds more weight then "write" does, I think the algorithm is broken.
I can certainly try to greatly reduce the weighting from extraneous types and increase the weighting for write or execute vs. read. I'll try to experiment a bit and see what I can come up with.
What would really help me the most is if you could start collecting audit messages that give both good and bad results from audit2allow. I need some well known test cases to tune the weighting algorithm.
Karl
Quoted 9 lines
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/iEYEARECAAYFAkvYVZEACgkQrlYvE4MpobPf6QCfY6wAi3VqF9s3do7QwAoQ8UrA PZwAoN5L0WvquabGFHNfINoJq4MkOy8S
=l2u0
-----END PGP SIGNATURE-----
Quoted 5 lines
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 1 line · Karl MacMillan
On Wed, Apr 28, 2010 at 11:34 AM, Daniel J Walsh<[email protected]> wrote:
<snip>>
Quoted 10 lines
Quoted 9 lines
I would argue that
allow X etc_t:file read;
allow X configfile:file read;Should be weighted equivalently if
etc_tis a configfile or only slightly heavier, and just becauseetc_runtime_tor some other random types are configfile does not mean we need to add weight.
I'm going to weigh in here even though policy isn't normally my thing.
I am very against reducing distance based on attribute match over individual unrelated types. allow X configfile:file read should be the exact same distance as having an allow rule for every type in configfile in the interface, otherwise you have inconsistent behavior and are rewarding interfaces that are overly broad.
The reason for using sepolgen is to find the best match, not the most broad, if we wanted that we could make sepolgen 1000% less complicated and just return allow domain filetype:file *;
I suppose there is a fundamental difference in the use of the tool, the people I know that use it use it to find the best match, the way you want to use it is to fix the denial any way possible. These 2 usages conflict and we can't have people thinking they are making secure policy when in fact they aren't.
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 15 lines · Joshua Brindle
Quoted 2 lines · Karl MacMillan
On Wed, Apr 28, 2010 at 11:34 AM, Daniel J Walsh<[email protected]> wrote:
<snip>>
Quoted 10 lines
Quoted 9 lines
I would argue that
allow X etc_t:file read;
allow X configfile:file read;Should be weighted equivalently if
etc_tis a configfile or only slightly heavier, and just becauseetc_runtime_tor some other random types are configfile does not mean we need to add weight.
Quoted 8 lines
I'm going to weigh in here even though policy isn't normally my thing.
I am very against reducing distance based on attribute match over individual unrelated types. allow X configfile:file read should be the exact same distance as having an allow rule for every type in configfile in the interface, otherwise you have inconsistent behavior and are rewarding interfaces that are overly broad.
I agree but the question is on an AVC that needs
allow $1 etc_t:file read;
Which is a better match
allow $1 configfile:file read;
Or
allow $1 etc_t:file { read write };
Quoted 10 lines
The reason for using sepolgen is to find the best match, not the most broad, if we wanted that we could make sepolgen 1000% less complicated and just return allow domain filetype:file *;
I suppose there is a fundamental difference in the use of the tool, the people I know that use it use it to find the best match, the way you want to use it is to fix the denial any way possible. These 2 usages conflict and we can't have people thinking they are making secure policy when in fact they aren't.
Thats Bullshit. I am trying to get the best match. The example I showed earlier the tool was getting way off, because it did not take into effect attributes. The access returned for a getattr was to allow the domain to delete the file.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvYgBAACgkQrlYvE4MpobNo3ACeIkGbGm9mWWUaAVPkA8B64YTS zMkAn3PhjVrB1cw0jSIZo7bUmmcK58e+
=A6kc
-----END PGP SIGNATURE-----
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 49 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 13 lines · Joshua Brindle
Quoted 2 lines · Karl MacMillan
On Wed, Apr 28, 2010 at 11:34 AM, Daniel J Walsh<[email protected]> wrote:
<snip>>
Quoted 9 lines
Quoted 9 lines
I would argue that
allow X etc_t:file read;
allow X configfile:file read;Should be weighted equivalently if
etc_tis a configfile or only slightly heavier, and just becauseetc_runtime_tor some other random types are configfile does not mean we need to add weight.Quoted 8 lines
I'm going to weigh in here even though policy isn't normally my thing.
I am very against reducing distance based on attribute match over individual unrelated types. allow X configfile:file read should be the exact same distance as having an allow rule for every type in configfile in the interface, otherwise you have inconsistent behavior and are rewarding interfaces that are overly broad.
I agree but the question is on an AVC that needs
allow $1 etc_t:file read;
Which is a better match
allow $1 configfile:file read;
Or
allow $1 etc_t:file { read write };
Quoted 10 lines
The reason for using sepolgen is to find the best match, not the most broad, if we wanted that we could make sepolgen 1000% less complicated and just return allow domain filetype:file *;
I suppose there is a fundamental difference in the use of the tool, the people I know that use it use it to find the best match, the way you want to use it is to fix the denial any way possible. These 2 usages conflict and we can't have people thinking they are making secure policy when in fact they aren't.
Quoted 5 lines
Thats Bullshit. I am trying to get the best match. The example I showed earlier the tool was getting way off, because it did not take into effect attributes. The access returned for a getattr was to allow the domain to delete the file.
Fair enough. It seems like it would work as expected if interfaces were relatively side effect free though (eg., files_read_etc_files shouldn't have the side effect of reading all config files, perhaps a new interface called files_read_config_files should be used instead).
I guess the big problem is that without looking at the interface (and unraveling all the interface calls within) the user can't actually determine what the matched interfaces do.
I agree with Karl about penalizing exec and delete though, even though exec really isn't necessary to execute something, all you need is read access.
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 61 lines · Joshua Brindle
Quoted 49 lines · Daniel J Walsh
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 13 lines · Joshua Brindle
Quoted 2 lines · Karl MacMillan
On Wed, Apr 28, 2010 at 11:34 AM, Daniel J Walsh<[email protected]> wrote:
<snip>>
Quoted 9 lines
Quoted 9 lines
I would argue that
allow X etc_t:file read;
allow X configfile:file read;Should be weighted equivalently if
etc_tis a configfile or only slightly heavier, and just becauseetc_runtime_tor some other random types are configfile does not mean we need to add weight.Quoted 8 lines
I'm going to weigh in here even though policy isn't normally my thing.
I am very against reducing distance based on attribute match over individual unrelated types. allow X configfile:file read should be the exact same distance as having an allow rule for every type in configfile in the interface, otherwise you have inconsistent behavior and are rewarding interfaces that are overly broad.
I agree but the question is on an AVC that needs
allow $1 etc_t:file read;
Which is a better match
allow $1 configfile:file read;
Or
allow $1 etc_t:file { read write };
Quoted 10 lines
The reason for using sepolgen is to find the best match, not the most broad, if we wanted that we could make sepolgen 1000% less complicated and just return allow domain filetype:file *;
I suppose there is a fundamental difference in the use of the tool, the people I know that use it use it to find the best match, the way you want to use it is to fix the denial any way possible. These 2 usages conflict and we can't have people thinking they are making secure policy when in fact they aren't.
Quoted 5 lines
Thats Bullshit. I am trying to get the best match. The example I showed earlier the tool was getting way off, because it did not take into effect attributes. The access returned for a getattr was to allow the domain to delete the file.
Fair enough. It seems like it would work as expected if interfaces were relatively side effect free though (eg.,
files_read_etc_filesshouldn't have the side effect of reading all config files, perhaps a new interface calledfiles_read_config_filesshould be used instead).
Quoted 13 lines
I guess the big problem is that without looking at the interface (and unraveling all the interface calls within) the user can't actually determine what the matched interfaces do.
I agree with Karl about penalizing exec and delete though, even though exec really isn't necessary to execute something, all you need is read access.
Signature · 4 lines
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
I think the best solution is to start expanding attributes so we at least have a chance at a match, without changing the weighting.
Secondly would be to start collecting oddball returns by the tool and sending them to Karl.
I just tried a few and they came up with the correct interface. Lets ask dgrift, mgrepl, Chris and other prolific policy writers to use this tool to see if the interface matches are working for them. The problem is people who write enough policy, tend to know which interface to use, so they do not necessarily use audit2allow -R.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvYhhcACgkQrlYvE4MpobMYjgCffoR0aerRBPvKu7BsvD1cZRxi k30AoOqKOQsiZH6BPBY77Oxq9wEY6PRC
=dTwd
-----END PGP SIGNATURE-----
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 30 lines · Joshua Brindle
Quoted 3 lines · Karl MacMillan
On Wed, Apr 28, 2010 at 11:34 AM, Daniel J Walsh<[email protected]> wrote:
<snip>>
Quoted 11 lines
Quoted 10 lines
I would argue that
allow X etc_t:file read;
allow X configfile:file read;Should be weighted equivalently if
etc_tis a configfile or only slightly heavier, and just becauseetc_runtime_tor some other random types are configfile does not mean we need to add weight.I'm going to weigh in here even though policy isn't normally my thing.
I am very against reducing distance based on attribute match over individual unrelated types. allow X configfile:file read should be the exact same distance as having an allow rule for every type in configfile in the interface, otherwise you have inconsistent behavior and are rewarding interfaces that are overly broad.
The reason for using sepolgen is to find the best match, not the most broad, if we wanted that we could make sepolgen 1000% less complicated and just return allow domain filetype:file *;
Quoted 6 lines
I suppose there is a fundamental difference in the use of the tool, the people I know that use it use it to find the best match, the way you want to use it is to fix the denial any way possible. These 2 usages conflict and we can't have people thinking they are making secure policy when in fact they aren't.
While I'm concerned about providing secure options as well, to characterize Dan's current position as fixing the denial in any way possible is not fair either. Here are the current matches in order:
# Interface options:
# automount_exec_config(openvpn_t) # [51] # files_exec_etc_files(openvpn_t) # [51] # files_delete_etc_files(openvpn_t) # [118] # files_relabel_etc_files(openvpn_t) # [136] # files_rw_etc_files(openvpn_t) # [161] # files_read_etc_files(openvpn_t) # [171] # files_manage_etc_files(openvpn_t) # [179] # auth_use_nsswitch(openvpn_t) # [1362] # seutil_semanage_policy(openvpn_t) # [3532] # auth_login_pgm_domain(openvpn_t) # [3736] # portage_compile_domain(openvpn_t) # [3902]
Something is clearly wrong - largely because I'm not distinguishing between exec, delete, relabel, and read/write.
Karl
Quoted 7 lines
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 04/28/2010 10:25 AM, Karl MacMillan wrote:
I understand, although I don't agree with penalizying because you match
on an attribute, Currently if I wrote this interface the way I want,
with just the attribute your algorithm would not find it at all.
files_read_etc_files to me means match all config files in the /etc directory, just because some random application decides to change the context of /etc/hostname to etc_runtime_t or net_conf_t, we should not need to change all domains that are supposed to read generic files in /etc. Especially when I don't even need to read them.
I would argue that
allow X etc_t:file read;
allow X configfile:file read;
Should be weighted equivalently if etc_t is a configfile or only slightly heavier, and just because etc_runtime_t or some other random types are configfile does not mean we need to add weight.
But when the attribute adds more weight then "write" does, I think the algorithm is broken.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvYVY4ACgkQrlYvE4MpobOKSgCgguxc5xhYFpW1GGSnN4N+6v/Z qUsAoOjz7qSp8kiDHBUN2SYoKWsZfTNK
=Ubgb
-----END PGP SIGNATURE-----
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 3 lines · Karl MacMillan
The
attached patch adds attribute handling to sepolgen. It's only lightly tested but I wanted you to get it sooner rather than later.
Evidently this patch has made its way into F-13 and RHEL-6, although it is still not upstream.
Some concerns/questions:
- This creates a dependency of sepolgen-ifgen on a specific policy. Previously it was only dependent on the headers. But this will mean that the data generated by sepolgen-ifgen and used by sepolgen could easily differ for targeted vs mls even if they use the same headers. Do we need per-policy data directories for sepolgen?
- It should be possible to load a specified policy file rather than always using the active one.
- You are using the latest policy version supported by the kernel rather than the one supported by libsepol. See audit2why.c or load_policy.c in libselinux to see how they determine the right policy version to use by default. Otherwise this will break when we have divergence between the libsepol and kernel supported policy versions (i.e. whenever we next introduce a new policy version).
- This creates another user of the static libsepol.
Signature · 8 lines
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 [email protected] with the words "unsubscribe selinux" without quotes as the message.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 37 lines · Daniel J Walsh
The reason for this is threshold, setting. I think the interfaces are getting more complicated and one AVC that is looking for read ends up being two far different from the threshold, so audit2allow does not report it.
For example.
node=(removed) type=AVC msg=audit(1271587735.632:422): avc: denied { getattr } for pid=13239 comm="openvpn" path="/home/bbaetz/.pki/vpn01_cacert.pem" dev=dm-3 ino=565334 scontext=system_u:system_r:openvpn_t:s0 tcontext=unconfined_u:object_r:home_cert_t:s0 tclass=file
node=(removed) type=SYSCALL msg=audit(1271587735.632:422): arch=c000003e syscall=5 success=yes exit=0 a0=6 a1=7fffd84f4a20 a2=7fffd84f4a20 a3=18 items=0 ppid=13235 pid=13239 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="openvpn" exe="/usr/sbin/openvpn" subj=system_u:system_r:openvpn_t:s0 key=(null)
Finds
userdom_read_home_certsbut it's threshold is two far off, so it reports nothing.I think we should either eliminate the threshold and report the best interface that we have, and let the policy writer decide if he wants the match.
If you look at the interface
userdom_read_home_certs.[InterfaceVector
userdom_read_home_certs$1:source ] $1,home_cert_t,file,read,lock,getattr,open,ioctl $1,home_cert_t,dir,ioctl,search,read,lock,open,getattr $1,home_cert_t,lnk_file,read,getattr $1,home_root_t,dir,getattr,open,search $1,home_root_t,lnk_file,read,getattr $1,user_home_dir_t,dir,getattr,open,search $1,user_home_dir_t,lnk_file,read,getattr
Quoted 6 lines
A domain that is allowed to search the homedir is always going to generate an AVC that is a long way off.
I thing we should either remove the bastards and just add all as childs, or recode it like the attachment.
I tried that but we got down to,
# userdom_read_home_certs(openvpn_t) # [283]
Which is still way higher then 120.
Isn't the problem that openvpn_t has
1# sesearch -A -s openvpn_t -t home_root_t
Found 2 semantic av rules:
allow openvpn_t home_root_t : dir { getattr search open } ; allow openvpn_t home_root_t : lnk_file { read getattr } ;
- -bash-4.1# sesearch -A -s openvpn_t -t user_home_dir_t Found 1 semantic av rules:
allow openvpn_t user_home_dir_t : dir { ioctl read getattr lock
search open } ;
But these count towards the total?
Should we be checking in the policy what access is already present in the domain, to make a better decision. Or would this end up taking to long. -----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/
iEYEARECAAYFAkvNvkYACgkQrlYvE4MpobPVGQCfZEeAd1f7424uWXrJGbiUDyPZ Z5UAn1k60lKjKJxZtq5d6ON51iKMvda2
=2SYZ
-----END PGP SIGNATURE-----
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.