* [PATCH] selinux: reject invalid ebitmaps
@ 2023-08-18 15:29 Christian Göttsche
2023-09-08 19:04 ` Stephen Smalley
2023-09-12 21:07 ` Paul Moore
0 siblings, 2 replies; 3+ messages in thread
From: Christian Göttsche @ 2023-08-18 15:29 UTC (permalink / raw)
To: selinux; +Cc: Paul Moore, Stephen Smalley, Eric Paris, linux-kernel
Reject ebitmaps with a node containing an empty map or with an incorrect
highbit. Both checks are already performed by userspace, the former
since 2008 (patch 13cd4c896068 ("initial import from svn trunk revision
2950")), the latter since v2.7 in 2017 (patch 75b14a5de10a ("libsepol:
ebitmap: reject loading bitmaps with incorrect high bit")).
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
security/selinux/ss/ebitmap.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
index 77875ad355f7..ac9da819531d 100644
--- a/security/selinux/ss/ebitmap.c
+++ b/security/selinux/ss/ebitmap.c
@@ -450,6 +450,10 @@ int ebitmap_read(struct ebitmap *e, void *fp)
goto bad;
}
map = le64_to_cpu(mapbits);
+ if (!map) {
+ pr_err("SELinux: ebitmap: empty map\n");
+ goto bad;
+ }
index = (startbit - n->startbit) / EBITMAP_UNIT_SIZE;
while (map) {
@@ -457,6 +461,13 @@ int ebitmap_read(struct ebitmap *e, void *fp)
map = EBITMAP_SHIFT_UNIT_SIZE(map);
}
}
+
+ if (n && n->startbit + EBITMAP_SIZE != e->highbit) {
+ pr_err("SELinux: ebitmap: high bit %d has not the expected value %ld\n",
+ e->highbit, n->startbit + EBITMAP_SIZE);
+ goto bad;
+ }
+
ok:
rc = 0;
out:
--
2.40.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selinux: reject invalid ebitmaps
2023-08-18 15:29 [PATCH] selinux: reject invalid ebitmaps Christian Göttsche
@ 2023-09-08 19:04 ` Stephen Smalley
2023-09-12 21:07 ` Paul Moore
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Smalley @ 2023-09-08 19:04 UTC (permalink / raw)
To: Christian Göttsche; +Cc: selinux, Paul Moore, Eric Paris, linux-kernel
On Fri, Aug 18, 2023 at 11:29 AM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> Reject ebitmaps with a node containing an empty map or with an incorrect
> highbit. Both checks are already performed by userspace, the former
> since 2008 (patch 13cd4c896068 ("initial import from svn trunk revision
> 2950")), the latter since v2.7 in 2017 (patch 75b14a5de10a ("libsepol:
> ebitmap: reject loading bitmaps with incorrect high bit")).
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Reviewed-by: Stephen Smalley <stephen.smalley.work@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selinux: reject invalid ebitmaps
2023-08-18 15:29 [PATCH] selinux: reject invalid ebitmaps Christian Göttsche
2023-09-08 19:04 ` Stephen Smalley
@ 2023-09-12 21:07 ` Paul Moore
1 sibling, 0 replies; 3+ messages in thread
From: Paul Moore @ 2023-09-12 21:07 UTC (permalink / raw)
To: Stephen Smalley, Christian Göttsche
Cc: selinux, Eric Paris, linux-kernel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1365 bytes --]
On Aug 18, 2023 Stephen Smalley <stephen.smalley.work@gmail.com> wrote:
>
> Reject ebitmaps with a node containing an empty map or with an incorrect
> highbit. Both checks are already performed by userspace, the former
> since 2008 (patch 13cd4c896068 ("initial import from svn trunk revision
> 2950")), the latter since v2.7 in 2017 (patch 75b14a5de10a ("libsepol:
> ebitmap: reject loading bitmaps with incorrect high bit")).
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> Reviewed-by: Stephen Smalley <stephen.smalley.work@gmail.com>
> ---
> security/selinux/ss/ebitmap.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
> index 77875ad355f7..ac9da819531d 100644
> --- a/security/selinux/ss/ebitmap.c
> +++ b/security/selinux/ss/ebitmap.c
...
> @@ -457,6 +461,13 @@ int ebitmap_read(struct ebitmap *e, void *fp)
> map = EBITMAP_SHIFT_UNIT_SIZE(map);
> }
> }
> +
> + if (n && n->startbit + EBITMAP_SIZE != e->highbit) {
> + pr_err("SELinux: ebitmap: high bit %d has not the expected value %ld\n",
That reads a little awkward in English, how about "high bit %d is not
equal to the expected value %ld\n"?
> + e->highbit, n->startbit + EBITMAP_SIZE);
> + goto bad;
> + }
> +
> ok:
> rc = 0;
> out:
> --
> 2.40.1
--
paul-moore.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-12 21:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-18 15:29 [PATCH] selinux: reject invalid ebitmaps Christian Göttsche
2023-09-08 19:04 ` Stephen Smalley
2023-09-12 21:07 ` Paul Moore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®