From patchwork Mon Mar 1 16:13:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 388700 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3604337jap; Mon, 1 Mar 2021 10:51:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdAFmcgBYfDRLvY/IMD3dTEMBioM5hNxMDJNB01JiWwg5QWmpBxMk9eakwz5Uv89Bq74m7 X-Received: by 2002:a17:906:25c4:: with SMTP id n4mr17425433ejb.359.1614624702161; Mon, 01 Mar 2021 10:51:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614624702; cv=none; d=google.com; s=arc-20160816; b=Dmi5A9LHjMhJZSqKTlM7gOkyvED/tGOEJj4Sz4Zf8Yo2/TkRASF5TyeqsDaB7qfykV Inv0iLDDm0sLTHYom1SLUbtyjF7LX4f6IxZEJzHmxHXtsFMFUfO7rmqjhwggvIfjqhSS /au2G3Wrt44a5Gyo7lkpMjne0VOW87QsUm3F4fiCWDGH4AlVIJtlOgtouv2+VoBvye0v Ky7ltThIoBCUQozlJoTffWpT8b4Ol9dFQNieI6nY//IikT1r/L3Y31+fhIyTnHDm52Bs G0Itn2tl9gZwGpWknKQTZHztkd95dga9K7ul46+OYSU9MO6DMDipPU7lPcndi5E5+Ajd 5n7w== 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=vJT2c9H/wx2TrTh+vZ6Q0EdS9ToNEfhjtdv6vI/LqwFYlgHvCOdtZMZSOGh5GU0oyN bFEVacrHw+lNwpMhPl+9zTkaLJo+/MiIxWSkeAEMkQWYECPeuC/NmgVhH5WIDY64vNJp KIEwEDURb6NtvQc+cHKPaV5kAwr2oMy6iA5D9RSGdQ71zt3iGKnZtnmT8rdNENCjCpas dtHZWZ3kMzfIQgaJaoN3H8phnLgptPy8V8FxoYs+gbqCzSQ2FHcL7T0QJTIbd0168aqF nhvqLVEDJBblXIZ33UXIp8DZYOUcy2PO/R4LFP+5PCv39/r/WnvhMNuk0N5Wgtleuf3m qnRQ== 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 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 e24si1197646edv.373.2021.03.01.10.51.41; Mon, 01 Mar 2021 10:51:42 -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=B1cT+neq; 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 S238002AbhCASuq (ORCPT + 13 others); Mon, 1 Mar 2021 13:50:46 -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 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 @@ -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; }