diff options
author | Yuli Khodorkovskiy <ykhodo@gmail.com> | 2018-03-29 17:16:41 -0700 |
---|---|---|
committer | William Roberts <william.c.roberts@intel.com> | 2018-04-04 11:09:11 -0500 |
commit | 814631d3aebaa041073a42c677c1ed62ce7830d5 (patch) | |
tree | f092806461d7ed1ed388bea94a1e953476d7ac9a /libselinux/src/label_internal.h | |
parent | 4ba19b541d066d9b0aa104deefc093f468d3d8a2 (diff) | |
download | android_external_selinux-814631d3aebaa041073a42c677c1ed62ce7830d5.tar.gz android_external_selinux-814631d3aebaa041073a42c677c1ed62ce7830d5.tar.bz2 android_external_selinux-814631d3aebaa041073a42c677c1ed62ce7830d5.zip |
libselinux: verify file_contexts when using restorecon
In permissive mode, calling restorecon with a bad label in file_contexts
does not verify the label's existence in the loaded policy. This
results in any label successfully applying to a file, as long as the
file exists.
This issue has two assumptions:
1) file_contexts must be manually updated with the invalid label.
Running `semanage fcontext` will error when attempting to add
an invalid label to file_contexts.
2) the system must be in permissive. Although applying an invalid label
in enforcing gives an error and fails, successfully labeling a file with a
bad label could cause issues during policy development in permissive.
Instead, as each context is used, verify it is valid before blindly
applying the label. If an error with validation occurs in restorecon,
application of remaining valid labels will be uninterrupted as before.
Signed-off-by: Yuli Khodorkovskiy <ykhodo@gmail.com>
Diffstat (limited to 'libselinux/src/label_internal.h')
-rw-r--r-- | libselinux/src/label_internal.h | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/libselinux/src/label_internal.h b/libselinux/src/label_internal.h index c55efb75..75451858 100644 --- a/libselinux/src/label_internal.h +++ b/libselinux/src/label_internal.h @@ -111,8 +111,7 @@ struct selabel_handle { * Validation function */ extern int -selabel_validate(struct selabel_handle *rec, - struct selabel_lookup_rec *contexts) hidden; +selabel_validate(struct selabel_lookup_rec *contexts) hidden; /* * Compatibility support @@ -127,8 +126,7 @@ extern void __attribute__ ((format(printf, 1, 2))) selinux_log(type, fmt); extern int -compat_validate(struct selabel_handle *rec, - struct selabel_lookup_rec *contexts, +compat_validate(struct selabel_lookup_rec *contexts, const char *path, unsigned lineno) hidden; /* |