From patchwork Mon Mar 8 12:30:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 395405 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp1669782jai; Mon, 8 Mar 2021 04:32:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEAq7BsOAq7vCSM2JWjNbg0iJ7+ibCoLScW9fMCZmqPXKpKzOpdQIEvEp0p6qUsHRG7URP X-Received: by 2002:a05:6402:2076:: with SMTP id bd22mr21548184edb.378.1615206727797; Mon, 08 Mar 2021 04:32:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615206727; cv=none; d=google.com; s=arc-20160816; b=HP4Y3XgP8M6P81c8OUyUxMVcuFJK8Z+f5PTkeuyQKRHygiYrqpNXgy+Tqfd3nKktiM 8mVtb0dtZWd6t7K6UVB3snwkblfF98uI+EvPT6HXnCXYq4iBk1Xiy21R8qFc3sl8Mlhh jKgPnFg33jqyjPWVh5YX5gFiSOqTbrbFtWojXvO5AlUpCWHpf3HcruXIEdvypunlOj8W KRg43DFgUq6DQyWzFuh9EsN7lKsP6EbWUwMZnErdelJaLZ+OX0OhzM1DccdjjZ+YMxE8 m7eC5Y4I+tDL9NDxFm/7d+g7/cHHSmenTK/TJHReq9ZjvNUQxlK6DUqiaEJpVzI2fRgG VTEQ== 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=eOHiqhuIXL57MzttX8N+PJO2umXYJupwRyZIbLskTDk=; b=kGjWQcDMk5M432AcJk6ybUIHokyfSvtSGFNiyOobjmcpwuTJcOGX2ub7gv1bKgNUXb bSRTU/b4p4VAEu/U1aTiPBfLvgZdQFOIKWNtF6hKrsXEtVNgQEfSlpzqrhVRVrdV7IrA VLysdIzHKqc4sbheJzbM+9+9xZUYXkbYErjHTXYGwGpBVx1dq1TFD3QtjK6fdThmPD9t xJYthC9DbOwWirGrrrztEK/4iePwdfAM6hlpDMx5seo2b4iP+8KL+Y+WOz3jkygYi69h JBxinQmJF9ATM3PdjsD5TpN9QgmPODnp1VkTM4UNhBqlbL1APKbGlZkSx5tKF9gK0Ej4 zzyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BZvSyYIc; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 t16si5490958edc.448.2021.03.08.04.32.07; Mon, 08 Mar 2021 04:32:07 -0800 (PST) Received-SPF: pass (google.com: domain of stable-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=BZvSyYIc; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-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 S230078AbhCHMbd (ORCPT + 13 others); Mon, 8 Mar 2021 07:31:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:40472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbhCHMbI (ORCPT ); Mon, 8 Mar 2021 07:31:08 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2BDC364EBC; Mon, 8 Mar 2021 12:31:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615206667; bh=aaZGSCPB3/0imlRKgvnEmmG7FWVeoTA9PuWRxWqkgNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BZvSyYIcv7tNx+3PJMOFGODbrjVAbSFwfA8QjkJZ+OJVGgfMgo55Tz41D7NVSvhIs UyqwQFfGJpukTGll0leE2jOUU43MoOA6mZOsTe6uX6L7ciPBdSy6/WV6lhpf654lqb 7Zx62OKWZLXn7eTyuNeZhiciW6doTPbSbA6dc6YY= 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.4 13/22] arm64: ptrace: Fix seccomp of traced syscall -1 (NO_SYSCALL) Date: Mon, 8 Mar 2021 13:30:30 +0100 Message-Id: <20210308122715.036978550@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210308122714.391917404@linuxfoundation.org> References: <20210308122714.391917404@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -1844,7 +1844,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 -1; }