selinux: fix pr_err() format specifier in ebitmap_read()
Paul Moore
maintainerPATCH 1/1 selinux: fix pr_err() format specifier in ebitmap_read()
Correct the use of integer specifiers when printing ebitmap and ebitmap_node information.
--- security/selinux/ss/ebitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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 ); goto bad; }
Signature · 1 line
2.44.0
Quoted 16 lines · Paul Moore
Correct the use of integer specifiers when printing ebitmap and
ebitmap_nodeinformation.Fixes 0142c56682fb ("selinux: reject invalid ebitmaps")Reported-by Stephen Rothwell <[email protected]>Signed-off-by Paul Moore <[email protected]>--- security/selinux/ss/ebitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)security/selinux/ss/ebitmap.c +0
-0
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
-1goto bad; } --2.44.0
Paul Moore
maintainerQuoted 19 lines · Christian Göttsche
Quoted 18 lines · Paul Moore
Correct the use of integer specifiers when printing ebitmap and
ebitmap_nodeinformation.Fixes 0142c56682fb ("selinux: reject invalid ebitmaps")Reported-by Stephen Rothwell <[email protected]>Signed-off-by Paul Moore <[email protected]>--- security/selinux/ss/ebitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)security/selinux/ss/ebitmap.c +0
-0@@ -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
-1if (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_SIZEshould be of typesize_tsinceEBITMAP_SIZEis computed viasizeof().See https://www.kernel.org/doc/html/v6.8/core-api/printk-formats.html
Signature · 1 line
paul-moore.com