Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5654146rdb; Wed, 13 Dec 2023 15:37:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHY0Qy2Qfgh6CYbrV4i3bGVgpg3E+TczXqA4XEHfuyMXNaYF48XicMUsDM7Md306wP2aelZ X-Received: by 2002:a05:6a20:8423:b0:190:80a:a41a with SMTP id c35-20020a056a20842300b00190080aa41amr12910233pzd.27.1702510649379; Wed, 13 Dec 2023 15:37:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702510649; cv=none; d=google.com; s=arc-20160816; b=S+hVrNib1va1iBZFjhTnibgtd12cGu9eqZGSdWu1ul7+R6XnBZrBbn3MJByVb2e4a0 4usO9CNnLpZkLtmjCFAlpXtqi5XpixPwsgV0AQXU9+Yd5JNX0XrKqjOXehQt8UfFikRP Cnpuhy56XD3WR9i7ZNmm1ErSVsjngQz/NJOxdVCVZRpOqzmyZxG3TeNvLjtDcxDAP6jj 69lppJukeQRpch17521V/CxZu0BbN4lHhf/FTMOXNlr/NoiWBTrHu27nx/MLkA5R29b1 lmXpaZexIOQB6JnNteJW/RhkzvrYUKdK6YG4YIUPjcygQIf2pMN3O+wXRlTeMuFIp8cW hmNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/+H88J6LmzDuOxLHJftJTV19pkCYIO+glC/rLzGPGs8=; fh=TQATEbdDZNcnk8L2eDP6eFL9HlexFaHIexhR1TH2IlY=; b=lFLJ61rMwS1UXCePIGxUFsJkZDs2VPSHIodMvXiEYvDKI32yPe2ddT0sg83fscPqYE eQhapqrSALs1Zd7HtWL605eos8b1qpDaXjeEXyVxBTYs/llJYdJPwwKrIjUCuiMCHvP5 oX+0labv12c/rI+oUyIFdhUxluvUjHas7YHs/qyAkq9SsI3ddWLrbueujocRNMhoR727 UMjdMjPVJLtBt2QQc5oo06l9I2LRfjiV1Qis7OZFg0CI4oeQ9z0UYSEXXQlBDs6WVHdK fm5nwhgfxbugfcF5hAHInkCBF9bl21tYcEQcOVKt9nqSSvxOh1W3+ZI5Ec89l4/ggk5O eZOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=UI9uSlKl; 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=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id ca14-20020a056a02068e00b005c66130e967si10395375pgb.264.2023.12.13.15.37.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 15:37:29 -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=@ibm.com header.s=pp1 header.b=UI9uSlKl; 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=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9C0048033DE3; Wed, 13 Dec 2023 15:37:26 -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 S1442771AbjLMXg4 (ORCPT + 99 others); Wed, 13 Dec 2023 18:36:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234154AbjLMXgr (ORCPT ); Wed, 13 Dec 2023 18:36:47 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C32E10F; Wed, 13 Dec 2023 15:36:52 -0800 (PST) Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BDKbG6K023678; Wed, 13 Dec 2023 23:36:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=/+H88J6LmzDuOxLHJftJTV19pkCYIO+glC/rLzGPGs8=; b=UI9uSlKlNddsJj1tCJnNBZJDnRjsMrinNpqtmQWnZUSd4it6tU+K5xw+EAtN3MFqI/zX HU8Tn1ERHyiG6sLflTO1HzzbaWBvtKu2VRvG8tYweqyPVkFbI2SZkWMcJ6392GrFeNI4 jfVqMkYqet5tqNMN0XTeOgs7uoJ2x1HzQBUr4hYVFfvZ2yABdooPQA0qRH4e6mUYOSro 9CkJ3I88ja987Sh763ERHrwEkOgTR1SybfMoFUM5kqHQmiWXq7LMw4xHEnCE/Nrxhvsd jyjw0TQcACHKbGiZt3zpXc3EvNNjgGMxbOCFOTujyOIgG72Wh5wEU4jjBfnLW0sBZL3P Uw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uyktbv0vc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:36:38 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BDNLHVw018587; Wed, 13 Dec 2023 23:36:38 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uyktbv0uu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:36:37 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BDGpBKh014833; Wed, 13 Dec 2023 23:36:36 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uw42kg1xm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:36:36 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3BDNaX8n4653612 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Dec 2023 23:36:33 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4F08920043; Wed, 13 Dec 2023 23:36:33 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCEF820040; Wed, 13 Dec 2023 23:36:31 +0000 (GMT) Received: from heavy.boeblingen.de.ibm.com (unknown [9.171.70.156]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 13 Dec 2023 23:36:31 +0000 (GMT) From: Ilya Leoshkevich To: Alexander Gordeev , Alexander Potapenko , Andrew Morton , Christoph Lameter , David Rientjes , Heiko Carstens , Joonsoo Kim , Marco Elver , Masami Hiramatsu , Pekka Enberg , Steven Rostedt , Vasily Gorbik , Vlastimil Babka Cc: 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 , Ilya Leoshkevich Subject: [PATCH v3 15/34] mm: slub: Unpoison the memchr_inv() return value Date: Thu, 14 Dec 2023 00:24:35 +0100 Message-ID: <20231213233605.661251-16-iii@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231213233605.661251-1-iii@linux.ibm.com> References: <20231213233605.661251-1-iii@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: kPY9E1UvYdSAN4yA0WGECmQaAwtxBTWd X-Proofpoint-ORIG-GUID: zPDn9MZkVLtny7zKhboJlYnQt5V5Co18 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-13_14,2023-12-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 impostorscore=0 clxscore=1015 adultscore=0 phishscore=0 mlxscore=0 bulkscore=0 suspectscore=0 spamscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2312130167 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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]); Wed, 13 Dec 2023 15:37:26 -0800 (PST) Even though the KMSAN warnings generated by memchr_inv() are suppressed by metadata_access_enable(), its return value may still be poisoned. The reason is that the last iteration of memchr_inv() returns `*start != value ? start : NULL`, where *start is poisoned. Because of this, somewhat counterintuitively, the shadow value computed by visitSelectInst() is equal to `(uintptr_t)start`. The intention behind guarding memchr_inv() behind metadata_access_enable() is to touch poisoned metadata without triggering KMSAN, so unpoison its return value. Signed-off-by: Ilya Leoshkevich --- mm/slub.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/slub.c b/mm/slub.c index 2d29d368894c..802702748925 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1076,6 +1076,7 @@ static int check_bytes_and_report(struct kmem_cache *s, struct slab *slab, metadata_access_enable(); fault = memchr_inv(kasan_reset_tag(start), value, bytes); metadata_access_disable(); + kmsan_unpoison_memory(&fault, sizeof(fault)); if (!fault) return 1; @@ -1182,6 +1183,7 @@ static void slab_pad_check(struct kmem_cache *s, struct slab *slab) metadata_access_enable(); fault = memchr_inv(kasan_reset_tag(pad), POISON_INUSE, remainder); metadata_access_disable(); + kmsan_unpoison_memory(&fault, sizeof(fault)); if (!fault) return; while (end > fault && end[-1] == POISON_INUSE) -- 2.43.0