From patchwork Fri Jun 21 11:34:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 13707328 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E0AFC27C4F for ; Fri, 21 Jun 2024 11:37:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1582C8D0157; Fri, 21 Jun 2024 07:37:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B05F8D00DB; Fri, 21 Jun 2024 07:37:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 769386B0121; Fri, 21 Jun 2024 07:37:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2B4886B0116 for ; Fri, 21 Jun 2024 07:37:31 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DCB1640D15 for ; Fri, 21 Jun 2024 11:37:30 +0000 (UTC) X-FDA: 82254695460.06.EABC054 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by imf17.hostedemail.com (Postfix) with ESMTP id 9ABC54000A for ; Fri, 21 Jun 2024 11:37:28 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=IS4ZtVj1; spf=pass (imf17.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=iii@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718969841; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=B2wiMcD3tdJRzJi1KnXmn1aGmTaVwcFVLNTdCb0XDUM=; b=H3F5m7ejt1CD+RhtDlht97Sb3h/a+ZuEMVCYup7pPRIHWFwqDL42uJj7j61rJ7BpNtz4Um 0/4pRHL+D7AzbS0O0L3zp5tqhAKB6JWF17P6Mf5F9CJ425BdWyu06GSekeO7lM2kO64pCt f515uP9quIwVQ1QtKdjrM8XNA82x7Gk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=ibm.com header.s=pp1 header.b=IS4ZtVj1; spf=pass (imf17.hostedemail.com: domain of iii@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=iii@linux.ibm.com; dmarc=pass (policy=none) header.from=ibm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718969841; a=rsa-sha256; cv=none; b=3a65z8owP0XJTefK/Pc98NfjZY9qtkwtNPgnnWea+QDRM1bx0lWOgK4wPfCVJCTI8Ac9Ja +9B5L4uBLmL0Adb4Tya2AStvf2OxyL9TVfg8uMvz0eugCPWVPz8vdCQHEM1DWleqA7OKxy QCCaXZ40yWr69Wbil4wnX5K6r8KH9SA= Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45LBT2fX021960; Fri, 21 Jun 2024 11:37:20 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=B2wiMcD3tdJRz Ji1KnXmn1aGmTaVwcFVLNTdCb0XDUM=; b=IS4ZtVj1AfvkUG7483Tgmr0DrzGsg H/yVfozsu61QHrsNj1KI+Q7OnIGCKzl3S6xWaImCS6mSKVlcmuoWjeMu4+RE83Da gBpGfdd6AzxJJTvkZr5hVOweY8PnLmFbKgKiAo1tMc95v1E3fV5TLExrgKUV6jnM 7aeYd0j75CQHwBZoNQIYtoz7xgCso1KJOBf6oQyYtv4nifZkGCeNWsn0D8z6S8GK uCRFaSSFxgsU+Hfa1VcTUETZTPSgZUQ8sI+8uxERh91AtMTFyPNWSQRXPM97JS4G KBHi/LlomHjU0AfPNcathcAfIijMU8k4D/qokj8DInEpcs/pc1QoccGpg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yw6ws09bd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 11:37:20 +0000 (GMT) Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45LBaJmL000419; Fri, 21 Jun 2024 11:37:19 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yw6ws09b6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 11:37:19 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45L9EjD0019980; Fri, 21 Jun 2024 11:37:18 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3yvrqupvym-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 21 Jun 2024 11:37:17 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45LBbC4S45613482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 21 Jun 2024 11:37:14 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2A8B62004B; Fri, 21 Jun 2024 11:37:12 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 92E262005A; Fri, 21 Jun 2024 11:37:11 +0000 (GMT) Received: from black.boeblingen.de.ibm.com (unknown [9.155.200.166]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 21 Jun 2024 11:37:11 +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 v7 05/38] kmsan: Fix is_bad_asm_addr() on arches with overlapping address spaces Date: Fri, 21 Jun 2024 13:34:49 +0200 Message-ID: <20240621113706.315500-6-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240621113706.315500-1-iii@linux.ibm.com> References: <20240621113706.315500-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _QxgKIXm-H474SZgRMjPUkGWFJ3XjBZb X-Proofpoint-GUID: yGqjU0FWgkV47EzU5yDvoLI2eE9WBVok X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-21_04,2024-06-21_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 suspectscore=0 malwarescore=0 spamscore=0 phishscore=0 priorityscore=1501 adultscore=0 mlxlogscore=952 impostorscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2406210084 X-Stat-Signature: nfnse859iptzu4kaqqqu15rft3fcjm6b X-Rspam-User: X-Rspamd-Queue-Id: 9ABC54000A X-Rspamd-Server: rspam02 X-HE-Tag: 1718969848-312641 X-HE-Meta: U2FsdGVkX1/P6BS9uEUQhHBjsDVoCRY9k24WRm7cEFJvUqr7N4laxqZ8datxPK8kM2y5CdlSvfAQnTfmtHb7xLPAGN5kbUIeZxv1GBL9bUdie6kDSPPkvTGso38hqLIS87kVw4E1BcjdKLUqinPcRwR4N+H8r4Sj4qul4b4K0kI+3mFqm6TZ3fI+vSG5oJrYPWXPrSWBZlDE+Cq9eMX5UxofQApB0qW+fOAUbFvf4MBm0Vz70NRFK7bkHWajFkktKIw3YRmka2Mt1076ej3xS/HGDs9UiPk6bpGG6IZ5g0Dq4c1yQfLNXGXQ1l2KKbg6cP16lMN65MClB0ZlQu2CNp5AwLodXH+hQydf9fC8AL7Myu+jZEudDxf36e9y3OKDHFqiqz55/Sm1EAaelYPXkaw8o5XqaXKvJ7wTqpQ0chOR8svCAigpbaNNuOPUf5LlHjWFs+EWyjGve8Lg/1u9SLwAgsPffT22pWFn9q39+7Ve1Tn8PEoA836BXB5x+8C5qyQx56IuMOdBDrhc+03tmioUIrdQyzVqFmJQ7PwMvJzA5NV4FOwSmaD5Qh+FiMuKAp+CThiaNP5RaR0Xe9Jmqdr8p0XjFN94MM2onmhDp3clP8pPyV/2G4oawk80unBuWmFcleiBYmWBtIes4GM0belZ+QAH1xpBMTUx3TT3WNx2rneqpxEEvSgU5FSjqekBvBFnvqCIkxy0P1jeM+sMh7Rcnrybf9H3ZlIL/K00zh2Ub6J9I004qOQ0jsw55nTwH9iBuQs+bQzR5qV3x9vISD2t8Z/CmOzwPgZhJCzhHxSiEvf1IHlr4AulDEznS10N0JP1daC6Q6H472EeCPjfdTp977kG4L3G32Xh6sBeT5XKbuHoCBr/gFYe7q/RP5bKfOY8yDBH9cJEHzPNmFQbzXvHoqPBSvF+H9RbkxGr6RFUc7fCb10wlfOwggromDtT0a+rmHX/09jmP5e2XnX Xs+mFrsz jGfbre0VEQxZ2plTAsjaxiZI5+C2+FPr8ogL8JB5eDXb3yIMWT3tPdOD5ylkSzN8d15dMlSA1yMDVddefw0F5bg9wEvBw9ztMW4zahdnA8R+6B1XVuBOBopfu6ImQEWJch+SdXpB9czd6rm4UNx8n/4B4U8y5iEhTBgXkdam8eABqXyXHCITmFSrkumI7DkbhftgNknKzfr3RlmMZQVE/o295RBZqKiSoPYvUlHv0PrV63wbALQfQOMhzGtJ7V36S/ruKieqY0Adb4/wUjAYPRkXvUxR22OaOpMqgk6QLYK7j08MZk66I9IcTDDi66ono1sy2SPQhqkclkFx9IgJLEoaI+Gbo0VcnVDMFBQEQlwdyio82hsT0LSK7AnTxTEW6UakGgQfv9WxuJ+c= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000003, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Comparing pointers with TASK_SIZE does not make sense when kernel and userspace overlap. Skip the comparison when this is the case. Reviewed-by: Alexander Potapenko Signed-off-by: Ilya Leoshkevich --- mm/kmsan/instrumentation.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/kmsan/instrumentation.c b/mm/kmsan/instrumentation.c index 470b0b4afcc4..8a1bbbc723ab 100644 --- a/mm/kmsan/instrumentation.c +++ b/mm/kmsan/instrumentation.c @@ -20,7 +20,8 @@ static inline bool is_bad_asm_addr(void *addr, uintptr_t size, bool is_store) { - if ((u64)addr < TASK_SIZE) + if (IS_ENABLED(CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE) && + (u64)addr < TASK_SIZE) return true; if (!kmsan_get_metadata(addr, KMSAN_META_SHADOW)) return true;