Skip to content

Commit 951b396

Browse files
author
Al Viro
committed
c6x: sanitize copy_thread(), get rid of clone(2) wrapper, switch to generic clone()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 24465a4 commit 951b396

4 files changed

Lines changed: 6 additions & 36 deletions

File tree

‎arch/c6x/include/asm/syscalls.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ extern long sys_fallocate_c6x(int fd, int mode,
4141
u32 len_lo, u32 len_hi);
4242
extern int sys_cache_sync(unsigned long s, unsigned long e);
4343

44-
struct pt_regs;
45-
46-
extern asmlinkage long sys_c6x_clone(struct pt_regs *regs);
47-
4844
#include <asm-generic/syscalls.h>
4945

5046
#endif /* __ASM_C6X_SYSCALLS_H */

‎arch/c6x/include/uapi/asm/unistd.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
#define __ARCH_WANT_SYS_EXECVE
18+
#define __ARCH_WANT_SYS_CLONE
1819

1920
/* Use the standard ABI for syscalls. */
2021
#include <asm-generic/unistd.h>

‎arch/c6x/kernel/entry.S‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -613,18 +613,6 @@ ENDPROC(sys_sigaltstack)
613613
;; Special system calls
614614
;; return address is in B3
615615
;;
616-
ENTRY(sys_clone)
617-
ADD .D1X SP,8,A4
618-
#ifdef CONFIG_C6X_BIG_KERNEL
619-
|| MVKL .S1 sys_c6x_clone,A0
620-
MVKH .S1 sys_c6x_clone,A0
621-
BNOP .S2X A0,5
622-
#else
623-
|| B .S2 sys_c6x_clone
624-
NOP 5
625-
#endif
626-
ENDPROC(sys_clone)
627-
628616
ENTRY(sys_rt_sigreturn)
629617
ADD .D1X SP,8,A4
630618
#ifdef CONFIG_C6X_BIG_KERNEL

‎arch/c6x/kernel/process.c‎

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,6 @@ void exit_thread(void)
112112
{
113113
}
114114

115-
SYSCALL_DEFINE1(c6x_clone, struct pt_regs *, regs)
116-
{
117-
unsigned long clone_flags;
118-
unsigned long newsp;
119-
120-
/* syscall puts clone_flags in A4 and usp in B4 */
121-
clone_flags = regs->orig_a4;
122-
if (regs->b4)
123-
newsp = regs->b4;
124-
else
125-
newsp = regs->sp;
126-
127-
return do_fork(clone_flags, newsp, regs, 0, (int __user *)regs->a6,
128-
(int __user *)regs->b6);
129-
}
130-
131115
/*
132116
* Do necessary setup to start up a newly executed thread.
133117
*/
@@ -155,13 +139,13 @@ void start_thread(struct pt_regs *regs, unsigned int pc, unsigned long usp)
155139
*/
156140
int copy_thread(unsigned long clone_flags, unsigned long usp,
157141
unsigned long ustk_size,
158-
struct task_struct *p, struct pt_regs *regs)
142+
struct task_struct *p, struct pt_regs *unused)
159143
{
160144
struct pt_regs *childregs;
161145

162146
childregs = task_pt_regs(p);
163147

164-
if (!regs) {
148+
if (unlikely(p->flags & PF_KTHREAD)) {
165149
/* case of __kernel_thread: we return to supervisor space */
166150
memset(childregs, 0, sizeof(struct pt_regs));
167151
childregs->sp = (unsigned long)(childregs + 1);
@@ -170,8 +154,9 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
170154
childregs->a1 = ustk_size; /* argument */
171155
} else {
172156
/* Otherwise use the given stack */
173-
*childregs = *regs;
174-
childregs->sp = usp;
157+
*childregs = *current_pt_regs();
158+
if (usp)
159+
childregs->sp = usp;
175160
p->thread.pc = (unsigned long) ret_from_fork;
176161
}
177162

0 commit comments

Comments
 (0)