mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-08 14:23:19 +00:00
binfmt_elf_fdpic: clean up debug warnings
The binfmt_elf_fdpic loader has some debug trace that can be enabled at
build time. The recent 64-bit additions cause some warnings if that
debug is enabled, such as:
fs/binfmt_elf_fdpic.c: In function ‘elf_fdpic_map_file’:
fs/binfmt_elf_fdpic.c:46:33: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘Elf64_Addr’ {aka ‘long long unsigned int’} [-Wformat=]
46 | #define kdebug(fmt, ...) printk("FDPIC "fmt"\n" ,##__VA_ARGS__ )
| ^~~~~~~~
./include/linux/printk.h:427:25: note: in definition of macro ‘printk_index_wrap’
427 | _p_func(_fmt, ##__VA_ARGS__); \
| ^~~~
Cast values to the largest possible type (which is equivilent to unsigned
long long in this case) and use appropriate format specifiers to match.
Fixes: b922bf04d2
("binfmt_elf_fdpic: support 64-bit systems")
Signed-off-by: Greg Ungerer <gerg@kernel.org>
Link: https://lore.kernel.org/r/20230927132933.3290734-1-gerg@kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
parent
2632bb84d1
commit
553e41d1bc
@ -900,10 +900,12 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
|
|||||||
kdebug("- DYNAMIC[]: %lx", params->dynamic_addr);
|
kdebug("- DYNAMIC[]: %lx", params->dynamic_addr);
|
||||||
seg = loadmap->segs;
|
seg = loadmap->segs;
|
||||||
for (loop = 0; loop < loadmap->nsegs; loop++, seg++)
|
for (loop = 0; loop < loadmap->nsegs; loop++, seg++)
|
||||||
kdebug("- LOAD[%d] : %08x-%08x [va=%x ms=%x]",
|
kdebug("- LOAD[%d] : %08llx-%08llx [va=%llx ms=%llx]",
|
||||||
loop,
|
loop,
|
||||||
seg->addr, seg->addr + seg->p_memsz - 1,
|
(unsigned long long) seg->addr,
|
||||||
seg->p_vaddr, seg->p_memsz);
|
(unsigned long long) seg->addr + seg->p_memsz - 1,
|
||||||
|
(unsigned long long) seg->p_vaddr,
|
||||||
|
(unsigned long long) seg->p_memsz);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@ -1082,9 +1084,10 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
|
|||||||
maddr = vm_mmap(file, maddr, phdr->p_memsz + disp, prot, flags,
|
maddr = vm_mmap(file, maddr, phdr->p_memsz + disp, prot, flags,
|
||||||
phdr->p_offset - disp);
|
phdr->p_offset - disp);
|
||||||
|
|
||||||
kdebug("mmap[%d] <file> sz=%lx pr=%x fl=%x of=%lx --> %08lx",
|
kdebug("mmap[%d] <file> sz=%llx pr=%x fl=%x of=%llx --> %08lx",
|
||||||
loop, phdr->p_memsz + disp, prot, flags,
|
loop, (unsigned long long) phdr->p_memsz + disp,
|
||||||
phdr->p_offset - disp, maddr);
|
prot, flags, (unsigned long long) phdr->p_offset - disp,
|
||||||
|
maddr);
|
||||||
|
|
||||||
if (IS_ERR_VALUE(maddr))
|
if (IS_ERR_VALUE(maddr))
|
||||||
return (int) maddr;
|
return (int) maddr;
|
||||||
@ -1146,8 +1149,9 @@ static int elf_fdpic_map_file_by_direct_mmap(struct elf_fdpic_params *params,
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
if (excess > 0) {
|
if (excess > 0) {
|
||||||
kdebug("clear[%d] ad=%lx sz=%lx",
|
kdebug("clear[%d] ad=%llx sz=%lx", loop,
|
||||||
loop, maddr + phdr->p_filesz, excess);
|
(unsigned long long) maddr + phdr->p_filesz,
|
||||||
|
excess);
|
||||||
if (clear_user((void *) maddr + phdr->p_filesz, excess))
|
if (clear_user((void *) maddr + phdr->p_filesz, excess))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user