Skip to content

Commit

Permalink
arm64: compat: Avoid sending SIGILL for unallocated syscall numbers
Browse files Browse the repository at this point in the history
The ARM Linux kernel handles the EABI syscall numbers as follows:

  0           - NR_SYSCALLS-1	: Invoke syscall via syscall table
  NR_SYSCALLS - 0xeffff		: -ENOSYS (to be allocated in future)
  0xf0000     - 0xf07ff		: Private syscall or -ENOSYS if not allocated
  > 0xf07ff			: SIGILL

Our compat code gets this wrong and ends up sending SIGILL in response
to all syscalls greater than NR_SYSCALLS which have a value greater
than 0x7ff in the bottom 16 bits.

Fix this by defining the end of the ARM private syscall region and
checking the syscall number against that directly. Update the comment
while we're at it.

Cc: <[email protected]>
Cc: Dave Martin <[email protected]>
Reported-by: Pi-Hsun Shih <[email protected]>
Signed-off-by: Will Deacon <[email protected]>
  • Loading branch information
wildea01 committed Jan 4, 2019
1 parent 9966a05 commit 169113e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions arch/arm64/include/asm/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
* The following SVCs are ARM private.
*/
#define __ARM_NR_COMPAT_BASE 0x0f0000
#define __ARM_NR_compat_cacheflush (__ARM_NR_COMPAT_BASE+2)
#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE+5)
#define __ARM_NR_compat_cacheflush (__ARM_NR_COMPAT_BASE + 2)
#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5)
#define __ARM_NR_COMPAT_END (__ARM_NR_COMPAT_BASE + 0x800)

#define __NR_compat_syscalls 399
#endif
Expand Down
4 changes: 2 additions & 2 deletions arch/arm64/kernel/sys_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ long compat_arm_syscall(struct pt_regs *regs)

default:
/*
* Calls 9f00xx..9f07ff are defined to return -ENOSYS
* Calls 0xf0xxx..0xf07ff are defined to return -ENOSYS
* if not implemented, rather than raising SIGILL. This
* way the calling program can gracefully determine whether
* a feature is supported.
*/
if ((no & 0xffff) <= 0x7ff)
if (no < __ARM_NR_COMPAT_END)
return -ENOSYS;
break;
}
Expand Down

0 comments on commit 169113e

Please sign in to comment.