From mboxrd@z Thu Jan 1 00:00:00 1970 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 2C85AC433EF for ; Fri, 10 Dec 2021 12:47:10 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dDrvm6TFdOetrMz1tU72IWSiIodLFEL57GtLG5bD+BE=; b=exvkNxTuMS0DSc PBUzUiVY2eGFUlo9/80TKGnEJJ5o5M16+eLvGSMJSGLs/0v6E0zoUAWHvmzSrUZNQZKaz/YtsBLTw FPIhdEnpL1/8JzIdcUvzjYkFbzU1vZnW+G+45tn1OesV4hKZSUOfq9WPWfuOTZ5Pywh1K2w1vAXc8 HzrgQdUSN05r2pJntCALoyCLlPQrqZ2xX68fM7t9WZM0x0RrjfHu5EsFdsi2Md5b574CCOnueuI14 +10QC/2+h8knAWUVNT6B7vnbyFmtCS/g8pg3iGXTEZIDUuPfqQ7f/7ODlSiHzIExJlv8TNCuTy/AP qSShc3MQItQ5EKbYOB9A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvfHR-001sH6-L7; Fri, 10 Dec 2021 12:45:41 +0000 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvfHN-001sFz-Im for linux-arm-kernel@lists.infradead.org; Fri, 10 Dec 2021 12:45:39 +0000 Received: by mail-wr1-x432.google.com with SMTP id c4so14701849wrd.9 for ; Fri, 10 Dec 2021 04:45:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9sJ/j648CjFEfYYwmgaJqm9n6E4hQ0hf+GgdNuFCf40=; b=sQ33cLM/SB7/dDXToTvBL6uRbSdkQ7Dv+ReEuw5JZ4N0AYWrCSXvVysI7vatB8NC6n r080596tnsP0VpHOxetN5gLwYR9KuvzItFpnfSnAtIbPq92BXcSArmILNKdMw1GGvosT tD7qDJgsTW4ysjAKkpJLKj1zknbrTkfhU0xApgNbkEBcQbdx8ADpiB/Z1xuvZzcRRuTR 9l8RLMxxWdzM2C08C2z9rUy3kFY23KREWnrO/6FLTVuAPraTcuq9XWXpvPlSsuguggZe TsXHYTK2mMaPP3Oa4PZMYvv65A+EtDh0H/xj6p+cj953DhEPK5fr+QCXeDUBn37fizif SqCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9sJ/j648CjFEfYYwmgaJqm9n6E4hQ0hf+GgdNuFCf40=; b=pSHON/J7gd+wZWd3qoB3qtwpBiBCGuBGeFHhPX0kQ80vGUcjcWz0nVhjDeB1CdPJns gusDMz9DapFiHX5xIkvM7/vIhbvsMAAwBPfrHCWwO7nCJfMEO7eZp+02MyawY28SEqqh /9EHsDbm3Z23q3RvzuI6/z5ifVunlbQ4QFyHuy3fwDLBJM3y3votwkf9StpERCZAEvS4 mRIWo4iD6l6dm9RXd43arEl1jKg9URGROT9Lij5OmtyOEU3JX0yG/EqbKaZOV6NMrrHE OPi/XHm/sBZGdT3fwIdLEX0KaIDUpoaYMTWEu/xU5TdCM5132WvArjidRlutHfYPGV9M zJIg== X-Gm-Message-State: AOAM530Xcx+vRThstN2/nrlweVU4fvSUKMW8k6haNyHW1c/gC8P3plTB ebsgYOOqOjoR+ZbFB8iTEUXUsg== X-Google-Smtp-Source: ABdhPJzgwrU/FmdlgYUrQ/W8IMfKbcwMAFyGKzuIXPCW6S7KdWuS0DbWzGfFTnCRWPoPE2mUxZ5jXA== X-Received: by 2002:adf:dd46:: with SMTP id u6mr14235805wrm.280.1639140335457; Fri, 10 Dec 2021 04:45:35 -0800 (PST) Received: from elver.google.com ([2a00:79e0:15:13:13f9:8295:8923:1942]) by smtp.gmail.com with ESMTPSA id g4sm2425890wro.12.2021.12.10.04.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 04:45:34 -0800 (PST) Date: Fri, 10 Dec 2021 13:45:27 +0100 From: Marco Elver To: Peter Collingbourne Cc: 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 , Mark Rutland , Frederic Weisbecker , Viresh Kumar , Andrey Konovalov , 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 , Alexander Potapenko , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Evgenii Stepanov Subject: Re: [PATCH v4 1/7] include: split out uaccess instrumentation into a separate header Message-ID: References: <20211209221545.2333249-1-pcc@google.com> <20211209221545.2333249-2-pcc@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211209221545.2333249-2-pcc@google.com> User-Agent: Mutt/2.0.5 (2021-01-21) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211210_044537_652919_1A9AF7E2 X-CRM114-Status: GOOD ( 28.29 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Dec 09, 2021 at 02:15PM -0800, Peter Collingbourne wrote: > In an upcoming change we are going to add uaccess instrumentation > that uses inline access to struct task_struct from the > instrumentation routines. Because instrumentation.h is included > from many places including (recursively) from sched.h this would > otherwise lead to a circular dependency. Break the dependency by > moving uaccess instrumentation routines into a separate header, > instrumentation-uaccess.h. > > Link: https://linux-review.googlesource.com/id/I625728db0c8db374e13e4ebc54985ac5c79ace7d > Signed-off-by: Peter Collingbourne > Acked-by: Dmitry Vyukov Reviewed-by: Marco Elver > --- > include/linux/instrumented-uaccess.h | 49 ++++++++++++++++++++++++++++ > include/linux/instrumented.h | 34 ------------------- > include/linux/uaccess.h | 2 +- > lib/iov_iter.c | 2 +- > lib/usercopy.c | 2 +- > 5 files changed, 52 insertions(+), 37 deletions(-) > create mode 100644 include/linux/instrumented-uaccess.h > > diff --git a/include/linux/instrumented-uaccess.h b/include/linux/instrumented-uaccess.h > new file mode 100644 > index 000000000000..ece549088e50 > --- /dev/null > +++ b/include/linux/instrumented-uaccess.h > @@ -0,0 +1,49 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > + > +/* > + * This header provides generic wrappers for memory access instrumentation for > + * uaccess routines that the compiler cannot emit for: KASAN, KCSAN. > + */ > +#ifndef _LINUX_INSTRUMENTED_UACCESS_H > +#define _LINUX_INSTRUMENTED_UACCESS_H > + > +#include > +#include > +#include > +#include > + > +/** > + * instrument_copy_to_user - instrument reads of copy_to_user > + * > + * Instrument reads from kernel memory, that are due to copy_to_user (and > + * variants). The instrumentation must be inserted before the accesses. > + * > + * @to destination address > + * @from source address > + * @n number of bytes to copy > + */ > +static __always_inline void > +instrument_copy_to_user(void __user *to, const void *from, unsigned long n) > +{ > + kasan_check_read(from, n); > + kcsan_check_read(from, n); > +} > + > +/** > + * instrument_copy_from_user - instrument writes of copy_from_user > + * > + * Instrument writes to kernel memory, that are due to copy_from_user (and > + * variants). The instrumentation should be inserted before the accesses. > + * > + * @to destination address > + * @from source address > + * @n number of bytes to copy > + */ > +static __always_inline void > +instrument_copy_from_user(const void *to, const void __user *from, unsigned long n) > +{ > + kasan_check_write(to, n); > + kcsan_check_write(to, n); > +} > + > +#endif /* _LINUX_INSTRUMENTED_UACCESS_H */ > diff --git a/include/linux/instrumented.h b/include/linux/instrumented.h > index 42faebbaa202..b68f415510c7 100644 > --- a/include/linux/instrumented.h > +++ b/include/linux/instrumented.h > @@ -102,38 +102,4 @@ static __always_inline void instrument_atomic_read_write(const volatile void *v, > kcsan_check_atomic_read_write(v, size); > } > > -/** > - * instrument_copy_to_user - instrument reads of copy_to_user > - * > - * Instrument reads from kernel memory, that are due to copy_to_user (and > - * variants). The instrumentation must be inserted before the accesses. > - * > - * @to destination address > - * @from source address > - * @n number of bytes to copy > - */ > -static __always_inline void > -instrument_copy_to_user(void __user *to, const void *from, unsigned long n) > -{ > - kasan_check_read(from, n); > - kcsan_check_read(from, n); > -} > - > -/** > - * instrument_copy_from_user - instrument writes of copy_from_user > - * > - * Instrument writes to kernel memory, that are due to copy_from_user (and > - * variants). The instrumentation should be inserted before the accesses. > - * > - * @to destination address > - * @from source address > - * @n number of bytes to copy > - */ > -static __always_inline void > -instrument_copy_from_user(const void *to, const void __user *from, unsigned long n) > -{ > - kasan_check_write(to, n); > - kcsan_check_write(to, n); > -} > - > #endif /* _LINUX_INSTRUMENTED_H */ > diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h > index ac0394087f7d..c0c467e39657 100644 > --- a/include/linux/uaccess.h > +++ b/include/linux/uaccess.h > @@ -3,7 +3,7 @@ > #define __LINUX_UACCESS_H__ > > #include > -#include > +#include > #include > #include > #include > diff --git a/lib/iov_iter.c b/lib/iov_iter.c > index 66a740e6e153..3f9dc6df7102 100644 > --- a/lib/iov_iter.c > +++ b/lib/iov_iter.c > @@ -12,7 +12,7 @@ > #include > #include > #include > -#include > +#include > > #define PIPE_PARANOIA /* for now */ > > diff --git a/lib/usercopy.c b/lib/usercopy.c > index 7413dd300516..1cd188e62d06 100644 > --- a/lib/usercopy.c > +++ b/lib/usercopy.c > @@ -1,7 +1,7 @@ > // SPDX-License-Identifier: GPL-2.0 > #include > #include > -#include > +#include > #include > > /* out-of-line parts */ > -- > 2.34.1.173.g76aa8bc2d0-goog > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel