mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs, binfmt_aout: Fix pointer warnings
@ 2010-03-08 15:46 Borislav Petkov
  2010-03-09  1:11 ` Daisuke HATAYAMA
  0 siblings, 1 reply; 2+ messages in thread
From: Borislav Petkov @ 2010-03-08 15:46 UTC (permalink / raw)
  To: Daisuke HATAYAMA; +Cc: akpm, linux-kernel

Hi,

I'm getting the warnings in the commit message below with current git. Maybe fix
them like this:

--
From: Borislav Petkov <petkovbb@gmail.com>
Date: Mon, 8 Mar 2010 16:37:42 +0100
Subject: [PATCH] fs, binfmt_aout: Fix pointer warnings
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

I get

fs/binfmt_aout.c: In function ‘aout_core_dump’:
fs/binfmt_aout.c:125: warning: passing argument 2 of ‘dump_write’ makes pointer from integer without a cast
include/linux/coredump.h:12: note: expected ‘const void *’ but argument is of type ‘long unsigned int’
fs/binfmt_aout.c:132: warning: passing argument 2 of ‘dump_write’ makes pointer from integer without a cast
include/linux/coredump.h:12: note: expected ‘const void *’ but argument is of type ‘long unsigned int’

due to dump_write() expecting a user void *. Fold casts into the
START_DATA/START_STACK macros and shut up the warnings.

Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
---
 fs/binfmt_aout.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
index 15d80bb..9b6aef0 100644
--- a/fs/binfmt_aout.c
+++ b/fs/binfmt_aout.c
@@ -75,14 +75,16 @@ static int aout_core_dump(struct coredump_params *cprm)
 	struct file *file = cprm->file;
 	mm_segment_t fs;
 	int has_dumped = 0;
-	unsigned long dump_start, dump_size;
+	void __user *dump_start;
+	int dump_size;
 	struct user dump;
 #ifdef __alpha__
-#       define START_DATA(u)	(u.start_data)
+#       define START_DATA(u)	((void __user *)u.start_data)
 #else
-#	define START_DATA(u)	((u.u_tsize << PAGE_SHIFT) + u.start_code)
+#	define START_DATA(u)	((void __user *)((u.u_tsize << PAGE_SHIFT) + \
+				 u.start_code))
 #endif
-#       define START_STACK(u)   (u.start_stack)
+#       define START_STACK(u)   ((void __user *)u.start_stack)
 
 	fs = get_fs();
 	set_fs(KERNEL_DS);
@@ -104,9 +106,9 @@ static int aout_core_dump(struct coredump_params *cprm)
 
 /* make sure we actually have a data and stack area to dump */
 	set_fs(USER_DS);
-	if (!access_ok(VERIFY_READ, (void __user *)START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
+	if (!access_ok(VERIFY_READ, START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
 		dump.u_dsize = 0;
-	if (!access_ok(VERIFY_READ, (void __user *)START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
+	if (!access_ok(VERIFY_READ, START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
 		dump.u_ssize = 0;
 
 	set_fs(KERNEL_DS);
-- 
1.6.6.1


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

* Re: [PATCH] fs, binfmt_aout: Fix pointer warnings
  2010-03-08 15:46 [PATCH] fs, binfmt_aout: Fix pointer warnings Borislav Petkov
@ 2010-03-09  1:11 ` Daisuke HATAYAMA
  0 siblings, 0 replies; 2+ messages in thread
From: Daisuke HATAYAMA @ 2010-03-09  1:11 UTC (permalink / raw)
  To: petkovbb; +Cc: akpm, linux-kernel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: Text/Plain; charset=utf-8, Size: 3340 bytes --]

Thanks for your report.

From: Borislav Petkov <petkovbb@googlemail.com>
Subject: [PATCH] fs, binfmt_aout: Fix pointer warnings
Date: Mon, 8 Mar 2010 16:46:01 +0100

> Hi,
> 
> I'm getting the warnings in the commit message below with current git. Maybe fix
> them like this:
> 
> --
> From: Borislav Petkov <petkovbb@gmail.com>
> Date: Mon, 8 Mar 2010 16:37:42 +0100
> Subject: [PATCH] fs, binfmt_aout: Fix pointer warnings
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> I get
> 
> fs/binfmt_aout.c: In function ‘aout_core_dump’:
> fs/binfmt_aout.c:125: warning: passing argument 2 of ‘dump_write’ makes pointer from integer without a cast
> include/linux/coredump.h:12: note: expected ‘const void *’ but argument is of type ‘long unsigned int’
> fs/binfmt_aout.c:132: warning: passing argument 2 of ‘dump_write’ makes pointer from integer without a cast
> include/linux/coredump.h:12: note: expected ‘const void *’ but argument is of type ‘long unsigned int’
> 
> due to dump_write() expecting a user void *. Fold casts into the
> START_DATA/START_STACK macros and shut up the warnings.
> 
> Signed-off-by: Borislav Petkov <petkovbb@gmail.com>
> ---
>  fs/binfmt_aout.c |   14 ++++++++------
>  1 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
> index 15d80bb..9b6aef0 100644
> --- a/fs/binfmt_aout.c
> +++ b/fs/binfmt_aout.c
> @@ -75,14 +75,16 @@ static int aout_core_dump(struct coredump_params *cprm)
>  	struct file *file = cprm->file;
>  	mm_segment_t fs;
>  	int has_dumped = 0;
> -	unsigned long dump_start, dump_size;
> +	void __user *dump_start;
> +	int dump_size;
>  	struct user dump;
>  #ifdef __alpha__
> -#       define START_DATA(u)	(u.start_data)
> +#       define START_DATA(u)	((void __user *)u.start_data)
>  #else
> -#	define START_DATA(u)	((u.u_tsize << PAGE_SHIFT) + u.start_code)
> +#	define START_DATA(u)	((void __user *)((u.u_tsize << PAGE_SHIFT) + \
> +				 u.start_code))
>  #endif
> -#       define START_STACK(u)   (u.start_stack)
> +#       define START_STACK(u)   ((void __user *)u.start_stack)
>  
>  	fs = get_fs();
>  	set_fs(KERNEL_DS);
> @@ -104,9 +106,9 @@ static int aout_core_dump(struct coredump_params *cprm)
>  
>  /* make sure we actually have a data and stack area to dump */
>  	set_fs(USER_DS);
> -	if (!access_ok(VERIFY_READ, (void __user *)START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
> +	if (!access_ok(VERIFY_READ, START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
>  		dump.u_dsize = 0;
> -	if (!access_ok(VERIFY_READ, (void __user *)START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
> +	if (!access_ok(VERIFY_READ, START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
>  		dump.u_ssize = 0;

Your fixing looks reasonable to me. I understand your patch set as
follows.

 - The START_DATA() and START_STACK() macro calls are all passed to
   the arguments of type (void *), meaning that they need casts in
   the appropreate positions.

 - Moreover, they are more natural to be used directly as (void *)
   than to be casted outside the macro.

Thanks.

>  
>  	set_fs(KERNEL_DS);
> -- 
> 1.6.6.1
> 
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

end of thread, other threads:[~2010-03-09  1:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-08 15:46 [PATCH] fs, binfmt_aout: Fix pointer warnings Borislav Petkov
2010-03-09  1:11 ` Daisuke HATAYAMA

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome