Skip to content

Commit 2df7a7d

Browse files
Sergei Trofimovichtorvalds
authored andcommitted
alpha: unbreak osf_setsysinfo(SSI_NVPAIRS, [SSIN_UACPROC, UAC_SIGBUS])
The bug was accidentally found by the following program: #include <asm/sysinfo.h> #include <asm/unistd.h> #include <sys/syscall.h> static int setsysinfo(unsigned long op, void *buffer, unsigned long size, int *start, void *arg, unsigned long flag) { return syscall(__NR_osf_setsysinfo, op, buffer, size, start, arg, flag); } int main(int argc, char **argv) { short x[10]; unsigned int buf[2] = { SSIN_UACPROC, UAC_SIGBUS, }; setsysinfo(SSI_NVPAIRS, buf, 1, 0, 0, 0); int *y = (int*) (x+1); *y = 0; return 0; } The program shoud fail on SIGBUS, but didn't. The patch is a second part of userspace flag fix (commit 745dd24 "Alpha: Rearrange thread info flags fixing two regressions"). Deleted outdated out-of-sync 'UAC_SHIFT' (the cause of bug) in favour of 'ALPHA_UAC_SHIFT'. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Acked-by: Michael Cree <mcree@orcon.net.nz> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Matt Turner <mattst88@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 06ed462 commit 2df7a7d

3 files changed

Lines changed: 11 additions & 18 deletions

File tree

‎arch/alpha/include/asm/sysinfo.h‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,4 @@
2727
#define UAC_NOFIX 2
2828
#define UAC_SIGBUS 4
2929

30-
31-
#ifdef __KERNEL__
32-
33-
/* This is the shift that is applied to the UAC bits as stored in the
34-
per-thread flags. See thread_info.h. */
35-
#define UAC_SHIFT 6
36-
37-
#endif
38-
3930
#endif /* __ASM_ALPHA_SYSINFO_H */

‎arch/alpha/include/asm/thread_info.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ register struct thread_info *__current_thread_info __asm__("$8");
7474
#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
7575
#define TIF_POLLING_NRFLAG 8 /* poll_idle is polling NEED_RESCHED */
7676
#define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */
77-
#define TIF_UAC_NOPRINT 10 /* see sysinfo.h */
78-
#define TIF_UAC_NOFIX 11
79-
#define TIF_UAC_SIGBUS 12
77+
#define TIF_UAC_NOPRINT 10 /* ! Preserve sequence of following */
78+
#define TIF_UAC_NOFIX 11 /* ! flags as they match */
79+
#define TIF_UAC_SIGBUS 12 /* ! userspace part of 'osf_sysinfo' */
8080
#define TIF_MEMDIE 13 /* is terminating due to OOM killer */
8181
#define TIF_RESTORE_SIGMASK 14 /* restore signal mask in do_signal */
8282
#define TIF_FREEZE 16 /* is freezing for suspend */
@@ -97,7 +97,7 @@ register struct thread_info *__current_thread_info __asm__("$8");
9797
#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \
9898
| _TIF_SYSCALL_TRACE)
9999

100-
#define ALPHA_UAC_SHIFT 10
100+
#define ALPHA_UAC_SHIFT TIF_UAC_NOPRINT
101101
#define ALPHA_UAC_MASK (1 << TIF_UAC_NOPRINT | 1 << TIF_UAC_NOFIX | \
102102
1 << TIF_UAC_SIGBUS)
103103

‎arch/alpha/kernel/osf_sys.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <asm/uaccess.h>
4343
#include <asm/system.h>
4444
#include <asm/sysinfo.h>
45+
#include <asm/thread_info.h>
4546
#include <asm/hwrpb.h>
4647
#include <asm/processor.h>
4748

@@ -633,9 +634,10 @@ SYSCALL_DEFINE5(osf_getsysinfo, unsigned long, op, void __user *, buffer,
633634
case GSI_UACPROC:
634635
if (nbytes < sizeof(unsigned int))
635636
return -EINVAL;
636-
w = (current_thread_info()->flags >> UAC_SHIFT) & UAC_BITMASK;
637-
if (put_user(w, (unsigned int __user *)buffer))
638-
return -EFAULT;
637+
w = (current_thread_info()->flags >> ALPHA_UAC_SHIFT) &
638+
UAC_BITMASK;
639+
if (put_user(w, (unsigned int __user *)buffer))
640+
return -EFAULT;
639641
return 1;
640642

641643
case GSI_PROC_TYPE:
@@ -756,8 +758,8 @@ SYSCALL_DEFINE5(osf_setsysinfo, unsigned long, op, void __user *, buffer,
756758
case SSIN_UACPROC:
757759
again:
758760
old = current_thread_info()->flags;
759-
new = old & ~(UAC_BITMASK << UAC_SHIFT);
760-
new = new | (w & UAC_BITMASK) << UAC_SHIFT;
761+
new = old & ~(UAC_BITMASK << ALPHA_UAC_SHIFT);
762+
new = new | (w & UAC_BITMASK) << ALPHA_UAC_SHIFT;
761763
if (cmpxchg(&current_thread_info()->flags,
762764
old, new) != old)
763765
goto again;

0 commit comments

Comments
 (0)