libsepol: restore basic validation for path/component names
Stephen Smalley
maintainerPATCH 1/1 libsepol: restore basic validation for path/component names
Commit 2360a8a12b99 ("libsepol: do not reject control characters in pathnames") dropped the validate_string_field() calls for path/component names because validate_string_field() prohibits control characters which are legal in pathnames. Commit 069ccd7a497b ("libsepol: validate genfs_seclabel_wildcard paths") restored basic validation for genfscon paths by checking that they are not NULL or the empty string as well as further validating that they end in a wildcard ("*") if the genfs_seclabel_wildcard policy capability is enabled. Restore basic validation for the other two path/component names to ensure that they also are not NULL or the empty string. Further path and component name validation is of course possible but if we added it, we would want to make it consistently enforced by the compiler frontends as well.
--- libsepol/src/policydb_validate.c | 4 ++++ 1 file changed, 4 insertions(+)
libsepol/src/policydb_validate.c +4 -0
@@ -1521,6 +1521,8 @@ static int validate_filename_trans(hashtab_key_t k, hashtab_datum_t d, goto bad;if (validate_value (ftk->tclass, &flavors[SYM_CLASSES ])) goto bad; +if (!ftk->name || !ftk->name[0 ]) + goto bad;if (!ftd) goto bad;for (; ftd; ftd = ftd->next) {
@@ -1880,6 +1882,8 @@ validate_filename_trans_rules(sepol_handle_t *handle, goto bad;if (validate_simpletype (filename_trans->otype, p, flavors)) goto bad; +if (!filename_trans->name || !filename_trans->name[0 ]) + goto bad;/* currently only the RULE_SELF flag can be set */ switch (filename_trans->flags) {
Signature · 1 line
2.55.0
Stephen Smalley
maintainerQuoted 15 lines · Stephen Smalley
Commit
2360a8a12b99("libsepol: do not reject control characters in pathnames") dropped thevalidate_string_field()calls for path/component names becausevalidate_string_field()prohibits control characters which are legal in pathnames. Commit069ccd7a497b("libsepol: validategenfs_seclabel_wildcardpaths") restored basic validation for genfscon paths by checking that they are not NULL or the empty string as well as further validating that they end in a wildcard ("*") if thegenfs_seclabel_wildcardpolicy capability is enabled. Restore basic validation for the other two path/component names to ensure that they also are not NULL or the empty string. Further path and component name validation is of course possible but if we added it, we would want to make it consistently enforced by the compiler frontends as well.
Quoted 1 line
Signed-off-by Stephen Smalley <[email protected]>
This has been merged.