From patchwork Tue Nov 23 05:16:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12693407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DA585C433F5 for ; Tue, 23 Nov 2021 05:19:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=55Gkn9kt5oyUCvLPMd/kaJyRdWqR40emsK8d5aN0DWs=; b=Wx1/MdfKL36UIOAdVhw7QqXQFT JxXHYZFPnTgKUiob1HYzf2q7CfNc4+uC0rGW9Vy8Upv7MzctCtAwzaZ4nleitYipb7hxPZY4rZTG4 sEBKzJV7QexxDTuYHlosrfe4k//sKLvkze67VWsdxRz5xCuGOcNza2EdFQVHMjJvVuh8dtbS9IhTu Xb7jJpd1mJIEJ/jVYSjxyKwYi4+KiwNTq2e8QzDqKSqcdQoGaJUz7NXD+ZznjxOvKWb1JMJ3YHXfd GeHRgG6ZXQfmnKyEbh21TFVQyOOo7L9EI/cNyV/lk8K3u6KtIZvRH8sUD/M7dwTWC0IhgXpN5NVVb nwUzcikA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpOC8-000q6b-Ew; Tue, 23 Nov 2021 05:18:16 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpOB9-000pmx-Og for linux-arm-kernel@lists.infradead.org; Tue, 23 Nov 2021 05:17:19 +0000 Received: by mail-pl1-x64a.google.com with SMTP id m15-20020a170902bb8f00b0014382b67873so8523445pls.19 for ; Mon, 22 Nov 2021 21:17:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Gty7Zd/Q5CRamg0gViS3X7VJ+4Eadmw90vku2OpMNR0=; b=i/FXNGYOe6PsaAxbsnm5RGEXWjnL3mlA0e019XvhMTOJ5jD4eah5o10OrcCelr/+Kl ZCM2ArN5xFg4uUGA14TEzzB9T6xMiVV8vnTqfAgIA8oDmPxZX9uO0g4m7cJz9wDoE60I 8PaUFXRlW0g5PbblIX6ZjKKdA3R5nPolWGTC0LJY/1HADB+JZ2PXA/qgv2/Vd6DLk0x1 ACkLigqPuw73RSKSoes5ibDH1aSgWsx5znBsEbKJQ9O9Du1eZTpBTNjVVNtCXH1cLSxM UUhv9tSV/ymEW9G/ux+VJtX/iMdy7Ce7KVAUyVi8CHOlReV4hJ1wZRr6H01xEcm3nU4K I2CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Gty7Zd/Q5CRamg0gViS3X7VJ+4Eadmw90vku2OpMNR0=; b=YMhZtLSpxlAtJGNoUM4pIo/2b1VveXq6YcrptBaX+tZRt9uOyzDnkwP4aaG3kmCBhE c8X0rWlf/RF6lleS0rXltamBPO8ClPuDvKlSivArwmIZjm8hKRiLdulkkpAuA3/Ctd8x NxuIX74DtwkYkmMKKY9tSD2wufDhf6UXfsKCGcozjHHHaBRQQhKUWdOsN9LTD0y6WU+n nXh3S/pIKofFlWmQczR9UkrtVA2YVz+whETLQLPL9b2Y90ZEubNAA7yZyhexfd4izU9s 627ki4usyD/+Z8LVVanqHcg+ELKBRboAIcGvEXIbUivAd8ldndWd880iiSUWA4HaOexC FboQ== X-Gm-Message-State: AOAM533dxBQYefJkhAW7uYn/QEvGvUyNmJgMy94ZMjpvBuHtBru4g2el PD7kDGGhGVqZfjLxC6rwkxWCjGk= X-Google-Smtp-Source: ABdhPJziBKpM/iqN33lOv4N3gylj/M4b6xWwzkHJc9LwUilKQIHPk1Gw7F/oNFYL6WWGZcDAEEVvryk= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:a876:2e6a:b5f:3d90]) (user=pcc job=sendgmr) by 2002:a05:6a00:b4c:b0:481:2a:f374 with SMTP id p12-20020a056a000b4c00b00481002af374mr2413056pfo.60.1637644634614; Mon, 22 Nov 2021 21:17:14 -0800 (PST) Date: Mon, 22 Nov 2021 21:16:57 -0800 In-Reply-To: <20211123051658.3195589-1-pcc@google.com> Message-Id: <20211123051658.3195589-5-pcc@google.com> Mime-Version: 1.0 References: <20211123051658.3195589-1-pcc@google.com> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog Subject: [PATCH v2 4/5] arm64: add support for uaccess logging From: Peter Collingbourne To: Catalin Marinas , Will Deacon , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Thomas Gleixner , Andy Lutomirski , Kees Cook , Andrew Morton , Masahiro Yamada , Sami Tolvanen , YiFei Zhu , Colin Ian King , Mark Rutland , Frederic Weisbecker , Viresh Kumar , Andrey Konovalov , Peter Collingbourne , Gabriel Krisman Bertazi , Chris Hyser , Daniel Vetter , Chris Wilson , Arnd Bergmann , Dmitry Vyukov , Christian Brauner , "Eric W. Biederman" , Alexey Gladkov , Ran Xiaokai , David Hildenbrand , Xiaofeng Cao , Cyrill Gorcunov , Thomas Cedeno , Marco Elver , Alexander Potapenko Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Evgenii Stepanov X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211122_211715_864340_D99D0786 X-CRM114-Status: GOOD ( 17.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org arm64 does not use CONFIG_GENERIC_ENTRY, so add the support for uaccess logging directly to the architecture. Link: https://linux-review.googlesource.com/id/I88de539fb9c4a9d27fa8cccbe201a6e4382faf89 Signed-off-by: Peter Collingbourne --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/signal.c | 5 +++++ arch/arm64/kernel/syscall.c | 3 +++ 3 files changed, 9 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index c4207cf9bb17..6023946abe4a 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -161,6 +161,7 @@ config ARM64 select HAVE_ARCH_THREAD_STRUCT_WHITELIST select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE + select HAVE_ARCH_UACCESS_BUFFER select HAVE_ARCH_VMAP_STACK select HAVE_ARM_SMCCC select HAVE_ASM_MODVERSIONS diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 8f6372b44b65..5bbd98e5c257 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -919,6 +920,8 @@ static void do_signal(struct pt_regs *regs) void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags) { + bool uaccess_buffer_pending = uaccess_buffer_pre_exit_loop(); + do { if (thread_flags & _TIF_NEED_RESCHED) { /* Unmask Debug and SError for the next task */ @@ -950,6 +953,8 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_flags) local_daif_mask(); thread_flags = READ_ONCE(current_thread_info()->flags); } while (thread_flags & _TIF_WORK_MASK); + + uaccess_buffer_post_exit_loop(uaccess_buffer_pending); } unsigned long __ro_after_init signal_minsigstksz; diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 50a0f1a38e84..6de801c1af05 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -139,7 +140,9 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, goto trace_exit; } + uaccess_buffer_syscall_entry(); invoke_syscall(regs, scno, sc_nr, syscall_table); + uaccess_buffer_syscall_exit(); /* * The tracing status may have changed under our feet, so we have to