From patchwork Tue Nov 23 05:16:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12693405 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 1A7F6C433EF for ; Tue, 23 Nov 2021 05:19:16 +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=oa53bgLpniboKGGQIZhyVNRJh1hxse8GHUokxypubTM=; b=Iwo0qsMeK1Y1wLOoQvsJuNhgpW y3FMnO3ojMbkkW7VXlNRC5qpzuX2hNLoM+37pMFuFXOnxBbN93Zq6OK1dcwgmegj/teom2SHWyC1A Bbc9yFf1mo7oabiK6X7eZznpSUyEjU46/T4tYzrrM/u2vTqPjVgi2qcBWoLgKyZeDQugqb8eMA8Hj FmK4aDAWLO4Na323uHpn1m3OPodKO/RdXJHmItfJDISF8m/nAvUPnKBXKJ9ZuV0H3dbsHFWPsuYKh BKUMKzuMOMXhha71XeWNfUu5jeM7dmy9vgaLzTYpB5ewvWhTE5ncwp3uSZescLYNtPTJLjRDuef9G TRBqw2wA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpOBZ-000pvh-1R; Tue, 23 Nov 2021 05:17:41 +0000 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mpOB8-000ple-H9 for linux-arm-kernel@lists.infradead.org; Tue, 23 Nov 2021 05:17:16 +0000 Received: by mail-pg1-x549.google.com with SMTP id i25-20020a631319000000b002cce0a43e94so7300103pgl.0 for ; Mon, 22 Nov 2021 21:17:13 -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=8YikxNtJWprMq/CBpWme0BytzCpItwTnBs0JI4g7h9M=; b=lr6jU+zyqsyUdEReZStYl3G49ZtLUI4FRjCCI6LwgfA4iWEF/hAOiHguW2mLPV1Jtb biEpdOkX+tP/eucrb3hTSTUeEZAA8IsY+FefkgpQdDEGEyBdG88kn1vOx1Hd751cdqgq RLanQtSikpeJXqg6AAuW28D/m0PfuXZK4I3yzqPhN9RlTWTcekgjkOvF6Vsxi5lwEeNy 4wfRl9Z9bjQSpxQaX89JGaOgKUnGpJjW2R81rbPp9qxmxlZ8OBNbEJVP3Maxvx6n4LeI PP+461MV/ampBKAJSBy4cJER48/666Tg+Hr3u6I8bSlmmHSp8KueiAApUUGR5RSamMw5 uFUA== 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=8YikxNtJWprMq/CBpWme0BytzCpItwTnBs0JI4g7h9M=; b=Wb5g//eVQsBBmvrJ9g76oogUYg0o693kAU/rcPgtU5zqlyNmcPgnVnywM8TgJeVqit ZQpldkPk+FLMC+iJjoEA+nDRXb2q8cehuMu7HyysqlB96o8MBDoxOTNGTYJ3+lOr8IH4 uTGxR4Lwkq2qp6dQ4atJnw+RYFhmSW381ibZE21J72poiAUEXsMNvew3DKy+H2/YX9v9 Qk/YooLV8DnHsifB+PpmHepW4Dbrz6hLAE9J5LasddYLMXVxHbsOT1TTGP6w+QiFWFYe jiE9p3S0k5FykiJL0KbWRqslvg0A404BTugKUX76qBuvsBpNOjED0ugzlniAB7TMSYKW eurg== X-Gm-Message-State: AOAM53216TlCKOvqp2qSJFGzquz5E/SGVhMScu5cdiPRHcY4UPhKlb7/ ikZxuWxKKcdKW8JFe/AvRPy70+E= X-Google-Smtp-Source: ABdhPJwFUF+MOVa4cKF7Nt3P3AYhZy5krLbbXlzRU0jE0MJn5GpfDjdnS4lCLzffhUcQ+vx5zPvE5Jk= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:a876:2e6a:b5f:3d90]) (user=pcc job=sendgmr) by 2002:a17:90a:a396:: with SMTP id x22mr3308358pjp.14.1637644632438; Mon, 22 Nov 2021 21:17:12 -0800 (PST) Date: Mon, 22 Nov 2021 21:16:56 -0800 In-Reply-To: <20211123051658.3195589-1-pcc@google.com> Message-Id: <20211123051658.3195589-4-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 3/5] uaccess-buffer: add CONFIG_GENERIC_ENTRY support 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_211714_600356_193AB1FB X-CRM114-Status: GOOD ( 15.02 ) 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 Add uaccess logging support on architectures that use CONFIG_GENERIC_ENTRY (currently only s390 and x86). Link: https://linux-review.googlesource.com/id/I3c5eb19a7e4a1dbe6095f6971f7826c4b0663f7d Signed-off-by: Peter Collingbourne --- arch/Kconfig | 1 + kernel/entry/common.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/arch/Kconfig b/arch/Kconfig index 6030298a7e9a..bc9cdbfdb57e 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -31,6 +31,7 @@ config HOTPLUG_SMT bool config GENERIC_ENTRY + select HAVE_ARCH_UACCESS_BUFFER bool config KPROBES diff --git a/kernel/entry/common.c b/kernel/entry/common.c index d5a61d565ad5..e06f88f77a70 100644 --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "common.h" @@ -89,6 +90,8 @@ __syscall_enter_from_user_work(struct pt_regs *regs, long syscall) if (work & SYSCALL_WORK_ENTER) syscall = syscall_trace_enter(regs, syscall, work); + uaccess_buffer_syscall_entry(); + return syscall; } @@ -197,14 +200,17 @@ static unsigned long exit_to_user_mode_loop(struct pt_regs *regs, static void exit_to_user_mode_prepare(struct pt_regs *regs) { unsigned long ti_work = READ_ONCE(current_thread_info()->flags); + bool uaccess_buffer_pending; lockdep_assert_irqs_disabled(); /* Flush pending rcuog wakeup before the last need_resched() check */ tick_nohz_user_enter_prepare(); + uaccess_buffer_pending = uaccess_buffer_pre_exit_loop(); if (unlikely(ti_work & EXIT_TO_USER_MODE_WORK)) ti_work = exit_to_user_mode_loop(regs, ti_work); + uaccess_buffer_post_exit_loop(uaccess_buffer_pending); arch_exit_to_user_mode_prepare(regs, ti_work); @@ -271,6 +277,7 @@ static void syscall_exit_to_user_mode_prepare(struct pt_regs *regs) local_irq_enable(); } + uaccess_buffer_syscall_exit(); rseq_syscall(regs); /*