linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] module: fix elf_validity_check() warns seen on 32-bit platforms
@ 2021-10-14 18:10 Shuah Khan
  2021-10-14 19:51 ` Luis Chamberlain
  0 siblings, 1 reply; 3+ messages in thread
From: Shuah Khan @ 2021-10-14 18:10 UTC (permalink / raw)
  To: mcgrof, jeyu; +Cc: Shuah Khan, linux-kernel, kernel test robot

Fix the following warnings introduced by

commit: 8b1185a4427b ("module: change to print useful messages from elf_validity_check()")

warning: format '%llu' expects argument of type 'long long unsigned int',
but argument 3 has type 'Elf32_Off' {aka 'unsigned int'}

Fix it by tweaking messages to not print ELF64* fields.

Fixes: 8b1185a4427b ("module: change to print useful messages from elf_validity_check()")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
 kernel/module.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index d972786b10ba..ebc70239f65a 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2950,8 +2950,8 @@ static int validate_section_offset(struct load_info *info, Elf_Shdr *shdr)
 	 */
 	secend = shdr->sh_offset + shdr->sh_size;
 	if (secend < shdr->sh_offset || secend > info->len) {
-		pr_err("Invalid ELF section offset/size: secend(%lu) < shdr->sh_offset(%llu) or secend(%lu) > e_shnum(%lu)\n",
-		       secend, shdr->sh_offset, secend, info->len);
+		pr_err("Invalid ELF section offset/size: sh_offset+sh_size(%lu) < sh_offset || > len(%lu)\n",
+		       secend, info->len);
 		return -ENOEXEC;
 	}
 
@@ -2971,8 +2971,7 @@ static int elf_validity_check(struct load_info *info)
 	int err;
 
 	if (info->len < sizeof(*(info->hdr))) {
-		pr_err("Invalid ELF header len %lu < %lu\n", info->len,
-		       sizeof(*(info->hdr)));
+		pr_err("Invalid ELF header len %lu\n", info->len);
 		goto no_exec;
 	}
 
@@ -2991,8 +2990,7 @@ static int elf_validity_check(struct load_info *info)
 		goto no_exec;
 	}
 	if (info->hdr->e_shentsize != sizeof(Elf_Shdr)) {
-		pr_err("Invalid ELF section header size %d != %lu\n",
-		       info->hdr->e_shentsize, sizeof(Elf_Shdr));
+		pr_err("Invalid ELF section header size\n");
 		goto no_exec;
 	}
 
@@ -3004,9 +3002,7 @@ static int elf_validity_check(struct load_info *info)
 	if (info->hdr->e_shoff >= info->len
 	    || (info->hdr->e_shnum * sizeof(Elf_Shdr) >
 		info->len - info->hdr->e_shoff)) {
-		pr_err("Invalid ELF section header overflow: %ld > %llu\n",
-		       info->hdr->e_shnum * sizeof(Elf_Shdr),
-		       info->len - info->hdr->e_shoff);
+		pr_err("Invalid ELF section header overflow\n");
 		goto no_exec;
 	}
 
@@ -3046,9 +3042,8 @@ static int elf_validity_check(struct load_info *info)
 	if (info->sechdrs[0].sh_type != SHT_NULL
 	    || info->sechdrs[0].sh_size != 0
 	    || info->sechdrs[0].sh_addr != 0) {
-		pr_err("ELF Spec violation: section 0 type!=SH_NULL(%d) or non-zero len(%llu) or addr(%llu)\n",
-		       info->sechdrs[0].sh_type, info->sechdrs[0].sh_size,
-		       info->sechdrs[0].sh_addr);
+		pr_err("ELF Spec violation: section 0 type(%d)!=SH_NULL or non-zero len or addr\n",
+		       info->sechdrs[0].sh_type);
 		goto no_exec;
 	}
 
-- 
2.30.2


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

* Re: [PATCH] module: fix elf_validity_check() warns seen on 32-bit platforms
  2021-10-14 18:10 [PATCH] module: fix elf_validity_check() warns seen on 32-bit platforms Shuah Khan
@ 2021-10-14 19:51 ` Luis Chamberlain
  2021-10-14 19:57   ` Shuah Khan
  0 siblings, 1 reply; 3+ messages in thread
From: Luis Chamberlain @ 2021-10-14 19:51 UTC (permalink / raw)
  To: Shuah Khan; +Cc: jeyu, linux-kernel, kernel test robot

On Thu, Oct 14, 2021 at 12:10:44PM -0600, Shuah Khan wrote:
> Fix the following warnings introduced by
> 
> commit: 8b1185a4427b ("module: change to print useful messages from elf_validity_check()")
> 
> warning: format '%llu' expects argument of type 'long long unsigned int',
> but argument 3 has type 'Elf32_Off' {aka 'unsigned int'}
> 
> Fix it by tweaking messages to not print ELF64* fields.
> 
> Fixes: 8b1185a4427b ("module: change to print useful messages from elf_validity_check()")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

Actually can I trouble you just fold this in with your older patch, I can just
drop your old patch and merge this one. No point in merging two patches
if we can just have one.

  Luis

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

* Re: [PATCH] module: fix elf_validity_check() warns seen on 32-bit platforms
  2021-10-14 19:51 ` Luis Chamberlain
@ 2021-10-14 19:57   ` Shuah Khan
  0 siblings, 0 replies; 3+ messages in thread
From: Shuah Khan @ 2021-10-14 19:57 UTC (permalink / raw)
  To: Luis Chamberlain; +Cc: jeyu, linux-kernel, kernel test robot, Shuah Khan

On 10/14/21 1:51 PM, Luis Chamberlain wrote:
> On Thu, Oct 14, 2021 at 12:10:44PM -0600, Shuah Khan wrote:
>> Fix the following warnings introduced by
>>
>> commit: 8b1185a4427b ("module: change to print useful messages from elf_validity_check()")
>>
>> warning: format '%llu' expects argument of type 'long long unsigned int',
>> but argument 3 has type 'Elf32_Off' {aka 'unsigned int'}
>>
>> Fix it by tweaking messages to not print ELF64* fields.
>>
>> Fixes: 8b1185a4427b ("module: change to print useful messages from elf_validity_check()")
>> Reported-by: kernel test robot <lkp@intel.com>
>> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
> 
> Actually can I trouble you just fold this in with your older patch, I can just
> drop your old patch and merge this one. No point in merging two patches
> if we can just have one.
> 

Yes. I can do that.

thanks,
-- Shuah

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

end of thread, other threads:[~2021-10-14 19:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-14 18:10 [PATCH] module: fix elf_validity_check() warns seen on 32-bit platforms Shuah Khan
2021-10-14 19:51 ` Luis Chamberlain
2021-10-14 19:57   ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).