From patchwork Mon Mar 1 16:13:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 388740 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp3668778jap; Mon, 1 Mar 2021 12:26:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJyDklpADxxRnSoBHCwLJDF5Si52WCcaVN8Em1C1x9oyKZXsVfhMF/RvPsCVUuJPfDFdqbHe X-Received: by 2002:a17:906:af91:: with SMTP id mj17mr16987757ejb.230.1614630387669; Mon, 01 Mar 2021 12:26:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614630387; cv=none; d=google.com; s=arc-20160816; b=HTMY4W73a9PVkrwk/KuhFk1X90BWKqg6wIMPzr9An86ovNFxbKrRhAKw6rkRK/NASD R9VePBEVsZhNFSWZsXYt4d6EtRDfWqiI3VoMsZeNjerXPQmU8gltMuZqNpKi6j2+i9oO ExfH0XCgS2Knh0HkaFFp6AmA6ASyblT71xldtS8yQYKUCSQ26EsbI9rXJHWuzczo83VR wAJNsY3/umSzb+U/77sRi5U7//12dTsojoPNNnCjoC0ZqPZ/PFAZHNCs95BrpMum6+r5 AT4f2o41gg8PFYfnRbcCR9OhtqqwuSTel5mAh9xVNj7+yKRXI5UECWELsAurRiwHoj98 cz8g== 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=G5L1E9JeGtgG8T0qCvENIy2b1dTabsGsvl+33zo7994=; b=M5fahp3X/xJPM1TI0IwFkZElOZ290YPvasgphTj3WELhUTpI8dmM6YauvzRGWYZcpv PpRTOmWNVgiwF3o/gTltGOzXCh0a61VCOXCSbs5L28WjF3qUn3ZM+Yft5PpvAuGL6g7+ lq0O29o/fkivv6PdfzVMN1sJRtOIAW/EgkqHKmWn4joiqNip9aCaa4LOlMEm6+c7M4kn A+T4NYX3eEHXm6l4QVgoam4J6vO2kL1iXiVO6MGJz71ArZ2QpoR24DI6iarMH4Oa/YFr iIO0i3QcXYBvgh4l6yDtk2R1j6PVi5l4OgWWNi2oeeXZjDntGhmZqK+TS6ppvEaJlkty GsbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=R+xJrTb3; 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 b25si2692924edx.341.2021.03.01.12.26.27; Mon, 01 Mar 2021 12:26:27 -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=R+xJrTb3; 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 S238466AbhCAUZY (ORCPT + 13 others); Mon, 1 Mar 2021 15:25:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:45786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243216AbhCAUS6 (ORCPT ); Mon, 1 Mar 2021 15:18:58 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 180AF651AC; Mon, 1 Mar 2021 18:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614621821; bh=VgKAkf1ykJyZbkeOvUqpBjSbR3B5Ik355Kn67/bLMs4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R+xJrTb3si//rT9jZ+zNRcQ18hHB3ILYfQTn+p+haBF8TPGWoGj2NYD7v9kdapp5s Dfaib6IPn0wNuJfBQIUyJaeJokR9+9uEpJ/xMO3Ogqj72l1Da5uHLV9Ch6g2J5OkKV 4L9Y8BjT5b0uUYG30VVFQuhS4QloQ3vksHkRoHrw= 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.11 655/775] arm64: ptrace: Fix seccomp of traced syscall -1 (NO_SYSCALL) Date: Mon, 1 Mar 2021 17:13:43 +0100 Message-Id: <20210301161233.751408303@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161201.679371205@linuxfoundation.org> References: <20210301161201.679371205@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 @@ -1796,7 +1796,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; }