Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp865877rwl; Thu, 5 Jan 2023 05:47:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXuQmvYfR5//oJWL3ze32XAW3TXF3+V6seBqtp9zoAvfxKvN7SCZfrwJWDXErE6BP7WhdVJC X-Received: by 2002:a17:903:451:b0:192:820d:d1 with SMTP id iw17-20020a170903045100b00192820d00d1mr41593557plb.25.1672926478495; Thu, 05 Jan 2023 05:47:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672926478; cv=none; d=google.com; s=arc-20160816; b=LGvKol/SY9vkU/t3Z5LY0jVkmS2NQTj49DE0wjOWEzPytdM92hWFZzv+6xuV8KaiI5 jWXImo4XaK9LwOBhgQdf87QVYiNVfRmbTl2jUvQopk2UqgkL2u0PJPf0wJHSC3I4PTSr yJ92YujKN7C8eQg5mDMb3fNoOwT7JPPIkaXOurW9ZqDYvd/I+DtBn/6UBFAz6XG1qHs9 7U86MUPt4IMSPXIEk3XdBbJomrUC+ZMGvSIMP4q6hRthNwhKZ3EFXTHAx6MBHIFkbHUN iFAvzsGtzLxUQl1RU47qINgVYO0w1yhgjRQjvW5aO3QW2VPbCB0oCMnJ5yqKGRLrGeWa GoDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=TMYXEk4lndOrw8goIICh9q2Q+fxdp6yIZD9WFVuj+yo=; b=wVBRu7yvJLRAUvggPIFmxtnQ23wsHk9Rk7QJIK8UwBIcRMt7PDJnN6uH4khW0VOyO4 G4nzfjqFrLP5DnNR0manOzz3tYu3lFIDm31MFGDAe1F2sqb1JGicyGJaPN2l++e6CClr wEQiiCMZ3gDdILos1cbF/DKVlrp8+epYbYlq4afT5edyEOGEghUQpsQya5uE49jyhCEp DTHm54eH6sT4Kje8ALbcgXNo2mSV3I3pnUYCLqG5PuqkgEfZM27B6yxX8f03xt8gTlJ+ 4PKfwvR4XUjvw67bMp2XYK0FD2mYvfHz+D2W4Jhl6XeIb3u3AKwNDHGaXby4uGl7xQpV z+5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=V94j5uLs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t4-20020a17090340c400b00180a7ff784csi36909393pld.360.2023.01.05.05.47.50; Thu, 05 Jan 2023 05:47:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=V94j5uLs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233118AbjAENW7 (ORCPT + 56 others); Thu, 5 Jan 2023 08:22:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232041AbjAENWw (ORCPT ); Thu, 5 Jan 2023 08:22:52 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D16E5392CD for ; Thu, 5 Jan 2023 05:22:51 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id b24-20020a05600c4a9800b003d21efdd61dso1286125wmp.3 for ; Thu, 05 Jan 2023 05:22:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=TMYXEk4lndOrw8goIICh9q2Q+fxdp6yIZD9WFVuj+yo=; b=V94j5uLsqkr1OjMTZXNgPq44eyqGmxT0IobSI51BRwh6FlTxLGJS6GlaplOQcu4J4i 1UIi3lNu7W2NDMt/4LU1E8bedgzj4cvGalflGyH+QwXn6vqCCv77tVy6hqfjnwomUkDg eNuk2sGyaPx9pQFWucJgrkT8p7Q17PrwKmruQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TMYXEk4lndOrw8goIICh9q2Q+fxdp6yIZD9WFVuj+yo=; b=Me/CixGO0LZ7q12FN5uIqd0N1DaEC6h/Z/4vNPYE7RWjSLq4cf4LjNCfT7hfptMU5V YSl5aXYvqTyf/Rz+L6t+2EBgKLfZ6cHVanqUhDn2cbh/frr/qX5n1CbWqp/fx3nYdKC6 wjxEfxvZ+gBMB6Kf7XO3Q7uGPzzJK4XAyJbbbPhPCV8XEn/6oPJFwJFPBzcrnLPMd8a8 sbr9ABG6UKYdSFKGEdxCm3mI7AjT1klmqGcQsAdZybeEs9zP6Xv4sTJkpuZsA5sDMxHz 3M7hkdwlGne4LHwBFf3loDk1an7HECcEBxGJI8VDf0HJhoqb90hFzpnyXaLaK94Y4mA0 Johg== X-Gm-Message-State: AFqh2kobveesfjxHYlW0Ua6g4Ms28R59CHdktBgWdfDNWqusYNIicpWQ kNKeZ0Yjndg3U1RVRisS+GUzGQ== X-Received: by 2002:a05:600c:1d89:b0:3d3:5cd6:781 with SMTP id p9-20020a05600c1d8900b003d35cd60781mr35560523wms.37.1672924970434; Thu, 05 Jan 2023 05:22:50 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id j25-20020a05600c1c1900b003cfa80443a0sm2701132wms.35.2023.01.05.05.22.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jan 2023 05:22:49 -0800 (PST) Date: Thu, 5 Jan 2023 14:22:47 +0100 From: Daniel Vetter To: Tetsuo Handa Cc: Alexander Potapenko , Geert Uytterhoeven , Marco Elver , Dmitry Vyukov , kasan-dev , Helge Deller , Linux Fbdev development list , DRI , Linux Kernel Mailing List , Kees Cook Subject: Re: [PATCH] fbcon: Use kzalloc() in fbcon_prepare_logo() Message-ID: Mail-Followup-To: Tetsuo Handa , Alexander Potapenko , Geert Uytterhoeven , Marco Elver , Dmitry Vyukov , kasan-dev , Helge Deller , Linux Fbdev development list , DRI , Linux Kernel Mailing List , Kees Cook References: <86bdfea2-7125-2e54-c2c0-920f28ff80ce@I-love.SAKURA.ne.jp> <032386fc-fffb-1f17-8cfd-94b35b6947ee@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <032386fc-fffb-1f17-8cfd-94b35b6947ee@I-love.SAKURA.ne.jp> X-Operating-System: Linux phenom 5.19.0-2-amd64 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 On Thu, Jan 05, 2023 at 10:17:24PM +0900, Tetsuo Handa wrote: > On 2023/01/05 20:54, Daniel Vetter wrote: > >>> . Plain memset() in arch/x86/include/asm/string_64.h is redirected to __msan_memset() > >>> but memsetXX() are not redirected to __msan_memsetXX(). That is, memory initialization > >>> via memsetXX() results in KMSAN's shadow memory being not updated. > >>> > >>> KMSAN folks, how should we fix this problem? > >>> Redirect assembly-implemented memset16(size) to memset(size*2) if KMSAN is enabled? > >>> > >> > >> I think the easiest way to fix it would be disable memsetXX asm > >> implementations by something like: > >> > >> ------------------------------------------------------------------------------------------------- > >> diff --git a/arch/x86/include/asm/string_64.h b/arch/x86/include/asm/string_64.h > >> index 888731ccf1f67..5fb330150a7d1 100644 > >> --- a/arch/x86/include/asm/string_64.h > >> +++ b/arch/x86/include/asm/string_64.h > >> @@ -33,6 +33,7 @@ void *memset(void *s, int c, size_t n); > >> #endif > >> void *__memset(void *s, int c, size_t n); > >> > >> +#if !defined(__SANITIZE_MEMORY__) > >> #define __HAVE_ARCH_MEMSET16 > >> static inline void *memset16(uint16_t *s, uint16_t v, size_t n) > >> { > >> @@ -68,6 +69,7 @@ static inline void *memset64(uint64_t *s, uint64_t > >> v, size_t n) > >> : "memory"); > >> return s; > >> } > >> +#endif > > > > So ... what should I do here? Can someone please send me a revert or patch > > to apply. I don't think I should do this, since I already tossed my credit > > for not looking at stuff carefully enough into the wind :-) > > -Daniel > > > >> > >> #define __HAVE_ARCH_MEMMOVE > >> #if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY) > >> ------------------------------------------------------------------------------------------------- > >> > >> This way we'll just pick the existing C implementations instead of > >> reinventing them. > >> > > I'd like to avoid touching per-arch asm/string.h files if possible. > > Can't we do like below (i.e. keep asm implementations as-is, but > automatically redirect to __msan_memset()) ? If yes, we could move all > __msan_*() redirection from per-arch asm/string.h files to the common > linux/string.h file? Oh I was more asking about the fbdev patch. This here sounds a lot more something that needs to be discussed with kmsan people, that's definitely not my area. -Daniel > > diff --git a/include/linux/string.h b/include/linux/string.h > index c062c581a98b..403813b04e00 100644 > --- a/include/linux/string.h > +++ b/include/linux/string.h > @@ -360,4 +360,15 @@ static __always_inline size_t str_has_prefix(const char *str, const char *prefix > return strncmp(str, prefix, len) == 0 ? len : 0; > } > > +#if defined(__SANITIZE_MEMORY__) && defined(__NO_FORTIFY) > +#undef memset > +#define memset(dest, src, count) __msan_memset((dest), (src), (count)) > +#undef memset16 > +#define memset16(dest, src, count) __msan_memset((dest), (src), (count) << 1) > +#undef memset32 > +#define memset32(dest, src, count) __msan_memset((dest), (src), (count) << 2) > +#undef memset64 > +#define memset64(dest, src, count) __msan_memset((dest), (src), (count) << 3) > +#endif > + > #endif /* _LINUX_STRING_H_ */ > > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch