sepolicy-generate: Handle more reserved port types
PATCH 1/1 sepolicy-generate: Handle more reserved port types
Currently only reserved_port_t, port_t and hi_reserved_port_t are handled as special when making a ports-dictionary. However, as fas as corenetwork.te.in of serefpolicy, both unreserved_port_t and ephemeral_port_t also handled in the same way.
--- policycoreutils/sepolicy/sepolicy/generate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
policycoreutils/sepolicy/sepolicy/generate.py +3 -1
@@ -90,7 +90,9 @@ def get_rpm_nvr_list(package): def get_all_ports(): dict = {} for p in sepolicy.info(sepolicy.PORT): - if p['type'] == "reserved_port_t" or \ + if p['type'] == "ephemeral_port_t" or \ + p['type'] == "unreserved_port_t" or \ + p['type'] == "reserved_port_t" or \ p['type'] == "port_t" or \ p['type'] == "hi_reserved_port_t": continue
Signature · 1 line
2.1.0
Quoted 17 lines · Masatake YAMATO
Currently only
reserved_port_t,port_tandhi_reserved_port_tare handled as special when making a ports-dictionary. However, as fas as corenetwork.te.in of serefpolicy, bothunreserved_port_tandephemeral_port_talso handled in the same way.Signed-off-by Masatake YAMATO <[email protected]>--- policycoreutils/sepolicy/sepolicy/generate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)policycoreutils/sepolicy/sepolicy/generate.py +0
-0
policycoreutils/sepolicy/sepolicy/generate.py def get_rpm_nvr_list(package): · line 98
Quoted 10 lines
policycoreutils/sepolicy/sepolicy/generate.py +3
-1@@ -90,7 +90,9 @@ def get_rpm_nvr_list(package): def get_all_ports(): dict = {} for p in sepolicy.info(sepolicy.PORT): - if p['type'] == "reserved_port_t" or \ + if p['type'] == "ephemeral_port_t" or \ + p['type'] == "unreserved_port_t" or \ + p['type'] == "reserved_port_t" or \ p['type'] == "port_t" or \ p['type'] == "hi_reserved_port_t": continue
Can you explain this a bit further? What is the difference in behavior for sepolicy generate after your change? Why do we want to treat these types differently? And is this change sufficient, or do we need to recognize and handle these cases elsewhere (e.g. I see some handling already in sepolicy/network.py for unreserved_port_t or unreserved_port_type but not for ephemeral)? Similarly, we have checking in semanage/seobject.py for reserved_port_t but not for these other types.
More broadly, it would be better if this list of types that requires special handling could itself be specified in policy so that we don't hardcode any knowledge of types in the tools.
Quoted 22 lines · Stephen Smalley
Quoted 21 lines · Masatake YAMATO
Currently only
reserved_port_t,port_tandhi_reserved_port_tare handled as special when making a ports-dictionary. However, as fas as corenetwork.te.in of serefpolicy, bothunreserved_port_tandephemeral_port_talso handled in the same way.Signed-off-by Masatake YAMATO <[email protected]>--- policycoreutils/sepolicy/sepolicy/generate.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)policycoreutils/sepolicy/sepolicy/generate.py +1
-1@@ -90,7 +90,9 @@ def get_rpm_nvr_list(package): def get_all_ports(): dict = {} for p in sepolicy.info(sepolicy.PORT): - if p['type'] == "reserved_port_t" or \ + if p['type'] == "ephemeral_port_t" or \
Quoted 8 lines
policycoreutils/sepolicy/sepolicy/generate.py def get_rpm_nvr_list(package): · line 98
Quoted 6 lines
policycoreutils/sepolicy/sepolicy/generate.py +2
-0+ p['type'] == "unreserved_port_t" or \ + p['type'] == "reserved_port_t" or \ p['type'] == "port_t" or \ p['type'] == "hi_reserved_port_t": continueCan you explain this a bit further? What is the difference in behavior
I found this is a distribution own issue; nothing to do with upstream code.
This is the corenetwork.te.in of the a distribution.
portcon tcp 512-1023 gen_context(system_u:object_r:hi_reserved_port_t, s0)
portcon udp 512-1023 gen_context(system_u:object_r:hi_reserved_port_t, s0)
portcon tcp 1-511 gen_context(system_u:object_r:reserved_port_t, s0)
portcon udp 1-511 gen_context(system_u:object_r:reserved_port_t, s0)
portcon tcp 1024-32767 gen_context(system_u:object_r:unreserved_port_t, s0)
portcon tcp 32768-61000 gen_context(system_u:object_r:ephemeral_port_t, s0)
portcon tcp 61001-65535 gen_context(system_u:object_r:unreserved_port_t, s0)
portcon udp 1024-32767 gen_context(system_u:object_r:unreserved_port_t, s0)
portcon udp 32768-61000 gen_context(system_u:object_r:ephemeral_port_t, s0)
portcon udp 61001-65535 gen_context(system_u:object_r:unreserved_port_t, s0)Let's forget my patch; and sorry for making noise.
Masatake YAMATO
Quoted 12 lines
for sepolicy generate after your change? Why do we want to treat these types differently? And is this change sufficient, or do we need to recognize and handle these cases elsewhere (e.g. I see some handling already in
sepolicy/network.pyforunreserved_port_torunreserved_port_typebut not for ephemeral)? Similarly, we have checking insemanage/seobject.pyforreserved_port_tbut not for these other types.More broadly, it would be better if this list of types that requires special handling could itself be specified in policy so that we don't hardcode any knowledge of types in the tools.