Skip to content

Commit 986db2d

Browse files
Christoph Hellwigtorvalds
authored andcommitted
exec: simplify the copy_strings_kernel calling convention
copy_strings_kernel is always used with a single argument, adjust the calling convention to that. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Link: http://lkml.kernel.org/r/20200501104105.2621149-2-hch@lst.de Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent eac2cec commit 986db2d

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

fs/binfmt_em86.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ static int load_em86(struct linux_binprm *bprm)
6868
* user environment and arguments are stored.
6969
*/
7070
remove_arg_zero(bprm);
71-
retval = copy_strings_kernel(1, &bprm->filename, bprm);
71+
retval = copy_string_kernel(bprm->filename, bprm);
7272
if (retval < 0) return retval;
7373
bprm->argc++;
7474
if (i_arg) {
75-
retval = copy_strings_kernel(1, &i_arg, bprm);
75+
retval = copy_string_kernel(i_arg, bprm);
7676
if (retval < 0) return retval;
7777
bprm->argc++;
7878
}
79-
retval = copy_strings_kernel(1, &i_name, bprm);
79+
retval = copy_string_kernel(i_name, bprm);
8080
if (retval < 0) return retval;
8181
bprm->argc++;
8282

fs/binfmt_misc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,13 @@ static int load_misc_binary(struct linux_binprm *bprm)
190190
bprm->file = NULL;
191191
}
192192
/* make argv[1] be the path to the binary */
193-
retval = copy_strings_kernel(1, &bprm->interp, bprm);
193+
retval = copy_string_kernel(bprm->interp, bprm);
194194
if (retval < 0)
195195
goto error;
196196
bprm->argc++;
197197

198198
/* add the interp as argv[0] */
199-
retval = copy_strings_kernel(1, &fmt->interpreter, bprm);
199+
retval = copy_string_kernel(fmt->interpreter, bprm);
200200
if (retval < 0)
201201
goto error;
202202
bprm->argc++;

fs/binfmt_script.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,17 @@ static int load_script(struct linux_binprm *bprm)
117117
retval = remove_arg_zero(bprm);
118118
if (retval)
119119
return retval;
120-
retval = copy_strings_kernel(1, &bprm->interp, bprm);
120+
retval = copy_string_kernel(bprm->interp, bprm);
121121
if (retval < 0)
122122
return retval;
123123
bprm->argc++;
124124
if (i_arg) {
125-
retval = copy_strings_kernel(1, &i_arg, bprm);
125+
retval = copy_string_kernel(i_arg, bprm);
126126
if (retval < 0)
127127
return retval;
128128
bprm->argc++;
129129
}
130-
retval = copy_strings_kernel(1, &i_name, bprm);
130+
retval = copy_string_kernel(i_name, bprm);
131131
if (retval)
132132
return retval;
133133
bprm->argc++;

fs/exec.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -588,24 +588,23 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
588588
}
589589

590590
/*
591-
* Like copy_strings, but get argv and its values from kernel memory.
591+
* Copy and argument/environment string from the kernel to the processes stack.
592592
*/
593-
int copy_strings_kernel(int argc, const char *const *__argv,
594-
struct linux_binprm *bprm)
593+
int copy_string_kernel(const char *arg, struct linux_binprm *bprm)
595594
{
596595
int r;
597596
mm_segment_t oldfs = get_fs();
598597
struct user_arg_ptr argv = {
599-
.ptr.native = (const char __user *const __user *)__argv,
598+
.ptr.native = (const char __user *const __user *)&arg,
600599
};
601600

602601
set_fs(KERNEL_DS);
603-
r = copy_strings(argc, argv, bprm);
602+
r = copy_strings(1, argv, bprm);
604603
set_fs(oldfs);
605604

606605
return r;
607606
}
608-
EXPORT_SYMBOL(copy_strings_kernel);
607+
EXPORT_SYMBOL(copy_string_kernel);
609608

610609
#ifdef CONFIG_MMU
611610

@@ -1865,7 +1864,7 @@ static int __do_execve_file(int fd, struct filename *filename,
18651864
if (retval < 0)
18661865
goto out;
18671866

1868-
retval = copy_strings_kernel(1, &bprm->filename, bprm);
1867+
retval = copy_string_kernel(bprm->filename, bprm);
18691868
if (retval < 0)
18701869
goto out;
18711870

include/linux/binfmts.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ extern int setup_arg_pages(struct linux_binprm * bprm,
144144
extern int transfer_args_to_stack(struct linux_binprm *bprm,
145145
unsigned long *sp_location);
146146
extern int bprm_change_interp(const char *interp, struct linux_binprm *bprm);
147-
extern int copy_strings_kernel(int argc, const char *const *argv,
148-
struct linux_binprm *bprm);
147+
int copy_string_kernel(const char *arg, struct linux_binprm *bprm);
149148
extern void install_exec_creds(struct linux_binprm *bprm);
150149
extern void set_binfmt(struct linux_binfmt *new);
151150
extern ssize_t read_code(struct file *, unsigned long, loff_t, size_t);

0 commit comments

Comments
 (0)