selinux: tighten type validation during policy load
Stephen Smalley
maintainerPATCH v3 1/1 selinux: tighten type validation during policy load
Tighten type validation during policy load to improve robustness in the face of ill-formed policies.
---
v3 removes a spurious empty line leftover from one of the changes dropped due to Christian's patches and adds the word "type" to the error message for clarity.
security/selinux/ss/policydb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
security/selinux/ss/policydb.c +8 -3
@@ -604,10 +604,15 @@ static int type_index(void *key, void *datum, void *datap) typdatum = datum; p = datap; +if (!typdatum->value || typdatum->value > p->p_types.nprim || + typdatum->bounds > p->p_types.nprim) { +pr_err ("SELinux: type %s had value %u bounds %u nprim %u\n" , + (char *)key, typdatum->value, typdatum->bounds, + p->p_types.nprim); +return -EINVAL ; + } +if (typdatum->primary) { -if (!typdatum->value || typdatum->value > p->p_types.nprim || - typdatum->bounds > p->p_types.nprim) -return -EINVAL ; p->sym_val_to_name[SYM_TYPES ][typdatum->value -1 ] = key; p->type_val_to_struct[typdatum->value -1 ] = typdatum; }
Signature · 1 line
2.54.0
Stephen Smalley
maintainerQuoted 5 lines · Stephen Smalley
Tighten type validation during policy load to improve robustness in the face of ill-formed policies.
Signed-off-by Stephen Smalley <[email protected]>
Ping.
Quoted 34 lines
---
v3 removes a spurious empty line leftover from one of the changes dropped due to Christian's patches and adds the word "type" to the error message for clarity.security/selinux/ss/policydb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)security/selinux/ss/policydb.c +8
-4@@ -604,10 +604,15 @@ static int type_index(void *key, void *datum, void *datap) typdatum = datum; p = datap; +if (!typdatum->value || typdatum->value > p->p_types.nprim || + typdatum->bounds > p->p_types.nprim) { +pr_err ("SELinux: type %s had value %u bounds %u nprim %u\n" , + (char *)key, typdatum->value, typdatum->bounds, + p->p_types.nprim); +return -EINVAL ; + } +if (typdatum->primary) { -if (!typdatum->value || typdatum->value > p->p_types.nprim || - typdatum->bounds > p->p_types.nprim) -return -EINVAL ; p->sym_val_to_name[SYM_TYPES ][typdatum->value -1 ] = key; p->type_val_to_struct[typdatum->value -1 ] = typdatum; } --2.54.0
Paul Moore
maintainerQuoted 9 lines · Stephen Smalley
Quoted 5 lines · Stephen Smalley
Tighten type validation during policy load to improve robustness in the face of ill-formed policies.
Signed-off-by Stephen Smalley <[email protected]>Ping.
Pong.
Just a reminder that there are free things I dislike more than "ping" nudges. If your patch hit the lore archive and is visible in patchwork, it's on my list; if I haven't acted upon it yet it is simply because I've been busy with other higher priority things. Nudging patches like this simply steals and wastes time that could be better spent elsewhere.
There were a few of Christian's patches that weren't merged due to feedback and other concerns, but I need to go back and see if it is preferable to fixup and merge those before looking at other patches. Maybe this is good regardless, we'll see.
--
paul-moore.com
Quoted 24 lines · Paul Moore
Quoted 9 lines · Stephen Smalley
Quoted 5 lines · Stephen Smalley
Tighten type validation during policy load to improve robustness in the face of ill-formed policies.
Signed-off-by Stephen Smalley <[email protected]>Ping.
Pong.
Just a reminder that there are free things I dislike more than "ping" nudges. If your patch hit the lore archive and is visible in patchwork, it's on my list; if I haven't acted upon it yet it is simply because I've been busy with other higher priority things. Nudging patches like this simply steals and wastes time that could be better spent elsewhere.
Quoted 4 lines
There were a few of Christian's patches that weren't merged due to feedback and other concerns, but I need to go back and see if it is preferable to fixup and merge those before looking at other patches. Maybe this is good regardless, we'll see.
I'll try to address the comments and rebase *soon*. (Haven't found the time yet)
Quoted 7 lines
--
paul-moore.com
Stephen Smalley
maintainerQuoted 26 lines · Christian Göttsche
Quoted 24 lines · Paul Moore
Quoted 9 lines · Stephen Smalley
Quoted 5 lines · Stephen Smalley
Tighten type validation during policy load to improve robustness in the face of ill-formed policies.
Signed-off-by Stephen Smalley <[email protected]>Ping.
Pong.
Just a reminder that there are free things I dislike more than "ping" nudges. If your patch hit the lore archive and is visible in patchwork, it's on my list; if I haven't acted upon it yet it is simply because I've been busy with other higher priority things. Nudging patches like this simply steals and wastes time that could be better spent elsewhere.
Quoted 6 lines
Quoted 4 lines
There were a few of Christian's patches that weren't merged due to feedback and other concerns, but I need to go back and see if it is preferable to fixup and merge those before looking at other patches. Maybe this is good regardless, we'll see.
I'll try to address the comments and rebase *soon*. (Haven't found the time yet)
Likely helpful if you can clarify whether your patches add equivalent validation; if so, I didn't see it.
Quoted 4 lines · On May 7, 2026 Stephen Smalley <[email protected]> wrote:
Tighten type validation during policy load to improve robustness in the face of ill-formed policies.
Quoted 8 lines
Signed-off-by Stephen Smalley <[email protected]>---
v3 removes a spurious empty line leftover from one of the changes dropped due to Christian's patches and adds the word "type" to the error message for clarity.security/selinux/ss/policydb.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
Merged into selinux/dev, thanks.
--
paul-moore.com