SELinux Archive mirror
 help / color / mirror / Atom feed
* [PATCH] selinux: fix pr_err() format specifier in ebitmap_read()
@ 2024-03-27 15:52 Paul Moore
  2024-03-27 16:56 ` Christian Göttsche
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Moore @ 2024-03-27 15:52 UTC (permalink / raw
  To: selinux

Correct the use of integer specifiers when printing ebitmap and
ebitmap_node information.

Fixes: 0142c56682fb ("selinux: reject invalid ebitmaps")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Paul Moore <paul@paul-moore.com>
---
 security/selinux/ss/ebitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
index f1ba333f127d..13d5fb47a2bb 100644
--- a/security/selinux/ss/ebitmap.c
+++ b/security/selinux/ss/ebitmap.c
@@ -461,7 +461,7 @@ int ebitmap_read(struct ebitmap *e, void *fp)
 	}
 
 	if (n && n->startbit + EBITMAP_SIZE != e->highbit) {
-		pr_err("SELinux: ebitmap: high bit %d is not equal to the expected value %ld\n",
+		pr_err("SELinux: ebitmap: high bit %u is not equal to the expected value %lu\n",
 		       e->highbit, n->startbit + EBITMAP_SIZE);
 		goto bad;
 	}
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] selinux: fix pr_err() format specifier in ebitmap_read()
  2024-03-27 15:52 [PATCH] selinux: fix pr_err() format specifier in ebitmap_read() Paul Moore
@ 2024-03-27 16:56 ` Christian Göttsche
  2024-03-27 19:02   ` Paul Moore
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Göttsche @ 2024-03-27 16:56 UTC (permalink / raw
  To: Paul Moore; +Cc: selinux

On Wed, 27 Mar 2024 at 16:52, Paul Moore <paul@paul-moore.com> wrote:
>
> Correct the use of integer specifiers when printing ebitmap and
> ebitmap_node information.
>
> Fixes: 0142c56682fb ("selinux: reject invalid ebitmaps")
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Signed-off-by: Paul Moore <paul@paul-moore.com>
> ---
>  security/selinux/ss/ebitmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
> index f1ba333f127d..13d5fb47a2bb 100644
> --- a/security/selinux/ss/ebitmap.c
> +++ b/security/selinux/ss/ebitmap.c
> @@ -461,7 +461,7 @@ int ebitmap_read(struct ebitmap *e, void *fp)
>         }
>
>         if (n && n->startbit + EBITMAP_SIZE != e->highbit) {
> -               pr_err("SELinux: ebitmap: high bit %d is not equal to the expected value %ld\n",
> +               pr_err("SELinux: ebitmap: high bit %u is not equal to the expected value %lu\n",
>                        e->highbit, n->startbit + EBITMAP_SIZE);

Maybe %zu is more appropriate for the second argument?
`n->startbit + EBITMAP_SIZE` should be of type size_t since
EBITMAP_SIZE is computed via sizeof().

See https://www.kernel.org/doc/html/v6.8/core-api/printk-formats.html

>                 goto bad;
>         }
> --
> 2.44.0
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] selinux: fix pr_err() format specifier in ebitmap_read()
  2024-03-27 16:56 ` Christian Göttsche
@ 2024-03-27 19:02   ` Paul Moore
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Moore @ 2024-03-27 19:02 UTC (permalink / raw
  To: Christian Göttsche; +Cc: selinux

On Wed, Mar 27, 2024 at 12:56 PM Christian Göttsche
<cgzones@googlemail.com> wrote:
> On Wed, 27 Mar 2024 at 16:52, Paul Moore <paul@paul-moore.com> wrote:
> >
> > Correct the use of integer specifiers when printing ebitmap and
> > ebitmap_node information.
> >
> > Fixes: 0142c56682fb ("selinux: reject invalid ebitmaps")
> > Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> > Signed-off-by: Paul Moore <paul@paul-moore.com>
> > ---
> >  security/selinux/ss/ebitmap.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
> > index f1ba333f127d..13d5fb47a2bb 100644
> > --- a/security/selinux/ss/ebitmap.c
> > +++ b/security/selinux/ss/ebitmap.c
> > @@ -461,7 +461,7 @@ int ebitmap_read(struct ebitmap *e, void *fp)
> >         }
> >
> >         if (n && n->startbit + EBITMAP_SIZE != e->highbit) {
> > -               pr_err("SELinux: ebitmap: high bit %d is not equal to the expected value %ld\n",
> > +               pr_err("SELinux: ebitmap: high bit %u is not equal to the expected value %lu\n",
> >                        e->highbit, n->startbit + EBITMAP_SIZE);
>
> Maybe %zu is more appropriate for the second argument?

Agreed, that would be better.  Did you want to submit a patch with
this?  I can always update my patch, but it's always nice when the
original patch author fixes the problems in their patch.

The catch is that you would need to submit the patch soon.

> `n->startbit + EBITMAP_SIZE` should be of type size_t since
> EBITMAP_SIZE is computed via sizeof().
>
> See https://www.kernel.org/doc/html/v6.8/core-api/printk-formats.html

-- 
paul-moore.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-27 19:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-27 15:52 [PATCH] selinux: fix pr_err() format specifier in ebitmap_read() Paul Moore
2024-03-27 16:56 ` Christian Göttsche
2024-03-27 19:02   ` Paul Moore

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 read-only IMAP folder(s) and NNTP newsgroup(s).