diff mbox

[integrity:next-restore-kexec,21/31] kernel/kexec_core.c:780:10: warning: passing argument 1 of '__va' makes integer from pointer without a cast

Message ID 14446997.EfN524sbRK@hactar (mailing list archive)
State New, archived
Headers show

Commit Message

Thiago Jung Bauermann Aug. 24, 2016, 9:59 p.m. UTC
Am Dienstag, 23 August 2016, 22:44:19 schrieb kbuild test robot:
> tree:  
> https://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git
> next-restore-kexec head:   62bc4b565254de4796a0835f6f67569eb4835f9f
> commit: d03a46a7730822305a2264c9defa21c06d4ff861 [21/31] kexec_file: Add
> mechanism to update kexec segments. config: m68k-sun3_defconfig (attached
> as .config)
> compiler: m68k-linux-gcc (GCC) 4.9.0
> reproduce:
>         wget
> https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin
> /make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
>         git checkout d03a46a7730822305a2264c9defa21c06d4ff861
>         # save the attached .config to linux build tree
>         make.cross ARCH=m68k
> 
> All warnings (new ones prefixed by >>):
> 
<snip>
>    kernel/kexec_core.c: In function 'kexec_update_segment':
> >> kernel/kexec_core.c:780:10: warning: passing argument 1 of '__va' makes
> >> integer from pointer without a cast
>        ptr = __va(addr);
>              ^
>    In file included from arch/m68k/include/asm/page.h:46:0,
>                     from arch/m68k/include/asm/thread_info.h:5,
>                     from include/linux/thread_info.h:54,
>                     from include/asm-generic/preempt.h:4,
>                     from ./arch/m68k/include/generated/asm/preempt.h:1,
>                     from include/linux/preempt.h:59,
>                     from include/linux/spinlock.h:50,
>                     from include/linux/mmzone.h:7,
>                     from include/linux/gfp.h:5,
>                     from include/linux/mm.h:9,
>                     from kernel/kexec_core.c:12:
>    arch/m68k/include/asm/page_mm.h:105:21: note: expected 'long unsigned
> int' but argument is of type 'void *' static inline void *__va(unsigned
> long x)
>                         ^

This doesn't produce a warning on x86 and powerpc because on both arches 
__va is a macro which does a cast to unsigned long, but on m68k __va is a 
function expecting an unsigned long argument.

>    In file included from include/asm-generic/bug.h:13:0,
>                     from arch/m68k/include/asm/bug.h:28,
>                     from include/linux/bug.h:4,
>                     from include/linux/mmdebug.h:4,
>                     from include/linux/mm.h:8,
>                     from kernel/kexec_core.c:12:
>    include/linux/kernel.h:742:17: warning: comparison of distinct pointer
> types lacks a cast (void) (&_min1 == &_min2);  \
>                     ^
>    kernel/kexec_core.c:800:14: note: in expansion of macro 'min'
>         uchunk = min(bufsz, mchunk);
>                  ^

This is because bufsz is unsigned long but mchunk is size_t.

Both warnings are fixed by the changes below, which will be in my next 
revision of the kexec buffer hand-over series.
diff mbox

Patch

diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index 6ec09e85efd9..ea2e5a7b9b69 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -261,8 +261,8 @@  extern int kexec_purgatory_get_set_symbol(struct kimage *image,
 					  unsigned int size, bool get_value);
 extern void *kexec_purgatory_get_symbol_addr(struct kimage *image,
 					     const char *name);
-int kexec_update_segment(const char *buffer, unsigned long bufsz,
-			 unsigned long load_addr, unsigned long memsz);
+int kexec_update_segment(const char *buffer, size_t bufsz,
+			 unsigned long load_addr, size_t memsz);
 extern void __crash_kexec(struct pt_regs *);
 extern void crash_kexec(struct pt_regs *);
 int kexec_should_crash(struct task_struct *);
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index 3740235d6819..11ca5f8678df 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -732,8 +732,8 @@  static struct page *kimage_alloc_page(struct kimage *image,
  *
  * Return: 0 on success, negative errno on error.
  */
-int kexec_update_segment(const char *buffer, unsigned long bufsz,
-			 unsigned long load_addr, unsigned long memsz)
+int kexec_update_segment(const char *buffer, size_t bufsz,
+			 unsigned long load_addr, size_t memsz)
 {
 	int i;
 	unsigned long entry;
@@ -763,7 +763,7 @@  int kexec_update_segment(const char *buffer, unsigned long bufsz,
 			break;
 		}
 	if (i == kexec_image->nr_segments) {
-		pr_err("Couldn't find segment to update: 0x%lx, size 0x%lx\n",
+		pr_err("Couldn't find segment to update: 0x%lx, size 0x%zx\n",
 		       load_addr, memsz);
 		return -EINVAL;
 	}
@@ -777,7 +777,7 @@  int kexec_update_segment(const char *buffer, unsigned long bufsz,
 			dest = addr;
 			break;
 		case IND_INDIRECTION:
-			ptr = __va(addr);
+			ptr = __va(entry & PAGE_MASK);
 			break;
 		case IND_SOURCE:
 			/* Shouldn't happen, but verify just to be safe. */