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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D70D8C636D3 for ; Thu, 9 Feb 2023 23:36:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230490AbjBIXgb (ORCPT ); Thu, 9 Feb 2023 18:36:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231190AbjBIXgQ (ORCPT ); Thu, 9 Feb 2023 18:36:16 -0500 Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94FCF6464A for ; Thu, 9 Feb 2023 15:35:37 -0800 (PST) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-52bdbd30328so46539887b3.8 for ; Thu, 09 Feb 2023 15:35:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=E3YfaKNVl2yQShNL4EAUThiXwGLjN3/+eFNVq1mrd+o=; b=KKm34kjzFdKs9ylAAOO5dxpyvVi621GkVn85UrRvKHXdOZMPEvXcCu7laq5RU6IhL+ O8w9o/npc/sxu8tZ2ETGG7RnUfoTia/Q4QTAx5fOnBY19yjUTl+uis9Z5zfvyDZjYl/t MsEBP5KmZdQEx7nAfb1ba7uYQHFdggZFoDQ0hNmKsmO8rSmER8nlM71VNT7Zc3tRti27 2Gg4ZOF33PyjciB4UUo2kSUHKpkP1JNgVNwUdoUhhJ7GERBGdvxceMF8WVp5SORjc7oz FsiUBQqke9bK7+n+7UJoW0oWMI7awzTpgWsG1FZEhNfLYkg/bY3ARjukyHNi8N5+k9BX brew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=E3YfaKNVl2yQShNL4EAUThiXwGLjN3/+eFNVq1mrd+o=; b=66CLof31NmIOBEqrwAYQDhzSOCt0TNMtyx88j0LGhe9dLEKcJS294E3Mj+tnjYqckd CioD6VgO5AHm8tnhVAYqilme9k3ropsmnK5kepaIH5+qt7wTFdtyO1wNcDH6Zz0Xk/zI Vk0g4SzxBKMHYR9PTWVTyU2iUFLIU1ChnGAj+/ymQGRy2TcItZYNM0L7rL/snBpbzCGZ sNST67uuGMdKCaR0H2Z+lBPGCfleeX6GNgH9Xoi8F+a8180M5RM/9Ubhw2As7A8h3GjW okxyZbkqEzy7mUqRfAPZhL/SpA1R//FwGtacMbDlx0WdYBFXvejK/Zwaj17GGM1cGwBJ Exgg== X-Gm-Message-State: AO0yUKXrrswDNUwmKrHy1B2GfmW7K/KHlObdVc1vsmtOTG6zGRYh9aCH Qsm9n44jEvTf5eqA00x8tAJxcuna5gaWHn5TS2NR2A== X-Google-Smtp-Source: AK7set+Pu8P2MLAAhgY/qe2gk0TWUQkshaxRSaoEXuuHO+2AWOBZUjU0Nbfh+s3Nxg0SRAUYMIYN+RoKyv4J4AQ9HpE= X-Received: by 2002:a0d:c906:0:b0:526:8ea9:49bd with SMTP id l6-20020a0dc906000000b005268ea949bdmr1250620ywd.339.1675985735029; Thu, 09 Feb 2023 15:35:35 -0800 (PST) MIME-Version: 1.0 References: <20230208184203.2260394-1-elver@google.com> In-Reply-To: From: Marco Elver Date: Fri, 10 Feb 2023 00:34:58 +0100 Message-ID: Subject: Re: [PATCH -tip] kasan: Emit different calls for instrumentable memintrinsics To: Andrey Konovalov Cc: Peter Zijlstra , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Vincenzo Frascino , linux-kbuild@vger.kernel.org, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, Ingo Molnar , Tony Lindgren , Ulf Hansson , linux-toolchains@vger.kernel.org, Mark Rutland Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-toolchains@vger.kernel.org On Thu, 9 Feb 2023 at 23:43, Andrey Konovalov wrote: > > On Wed, Feb 8, 2023 at 7:42 PM Marco Elver wrote: > > > > Clang 15 will provide an option to prefix calls to memcpy/memset/memmove > > with __asan_ in instrumented functions: https://reviews.llvm.org/D122724 > > Hi Marco, > > Does this option affect all functions or only the ones that are marked > with no_sanitize? Only functions that are instrumented, i.e. wherever fsanitize=kernel-address inserts instrumentation. > Based on the LLVM patch description, should we also change the normal > memcpy/memset/memmove to be noninstrumented? They are no longer instrumented as of 69d4c0d32186 (for CONFIG_GENERIC_ENTRY arches). > These __asan_mem* functions are not defined in the kernel AFAICS. > Should we add them? Peter introduced them in 69d4c0d32186, and we effectively have no mem*() instrumentation on x86 w/o the compiler-enablement patch here. > Or maybe we should just use "__" as the prefix, as right now __mem* > functions are the ones that are not instrumented? __asan_mem* is for instrumented code, just like ASan userspace does (actually ASan userspace has been doing it like this forever, just the kernel was somehow special). [...] > > Fixes: 69d4c0d32186 ("entry, kasan, x86: Disallow overriding mem*() functions") > > Signed-off-by: Marco Elver > > --- > > > > The Fixes tag is just there to show the dependency, and that people > > shouldn't apply this patch without 69d4c0d32186. ^^^ Depends on this commit, which is only in -tip. > > +ifdef CONFIG_GENERIC_ENTRY It also only affects GENERIC_ENTRY arches. > > +# Instrument memcpy/memset/memmove calls by using instrumented __asan_mem*() > > +# instead. With compilers that don't support this option, compiler-inserted > > +# memintrinsics won't be checked by KASAN. > > +CFLAGS_KASAN += $(call cc-param,asan-kernel-mem-intrinsic-prefix) > > +endif Probably the same should be done for SW_TAGS, because arm64 will be GENERIC_ENTRY at one point or another as well. KASAN + GCC on x86 will have no mem*() instrumentation after 69d4c0d32186, which is sad, so somebody ought to teach it the same param as above. Thanks, -- Marco