Skip to contentSkip to conversation

selinux: fix pr_err() format specifier in ebitmap_read()

PATCH In review Paul Moore 2 participants 3 messages Mar 27, 2024 SELinux security module

lore
Share & tools
lore

Paul Moore

author maintainer
#0 lore raw

PATCH 1/1 selinux: fix pr_err() format specifier in ebitmap_read()

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

Fixes 0142c56682fb ("selinux: reject invalid ebitmaps")
---
 security/selinux/ss/ebitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/ss/ebitmap.c +1 -1
index f1ba333f127d..13d5fb47a2bb 100644
@@ -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;
 	}
Signature · 1 line
2.44.0
#1 lore raw
Quoted 16 lines · Paul Moore

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

Fixes 0142c56682fb ("selinux: reject invalid ebitmaps")
---
 security/selinux/ss/ebitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/ss/ebitmap.c +0 -0
index f1ba333f127d..13d5fb47a2bb 100644

security/selinux/ss/ebitmap.c int ebitmap_read(struct ebitmap *e, void *fp) · line 465

Quoted 6 lines
security/selinux/ss/ebitmap.c +1 -1
@@ -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

Quoted 6 lines
security/selinux/ss/ebitmap.c +0 -1
                goto bad;
        }
--

2.44.0

author maintainer
#2 lore raw
Quoted 19 lines · Christian Göttsche
Quoted 18 lines · Paul Moore

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

Fixes 0142c56682fb ("selinux: reject invalid ebitmaps")
---
 security/selinux/ss/ebitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/ss/ebitmap.c +0 -0
index f1ba333f127d..13d5fb47a2bb 100644
@@ -461,7 +461,7 @@ int ebitmap_read(struct ebitmap *e, void *fp)
        }
 
Quoted 6 lines

security/selinux/ss/ebitmap.c int ebitmap_read(struct ebitmap *e, void *fp) · line 465

Quoted 4 lines
security/selinux/ss/ebitmap.c +1 -1
        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.

Quoted 4 lines

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

Signature · 1 line
paul-moore.com