All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selinux: update numeric format specifiers for ebitmaps
@ 2024-03-27 19:25 Christian Göttsche
  2024-03-27 20:44 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Göttsche @ 2024-03-27 19:25 UTC (permalink / raw)
  To: selinux; +Cc: Christian Göttsche, Stephen Rothwell

From: Christian Göttsche <cgzones@googlemail.com>

Use the correct, according to Documentation/core-api/printk-formats.rst,
format specifiers for numeric arguments in string formatting.
The general bit type is u32 thus use %u, EBITMAP_SIZE is a constant
computed via sizeof() thus use %zu.

Fixes: 0142c56682fb ("selinux: reject invalid ebitmaps")
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Closes: https://lore.kernel.org/linux-next/20240327131044.2c629921@canb.auug.org.au/
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 security/selinux/ss/ebitmap.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/security/selinux/ss/ebitmap.c b/security/selinux/ss/ebitmap.c
index f1ba333f127d..e515ad040ea2 100644
--- a/security/selinux/ss/ebitmap.c
+++ b/security/selinux/ss/ebitmap.c
@@ -381,7 +381,7 @@ int ebitmap_read(struct ebitmap *e, void *fp)
 
 	if (mapunit != BITS_PER_U64) {
 		pr_err("SELinux: ebitmap: map size %u does not "
-		       "match my size %zd (high bit was %d)\n",
+		       "match my size %zd (high bit was %u)\n",
 		       mapunit, BITS_PER_U64, e->highbit);
 		goto bad;
 	}
@@ -407,13 +407,13 @@ int ebitmap_read(struct ebitmap *e, void *fp)
 		startbit = le32_to_cpu(ebitmap_start);
 
 		if (startbit & (mapunit - 1)) {
-			pr_err("SELinux: ebitmap start bit (%d) is "
+			pr_err("SELinux: ebitmap start bit (%u) is "
 			       "not a multiple of the map unit size (%u)\n",
 			       startbit, mapunit);
 			goto bad;
 		}
 		if (startbit > e->highbit - mapunit) {
-			pr_err("SELinux: ebitmap start bit (%d) is "
+			pr_err("SELinux: ebitmap start bit (%u) is "
 			       "beyond the end of the bitmap (%u)\n",
 			       startbit, (e->highbit - mapunit));
 			goto bad;
@@ -436,8 +436,8 @@ int ebitmap_read(struct ebitmap *e, void *fp)
 				e->node = tmp;
 			n = tmp;
 		} else if (startbit <= n->startbit) {
-			pr_err("SELinux: ebitmap: start bit %d"
-			       " comes after start bit %d\n",
+			pr_err("SELinux: ebitmap: start bit %u"
+			       " comes after start bit %u\n",
 			       startbit, n->startbit);
 			goto bad;
 		}
@@ -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 %zu\n",
 		       e->highbit, n->startbit + EBITMAP_SIZE);
 		goto bad;
 	}
-- 
2.43.0


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

* Re: [PATCH] selinux: update numeric format specifiers for ebitmaps
  2024-03-27 19:25 [PATCH] selinux: update numeric format specifiers for ebitmaps Christian Göttsche
@ 2024-03-27 20:44 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2024-03-27 20:44 UTC (permalink / raw)
  To: Christian Göttsche, selinux
  Cc: Christian Göttsche, Stephen Rothwell

On Mar 27, 2024 =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgoettsche@seltendoof.de> wrote:
> 
> Use the correct, according to Documentation/core-api/printk-formats.rst,
> format specifiers for numeric arguments in string formatting.
> The general bit type is u32 thus use %u, EBITMAP_SIZE is a constant
> computed via sizeof() thus use %zu.
> 
> Fixes: 0142c56682fb ("selinux: reject invalid ebitmaps")
> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
> Closes: https://lore.kernel.org/linux-next/20240327131044.2c629921@canb.auug.org.au/
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
> ---
>  security/selinux/ss/ebitmap.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

Looks good, thanks.  Merged into selinux/dev.

--
paul-moore.com

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-27 19:25 [PATCH] selinux: update numeric format specifiers for ebitmaps Christian Göttsche
2024-03-27 20:44 ` Paul Moore

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.