diff options
author | David Howells <dhowells@redhat.com> | 2010-08-17 18:52:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-17 21:07:43 -0400 |
commit | d7627467b7a8dd6944885290a03a07ceb28c10eb (patch) | |
tree | a18c83468418e878cfb2d44e4310d81b8db84ad7 /arch/sh/kernel | |
parent | da5cabf80e2433131bf0ed8993abc0f7ea618c73 (diff) |
Make do_execve() take a const filename pointer
Make do_execve() take a const filename pointer so that kernel_execve() compiles
correctly on ARM:
arch/arm/kernel/sys_arm.c:88: warning: passing argument 1 of 'do_execve' discards qualifiers from pointer target type
This also requires the argv and envp arguments to be consted twice, once for
the pointer array and once for the strings the array points to. This is
because do_execve() passes a pointer to the filename (now const) to
copy_strings_kernel(). A simpler alternative would be to cast the filename
pointer in do_execve() when it's passed to copy_strings_kernel().
do_execve() may not change any of the strings it is passed as part of the argv
or envp lists as they are some of them in .rodata, so marking these strings as
const should be fine.
Further kernel_execve() and sys_execve() need to be changed to match.
This has been test built on x86_64, frv, arm and mips.
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Ralf Baechle <ralf@linux-mips.org>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/sh/kernel')
-rw-r--r-- | arch/sh/kernel/process_32.c | 7 | ||||
-rw-r--r-- | arch/sh/kernel/process_64.c | 4 | ||||
-rw-r--r-- | arch/sh/kernel/sys_sh32.c | 4 | ||||
-rw-r--r-- | arch/sh/kernel/sys_sh64.c | 4 |
4 files changed, 12 insertions, 7 deletions
diff --git a/arch/sh/kernel/process_32.c b/arch/sh/kernel/process_32.c index 052981972ae6..762a13984bbd 100644 --- a/arch/sh/kernel/process_32.c +++ b/arch/sh/kernel/process_32.c | |||
@@ -296,9 +296,10 @@ asmlinkage int sys_vfork(unsigned long r4, unsigned long r5, | |||
296 | /* | 296 | /* |
297 | * sys_execve() executes a new program. | 297 | * sys_execve() executes a new program. |
298 | */ | 298 | */ |
299 | asmlinkage int sys_execve(char __user *ufilename, char __user * __user *uargv, | 299 | asmlinkage int sys_execve(const char __user *ufilename, |
300 | char __user * __user *uenvp, unsigned long r7, | 300 | const char __user *const __user *uargv, |
301 | struct pt_regs __regs) | 301 | const char __user *const __user *uenvp, |
302 | unsigned long r7, struct pt_regs __regs) | ||
302 | { | 303 | { |
303 | struct pt_regs *regs = RELOC_HIDE(&__regs, 0); | 304 | struct pt_regs *regs = RELOC_HIDE(&__regs, 0); |
304 | int error; | 305 | int error; |
diff --git a/arch/sh/kernel/process_64.c b/arch/sh/kernel/process_64.c index 68d128d651b3..210c1cabcb7f 100644 --- a/arch/sh/kernel/process_64.c +++ b/arch/sh/kernel/process_64.c | |||
@@ -497,8 +497,8 @@ asmlinkage int sys_execve(const char *ufilename, char **uargv, | |||
497 | goto out; | 497 | goto out; |
498 | 498 | ||
499 | error = do_execve(filename, | 499 | error = do_execve(filename, |
500 | (char __user * __user *)uargv, | 500 | (const char __user *const __user *)uargv, |
501 | (char __user * __user *)uenvp, | 501 | (const char __user *const __user *)uenvp, |
502 | pregs); | 502 | pregs); |
503 | putname(filename); | 503 | putname(filename); |
504 | out: | 504 | out: |
diff --git a/arch/sh/kernel/sys_sh32.c b/arch/sh/kernel/sys_sh32.c index eb68bfdd86e6..f56b6fe5c5d0 100644 --- a/arch/sh/kernel/sys_sh32.c +++ b/arch/sh/kernel/sys_sh32.c | |||
@@ -71,7 +71,9 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, | |||
71 | * Do a system call from kernel instead of calling sys_execve so we | 71 | * Do a system call from kernel instead of calling sys_execve so we |
72 | * end up with proper pt_regs. | 72 | * end up with proper pt_regs. |
73 | */ | 73 | */ |
74 | int kernel_execve(const char *filename, char *const argv[], char *const envp[]) | 74 | int kernel_execve(const char *filename, |
75 | const char *const argv[], | ||
76 | const char *const envp[]) | ||
75 | { | 77 | { |
76 | register long __sc0 __asm__ ("r3") = __NR_execve; | 78 | register long __sc0 __asm__ ("r3") = __NR_execve; |
77 | register long __sc4 __asm__ ("r4") = (long) filename; | 79 | register long __sc4 __asm__ ("r4") = (long) filename; |
diff --git a/arch/sh/kernel/sys_sh64.c b/arch/sh/kernel/sys_sh64.c index 287235768bc5..c5a38c4bf410 100644 --- a/arch/sh/kernel/sys_sh64.c +++ b/arch/sh/kernel/sys_sh64.c | |||
@@ -33,7 +33,9 @@ | |||
33 | * Do a system call from kernel instead of calling sys_execve so we | 33 | * Do a system call from kernel instead of calling sys_execve so we |
34 | * end up with proper pt_regs. | 34 | * end up with proper pt_regs. |
35 | */ | 35 | */ |
36 | int kernel_execve(const char *filename, char *const argv[], char *const envp[]) | 36 | int kernel_execve(const char *filename, |
37 | const char *const argv[], | ||
38 | const char *const envp[]) | ||
37 | { | 39 | { |
38 | register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_execve); | 40 | register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_execve); |
39 | register unsigned long __sc2 __asm__ ("r2") = (unsigned long) filename; | 41 | register unsigned long __sc2 __asm__ ("r2") = (unsigned long) filename; |