Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5654071rdb; Wed, 13 Dec 2023 15:37:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWUiqDPC07ibC9xyfJOuMqIt7oWx1iq4VAkzqNPXQhi4qqam1/+xhx+qdXc57552B1AJH+ X-Received: by 2002:a05:6870:c1cf:b0:203:89b:4597 with SMTP id i15-20020a056870c1cf00b00203089b4597mr3488038oad.40.1702510637632; Wed, 13 Dec 2023 15:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702510637; cv=none; d=google.com; s=arc-20160816; b=qXZmqnDp5ozonoWxnkfJqELpOQNJ3JPz2wZkkx4QmqLiaZ8HGr6QozbD4QPIlcx+8e SPyv9vp6puGV9Mk2HQja/MF9ggfjW/3rXqW42+UjMu45kd28O27NtR4ztYVH3CCh3ZAb lL7HNMg7MdIbol9rzLxwoZ4qKSsRZR+C0+EJaCOQKcuYhCv9CL5bUJNqgDc9YfRQCYyM 03cZARo9fiyiBSkb44vJsGXhQzh5fveFb8bAmuU5sakSeDAwZR2/aofC+KG9m8xt2RyO c4rziVf/61lOCuFJen8uLQuZfMqHryv6uxe0iDucFnWwXztfavIugwpqr7UG3fCS1rYy sjeA== 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=+JRbg3kPizc/tKO6MSNyeUjOi3r5ENUit3Ra9toPyEk=; fh=TQATEbdDZNcnk8L2eDP6eFL9HlexFaHIexhR1TH2IlY=; b=KjxMf/tsHdncM23HVqLBKN9JjYSwFiNk3up+KNeUJVooMX+Rb9V2zlg7mxeuHnTSUs U3OFbyaoEzbVEZsEF39v+RJU9+438SQ1N8aOckGUp9JkJ7orkY+eOMyW+sUEVCkMfvcm t72s8Euhtf8Lpa2NB/rw/0schMGabI7vNOfhHpTh21QI8zJsu6rtAWixc6hX9tWFP/FC JAGGJ68y0wmY4RHv0gO6ZZfoaLWBNPSrLL8vdACsVztpwTUwy6R+iqOtIM2vgTDS815a AtyrOJ3fzyQyQsFTx8Ddwzo7jVfWM2SepQ0cSdvHAw7lhdKwRCYBpArCOebWEY9itXFJ hDWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="a/H46swg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id o62-20020a634141000000b005c662c8da88si10189521pga.146.2023.12.13.15.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 15:37:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="a/H46swg"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 82FB081C19E7; Wed, 13 Dec 2023 15:37:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234210AbjLMXgs (ORCPT + 99 others); Wed, 13 Dec 2023 18:36:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234068AbjLMXgn (ORCPT ); Wed, 13 Dec 2023 18:36:43 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE4AAE3; Wed, 13 Dec 2023 15:36:49 -0800 (PST) Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3BDKaLvr003754; Wed, 13 Dec 2023 23:36:25 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=+JRbg3kPizc/tKO6MSNyeUjOi3r5ENUit3Ra9toPyEk=; b=a/H46swgQVoQJZy7TsbXl7UvL7/fJ5cvph7WQ/+Iu0P3yxpByVz5l4lm2BST54peKoyF c/cLiYwJv7/wv4W4cVj5NQj3GeAs20M8LfFBLZ45kAUFnXWX3TMHXX2ZHvP71bNg/ndl dDVnTFouAA/9wvUHMfxjJwa4kxSH/mymbzr+51Qa0TVUad2O+XreWelrI50E8pOa4bE6 qry0r5zWMlD/5wM/UCwIRVaKg0W2ukAotdoW+XoQbs//O/YS2sBXkvorlMJqF49eD5FH I1Ow08Yu+bWcJ4BTwxA38ceI79HYt/bJyy/+TCS5pB93o9czuty8nBkT0bOJRR54Rclz RQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uykek48y7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:36:24 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3BDNQT09028957; Wed, 13 Dec 2023 23:36:24 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3uykek48xm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:36:23 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3BDL4sCB028206; Wed, 13 Dec 2023 23:36:22 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3uw2xyvrnv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 13 Dec 2023 23:36:22 +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 3BDNaJNT16188036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Dec 2023 23:36:19 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46D0F20043; Wed, 13 Dec 2023 23:36:19 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D4A3220040; Wed, 13 Dec 2023 23:36:17 +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:17 +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 06/34] kmsan: Fix kmsan_copy_to_user() on arches with overlapping address spaces Date: Thu, 14 Dec 2023 00:24:26 +0100 Message-ID: <20231213233605.661251-7-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: NvNFv9kzwaXyDaiNbiRkqnwnGpAGbYvC X-Proofpoint-ORIG-GUID: 36qScC5OQSchjdmhk5MojrGx989GqACk 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 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 bulkscore=0 mlxlogscore=748 suspectscore=0 clxscore=1015 spamscore=0 impostorscore=0 priorityscore=1501 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 pete.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 (pete.vger.email [0.0.0.0]); Wed, 13 Dec 2023 15:37:13 -0800 (PST) Comparing pointers with TASK_SIZE does not make sense when kernel and userspace overlap. Assume that we are handling user memory access in this case. Reported-by: Alexander Gordeev Reviewed-by: Alexander Potapenko Signed-off-by: Ilya Leoshkevich --- mm/kmsan/hooks.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/kmsan/hooks.c b/mm/kmsan/hooks.c index 5d6e2dee5692..eafc45f937eb 100644 --- a/mm/kmsan/hooks.c +++ b/mm/kmsan/hooks.c @@ -267,7 +267,8 @@ void kmsan_copy_to_user(void __user *to, const void *from, size_t to_copy, return; ua_flags = user_access_save(); - if ((u64)to < TASK_SIZE) { + if (!IS_ENABLED(CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE) || + (u64)to < TASK_SIZE) { /* This is a user memory access, check it. */ kmsan_internal_check_memory((void *)from, to_copy - left, to, REASON_COPY_TO_USER); -- 2.43.0