Commit d7627467 authored by David Howells's avatar David Howells Committed by Linus Torvalds

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: default avatarDavid Howells <dhowells@redhat.com>
Tested-by: default avatarRalf Baechle <ralf@linux-mips.org>
Acked-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent da5cabf8
...@@ -387,8 +387,9 @@ EXPORT_SYMBOL(dump_elf_task_fp); ...@@ -387,8 +387,9 @@ EXPORT_SYMBOL(dump_elf_task_fp);
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
asmlinkage int asmlinkage int
do_sys_execve(const char __user *ufilename, char __user * __user *argv, do_sys_execve(const char __user *ufilename,
char __user * __user *envp, struct pt_regs *regs) const char __user *const __user *argv,
const char __user *const __user *envp, struct pt_regs *regs)
{ {
int error; int error;
char *filename; char *filename;
......
...@@ -62,8 +62,9 @@ asmlinkage int sys_vfork(struct pt_regs *regs) ...@@ -62,8 +62,9 @@ asmlinkage int sys_vfork(struct pt_regs *regs)
/* sys_execve() executes a new program. /* sys_execve() executes a new program.
* This is called indirectly via a small wrapper * This is called indirectly via a small wrapper
*/ */
asmlinkage int sys_execve(const char __user *filenamei, char __user * __user *argv, asmlinkage int sys_execve(const char __user *filenamei,
char __user * __user *envp, struct pt_regs *regs) const char __user *const __user *argv,
const char __user *const __user *envp, struct pt_regs *regs)
{ {
int error; int error;
char * filename; char * filename;
...@@ -78,14 +79,17 @@ asmlinkage int sys_execve(const char __user *filenamei, char __user * __user *ar ...@@ -78,14 +79,17 @@ asmlinkage int sys_execve(const char __user *filenamei, char __user * __user *ar
return error; return error;
} }
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
struct pt_regs regs; struct pt_regs regs;
int ret; int ret;
memset(&regs, 0, sizeof(struct pt_regs)); memset(&regs, 0, sizeof(struct pt_regs));
ret = do_execve(filename, (char __user * __user *)argv, ret = do_execve(filename,
(char __user * __user *)envp, &regs); (const char __user *const __user *)argv,
(const char __user *const __user *)envp, &regs);
if (ret < 0) if (ret < 0)
goto out; goto out;
......
...@@ -384,8 +384,9 @@ asmlinkage int sys_vfork(struct pt_regs *regs) ...@@ -384,8 +384,9 @@ asmlinkage int sys_vfork(struct pt_regs *regs)
} }
asmlinkage int sys_execve(const char __user *ufilename, asmlinkage int sys_execve(const char __user *ufilename,
char __user *__user *uargv, const char __user *const __user *uargv,
char __user *__user *uenvp, struct pt_regs *regs) const char __user *const __user *uenvp,
struct pt_regs *regs)
{ {
int error; int error;
char *filename; char *filename;
......
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
*/ */
#include <linux/unistd.h> #include <linux/unistd.h>
int kernel_execve(const char *file, char **argv, char **envp) int kernel_execve(const char *file,
const char *const *argv,
const char *const *envp)
{ {
register long scno asm("r8") = __NR_execve; register long scno asm("r8") = __NR_execve;
register long sc1 asm("r12") = (long)file; register long sc1 asm("r12") = (long)file;
......
...@@ -209,7 +209,9 @@ copy_thread(unsigned long clone_flags, ...@@ -209,7 +209,9 @@ copy_thread(unsigned long clone_flags,
/* /*
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
asmlinkage int sys_execve(const char __user *name, char __user * __user *argv, char __user * __user *envp) asmlinkage int sys_execve(const char __user *name,
const char __user *const __user *argv,
const char __user *const __user *envp)
{ {
int error; int error;
char *filename; char *filename;
......
...@@ -204,7 +204,9 @@ asmlinkage int sys_vfork(long r10, long r11, long r12, long r13, long mof, long ...@@ -204,7 +204,9 @@ asmlinkage int sys_vfork(long r10, long r11, long r12, long r13, long mof, long
/* /*
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
asmlinkage int sys_execve(const char *fname, char **argv, char **envp, asmlinkage int sys_execve(const char *fname,
const char *const *argv,
const char *const *envp,
long r13, long mof, long srp, long r13, long mof, long srp,
struct pt_regs *regs) struct pt_regs *regs)
{ {
......
...@@ -218,7 +218,9 @@ sys_vfork(long r10, long r11, long r12, long r13, long mof, long srp, ...@@ -218,7 +218,9 @@ sys_vfork(long r10, long r11, long r12, long r13, long mof, long srp,
/* sys_execve() executes a new program. */ /* sys_execve() executes a new program. */
asmlinkage int asmlinkage int
sys_execve(const char *fname, char **argv, char **envp, long r13, long mof, long srp, sys_execve(const char *fname,
const char *const *argv,
const char *const *envp, long r13, long mof, long srp,
struct pt_regs *regs) struct pt_regs *regs)
{ {
int error; int error;
......
...@@ -250,8 +250,9 @@ int copy_thread(unsigned long clone_flags, ...@@ -250,8 +250,9 @@ int copy_thread(unsigned long clone_flags,
/* /*
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
asmlinkage int sys_execve(const char __user *name, char __user * __user *argv, asmlinkage int sys_execve(const char __user *name,
char __user * __user *envp) const char __user *const __user *argv,
const char __user *const __user *envp)
{ {
int error; int error;
char * filename; char * filename;
......
...@@ -212,7 +212,10 @@ int copy_thread(unsigned long clone_flags, ...@@ -212,7 +212,10 @@ int copy_thread(unsigned long clone_flags,
/* /*
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
asmlinkage int sys_execve(const char *name, char **argv, char **envp,int dummy,...) asmlinkage int sys_execve(const char *name,
const char *const *argv,
const char *const *envp,
int dummy, ...)
{ {
int error; int error;
char * filename; char * filename;
......
...@@ -51,7 +51,9 @@ asmlinkage void syscall_print(void *dummy,...) ...@@ -51,7 +51,9 @@ asmlinkage void syscall_print(void *dummy,...)
* Do a system call from kernel instead of calling sys_execve so we * Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs. * end up with proper pt_regs.
*/ */
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
register long res __asm__("er0"); register long res __asm__("er0");
register char *const *_c __asm__("er3") = envp; register char *const *_c __asm__("er3") = envp;
......
...@@ -633,7 +633,9 @@ dump_fpu (struct pt_regs *pt, elf_fpregset_t dst) ...@@ -633,7 +633,9 @@ dump_fpu (struct pt_regs *pt, elf_fpregset_t dst)
} }
long long
sys_execve (const char __user *filename, char __user * __user *argv, char __user * __user *envp, sys_execve (const char __user *filename,
const char __user *const __user *argv,
const char __user *const __user *envp,
struct pt_regs *regs) struct pt_regs *regs)
{ {
char *fname; char *fname;
......
...@@ -289,8 +289,8 @@ asmlinkage int sys_vfork(unsigned long r0, unsigned long r1, unsigned long r2, ...@@ -289,8 +289,8 @@ asmlinkage int sys_vfork(unsigned long r0, unsigned long r1, unsigned long r2,
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
asmlinkage int sys_execve(const char __user *ufilename, asmlinkage int sys_execve(const char __user *ufilename,
char __user * __user *uargv, const char __user *const __user *uargv,
char __user * __user *uenvp, const char __user *const __user *uenvp,
unsigned long r3, unsigned long r4, unsigned long r5, unsigned long r3, unsigned long r4, unsigned long r5,
unsigned long r6, struct pt_regs regs) unsigned long r6, struct pt_regs regs)
{ {
......
...@@ -93,7 +93,9 @@ asmlinkage int sys_cachectl(char *addr, int nbytes, int op) ...@@ -93,7 +93,9 @@ asmlinkage int sys_cachectl(char *addr, int nbytes, int op)
* Do a system call from kernel instead of calling sys_execve so we * Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs. * end up with proper pt_regs.
*/ */
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
register long __scno __asm__ ("r7") = __NR_execve; register long __scno __asm__ ("r7") = __NR_execve;
register long __arg3 __asm__ ("r2") = (long)(envp); register long __arg3 __asm__ ("r2") = (long)(envp);
......
...@@ -315,7 +315,9 @@ EXPORT_SYMBOL(dump_fpu); ...@@ -315,7 +315,9 @@ EXPORT_SYMBOL(dump_fpu);
/* /*
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
asmlinkage int sys_execve(const char __user *name, char __user * __user *argv, char __user * __user *envp) asmlinkage int sys_execve(const char __user *name,
const char __user *const __user *argv,
const char __user *const __user *envp)
{ {
int error; int error;
char * filename; char * filename;
......
...@@ -459,7 +459,9 @@ asmlinkage int sys_getpagesize(void) ...@@ -459,7 +459,9 @@ asmlinkage int sys_getpagesize(void)
* Do a system call from kernel instead of calling sys_execve so we * Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs. * end up with proper pt_regs.
*/ */
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
register long __res asm ("%d0") = __NR_execve; register long __res asm ("%d0") = __NR_execve;
register long __a asm ("%d1") = (long)(filename); register long __a asm ("%d1") = (long)(filename);
......
...@@ -350,7 +350,9 @@ void dump(struct pt_regs *fp) ...@@ -350,7 +350,9 @@ void dump(struct pt_regs *fp)
/* /*
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
asmlinkage int sys_execve(const char *name, char **argv, char **envp) asmlinkage int sys_execve(const char *name,
const char *const *argv,
const char *const *envp)
{ {
int error; int error;
char * filename; char * filename;
......
...@@ -44,7 +44,9 @@ asmlinkage int sys_getpagesize(void) ...@@ -44,7 +44,9 @@ asmlinkage int sys_getpagesize(void)
* Do a system call from kernel instead of calling sys_execve so we * Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs. * end up with proper pt_regs.
*/ */
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
register long __res asm ("%d0") = __NR_execve; register long __res asm ("%d0") = __NR_execve;
register long __a asm ("%d1") = (long)(filename); register long __a asm ("%d1") = (long)(filename);
......
...@@ -47,8 +47,10 @@ asmlinkage long microblaze_clone(int flags, unsigned long stack, struct pt_regs ...@@ -47,8 +47,10 @@ asmlinkage long microblaze_clone(int flags, unsigned long stack, struct pt_regs
return do_fork(flags, stack, regs, 0, NULL, NULL); return do_fork(flags, stack, regs, 0, NULL, NULL);
} }
asmlinkage long microblaze_execve(const char __user *filenamei, char __user *__user *argv, asmlinkage long microblaze_execve(const char __user *filenamei,
char __user *__user *envp, struct pt_regs *regs) const char __user *const __user *argv,
const char __user *const __user *envp,
struct pt_regs *regs)
{ {
int error; int error;
char *filename; char *filename;
...@@ -77,7 +79,9 @@ asmlinkage long sys_mmap(unsigned long addr, unsigned long len, ...@@ -77,7 +79,9 @@ asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
* Do a system call from kernel instead of calling sys_execve so we * Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs. * end up with proper pt_regs.
*/ */
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
register const char *__a __asm__("r5") = filename; register const char *__a __asm__("r5") = filename;
register const void *__b __asm__("r6") = argv; register const void *__b __asm__("r6") = argv;
......
...@@ -258,8 +258,10 @@ asmlinkage int sys_execve(nabi_no_regargs struct pt_regs regs) ...@@ -258,8 +258,10 @@ asmlinkage int sys_execve(nabi_no_regargs struct pt_regs regs)
error = PTR_ERR(filename); error = PTR_ERR(filename);
if (IS_ERR(filename)) if (IS_ERR(filename))
goto out; goto out;
error = do_execve(filename, (char __user *__user *) (long)regs.regs[5], error = do_execve(filename,
(char __user *__user *) (long)regs.regs[6], &regs); (const char __user *const __user *) (long)regs.regs[5],
(const char __user *const __user *) (long)regs.regs[6],
&regs);
putname(filename); putname(filename);
out: out:
...@@ -436,7 +438,9 @@ asmlinkage void bad_stack(void) ...@@ -436,7 +438,9 @@ asmlinkage void bad_stack(void)
* Do a system call from kernel instead of calling sys_execve so we * Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs. * end up with proper pt_regs.
*/ */
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
register unsigned long __a0 asm("$4") = (unsigned long) filename; register unsigned long __a0 asm("$4") = (unsigned long) filename;
register unsigned long __a1 asm("$5") = (unsigned long) argv; register unsigned long __a1 asm("$5") = (unsigned long) argv;
......
...@@ -269,8 +269,8 @@ asmlinkage long sys_vfork(void) ...@@ -269,8 +269,8 @@ asmlinkage long sys_vfork(void)
} }
asmlinkage long sys_execve(const char __user *name, asmlinkage long sys_execve(const char __user *name,
char __user * __user *argv, const char __user *const __user *argv,
char __user * __user *envp) const char __user *const __user *envp)
{ {
char *filename; char *filename;
int error; int error;
......
...@@ -41,8 +41,10 @@ int hpux_execve(struct pt_regs *regs) ...@@ -41,8 +41,10 @@ int hpux_execve(struct pt_regs *regs)
if (IS_ERR(filename)) if (IS_ERR(filename))
goto out; goto out;
error = do_execve(filename, (char __user * __user *) regs->gr[25], error = do_execve(filename,
(char __user * __user *) regs->gr[24], regs); (const char __user *const __user *) regs->gr[25],
(const char __user *const __user *) regs->gr[24],
regs);
putname(filename); putname(filename);
......
...@@ -348,17 +348,22 @@ asmlinkage int sys_execve(struct pt_regs *regs) ...@@ -348,17 +348,22 @@ asmlinkage int sys_execve(struct pt_regs *regs)
error = PTR_ERR(filename); error = PTR_ERR(filename);
if (IS_ERR(filename)) if (IS_ERR(filename))
goto out; goto out;
error = do_execve(filename, (char __user * __user *) regs->gr[25], error = do_execve(filename,
(char __user * __user *) regs->gr[24], regs); (const char __user *const __user *) regs->gr[25],
(const char __user *const __user *) regs->gr[24],
regs);
putname(filename); putname(filename);
out: out:
return error; return error;
} }
extern int __execve(const char *filename, char *const argv[], extern int __execve(const char *filename,
char *const envp[], struct task_struct *task); const char *const argv[],
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) const char *const envp[], struct task_struct *task);
int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
return __execve(filename, argv, envp, current); return __execve(filename, argv, envp, current);
} }
......
...@@ -1034,8 +1034,9 @@ int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2, ...@@ -1034,8 +1034,9 @@ int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2,
flush_fp_to_thread(current); flush_fp_to_thread(current);
flush_altivec_to_thread(current); flush_altivec_to_thread(current);
flush_spe_to_thread(current); flush_spe_to_thread(current);
error = do_execve(filename, (char __user * __user *) a1, error = do_execve(filename,
(char __user * __user *) a2, regs); (const char __user *const __user *) a1,
(const char __user *const __user *) a2, regs);
putname(filename); putname(filename);
out: out:
return error; return error;
......
...@@ -267,8 +267,9 @@ asmlinkage void execve_tail(void) ...@@ -267,8 +267,9 @@ asmlinkage void execve_tail(void)
/* /*
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
SYSCALL_DEFINE3(execve, const char __user *, name, char __user * __user *, argv, SYSCALL_DEFINE3(execve, const char __user *, name,
char __user * __user *, envp) const char __user *const __user *, argv,
const char __user *const __user *, envp)
{ {
struct pt_regs *regs = task_pt_regs(current); struct pt_regs *regs = task_pt_regs(current);
char *filename; char *filename;
......
...@@ -99,8 +99,10 @@ score_execve(struct pt_regs *regs) ...@@ -99,8 +99,10 @@ score_execve(struct pt_regs *regs)
if (IS_ERR(filename)) if (IS_ERR(filename))
return error; return error;
error = do_execve(filename, (char __user *__user*)regs->regs[5], error = do_execve(filename,
(char __user *__user *) regs->regs[6], regs); (const char __user *const __user *)regs->regs[5],
(const char __user *const __user *)regs->regs[6],
regs);
putname(filename); putname(filename);
return error; return error;
...@@ -110,7 +112,9 @@ score_execve(struct pt_regs *regs) ...@@ -110,7 +112,9 @@ score_execve(struct pt_regs *regs)
* Do a system call from kernel instead of calling sys_execve so we * Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs. * end up with proper pt_regs.
*/ */
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
register unsigned long __r4 asm("r4") = (unsigned long) filename; register unsigned long __r4 asm("r4") = (unsigned long) filename;
register unsigned long __r5 asm("r5") = (unsigned long) argv; register unsigned long __r5 asm("r5") = (unsigned long) argv;
......
...@@ -296,9 +296,10 @@ asmlinkage int sys_vfork(unsigned long r4, unsigned long r5, ...@@ -296,9 +296,10 @@ asmlinkage int sys_vfork(unsigned long r4, unsigned long r5,
/* /*
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
asmlinkage int sys_execve(char __user *ufilename, char __user * __user *uargv, asmlinkage int sys_execve(const char __user *ufilename,
char __user * __user *uenvp, unsigned long r7, const char __user *const __user *uargv,
struct pt_regs __regs) const char __user *const __user *uenvp,
unsigned long r7, struct pt_regs __regs)
{ {
struct pt_regs *regs = RELOC_HIDE(&__regs, 0); struct pt_regs *regs = RELOC_HIDE(&__regs, 0);
int error; int error;
......
...@@ -497,8 +497,8 @@ asmlinkage int sys_execve(const char *ufilename, char **uargv, ...@@ -497,8 +497,8 @@ asmlinkage int sys_execve(const char *ufilename, char **uargv,
goto out; goto out;
error = do_execve(filename, error = do_execve(filename,
(char __user * __user *)uargv, (const char __user *const __user *)uargv,
(char __user * __user *)uenvp, (const char __user *const __user *)uenvp,
pregs); pregs);
putname(filename); putname(filename);
out: out:
......
...@@ -71,7 +71,9 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1, ...@@ -71,7 +71,9 @@ asmlinkage int sys_fadvise64_64_wrapper(int fd, u32 offset0, u32 offset1,
* Do a system call from kernel instead of calling sys_execve so we * Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs. * end up with proper pt_regs.
*/ */
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
register long __sc0 __asm__ ("r3") = __NR_execve; register long __sc0 __asm__ ("r3") = __NR_execve;
register long __sc4 __asm__ ("r4") = (long) filename; register long __sc4 __asm__ ("r4") = (long) filename;
......
...@@ -33,7 +33,9 @@ ...@@ -33,7 +33,9 @@
* Do a system call from kernel instead of calling sys_execve so we * Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs. * end up with proper pt_regs.
*/ */
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_execve); register unsigned long __sc0 __asm__ ("r9") = ((0x13 << 16) | __NR_execve);
register unsigned long __sc2 __asm__ ("r2") = (unsigned long) filename; register unsigned long __sc2 __asm__ ("r2") = (unsigned long) filename;
......
...@@ -633,8 +633,10 @@ asmlinkage int sparc_execve(struct pt_regs *regs) ...@@ -633,8 +633,10 @@ asmlinkage int sparc_execve(struct pt_regs *regs)
if(IS_ERR(filename)) if(IS_ERR(filename))
goto out; goto out;
error = do_execve(filename, error = do_execve(filename,
(char __user * __user *)regs->u_regs[base + UREG_I1], (const char __user *const __user *)
(char __user * __user *)regs->u_regs[base + UREG_I2], regs->u_regs[base + UREG_I1],
(const char __user *const __user *)
regs->u_regs[base + UREG_I2],
regs); regs);
putname(filename); putname(filename);
out: out:
......
...@@ -739,9 +739,9 @@ asmlinkage int sparc_execve(struct pt_regs *regs) ...@@ -739,9 +739,9 @@ asmlinkage int sparc_execve(struct pt_regs *regs)
if (IS_ERR(filename)) if (IS_ERR(filename))
goto out; goto out;
error = do_execve(filename, error = do_execve(filename,
(char __user * __user *) (const char __user *const __user *)
regs->u_regs[base + UREG_I1], regs->u_regs[base + UREG_I1],
(char __user * __user *) (const char __user *const __user *)
regs->u_regs[base + UREG_I2], regs); regs->u_regs[base + UREG_I2], regs);
putname(filename); putname(filename);
if (!error) { if (!error) {
......
...@@ -282,7 +282,9 @@ asmlinkage int sys_getdomainname(char __user *name, int len) ...@@ -282,7 +282,9 @@ asmlinkage int sys_getdomainname(char __user *name, int len)
* Do a system call from kernel instead of calling sys_execve so we * Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs. * end up with proper pt_regs.
*/ */
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
long __res; long __res;
register long __g1 __asm__ ("g1") = __NR_execve; register long __g1 __asm__ ("g1") = __NR_execve;
......
...@@ -758,7 +758,9 @@ SYSCALL_DEFINE5(rt_sigaction, int, sig, const struct sigaction __user *, act, ...@@ -758,7 +758,9 @@ SYSCALL_DEFINE5(rt_sigaction, int, sig, const struct sigaction __user *, act,
* Do a system call from kernel instead of calling sys_execve so we * Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs. * end up with proper pt_regs.
*/ */
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
long __res; long __res;
register long __g1 __asm__ ("g1") = __NR_execve; register long __g1 __asm__ ("g1") = __NR_execve;
......
...@@ -543,8 +543,9 @@ long _sys_vfork(struct pt_regs *regs) ...@@ -543,8 +543,9 @@ long _sys_vfork(struct pt_regs *regs)
/* /*
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
long _sys_execve(char __user *path, char __user *__user *argv, long _sys_execve(const char __user *path,
char __user *__user *envp, struct pt_regs *regs) const char __user *const __user *argv,
const char __user *const __user *envp, struct pt_regs *regs)
{ {
long error; long error;
char *filename; char *filename;
......
...@@ -44,8 +44,9 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp) ...@@ -44,8 +44,9 @@ void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
PT_REGS_SP(regs) = esp; PT_REGS_SP(regs) = esp;
} }
static long execve1(const char *file, char __user * __user *argv, static long execve1(const char *file,
char __user *__user *env) const char __user *const __user *argv,
const char __user *const __user *env)
{ {
long error; long error;
......
...@@ -51,7 +51,9 @@ long old_mmap(unsigned long addr, unsigned long len, ...@@ -51,7 +51,9 @@ long old_mmap(unsigned long addr, unsigned long len,
return err; return err;
} }
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
mm_segment_t fs; mm_segment_t fs;
int ret; int ret;
......
...@@ -23,8 +23,9 @@ long sys_iopl(unsigned int, struct pt_regs *); ...@@ -23,8 +23,9 @@ long sys_iopl(unsigned int, struct pt_regs *);
/* kernel/process.c */ /* kernel/process.c */
int sys_fork(struct pt_regs *); int sys_fork(struct pt_regs *);
int sys_vfork(struct pt_regs *); int sys_vfork(struct pt_regs *);
long sys_execve(const char __user *, char __user * __user *, long sys_execve(const char __user *,
char __user * __user *, struct pt_regs *); const char __user *const __user *,
const char __user *const __user *, struct pt_regs *);
long sys_clone(unsigned long, unsigned long, void __user *, long sys_clone(unsigned long, unsigned long, void __user *,
void __user *, struct pt_regs *); void __user *, struct pt_regs *);
......
...@@ -301,8 +301,9 @@ EXPORT_SYMBOL(kernel_thread); ...@@ -301,8 +301,9 @@ EXPORT_SYMBOL(kernel_thread);
/* /*
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
long sys_execve(const char __user *name, char __user * __user *argv, long sys_execve(const char __user *name,
char __user * __user *envp, struct pt_regs *regs) const char __user *const __user *argv,
const char __user *const __user *envp, struct pt_regs *regs)
{ {
long error; long error;
char *filename; char *filename;
......
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
* Do a system call from kernel instead of calling sys_execve so we * Do a system call from kernel instead of calling sys_execve so we
* end up with proper pt_regs. * end up with proper pt_regs.
*/ */
int kernel_execve(const char *filename, char *const argv[], char *const envp[]) int kernel_execve(const char *filename,
const char *const argv[],
const char *const envp[])
{ {
long __res; long __res;
asm volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx" asm volatile ("push %%ebx ; movl %2,%%ebx ; int $0x80 ; pop %%ebx"
......
...@@ -318,8 +318,9 @@ long xtensa_clone(unsigned long clone_flags, unsigned long newsp, ...@@ -318,8 +318,9 @@ long xtensa_clone(unsigned long clone_flags, unsigned long newsp,
*/ */
asmlinkage asmlinkage
long xtensa_execve(const char __user *name, char __user * __user *argv, long xtensa_execve(const char __user *name,
char __user * __user *envp, const char __user *const __user *argv,
const char __user *const __user *envp,
long a3, long a4, long a5, long a3, long a4, long a5,
struct pt_regs *regs) struct pt_regs *regs)
{ {
......
...@@ -108,7 +108,7 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs) ...@@ -108,7 +108,7 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
Node *fmt; Node *fmt;
struct file * interp_file = NULL; struct file * interp_file = NULL;
char iname[BINPRM_BUF_SIZE]; char iname[BINPRM_BUF_SIZE];
char *iname_addr = iname; const char *iname_addr = iname;
int retval; int retval;
int fd_binary = -1; int fd_binary = -1;
......
...@@ -16,7 +16,8 @@ ...@@ -16,7 +16,8 @@
static int load_script(struct linux_binprm *bprm,struct pt_regs *regs) static int load_script(struct linux_binprm *bprm,struct pt_regs *regs)
{ {
char *cp, *i_name, *i_arg; const char *i_arg, *i_name;
char *cp;
struct file *file; struct file *file;
char interp[BINPRM_BUF_SIZE]; char interp[BINPRM_BUF_SIZE];
int retval; int retval;
......
...@@ -361,13 +361,13 @@ int bprm_mm_init(struct linux_binprm *bprm) ...@@ -361,13 +361,13 @@ int bprm_mm_init(struct linux_binprm *bprm)
/* /*
* count() counts the number of strings in array ARGV. * count() counts the number of strings in array ARGV.
*/ */
static int count(char __user * __user * argv, int max) static int count(const char __user * const __user * argv, int max)
{ {
int i = 0; int i = 0;
if (argv != NULL) { if (argv != NULL) {
for (;;) { for (;;) {
char __user * p; const char __user * p;
if (get_user(p, argv)) if (get_user(p, argv))
return -EFAULT; return -EFAULT;
...@@ -387,7 +387,7 @@ static int count(char __user * __user * argv, int max) ...@@ -387,7 +387,7 @@ static int count(char __user * __user * argv, int max)
* processes's memory to the new process's stack. The call to get_user_pages() * processes's memory to the new process's stack. The call to get_user_pages()
* ensures the destination page is created and not swapped out. * ensures the destination page is created and not swapped out.
*/ */
static int copy_strings(int argc, char __user * __user * argv, static int copy_strings(int argc, const char __user *const __user *argv,
struct linux_binprm *bprm) struct linux_binprm *bprm)
{ {
struct page *kmapped_page = NULL; struct page *kmapped_page = NULL;
...@@ -396,7 +396,7 @@ static int copy_strings(int argc, char __user * __user * argv, ...@@ -396,7 +396,7 @@ static int copy_strings(int argc, char __user * __user * argv,
int ret; int ret;
while (argc-- > 0) { while (argc-- > 0) {
char __user *str; const char __user *str;
int len; int len;
unsigned long pos; unsigned long pos;
...@@ -470,12 +470,13 @@ static int copy_strings(int argc, char __user * __user * argv, ...@@ -470,12 +470,13 @@ static int copy_strings(int argc, char __user * __user * argv,
/* /*
* Like copy_strings, but get argv and its values from kernel memory. * Like copy_strings, but get argv and its values from kernel memory.
*/ */
int copy_strings_kernel(int argc,char ** argv, struct linux_binprm *bprm) int copy_strings_kernel(int argc, const char *const *argv,
struct linux_binprm *bprm)
{ {
int r; int r;
mm_segment_t oldfs = get_fs(); mm_segment_t oldfs = get_fs();
set_fs(KERNEL_DS); set_fs(KERNEL_DS);
r = copy_strings(argc, (char __user * __user *)argv, bprm); r = copy_strings(argc, (const char __user *const __user *)argv, bprm);
set_fs(oldfs); set_fs(oldfs);
return r; return r;
} }
...@@ -997,7 +998,7 @@ EXPORT_SYMBOL(flush_old_exec); ...@@ -997,7 +998,7 @@ EXPORT_SYMBOL(flush_old_exec);
void setup_new_exec(struct linux_binprm * bprm) void setup_new_exec(struct linux_binprm * bprm)
{ {
int i, ch; int i, ch;
char * name; const char *name;
char tcomm[sizeof(current->comm)]; char tcomm[sizeof(current->comm)];
arch_pick_mmap_layout(current->mm); arch_pick_mmap_layout(current->mm);
...@@ -1316,9 +1317,9 @@ EXPORT_SYMBOL(search_binary_handler); ...@@ -1316,9 +1317,9 @@ EXPORT_SYMBOL(search_binary_handler);
/* /*
* sys_execve() executes a new program. * sys_execve() executes a new program.
*/ */
int do_execve(char * filename, int do_execve(const char * filename,
char __user *__user *argv, const char __user *const __user *argv,
char __user *__user *envp, const char __user *const __user *envp,
struct pt_regs * regs) struct pt_regs * regs)
{ {
struct linux_binprm *bprm; struct linux_binprm *bprm;
......
...@@ -50,8 +50,8 @@ struct linux_binprm{ ...@@ -50,8 +50,8 @@ struct linux_binprm{
int unsafe; /* how unsafe this exec is (mask of LSM_UNSAFE_*) */ int unsafe; /* how unsafe this exec is (mask of LSM_UNSAFE_*) */
unsigned int per_clear; /* bits to clear in current->personality */ unsigned int per_clear; /* bits to clear in current->personality */
int argc, envc; int argc, envc;
char * filename; /* Name of binary as seen by procps */ const char * filename; /* Name of binary as seen by procps */
char * interp; /* Name of the binary really executed. Most const char * interp; /* Name of the binary really executed. Most
of the time same as filename, but could be of the time same as filename, but could be
different for binfmt_{misc,script} */ different for binfmt_{misc,script} */
unsigned interp_flags; unsigned interp_flags;
...@@ -126,7 +126,8 @@ extern int setup_arg_pages(struct linux_binprm * bprm, ...@@ -126,7 +126,8 @@ extern int setup_arg_pages(struct linux_binprm * bprm,
unsigned long stack_top, unsigned long stack_top,
int executable_stack); int executable_stack);
extern int bprm_mm_init(struct linux_binprm *bprm); extern int bprm_mm_init(struct linux_binprm *bprm);
extern int copy_strings_kernel(int argc,char ** argv,struct linux_binprm *bprm); extern int copy_strings_kernel(int argc, const char *const *argv,
struct linux_binprm *bprm);
extern int prepare_bprm_creds(struct linux_binprm *bprm); extern int prepare_bprm_creds(struct linux_binprm *bprm);
extern void install_exec_creds(struct linux_binprm *bprm); extern void install_exec_creds(struct linux_binprm *bprm);
extern void do_coredump(long signr, int exit_code, struct pt_regs *regs); extern void do_coredump(long signr, int exit_code, struct pt_regs *regs);
......
...@@ -2109,7 +2109,9 @@ extern void daemonize(const char *, ...); ...@@ -2109,7 +2109,9 @@ extern void daemonize(const char *, ...);
extern int allow_signal(int); extern int allow_signal(int);
extern int disallow_signal(int); extern int disallow_signal(int);
extern int do_execve(char *, char __user * __user *, char __user * __user *, struct pt_regs *); extern int do_execve(const char *,
const char __user * const __user *,
const char __user * const __user *, struct pt_regs *);
extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *); extern long do_fork(unsigned long, unsigned long, struct pt_regs *, unsigned long, int __user *, int __user *);
struct task_struct *fork_idle(int); struct task_struct *fork_idle(int);
......
...@@ -820,7 +820,7 @@ asmlinkage long sys_fanotify_mark(int fanotify_fd, unsigned int flags, ...@@ -820,7 +820,7 @@ asmlinkage long sys_fanotify_mark(int fanotify_fd, unsigned int flags,
u64 mask, int fd, u64 mask, int fd,
const char __user *pathname); const char __user *pathname);
int kernel_execve(const char *filename, char *const argv[], char *const envp[]); int kernel_execve(const char *filename, const char *const argv[], const char *const envp[]);
asmlinkage long sys_perf_event_open( asmlinkage long sys_perf_event_open(
......
...@@ -24,10 +24,11 @@ static int __init no_initrd(char *str) ...@@ -24,10 +24,11 @@ static int __init no_initrd(char *str)
__setup("noinitrd", no_initrd); __setup("noinitrd", no_initrd);
static int __init do_linuxrc(void * shell) static int __init do_linuxrc(void *_shell)
{ {
static char *argv[] = { "linuxrc", NULL, }; static const char *argv[] = { "linuxrc", NULL, };
extern char * envp_init[]; extern const char *envp_init[];
const char *shell = _shell;
sys_close(old_fd);sys_close(root_fd); sys_close(old_fd);sys_close(root_fd);
sys_setsid(); sys_setsid();
......
...@@ -197,8 +197,8 @@ static int __init set_reset_devices(char *str) ...@@ -197,8 +197,8 @@ static int __init set_reset_devices(char *str)
__setup("reset_devices", set_reset_devices); __setup("reset_devices", set_reset_devices);
static char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, }; static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, }; const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
static const char *panic_later, *panic_param; static const char *panic_later, *panic_param;
extern const struct obs_kernel_param __setup_start[], __setup_end[]; extern const struct obs_kernel_param __setup_start[], __setup_end[];
...@@ -809,7 +809,7 @@ static void __init do_pre_smp_initcalls(void) ...@@ -809,7 +809,7 @@ static void __init do_pre_smp_initcalls(void)
do_one_initcall(*fn); do_one_initcall(*fn);
} }
static void run_init_process(char *init_filename) static void run_init_process(const char *init_filename)
{ {
argv_init[0] = init_filename; argv_init[0] = init_filename;
kernel_execve(init_filename, argv_init, envp_init); kernel_execve(init_filename, argv_init, envp_init);
......
...@@ -153,7 +153,9 @@ static int ____call_usermodehelper(void *data) ...@@ -153,7 +153,9 @@ static int ____call_usermodehelper(void *data)
goto fail; goto fail;
} }
retval = kernel_execve(sub_info->path, sub_info->argv, sub_info->envp); retval = kernel_execve(sub_info->path,
(const char *const *)sub_info->argv,
(const char *const *)sub_info->envp);
/* Exec failed? */ /* Exec failed? */
fail: fail:
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
* *
* Warn if that happens, once per boot. * Warn if that happens, once per boot.
*/ */
static void warn_setuid_and_fcaps_mixed(char *fname) static void warn_setuid_and_fcaps_mixed(const char *fname)
{ {
static int warned; static int warned;
if (!warned) { if (!warned) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment