From patchwork Fri Jul 1 14:22:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 12903362 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A11CC43334 for ; Fri, 1 Jul 2022 14:23:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFF346B007E; Fri, 1 Jul 2022 10:23:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C87476B007D; Fri, 1 Jul 2022 10:23:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B27B06B007E; Fri, 1 Jul 2022 10:23:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id A25756B007B for ; Fri, 1 Jul 2022 10:23:31 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7FC5235AA8 for ; Fri, 1 Jul 2022 14:23:31 +0000 (UTC) X-FDA: 79638749022.02.285B27E Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) by imf01.hostedemail.com (Postfix) with ESMTP id 16D9D40047 for ; Fri, 1 Jul 2022 14:23:30 +0000 (UTC) Received: by mail-ej1-f73.google.com with SMTP id hp8-20020a1709073e0800b0072629757566so851533ejc.0 for ; Fri, 01 Jul 2022 07:23:30 -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=sNk4k5DciAOkO5h7/BC6MFN9iBnnGwQh539wFyt7ZSqBLmarspsGxHeUbx7pHbSRAH XOHgHUK4hrRjS3cjXCUkATfl18K58z2wSYHmt0fISfDmn0Ks536xG2Y2UxTB8appLPGs rY9bBSsWQFCEslQXGAC/S626Ect/fqdlH9H/jwom+9h02pdm/rtGuPu3nBz5Swbv1AEl 9/K9+gjRZ4qDy37ApmvgOv73y5GE061UjxQ1Zlkw/eMzHgLI+plnxIxJkOw5+IDKoytv cHzspao6zU4c4M5NfkLVQnpkTZxZ5SnydLUoHoWTB2UV2j4ddV4lYl0aNOKxEKZwmOP1 l2Wg== X-Gm-Message-State: AJIora8uiF5WCkVJzfI1ZHblfPrz4tfIhqVGffsYDV843PFpq3ptpa+j 8cByV33z6kEJU+r4DblY9GVL7AbbreI= 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656685411; a=rsa-sha256; cv=none; b=rv4vAEN836T5ZmPaCbLQWZg388JwsHrsJRPOOpJTbkS+KvID8Vb0q5BMeo5hDJBVskIQRh VTzRpdihWsvsw++0irM12Wsu3NjKKbRjxEMuw/1m1S2fqMnjaoIpIIwpHSniL+BZ5LWb7b CCEiSYviU4/sX6g+lH/Vu13K9c2mRL0= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=S+rhPYqi; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of 3YQO_YgYKCIAkpmhivksskpi.gsqpmry1-qqozego.svk@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3YQO_YgYKCIAkpmhivksskpi.gsqpmry1-qqozego.svk@flex--glider.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656685411; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=pc6R18JS+sE1u3dlHmLsZDbE6VaTO3tMmut2L/JxCPM=; b=D6c4FiC5UcK9P2kWe6mDlbCqRvv8F7ZrDB09c1SIc70AMJdlPd0cx7/Ozk1QKO9emBC9YY qL+JeOlLiFhMreRmhdTMBNLnEEq2GJ8VS4IpqgMXKuLqqgkI0bs7G2diGvA6IQtKHuvlz/ HeImFzVYOpnBUtWQ+SwjJIkuUes6lbE= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 16D9D40047 Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=S+rhPYqi; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf01.hostedemail.com: domain of 3YQO_YgYKCIAkpmhivksskpi.gsqpmry1-qqozego.svk@flex--glider.bounces.google.com designates 209.85.218.73 as permitted sender) smtp.mailfrom=3YQO_YgYKCIAkpmhivksskpi.gsqpmry1-qqozego.svk@flex--glider.bounces.google.com X-Rspam-User: X-Stat-Signature: uq99utsurcd8pe3i7n7zaqwrxs8xw7nx X-HE-Tag: 1656685410-768883 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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/Ic1ee8da1886325f46ad67f52176f48c2c836c48f --- 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/cacheflush.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 +#include + struct mm_struct; struct vm_area_struct; struct page; @@ -105,6 +107,7 @@ static inline void flush_cache_vunmap(unsigned long start, 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 start, unsigned long end) #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 #endif /* _ASM_GENERIC_CACHEFLUSH_H */