selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: "Stephen Smalley" <stephen.smalley.work@gmail.com>,
	"Christian Göttsche" <cgzones@googlemail.com>
Cc: selinux@vger.kernel.org, Eric Paris <eparis@parisplace.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selinux: reject invalid ebitmaps
Date: Tue, 12 Sep 2023 17:07:58 -0400	[thread overview]
Message-ID: <d476b21729cafb28c1b881113a563b1f.paul@paul-moore.com> (raw)
In-Reply-To: <20230818152910.176044-1-cgzones@googlemail.com>

[-- 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

      parent reply	other threads:[~2023-09-12 21:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d476b21729cafb28c1b881113a563b1f.paul@paul-moore.com \
    --to=paul@paul-moore.com \
    --cc=cgzones@googlemail.com \
    --cc=eparis@parisplace.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=selinux@vger.kernel.org \
    --cc=stephen.smalley.work@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).