Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp554698pxb; Wed, 3 Mar 2021 09:26:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxMwoT/mQOo4ZgJk4YMIJ9NElAYhg4F8O++U+fJX5Gk4Xs0yz6Pgf+JfNaFVLojqd5X/bjm X-Received: by 2002:a05:6402:220a:: with SMTP id cq10mr309815edb.345.1614792406496; Wed, 03 Mar 2021 09:26:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614792406; cv=none; d=google.com; s=arc-20160816; b=ZqjioqTfDJhDQr99f0MDsgJVp99QKUwFCPF0L53Dl/fAJVoMakB7nLP3D5Tq2CmRy+ ycvNw9+hLY3O1qb5NMWilE48TaR/NzppOmKVZBo+kGe/IarcuGceDyPxuogJgfEFcK+9 ZyHYCbFee/aDfwO8V744vJ44/DYuIuyoJFofN8pLHHsSKvOj9UDgOchDx+BRQkkOLzQg /WQWxXFT5mHIwqX3Afb3GFeg6f7F0KSUZ3DESckKvJOiOqg+nFDAJ/pMJLhb5tFrGA1P 8dhZVaFQOp9LvtKClEeCvWrVS43ebq50vFFyk83Z0aCKvpjx6Tls4Y9N7uYWF5OeI2OL FDOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DP/yl1nMbUClB+IQ8VHb+Ylrq0A30QMu0mNTCjwyqIg=; b=sIGnQtXinGSBDyhNYmv2faMNqfelUQzxz7mnq05BooZNOEFfighEgGg6cuN3AGGBVj XABTriSx9TXe3GVuBAcpMTCAKS07YqMH+5byYIFh8WqMJUztA9HQ9i0k02BGYPcAfw0w YxUQGHwAG9wGliP+zxBELmDT/IWun4Gs3g2IUXaqea05/qyTYFY7k57MNXJOSL6zGnc6 f7NNIDhCESrKYSrkiSu56SmfpXpUKkaSRnxfrwCJwUEOnqghrFmlg33zzbvP4Hy9qbAT b2SiIGjPsHHxw6FbKMNtVQP/5E9srL52rSZ9iu6KjqUP9ONGe9Th73rTULlRONWECccG MjKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B1cT+neq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c8si15450185ejk.354.2021.03.03.09.25.40; Wed, 03 Mar 2021 09:26:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=B1cT+neq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377460AbhCBArX (ORCPT + 99 others); Mon, 1 Mar 2021 19:47:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:53754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239107AbhCASoG (ORCPT ); Mon, 1 Mar 2021 13:44:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 562BB6525B; Mon, 1 Mar 2021 17:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614619710; bh=TGmsIkonSlL6CLU2vGKsEzCDPcXORtC9nd7WyseilKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B1cT+neqtrMSpir2HNfEROyW2aRleTRYt8l9zfFfgiWiw9wBcPf9aRK/6DfPRKe4M cVkiSh6niYY7LZ1Hzyc7vT4G0vHJ4Ue2xnmYT9bU02fTDsZOc0uUm+SvWJHdGK3aj3 7Hu5uhb/g0bXmUzFueh1o8PUY0TLjpZYPDmjGoPo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleg Nesterov , Catalin Marinas , Kees Cook , Sudeep Holla , Timothy E Baldwin , Will Deacon Subject: [PATCH 5.10 552/663] arm64: ptrace: Fix seccomp of traced syscall -1 (NO_SYSCALL) Date: Mon, 1 Mar 2021 17:13:20 +0100 Message-Id: <20210301161209.186346098@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Timothy E Baldwin commit df84fe94708985cdfb78a83148322bcd0a699472 upstream. Since commit f086f67485c5 ("arm64: ptrace: add support for syscall emulation"), if system call number -1 is called and the process is being traced with PTRACE_SYSCALL, for example by strace, the seccomp check is skipped and -ENOSYS is returned unconditionally (unless altered by the tracer) rather than carrying out action specified in the seccomp filter. The consequence of this is that it is not possible to reliably strace a seccomp based implementation of a foreign system call interface in which r7/x8 is permitted to be -1 on entry to a system call. Also trace_sys_enter and audit_syscall_entry are skipped if a system call is skipped. Fix by removing the in_syscall(regs) check restoring the previous behaviour which is like AArch32, x86 (which uses generic code) and everything else. Cc: Oleg Nesterov Cc: Catalin Marinas Cc: Fixes: f086f67485c5 ("arm64: ptrace: add support for syscall emulation") Reviewed-by: Kees Cook Reviewed-by: Sudeep Holla Tested-by: Sudeep Holla Signed-off-by: Timothy E Baldwin Link: https://lore.kernel.org/r/90edd33b-6353-1228-791f-0336d94d5f8c@majoroak.me.uk Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/ptrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1799,7 +1799,7 @@ int syscall_trace_enter(struct pt_regs * if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) { tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER); - if (!in_syscall(regs) || (flags & _TIF_SYSCALL_EMU)) + if (flags & _TIF_SYSCALL_EMU) return NO_SYSCALL; }