Received: by 2002:a05:7412:b101:b0:e2:908c:2ebd with SMTP id az1csp3332617rdb; Thu, 16 Nov 2023 06:56:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IGHfI4RZOM4gJotn2ikycA42NDDrSpEXI4jWXeyU2EEXVUtt+wfVDkRLabYxQjQ7Q6qD6FZ X-Received: by 2002:a17:90b:4f88:b0:280:c576:31af with SMTP id qe8-20020a17090b4f8800b00280c57631afmr12686644pjb.40.1700146601729; Thu, 16 Nov 2023 06:56:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700146601; cv=none; d=google.com; s=arc-20160816; b=a3Qs3ldEc51X0QSZO8LvfU4Nmu8Hi1AtmnYFIELuYMLsbvvR5fte+H/UdXxOFGM4lT ATN1Ns3Z5ShKWhEo9zd06xsFE2SSuBmTd5iTtLeXP+vkFAtz1VJSxeG5mffYQrmha5jO 5vEeujmSJ28dn3Vf2Fatl03s3Qe6ZvDvKYZ0G89qsHkze5l2gJZ7NCbji8IqpbSqQD51 xhRiUo9DtegHoOhrmNYN5ddzm7l4OU7Df2oUWoGIXS9KWaogIx71V7rcQ9kR6tUAUCU+ tl83ciplDhy1eGIWwSp7cU7MMsjosrEbJWmSo3JgJmDOQZ9FGsTecautiNQm/jKXP/Vp JUsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=tzM0stGZCClmmzmredmePw1BMrI7dq9aY1ehb48KIQU=; fh=YZa8vkdUz4pzRj6QFVU/SyYW+LsIH/Wz0o5e5dUhKFo=; b=RJevIncSndP57JNK0xbKrNi+kpTuYZ33WirU0m5BGFQaQBfUlwRTLWSCEYNVPkuGvP deBXTY2wNcoozxM2DLyffqd+z78M8SdtnQEVzAxtrraHVTeSEn/IMDgXFPIU2PK0XzBJ aghFyx9qcIjC71Ltfwh52rO9pvF0beGf5E9/dy8irDTC06wrK2Q7Xvx+estdq/xkSzcT GhmMyGUwOAq8bY3I+tS8wVeSK2f3P94C/NUzpK9x6epKxyJSgiVfbpq8CpO6puR6QzyE gDmORo9JeLYq6p4OoPBIFn3+oI+kdvzA4obHMm76JPpanPk7hMTICGVQnwaORQj7RobY 9e0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=FNLXCl1J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id p10-20020a17090ab90a00b002809a033855si2127447pjr.157.2023.11.16.06.56.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 06:56:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=FNLXCl1J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 350348026ABB; Thu, 16 Nov 2023 06:56:39 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235428AbjKPO4b (ORCPT + 99 others); Thu, 16 Nov 2023 09:56:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbjKPO4a (ORCPT ); Thu, 16 Nov 2023 09:56:30 -0500 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76D151A8 for ; Thu, 16 Nov 2023 06:56:27 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id 6a1803df08f44-6707401e1edso4718736d6.1 for ; Thu, 16 Nov 2023 06:56:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700146586; x=1700751386; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=tzM0stGZCClmmzmredmePw1BMrI7dq9aY1ehb48KIQU=; b=FNLXCl1JfVrSP3wlr5c1EzCFRf4WU+SKRk5ziIleaUK4O05dpZtUZsJLwVwAI/76ZH JHZGLZRdv6Dbz2lSp9sb3b/cA/o8QkcyXWKsz2kQ2e+6LVd+vobUDAcOd5t0XcuXqIHl Fp1koZU/BZrbsvki7hCSZ7avhZooOTGOl0Nhnm2Xyc5E7K7LiuXZZJ/MyHcv6MNVqN4M Vg/Zsxqm7ou5hRnI8YOos7QUrCpBV/ICrSrICeFbj/+HhCDeNmT7RCqv5+4x7R7MgMUu P+lm3ysD0XGQiXYwq73x+6UR1DFOzQ52uDNhwPNmuXaMi1wY8AmrixwxvRwW7Kur73cP 9kOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700146586; x=1700751386; h=content-transfer-encoding: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=tzM0stGZCClmmzmredmePw1BMrI7dq9aY1ehb48KIQU=; b=RNJU0FaVgr90LJCi4re9O5LDwZwjAnv81UU0wFVDCEA/P9D/g9xRq5QKy18q0cypwY aKoPJmFUI/nFDIIaqIXNM6V1A2gxte+u/mnsP4elzYNZ6Wwh5jpDbMZ0L1miAS8MT4ji 1LkMUs3vtoruEfbIHpIWBJI9SprOUnxHx6J60dnUYfUuf6cIng080UPn7QwhS8k3hrl4 VFEXM2rUMsrgAzTokMPgZN/cT03shAKtnKO7t+62VfCdGVAv0bYUJUf13uuEZsM4wYQA WipKUQdRxD0LFgeSwJisaRgAlE2dBMA7hui1YF7CIF7RaZWAEjApFQ3Ffd01jem6mAY3 QH2Q== X-Gm-Message-State: AOJu0YxHdZ4ERipl7TuJWaOp0V8TMd3Mof85r1fPJkyEkJPWktOCwZp1 KgJspfd0I1bEKgO0unUt0Q0kQ+IZjwWxnX13toJtcA== X-Received: by 2002:a0c:bf02:0:b0:675:5925:7e08 with SMTP id m2-20020a0cbf02000000b0067559257e08mr8062067qvi.32.1700146586474; Thu, 16 Nov 2023 06:56:26 -0800 (PST) MIME-Version: 1.0 References: <20231115203401.2495875-1-iii@linux.ibm.com> <20231115203401.2495875-14-iii@linux.ibm.com> In-Reply-To: <20231115203401.2495875-14-iii@linux.ibm.com> From: Alexander Potapenko Date: Thu, 16 Nov 2023 15:55:45 +0100 Message-ID: Subject: Re: [PATCH 13/32] kmsan: Support SLAB_POISON To: Ilya Leoshkevich Cc: Alexander Gordeev , Andrew Morton , Christoph Lameter , David Rientjes , Joonsoo Kim , Marco Elver , Masami Hiramatsu , Pekka Enberg , Steven Rostedt , Vasily Gorbik , Vlastimil Babka , Christian Borntraeger , Dmitry Vyukov , Hyeonggon Yoo <42.hyeyoo@gmail.com>, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Mark Rutland , Roman Gushchin , Sven Schnelle Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 16 Nov 2023 06:56:39 -0800 (PST) On Wed, Nov 15, 2023 at 9:34=E2=80=AFPM Ilya Leoshkevich wrote: > > Avoid false KMSAN negatives with SLUB_DEBUG by allowing > kmsan_slab_free() to poison the freed memory, and by preventing > init_object() from unpoisoning new allocations. > > Signed-off-by: Ilya Leoshkevich > --- > mm/kmsan/hooks.c | 2 +- > mm/slub.c | 3 ++- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/mm/kmsan/hooks.c b/mm/kmsan/hooks.c > index 7b5814412e9f..7a30274b893c 100644 > --- a/mm/kmsan/hooks.c > +++ b/mm/kmsan/hooks.c > @@ -76,7 +76,7 @@ void kmsan_slab_free(struct kmem_cache *s, void *object= ) > return; > > /* RCU slabs could be legally used after free within the RCU peri= od */ > - if (unlikely(s->flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON))) > + if (unlikely(s->flags & SLAB_TYPESAFE_BY_RCU)) > return; > /* > * If there's a constructor, freed memory must remain in the same= state > diff --git a/mm/slub.c b/mm/slub.c > index 63d281dfacdb..8d9aa4d7cb7e 100644 > --- a/mm/slub.c > +++ b/mm/slub.c > @@ -1024,7 +1024,8 @@ static __printf(3, 4) void slab_err(struct kmem_cac= he *s, struct slab *slab, > add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); > } > > -static void init_object(struct kmem_cache *s, void *object, u8 val) > +__no_sanitize_memory static void __no_sanitize_memory should be used with great care, because it drops all instrumentation from the function, and any shadow writes will be lost. Won't it be better to add kmsan_poison() to init_object() if you want it to stay uninitialized?