From nobody Sun Feb 8 07:40:17 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49EADC43334 for ; Fri, 1 Jul 2022 14:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231722AbiGAOYM (ORCPT ); Fri, 1 Jul 2022 10:24:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbiGAOXh (ORCPT ); Fri, 1 Jul 2022 10:23:37 -0400 Received: from mail-ed1-x549.google.com (mail-ed1-x549.google.com [IPv6:2a00:1450:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80B3539698 for ; Fri, 1 Jul 2022 07:23:31 -0700 (PDT) Received: by mail-ed1-x549.google.com with SMTP id x21-20020a05640226d500b00435bd7f9367so1884355edd.8 for ; Fri, 01 Jul 2022 07:23:31 -0700 (PDT) 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=pc6R18JS+sE1u3dlHmLsZDbE6VaTO3tMmut2L/JxCPM=; b=S+rhPYqifq/yKHIbjTCu4N0+Z7NmA9VGY0y8mmzTIhWAs4YaTE8GZZ/d43VgjMb7UK az5tdkPj9m+23R3TaCa0oezo79iWHEHsoOzkGkp2TjQQUNIdG/x1dKhPZaJZhlGLwZdu OjzMamB1js4+neGeWSDKWbw+2TwxoP4epnmauaWHGLcm5vCoQvR64fFA9xoH25lw6mWd RLVZUTkg987xWln4gHc8u6k+gTKox0fy6iKvm0z+TJUaI4tHLawej5SvXm+skA79uSIb qPS9h+WO1w5qn9e14232gpg/imXEIDcl9Inw5qmcqk5oV1wYuWBucbpYRkDhcT0pyMzj XIag== 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=pc6R18JS+sE1u3dlHmLsZDbE6VaTO3tMmut2L/JxCPM=; b=B4h0BQfFwC3EPvb9myiNelm7CEGS0Oh2Sd6Xke/7060BooLF31jK4zjmo9zui47qOW /wkSwdiSiEiLPW7C8RbIcA+IhHEqvFsRxk/HVa5L7VjOvVSJ+Z7oCBE64gQz0W6AaQ0H 6J9TXLK+0OiINj2Q8im2kDdPhPBPS9hb84Ez5RARhXM4hFZGCDlWoIGWv/NbJGIQvJs0 sSSbCd9QI/WM3ZhBwt0fE3iRneMWq8ucB3y6XBrMcMvqlrp/moe1v4wI0eY9iKb1WLuJ S/MlN9huNramuayYFsnQQrxYEsKseuvky7EgC5xH9Gk/sOfbLuMum0RHQvVZ67cYRDA7 Vcpw== X-Gm-Message-State: AJIora8vcpoohR6LZVFV9ZGdI4F5McC2lDZFkumeyi3kYeqxNrQglQFJ afwzI8NSDBMYIgmR8b6suKWTmTwSQD4= X-Google-Smtp-Source: AGRyM1tGUA53rIsnnKld405DIJFvq8TS/2FfFMNmonYGXrqujK7Cf69LRpSQi0Bl4dPyssWWDST2mmIbkrQ= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:a6f5:f713:759c:abb6]) (user=glider job=sendgmr) by 2002:a05:6402:3514:b0:435:f24a:fbad with SMTP id b20-20020a056402351400b00435f24afbadmr18590781edd.311.1656685409756; Fri, 01 Jul 2022 07:23:29 -0700 (PDT) Date: Fri, 1 Jul 2022 16:22:30 +0200 In-Reply-To: <20220701142310.2188015-1-glider@google.com> Message-Id: <20220701142310.2188015-6-glider@google.com> Mime-Version: 1.0 References: <20220701142310.2188015-1-glider@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v4 05/45] asm-generic: instrument usercopy in cacheflush.h From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Notify memory tools about usercopy events in copy_to_user_page() and copy_from_user_page(). Signed-off-by: Alexander Potapenko Reviewed-by: Marco Elver --- Link: https://linux-review.googlesource.com/id/Ic1ee8da1886325f46ad67f52176= f48c2c836c48f --- include/asm-generic/cacheflush.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/asm-generic/cacheflush.h b/include/asm-generic/cachefl= ush.h index 4f07afacbc239..0f63eb325025f 100644 --- a/include/asm-generic/cacheflush.h +++ b/include/asm-generic/cacheflush.h @@ -2,6 +2,8 @@ #ifndef _ASM_GENERIC_CACHEFLUSH_H #define _ASM_GENERIC_CACHEFLUSH_H =20 +#include + struct mm_struct; struct vm_area_struct; struct page; @@ -105,6 +107,7 @@ static inline void flush_cache_vunmap(unsigned long sta= rt, unsigned long end) #ifndef copy_to_user_page #define copy_to_user_page(vma, page, vaddr, dst, src, len) \ do { \ + instrument_copy_to_user(dst, src, len); \ memcpy(dst, src, len); \ flush_icache_user_page(vma, page, vaddr, len); \ } while (0) @@ -112,7 +115,11 @@ static inline void flush_cache_vunmap(unsigned long st= art, unsigned long end) =20 #ifndef copy_from_user_page #define copy_from_user_page(vma, page, vaddr, dst, src, len) \ - memcpy(dst, src, len) + do { \ + instrument_copy_from_user_before(dst, src, len); \ + memcpy(dst, src, len); \ + instrument_copy_from_user_after(dst, src, len, 0); \ + } while (0) #endif =20 #endif /* _ASM_GENERIC_CACHEFLUSH_H */ --=20 2.37.0.rc0.161.g10f37bed90-goog