Commit 4b3124de authored by Christian Göttsche's avatar Christian Göttsche Committed by Paul Moore

selinux: update numeric format specifiers for ebitmaps

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: 0142c566 ("selinux: reject invalid ebitmaps")
Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Closes: https://lore.kernel.org/linux-next/20240327131044.2c629921@canb.auug.org.au/Signed-off-by: default avatarChristian Göttsche <cgzones@googlemail.com>
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
parent 42c77323
...@@ -381,7 +381,7 @@ int ebitmap_read(struct ebitmap *e, void *fp) ...@@ -381,7 +381,7 @@ int ebitmap_read(struct ebitmap *e, void *fp)
if (mapunit != BITS_PER_U64) { if (mapunit != BITS_PER_U64) {
pr_err("SELinux: ebitmap: map size %u does not " 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); mapunit, BITS_PER_U64, e->highbit);
goto bad; goto bad;
} }
...@@ -407,13 +407,13 @@ int ebitmap_read(struct ebitmap *e, void *fp) ...@@ -407,13 +407,13 @@ int ebitmap_read(struct ebitmap *e, void *fp)
startbit = le32_to_cpu(ebitmap_start); startbit = le32_to_cpu(ebitmap_start);
if (startbit & (mapunit - 1)) { 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", "not a multiple of the map unit size (%u)\n",
startbit, mapunit); startbit, mapunit);
goto bad; goto bad;
} }
if (startbit > e->highbit - mapunit) { 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", "beyond the end of the bitmap (%u)\n",
startbit, (e->highbit - mapunit)); startbit, (e->highbit - mapunit));
goto bad; goto bad;
...@@ -436,8 +436,8 @@ int ebitmap_read(struct ebitmap *e, void *fp) ...@@ -436,8 +436,8 @@ int ebitmap_read(struct ebitmap *e, void *fp)
e->node = tmp; e->node = tmp;
n = tmp; n = tmp;
} else if (startbit <= n->startbit) { } else if (startbit <= n->startbit) {
pr_err("SELinux: ebitmap: start bit %d" pr_err("SELinux: ebitmap: start bit %u"
" comes after start bit %d\n", " comes after start bit %u\n",
startbit, n->startbit); startbit, n->startbit);
goto bad; goto bad;
} }
...@@ -461,7 +461,7 @@ int ebitmap_read(struct ebitmap *e, void *fp) ...@@ -461,7 +461,7 @@ int ebitmap_read(struct ebitmap *e, void *fp)
} }
if (n && n->startbit + EBITMAP_SIZE != e->highbit) { 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); e->highbit, n->startbit + EBITMAP_SIZE);
goto bad; goto bad;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment