Skip to content

compat: Introduce and use in_compat_syscall

Andy Lutomirski linux-arch linux-mips linux-parisc linux-s390 sparclinux 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest16 patches 11 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16compat: Add in_compat_syscall to ask whether we're in a compat syscallinclude/linux/compat.h+15 -00 replies
2/16sparc/compat: Provide an accurate in_compat_syscall implementationarch/sparc/include/asm/compat.h+6 -06 replies
3/16sparc/syscall: Fix syscall_get_archarch/sparc/include/asm/syscall.h+8 -10 replies
4/16seccomp: Check in_compat_syscall, not is_compat_task, in strict modekernel/seccomp.c+2 -20 replies
5/16ptrace: in PEEK_SIGINFO, check syscall bitness, not task bitnesskernel/ptrace.c+1 -10 replies
6/16auditsc: For seccomp events, log syscall compat state using in_compat_syscallkernel/auditsc.c+2 -20 replies
7/16staging/lustre: Switch from is_compat_task to in_compat_syscalldrivers/staging/lustre/lustre/llite/llite_internal.h+1 -10 replies
8/16ext4: In ext4_dir_llseek, check syscall bitness directlyfs/ext4/dir.c+1 -10 replies
9/16net/sctp: Use in_compat_syscall for sctp_getsockopt_connectx3net/sctp/socket.c+1 -10 replies
10/16net/xfrm_user: Use in_compat_syscall to deny compat syscallsnet/xfrm/xfrm_user.c+1 -10 replies
11/16firewire: Use in_compat_syscall to check ioctl compatnessdrivers/firewire/core-cdev.c+2 -20 replies
12/16efivars: Use in_compat_syscall to check for compat callersdrivers/firmware/efi/efivars.c+1 -10 replies
13/16amdkfd: Use in_compat_syscall to check open() caller typedrivers/gpu/drm/amd/amdkfd/kfd_chardev.c drivers/gpu/drm/amd/amdkfd/kfd_process.c+2 -20 replies
14/16input: Redefine INPUT_COMPAT_TEST as in_compat_syscall()drivers/input/input-compat.h+1 -115 replies
15/16uhid: Check write() bitness using in_compat_syscalldrivers/hid/uhid.c+1 -10 replies
16/16x86/compat: Remove is_compat_taskarch/x86/include/asm/compat.h arch/x86/include/asm/ftrace.h arch/x86/kernel/process_64.c+4 -30 replies

Reviews trailers per patch

2 of 16 patches have a Reviewed-by or Acked-by.

PatchDavid S. MillerDmitry Torokhov
1/16
2/16A-b
3/16
4/16
5/16
6/16
7/16
8/16
9/16
10/16
11/16
12/16
13/16
14/16A-b
15/16
16/16

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 00/16] compat: Introduce and use in_compat_syscall

Linux distinguishes compat syscalls from normal syscalls in two ways. First, compat syscalls use separate entry points. This is entirely sensible. Second, code paths that are common to compat and non-compat syscalls can query is_compat_task() to check whether they are being called from a compat syscall or not.

The latter is problematic. Two architectures explicitly allow tasks to issue syscalls for which the task bitness and the syscall bitness don't match. On x86, is_compat_task returns true if the current syscall is a compat syscall, which is a different condition from being a compat task. This oddity is confusing. On SPARC, is_compat_task does what it sounds like, which means that user programs can cause is_compat_task to fail to match the syscall entry used. That could expose bugs.

This series introduces in_compat_syscall() as a new way to query the syscall type. On SPARC, it really does check the syscall bitness. Later patches change all of the non arch-specific is_compat_task callers to use in_compat_syscall. The last patch removes is_compat_task on x86, which will prevent this confusion from recurring.

I've cc'd the maintainers of all archs that support compat. If your arch makes it possible for a malicious user process to invoke a compat syscall in a nominally 64-bit task or vice versa and your arch is not x86 or SPARC, please tell me.

Davem, can you check whether I handled SPARC correctly?

Andy Lutomirski (16):
compat: Add in_compat_syscall to ask whether we're in a compat syscall sparc/compat: Provide an accurate in_compat_syscall implementation sparc/syscall: Fix syscall_get_arch
seccomp: Check in_compat_syscall, not is_compat_task, in strict mode
ptrace: in PEEK_SIGINFO, check syscall bitness, not task bitness
auditsc: For seccomp events, log syscall compat state using
in_compat_syscall
staging/lustre: Switch from is_compat_task to in_compat_syscall
ext4: In ext4_dir_llseek, check syscall bitness directly net/sctp: Use in_compat_syscall for sctp_getsockopt_connectx3 net/xfrm_user: Use in_compat_syscall to deny compat syscalls
firewire: Use in_compat_syscall to check ioctl compatness
efivars: Use in_compat_syscall to check for compat callers
amdkfd: Use in_compat_syscall to check open() caller type
input: Redefine INPUT_COMPAT_TEST as in_compat_syscall()
uhid: Check write() bitness using in_compat_syscall x86/compat: Remove is_compat_task

 arch/sparc/include/asm/compat.h                      |  6 ++++++
 arch/sparc/include/asm/syscall.h                     |  9 ++++++++-
 arch/x86/include/asm/compat.h                        |  3 ++-
 arch/x86/include/asm/ftrace.h                        |  2 +-
 arch/x86/kernel/process_64.c                         |  2 +-
 drivers/firewire/core-cdev.c                         |  4 ++--
 drivers/firmware/efi/efivars.c                       |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c             |  2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_process.c             |  2 +-
 drivers/hid/uhid.c                                   |  2 +-
 drivers/input/input-compat.h                         | 12 +-----------
 drivers/staging/lustre/lustre/llite/llite_internal.h |  2 +-
 fs/ext4/dir.c                                        |  2 +-
 include/linux/compat.h                               | 15 +++++++++++++++
 kernel/auditsc.c                                     |  4 ++--
 kernel/ptrace.c                                      |  2 +-
 kernel/seccomp.c                                     |  4 ++--
 net/sctp/socket.c                                    |  2 +-
 net/xfrm/xfrm_user.c                                 |  2 +-
 19 files changed, 49 insertions(+), 30 deletions(-)
Signature · 1 line
2.5.0