fix (some) ignoring return value of copy_*_user
Subsystems (2)
PATCH 1/1 fix (some) ignoring return value of copy_*_user
In .10-rc3-bk8, we get a bunch of these:
warning: ignoring return value of `copy_to_user', declared with attribute warn_unused_result
I've started cleaning it up, but I'm going to bed... so I thought I'd send it here and let someone else use it as a starting point for the rest of it.
Signature · 1 line
Jeremy Huddleston <[email protected]>
arch/sparc64/kernel/sys_sparc32.c +2 -1
@@ -1683,7 +1683,8 @@ asmlinkage long sys32_sysctl(struct __sy put_user(oldlen, (u32 __user *)(unsigned long) tmp.oldlenp)) error = -EFAULT; } -copy_to_user (args->__unused, tmp.__unused,sizeof (tmp.__unused)); +if (copy_to_user (args->__unused, tmp.__unused,sizeof (tmp.__unused))) + error = -EFAULT ; }return error;#endif
fs/binfmt_elf.c +15 -5
@@ -103,15 +103,18 @@ static int set_brk(unsigned long start,be in memory */ -static void padzero (unsigned long elf_bss) +static int padzero (unsigned long elf_bss) {unsigned long nbyte; nbyte =ELF_PAGEOFFSET (elf_bss);if (nbyte) { nbyte =ELF_MIN_ALIGN - nbyte; -clear_user ((void __user *) elf_bss, nbyte); +if (clear_user ((void __user *) elf_bss, nbyte)) +return -EFAULT ; } + +return 0 ; }/* Let's use some macros to make this stack manipulation a litle clearer */
@@ -403,7 +406,10 @@ static unsigned long load_elf_interp(str* that there are zero-mapped pages up to and including the * last bss page. */ -padzero (elf_bss); + error =padzero (elf_bss); +if (error) + goto out_close; + elf_bss =ELF_PAGESTART (elf_bss +ELF_MIN_ALIGN -1 );/* What we have mapped so far */ /* Map the last of the bss segment */
@@ -857,7 +863,9 @@ static int load_elf_binary(struct linux_send_sig (SIGKILL , current,0 ); goto out_free_dentry; } -padzero (elf_bss); + error =padzero (elf_bss); +if (error) + goto out_free_dentry;if (elf_interpreter) {if (interpreter_type ==INTERPRETER_AOUT )
@@ -1020,7 +1028,9 @@ static int load_elf_library(struct file goto out_free_ph; elf_bss = elf_phdata->p_vaddr + elf_phdata->p_filesz; -padzero (elf_bss); + error =padzero (elf_bss); +if (error) + goto out_free_ph; len =ELF_PAGESTART (elf_phdata->p_filesz + elf_phdata->p_vaddr +ELF_MIN_ALIGN -1 ); bss = elf_phdata->p_memsz + elf_phdata->p_vaddr;
fs/compat_ioctl.c +28 -25
81 lines not on this page · raw message
the binfmt_elf.c:load_elf_binary() hunk in my previous patch was wrong. It is fixed in this one.
I also fixed the one in binfmt_elf.c:load_elf_binary() but left binfmt_elf.c:create_elf_tables() alone as I'm not quite sure the best way to handle that.
Would it be best to send the fs/{binfmt_elf,compat_ioctl}.c patches to a different list (lkml?) or maintainer?
Quoted 7 lines · Jeremy Huddleston
In .10-rc3-bk8, we get a bunch of these:
warning: ignoring return value of `copy_to_user', declared with attributewarn_unused_resultI've started cleaning it up, but I'm going to bed... so I thought I'd send it here and let someone else use it as a starting point for the rest of it.
Signature · 1 line
Jeremy Huddleston <[email protected]>
arch/sparc64/kernel/sys_sparc32.c +2 -1
@@ -1683,7 +1683,8 @@ asmlinkage long sys32_sysctl(struct __sy put_user(oldlen, (u32 __user *)(unsigned long) tmp.oldlenp)) error = -EFAULT; } -copy_to_user (args->__unused, tmp.__unused,sizeof (tmp.__unused)); +if (copy_to_user (args->__unused, tmp.__unused,sizeof (tmp.__unused))) + error = -EFAULT ; }return error;#endif
fs/binfmt_elf.c +22 -6
@@ -103,15 +103,18 @@ static int set_brk(unsigned long start,be in memory */ -static void padzero (unsigned long elf_bss) +static int padzero (unsigned long elf_bss) {unsigned long nbyte; nbyte =ELF_PAGEOFFSET (elf_bss);if (nbyte) { nbyte =ELF_MIN_ALIGN - nbyte; -clear_user ((void __user *) elf_bss, nbyte); +if (clear_user ((void __user *) elf_bss, nbyte)) +return -EFAULT ; } + +return 0 ; }/* Let's use some macros to make this stack manipulation a litle clearer */
@@ -403,7 +406,10 @@ static unsigned long load_elf_interp(str* that there are zero-mapped pages up to and including the * last bss page. */ -padzero (elf_bss); + error =padzero (elf_bss); +if (error) + goto out_close; + elf_bss =ELF_PAGESTART (elf_bss +ELF_MIN_ALIGN -1 );/* What we have mapped so far */ /* Map the last of the bss segment */
@@ -773,7 +779,11 @@ static int load_elf_binary(struct linux_ nbyte =ELF_MIN_ALIGN - nbyte;if (nbyte > elf_brk - elf_bss) nbyte = elf_brk - elf_bss; -clear_user ((void __user *) elf_bss + load_bias, nbyte); + retval =clear_user ((void __user *) elf_bss + load_bias, nbyte); +if (retval) { +send_sig (SIGKILL , current,0 ); + goto out_free_dentry; + } } }
@@ -857,7 +867,11 @@ static int load_elf_binary(struct linux_send_sig (SIGKILL , current,0 ); goto out_free_dentry; } -padzero (elf_bss); + retval =padzero (elf_bss); +if (retval) { +send_sig (SIGKILL , current,0 ); + goto out_free_dentry; + }if (elf_interpreter) {if (interpreter_type ==INTERPRETER_AOUT )
@@ -1020,7 +1034,9 @@ static int load_elf_library(struct file goto out_free_ph; elf_bss = elf_phdata->p_vaddr + elf_phdata->p_filesz; -padzero (elf_bss); + error =padzero (elf_bss); +if (error) + goto out_free_ph; len =ELF_PAGESTART (elf_phdata->p_filesz + elf_phdata->p_vaddr +ELF_MIN_ALIGN -1 ); bss = elf_phdata->p_memsz + elf_phdata->p_vaddr;
fs/compat_ioctl.c +28 -25
81 lines not on this page · raw message