Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4387024ioa; Wed, 27 Apr 2022 02:41:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxarihjLYk0QeSd0CfLGSUPx50ZyfBjIKI14ZoDmJnBdoJBm9MGKzkT9FyWCE5QgbvngLFI X-Received: by 2002:a17:90b:1a8a:b0:1d2:e42f:9993 with SMTP id ng10-20020a17090b1a8a00b001d2e42f9993mr32007845pjb.68.1651052476684; Wed, 27 Apr 2022 02:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651052476; cv=none; d=google.com; s=arc-20160816; b=Pq/3w+DIlF2RTGOsf0OLBW8P6YnaGQUuIr/Sh5VAOmnkdhnuRDAU6p/sBNWPKkSOMz Tj5+589VUoa1PkOl1PpsE+P5vmbe0SDsyYrksC9sY9tj7fY5f9YXvYgJ1h2p8bzhd+PU cwQrluIw8pwfS+CM96shz62UedatTTFmaeV/AOvVgKus6aDgQ2161bx33XDlNf3hH6kZ nqT25zEXNpNqKavdl8BBZg7geBdGWcyBWCIEl4WZXmo+0dJ7teEvfViC7lvTRktpu5fN FRffVphNzjMgewkb9bAAizGEtJ2JRdPWLivesZuwPZe4Gp0MAVvjZJQr7ud1RnelYWOM Q6MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=cG4bw4Dybp9do4PvtZBZ2e2ITt4Wsjs9LSUgy4lmV+4=; b=O6x1d4EEYsYtuHDMjSrEW/F1chieoLs6T4JPRgpSqy+OpD2o8Ht8xi13QH5+nUy93a qdWmS9sQu02uGS4+kofWvnP7ZGxX+ggKt3w2li34lQNr+5zhOM5VClf/Sey7gvx1ao3t 0YrNy03DZCKCa34nykFmKHOplwvjb2dFbC0ld1aj5rYn9GaOgQULq1AYAiSr7IgqB8ce fIZVm1APtjEMoUyBFsQxfEelSclM3iZF4X6DNMLHAUbLwtJCxndp/bAmakCJo6VBGgYD ggYvWzw8m8N/0WayGdQb8z8aVysMPtfyX5vVsW/RPV9JHHFbytBFIJkUBzj3iIFFyPNz YF2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RcuVhtgi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n11-20020a170902d2cb00b00153b2d165bdsi1119929plc.453.2022.04.27.02.41.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 02:41:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RcuVhtgi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B79FC27274C; Wed, 27 Apr 2022 02:16:52 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353139AbiDZQsC (ORCPT + 99 others); Tue, 26 Apr 2022 12:48:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353147AbiDZQrt (ORCPT ); Tue, 26 Apr 2022 12:47:49 -0400 Received: from mail-ed1-x54a.google.com (mail-ed1-x54a.google.com [IPv6:2a00:1450:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B718191C60 for ; Tue, 26 Apr 2022 09:44:37 -0700 (PDT) Received: by mail-ed1-x54a.google.com with SMTP id w8-20020a50d788000000b00418e6810364so10517303edi.13 for ; Tue, 26 Apr 2022 09:44:37 -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=cG4bw4Dybp9do4PvtZBZ2e2ITt4Wsjs9LSUgy4lmV+4=; b=RcuVhtgi/Tw1bMDtabWe38GwlUcwg4SUjFJCfkW2os/ElbHByzMYCT2RYzqn62C0bn cbc56TqAri4pL54mxEkGuVkiAaJJ9tXSwdeAGi+nY3slj4lCV4ZtmvWqeaNCS3QKANio WW7rLfKq9u9Kd3RXcYrkCGHS0aT05KrVMUMkow7J5zXgyXnRiQ3E/SReE2LZFqObeM2p smA+CIkkQF6Odog2q36ChSrXewTMVXM+93iY1Gau5URCGueQT5zBnFATmZOSwzbaRVC1 zWWjq4eJBwkMFtGAv2hVypAFZhEDp0HEN6QVTrNW6nJcUAwldpsVdCTpJbkD3ZSC1KHK QTEQ== 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=cG4bw4Dybp9do4PvtZBZ2e2ITt4Wsjs9LSUgy4lmV+4=; b=dygRiz9TQFJZMlHeuDyb59bwrVUME6alQw/eQkbf7IzVFN+/88Zo+HIZZSWMbI9pbn lOboZ2r1VExo+wjV3Gp4hcUZLULWnjkyn8NlAP9AtrFcUhL2AeGbGsfJT+7OJVFoY1Mj KfFB5184eaKyJtcLanOXnHReSrZjpK0OEhC+dkvJKSQzvD8a/9DzorPnegWwJxqBLcLe yhR4uHckzihwyvemYTmyN6RgGHZa0rUXPOazP7uYPfxquPiWILtOvpp6Hxz8VXDzom3v VZzazdO4E4ag6xNWGTNKr7INQg62pOwWwMEu6EB3zftKwj+w2Z7ron8BUrhiFfaW/1wN +GSw== X-Gm-Message-State: AOAM531boYWRaasfVelv/EcXQa7Lo9aQOkE+FFoSzSBVJOSEL9QDM8PZ XXrFKxssZBsv4FMwIapZPx9EeomxZbU= X-Received: from glider.muc.corp.google.com ([2a00:79e0:15:13:d580:abeb:bf6d:5726]) (user=glider job=sendgmr) by 2002:a05:6402:2809:b0:423:e123:5e40 with SMTP id h9-20020a056402280900b00423e1235e40mr25792114ede.84.1650991475654; Tue, 26 Apr 2022 09:44:35 -0700 (PDT) Date: Tue, 26 Apr 2022 18:42:35 +0200 In-Reply-To: <20220426164315.625149-1-glider@google.com> Message-Id: <20220426164315.625149-7-glider@google.com> Mime-Version: 1.0 References: <20220426164315.625149-1-glider@google.com> X-Mailer: git-send-email 2.36.0.rc2.479.g8af0fa9b8e-goog Subject: [PATCH v3 06/46] asm-generic: instrument usercopy in cacheflush.h From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Notify memory tools about usercopy events in copy_to_user_page() and copy_from_user_page(). Signed-off-by: Alexander Potapenko --- 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 */ -- 2.36.0.rc2.479.g8af0fa9b8e-goog