Skip to content

Commit 5ae4998

Browse files
Christoph HellwigAl Viro
authored andcommitted
powerpc: remove address space overrides using set_fs()
Stop providing the possibility to override the address space using set_fs() now that there is no need for that any more. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent c331652 commit 5ae4998

6 files changed

Lines changed: 9 additions & 64 deletions

File tree

arch/powerpc/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ config PPC
249249
select PCI_SYSCALL if PCI
250250
select PPC_DAWR if PPC64
251251
select RTC_LIB
252-
select SET_FS
253252
select SPARSE_IRQ
254253
select SYSCTL_EXCEPTION_TRACE
255254
select THREAD_INFO_IN_TASK

arch/powerpc/include/asm/processor.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ struct task_struct;
8383
void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp);
8484
void release_thread(struct task_struct *);
8585

86-
typedef struct {
87-
unsigned long seg;
88-
} mm_segment_t;
89-
9086
#define TS_FPR(i) fp_state.fpr[i][TS_FPROFFSET]
9187
#define TS_CKFPR(i) ckfp_state.fpr[i][TS_FPROFFSET]
9288

@@ -148,7 +144,6 @@ struct thread_struct {
148144
unsigned long ksp_vsid;
149145
#endif
150146
struct pt_regs *regs; /* Pointer to saved register state */
151-
mm_segment_t addr_limit; /* for get_fs() validation */
152147
#ifdef CONFIG_BOOKE
153148
/* BookE base exception scratch space; align on cacheline */
154149
unsigned long normsave[8] ____cacheline_aligned;
@@ -295,15 +290,13 @@ struct thread_struct {
295290
#define INIT_THREAD { \
296291
.ksp = INIT_SP, \
297292
.ksp_limit = INIT_SP_LIMIT, \
298-
.addr_limit = KERNEL_DS, \
299293
.pgdir = swapper_pg_dir, \
300294
.fpexc_mode = MSR_FE0 | MSR_FE1, \
301295
SPEFSCR_INIT \
302296
}
303297
#else
304298
#define INIT_THREAD { \
305299
.ksp = INIT_SP, \
306-
.addr_limit = KERNEL_DS, \
307300
.fpexc_mode = 0, \
308301
}
309302
#endif

arch/powerpc/include/asm/thread_info.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ void arch_setup_new_exec(void);
9090
#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
9191
#define TIF_SIGPENDING 1 /* signal pending */
9292
#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
93-
#define TIF_FSCHECK 3 /* Check FS is USER_DS on return */
9493
#define TIF_SYSCALL_EMU 4 /* syscall emulation active */
9594
#define TIF_RESTORE_TM 5 /* need to restore TM FP/VEC/VSX */
9695
#define TIF_PATCH_PENDING 6 /* pending live patching update */
@@ -130,16 +129,14 @@ void arch_setup_new_exec(void);
130129
#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
131130
#define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
132131
#define _TIF_NOHZ (1<<TIF_NOHZ)
133-
#define _TIF_FSCHECK (1<<TIF_FSCHECK)
134132
#define _TIF_SYSCALL_EMU (1<<TIF_SYSCALL_EMU)
135133
#define _TIF_SYSCALL_DOTRACE (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
136134
_TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
137135
_TIF_NOHZ | _TIF_SYSCALL_EMU)
138136

139137
#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
140138
_TIF_NOTIFY_RESUME | _TIF_UPROBE | \
141-
_TIF_RESTORE_TM | _TIF_PATCH_PENDING | \
142-
_TIF_FSCHECK)
139+
_TIF_RESTORE_TM | _TIF_PATCH_PENDING)
143140
#define _TIF_PERSYSCALL_MASK (_TIF_RESTOREALL|_TIF_NOERROR)
144141

145142
/* Bits in local_flags */

arch/powerpc/include/asm/uaccess.h

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,62 +8,21 @@
88
#include <asm/extable.h>
99
#include <asm/kup.h>
1010

11-
/*
12-
* The fs value determines whether argument validity checking should be
13-
* performed or not. If get_fs() == USER_DS, checking is performed, with
14-
* get_fs() == KERNEL_DS, checking is bypassed.
15-
*
16-
* For historical reasons, these macros are grossly misnamed.
17-
*
18-
* The fs/ds values are now the highest legal address in the "segment".
19-
* This simplifies the checking in the routines below.
20-
*/
21-
22-
#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
23-
24-
#define KERNEL_DS MAKE_MM_SEG(~0UL)
2511
#ifdef __powerpc64__
2612
/* We use TASK_SIZE_USER64 as TASK_SIZE is not constant */
27-
#define USER_DS MAKE_MM_SEG(TASK_SIZE_USER64 - 1)
13+
#define TASK_SIZE_MAX TASK_SIZE_USER64
2814
#else
29-
#define USER_DS MAKE_MM_SEG(TASK_SIZE - 1)
15+
#define TASK_SIZE_MAX TASK_SIZE
3016
#endif
3117

32-
#define get_fs() (current->thread.addr_limit)
33-
34-
static inline void set_fs(mm_segment_t fs)
18+
static inline bool __access_ok(unsigned long addr, unsigned long size)
3519
{
36-
current->thread.addr_limit = fs;
37-
/* On user-mode return check addr_limit (fs) is correct */
38-
set_thread_flag(TIF_FSCHECK);
20+
return addr < TASK_SIZE_MAX && size <= TASK_SIZE_MAX - addr;
3921
}
4022

41-
#define uaccess_kernel() (get_fs().seg == KERNEL_DS.seg)
42-
#define user_addr_max() (get_fs().seg)
43-
44-
#ifdef __powerpc64__
45-
/*
46-
* This check is sufficient because there is a large enough
47-
* gap between user addresses and the kernel addresses
48-
*/
49-
#define __access_ok(addr, size, segment) \
50-
(((addr) <= (segment).seg) && ((size) <= (segment).seg))
51-
52-
#else
53-
54-
static inline int __access_ok(unsigned long addr, unsigned long size,
55-
mm_segment_t seg)
56-
{
57-
if (addr > seg.seg)
58-
return 0;
59-
return (size == 0 || size - 1 <= seg.seg - addr);
60-
}
61-
62-
#endif
63-
6423
#define access_ok(addr, size) \
6524
(__chk_user_ptr(addr), \
66-
__access_ok((__force unsigned long)(addr), (size), get_fs()))
25+
__access_ok((unsigned long)(addr), (size)))
6726

6827
/*
6928
* These are the main single-value transfer routines. They automatically

arch/powerpc/kernel/signal.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,6 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)
312312
{
313313
user_exit();
314314

315-
/* Check valid addr_limit, TIF check is done there */
316-
addr_limit_user_check();
317-
318315
if (thread_info_flags & _TIF_UPROBE)
319316
uprobe_notify_resume(regs);
320317

arch/powerpc/lib/sstep.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ static nokprobe_inline long address_ok(struct pt_regs *regs,
108108
{
109109
if (!user_mode(regs))
110110
return 1;
111-
if (__access_ok(ea, nb, USER_DS))
111+
if (__access_ok(ea, nb))
112112
return 1;
113-
if (__access_ok(ea, 1, USER_DS))
113+
if (__access_ok(ea, 1))
114114
/* Access overlaps the end of the user region */
115-
regs->dar = USER_DS.seg;
115+
regs->dar = TASK_SIZE_MAX - 1;
116116
else
117117
regs->dar = ea;
118118
return 0;

0 commit comments

Comments
 (0)