Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp234669lqs; Thu, 13 Jun 2024 08:40:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0opCdIHov9DvqB6alyazs9xX/kSSdWdXkfNLDdE5ObLhd8XkqHPQhje5BrWqPp9zNWyjfyPq7XWfeaQ7jnC+mqByMfwY9azjbRbYWgg== X-Google-Smtp-Source: AGHT+IHm/k3r4drC+qJomXmyKcD29R2gVGaEkwlTj+11kHYcKZsLFQ8DdhuL0/KxeN/Oyp+0u4aB X-Received: by 2002:ac8:5a4e:0:b0:441:5704:af4a with SMTP id d75a77b69052e-4415ac60ab9mr63478481cf.55.1718293221452; Thu, 13 Jun 2024 08:40:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718293221; cv=pass; d=google.com; s=arc-20160816; b=z9X6jDmjL3a8w4t8owntOQeHrvM6qLNskaZWNAXgDWUkBqokb0ajwDmtWpRAvKkS80 zDPcpdwtGNXnfoZ+z6sqJo9SJN11zkcDggu3lfw6Kyj2xtmWKFgfJDNCDsR5dkOXbVhW GjtT3AT1d9f6RjkN7UgXdCa/ZjB60nu/RqKX/7kX5DN3S6MiffElKLvlUHQJDZwtfgWz 6g138NnbuFktzJJZ6SMsnCneyrYx/Xh3taK56rrdWFVISEva5Dq4Fn5rfxUA6hXICHaM lynd8xMRV+082q08Xag0JDCG3FD64uAGeZRZJvj8AgtKjZy8RHpy/k92C8+36UmWRlzs nutg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=1qF7H4bGHDZ6iOOMBP071rdyF1q1YAWA6gRStiWbHSM=; fh=TQATEbdDZNcnk8L2eDP6eFL9HlexFaHIexhR1TH2IlY=; b=Nih4kjPGnP1zsJasnPUvB5XImtomwQhzLNzdA3n3RyjRCOFUrZqLZKwzH9dm524eok TZoesViUItgNKIFilgB/w3KbOF8Z2SNl69RdJnFogVoBN+asf7sGLfYttUMj/0WVJx69 63lEsZlRFct170/NHktbdEDw7Ux6FY4W3N2IFwlo0+IIwf3+Gu1ptK9mVOQQgr6cUBn4 9oo2lg30dg2WlwB3AaZ1w8//6n0rjtZrEPSdwh2cUGbnAyzEg9H0KUTb4j81E/ClNhPx 7tpNM1gKnHWEgvJoslRwj4rpLL9YiJx/6RXCBuXmWvQzxvTBXE+yANY2Wit7rOSeoVQT Sgsg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ryxyigWW; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-213556-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-441f30f86afsi18028941cf.678.2024.06.13.08.40.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 08:40:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-213556-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=ryxyigWW; arc=pass (i=1 spf=pass spfdomain=linux.ibm.com dkim=pass dkdomain=ibm.com dmarc=pass fromdomain=linux.ibm.com); spf=pass (google.com: domain of linux-kernel+bounces-213556-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-213556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 19D631C243C6 for ; Thu, 13 Jun 2024 15:40:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A7F412FB09; Thu, 13 Jun 2024 15:40:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="ryxyigWW" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DE2612DDA7; Thu, 13 Jun 2024 15:40:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718293209; cv=none; b=CY37EpZPfN4nxkKmFnbJ7oHQriltJm56/jrKS5etl4KpmdSiY9gBi6hxhaNe/9XR7Qc3xyRAp71gJPU6j4Ypsq1uIOUpW4gMe4eVKHZKtze+iYeYE3oENKEwcHDNsa4gGw2uSzLstZ3I/F0Wdg71Dj5iMNRJ+Pn6MxGVZouDFKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718293209; c=relaxed/simple; bh=yEkUFwHzqM2QxOJ6rCJjLwbF170i74UCFAzqXMXYm3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FrUvuiUNV3BC5XaSvgeT5GVdUREGGvY8QO4/cMwQ2taTwC1R1wvKK9pHdW2ZJQ28jMSdUrXC9xmCHHINfVisLt3y++Kl9Nx4zLCXZsQBVwWyHhP/Iw43y3SOwyftXKsB1zszYB0tfvt6w2o3GNEm+ZNp6ihIz3VpJntu6b3m8KY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=ryxyigWW; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com 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 45DFSfR3005622; Thu, 13 Jun 2024 15:39:43 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=1qF7H4bGHDZ6i OOMBP071rdyF1q1YAWA6gRStiWbHSM=; b=ryxyigWWBAbBzH974FCHVE7kIkoK7 di4AAZ53RZtshynJdpHipao6ULTlz0/VdrdNOHq/6zOPyLw20BIAkb/RDeH5NmB/ zLpinOzGqxtkXlIoufDeKr0cHILt6UX0V58cRn9fmGGd9XTyTCyID555g/Ltuasm p5RTpBphzm+RkKrKAIWN9Vuas4JMbAQoRQcEphMj93XRoW3kimg5kgsYeFRgoNzm rFwhwPli8yS0IFozsZ7yvROKojDVx1VTgZAn7k/lioAzhWwlS+AIEkXCGCWhCt5E eD6B7yunqu0LJF4otUHQAvC3QTgCnqPqHO8moN3/Jwj5wgiiIah/BS6BQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yqrw11ymw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jun 2024 15:39:43 +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 45DFdgZ7026429; Thu, 13 Jun 2024 15:39:42 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yqrw11ymj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jun 2024 15:39:42 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 45DELJwo008711; Thu, 13 Jun 2024 15:39:41 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3yn4b3rk0e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jun 2024 15:39:41 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45DFda8o48038272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 13 Jun 2024 15:39:38 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 310F220067; Thu, 13 Jun 2024 15:39:36 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B32ED20065; Thu, 13 Jun 2024 15:39:35 +0000 (GMT) Received: from black.boeblingen.de.ibm.com (unknown [9.155.200.166]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 13 Jun 2024 15:39:35 +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 v4 06/35] kmsan: Fix kmsan_copy_to_user() on arches with overlapping address spaces Date: Thu, 13 Jun 2024 17:34:08 +0200 Message-ID: <20240613153924.961511-7-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240613153924.961511-1-iii@linux.ibm.com> References: <20240613153924.961511-1-iii@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: vlPBHhf6wo8Wwm-gnrID75BnVJjJBeF8 X-Proofpoint-ORIG-GUID: vSngS5dm6lATwFHi4uKxppdf7UV1X5cJ 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-13_09,2024-06-13_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=0 clxscore=1015 lowpriorityscore=0 phishscore=0 priorityscore=1501 mlxlogscore=801 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406130112 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 22e8657800ef..b408714f9ba3 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.45.1