From patchwork Tue Jan 7 15:14:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13929151 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 99C80E77197 for ; Tue, 7 Jan 2025 15:15:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 037386B00AD; Tue, 7 Jan 2025 10:15:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ED7186B00B3; Tue, 7 Jan 2025 10:15:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D83EB6B00B4; Tue, 7 Jan 2025 10:15:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B8BA46B00AD for ; Tue, 7 Jan 2025 10:15:04 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7693A80A63 for ; Tue, 7 Jan 2025 15:14:59 +0000 (UTC) X-FDA: 82981003518.12.09D2AA6 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf02.hostedemail.com (Postfix) with ESMTP id 828AF80019 for ; Tue, 7 Jan 2025 15:14:57 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=a9oDTS+H; dkim=pass header.d=linutronix.de header.s=2020e header.b=MlKdOtsV; spf=pass (imf02.hostedemail.com: domain of t-8ch@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=t-8ch@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736262897; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xr/B0xvK7sGkfKbzNUSoXapb4RwCqM0VBcWsRspXohE=; b=UvmtMA+0Wcn7FzKd6F060UWL/UOMsmRNqrMFbsrxtXG1Cuck+tgeRGJBJYIIP0bM9tz7BF 1SlowN/wWkB9bBP25B5wACDnh1NJCwQmmjYo8aetciss+7qhc8DSzxqesvDWzqcs4pDU1x HP29iOLzs1qenqIFRrE8b31tOM3sQsI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736262897; a=rsa-sha256; cv=none; b=pIeJKumlTr+RIWaStnPBRoeb4yEYowwdMeYNTRLTrs0XnARWihqzsba4buzgfRw2a1O0br ATaRfycouDzKRQe//o3Yo2ueMJ7N+UoZCupKJ615v5ZDj6V9YPIJCjtDeP0zpLxf6NJZhf K6ArwIajT6sHeNAwRzCaBElPKEh7VJc= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=a9oDTS+H; dkim=pass header.d=linutronix.de header.s=2020e header.b=MlKdOtsV; spf=pass (imf02.hostedemail.com: domain of t-8ch@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=t-8ch@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1736262895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xr/B0xvK7sGkfKbzNUSoXapb4RwCqM0VBcWsRspXohE=; b=a9oDTS+H17gco4eQ8kGhsCqsv9PlMnDDDlrs5LYGf2TxvF6Hc5SBP64YFNV0nppAvZUusn M/G7DF0KH/LcmAEI1xWxZL+QNzgVlBsgjstoBDXG+O5kcLjbzcxJ73XRFUfad5bU/BSlXo A7Y1TLhJxAJJJUB1Cu+ZmF8o4HPSLIsSPIGcqtN8vDA3eYzeCZSbOkqrbjlbcq4O2qsS/n 7bsoJ93HjH1DQiw0HcpeuRycJzpZhiOC/HLEyk8byYgd9q0UkBKXyK2nM17peGau2Mh0ah 0BAgqvWbeo6MZ37fDRAIoWa1XTY/LDxATu4Oigy2pzOK7TSbTD+y5AJX8XyKGw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1736262895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xr/B0xvK7sGkfKbzNUSoXapb4RwCqM0VBcWsRspXohE=; b=MlKdOtsVGTXjDdT5TITCXHSRGRiOVe9EHCVyyPc/IRYFURbCmmQ3GfZsh8mk9woFCpH0+G JprG5Ns6Ac7MHGDQ== Date: Tue, 07 Jan 2025 16:14:46 +0100 Subject: [PATCH 2/3] selftests/mm: virtual_address_range: Avoid reading VVAR mappings MIME-Version: 1.0 Message-Id: <20250107-virtual_address_range-tests-v1-2-3834a2fb47fe@linutronix.de> References: <20250107-virtual_address_range-tests-v1-0-3834a2fb47fe@linutronix.de> In-Reply-To: <20250107-virtual_address_range-tests-v1-0-3834a2fb47fe@linutronix.de> To: Andrew Morton , Shuah Khan , Dev Jain , Thomas Gleixner Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , stable@vger.kernel.org, kernel test robot X-Developer-Signature: v=1; a=ed25519-sha256; t=1736262892; l=2470; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=JV1EmwhzZN8rbAZfsKr/X1cMrrhDBFJbY8LiCwcvoc8=; b=UWmnjc1iTVSO0yiJVv6/4RPN2Sb/xWnNUD78AugJktpFzXZZymMS0+1ZQxMl27beVnu+e+YDZ 8Nc8ASPkmPSCTTatBfxeZhgcl4WR/ohvWgXLmHZ4bc0wTeHWOo89/b8 X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= X-Rspamd-Queue-Id: 828AF80019 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: hj5tjk6xc9djyr3owb9ezky8zor4nkc6 X-HE-Tag: 1736262897-496456 X-HE-Meta: U2FsdGVkX18DURYob5KV7wIq2SfDBGqBwXmjOzDq+69mk3U+bkas7k6bvBPxnmCR05ZvcDSIAfhplkKp1cedHqRI8yF/sba5KtVCXj2TebbQv1o4TeJ1x9jBYpxmFutH75j5jyZto+87EV+LIyYlii1p/5yT5vEd28lnwA4iinKIkgV9jNtssWkpsZoGi8LHi6l4lFWsQbDT9Ne7zH4IJRbfR/FKPnGXIofQn7sWrOWVRz6tDWh+UcCOj8y+17ZdNnmjtUym8t4BK83td7e6AXLSWTGl02QYXO5xAhUyJ+wSyDFdE0DQXLPa6/31MwHZ7xVGbBqdxNo4Pv/40ZYXKt9R8SwnhUTUQEfnLrrMrvQChOtP8oLUOUAAA+2MZSnQVc/fxEgAQt98rc8pzZc41ZIru5E9rPnNewmIlSZGj6XfnbUkrWR8fHU1uhJ2s5xB/i1QnQxdwslhGplZDp8xjhbnyP624GLb9LEFGPLy2JU5s296NWMdv5LG7pCZKEzcgRCC36fEk6BpzN8aHxVhwx7pvDuqJwbdDYPtyoFUVfPqN5l8kQQ2r3Gx6LO9SXC3rknMhlpkU0NB1dKvxv6xVbNx9CMeq7EeifDdl7Hk60Ah41cJ2z+Z7nOVFVXHQBh5RWSjKXRI8evk9P9N8Kom9wv2vSCOYw8wtNrrwTPN25w2Gmk+HpoJ5sRJr4rKqA8chqopaIKhzyW8AIxdB6SprJPAIWRkj0rNBuamcBAjialUKMBKLBfNIp5S7ltuBLu1vhGBq2Y2gTOJ9O+ZmukMYtBn7971lBxK5jUAtmfOs32L+ge4DipmQ3MRAPA0Y1nScL771NNaWmwuFHJSUJmRzbU0uk6ljgKO86bRsM29PxRfToun2W1TtWDk6u9hjJIIXYBs6T34HCG0Grc9vyzwUQhMKer4hJL5YR9PCDpCCUQBmzq4wyF1uGD0Li9L/Q2jhdmHXFmeuzNisVkk9Yx t6pUKaei kTB/wSCpDCYaxN4/ZeoHUJnobFrnrxKGfxckWgf5jVNd7rCPMz/5yjyHAsflwHmJua6uovuut070/52UmWer9Nz9BPVrWnuJdwwnT/ppOXFVD9jjoB4zBBvJXZhbw18Vg/ebnOZX7hLP9Rcji9cC1T92l6mvzyEz9p8kGtbxsM03/gS67/bMLKSuR2LmWgKq+3R8JlMZgTnYmabR35oQNEt/SCbmKjWDr3vqqF1u9WPmKXpi+TqhrYbO3D2Mus2nUEHQR+8JK0WdkQ6RZxdY6Za93F2LM5i4LD3evZG5SJhSZKwQnQ4WjkNoykPk5frvKGb36JLrFjznlN2tOIPAsC6I+fHCEJ3Mrtma3iOxBpsaiSpY9QcYytyHguAl/kE6u3OZpFajUyRq3x/qikwvGCGN1KxdIOU4zWR19Q9M6+fTmFbXSdglxbEYfJrxr+PEf1Lbzi2uTzleeimP2qDKhaGiwWSpwTQx4m8lPxUvJw4fDQfJ79N9KK6MYBQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The virtual_address_range selftest reads from the start of each mapping listed in /proc/self/maps. However not all mappings are valid to be arbitrarily accessed. For example the vvar data used for virtual clocks on x86 can only be accessed if 1) the kernel configuration enables virtual clocks and 2) the hypervisor provided the data for it, which can only determined by the VDSO code itself. Since commit e93d2521b27f ("x86/vdso: Split virtual clock pages into dedicated mapping") the virtual clock data was split out into its own mapping, triggering faulting accesses by virtual_address_range. Skip the various vvar mappings in virtual_address_range to avoid errors. Fixes: e93d2521b27f ("x86/vdso: Split virtual clock pages into dedicated mapping") Fixes: 010409649885 ("selftests/mm: confirm VA exhaustion without reliance on correctness of mmap()") Cc: stable@vger.kernel.org Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202412271148.2656e485-lkp@intel.com Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/mm/virtual_address_range.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/virtual_address_range.c b/tools/testing/selftests/mm/virtual_address_range.c index d7bf8094d8bcd4bc96e2db4dc3fcb41968def859..484f82c7b7c871f82a7d9ec6d6c649f2ab1eb0cd 100644 --- a/tools/testing/selftests/mm/virtual_address_range.c +++ b/tools/testing/selftests/mm/virtual_address_range.c @@ -116,10 +116,11 @@ static int validate_complete_va_space(void) prev_end_addr = 0; while (fgets(line, sizeof(line), file)) { + int path_offset = 0; unsigned long hop; - if (sscanf(line, "%lx-%lx %s[rwxp-]", - &start_addr, &end_addr, prot) != 3) + if (sscanf(line, "%lx-%lx %4s %*s %*s %*s %n", + &start_addr, &end_addr, prot, &path_offset) != 3) ksft_exit_fail_msg("cannot parse /proc/self/maps\n"); /* end of userspace mappings; ignore vsyscall mapping */ @@ -135,6 +136,10 @@ static int validate_complete_va_space(void) if (prot[0] != 'r') continue; + /* Only the VDSO can know if a VVAR mapping is really readable */ + if (path_offset && !strncmp(line + path_offset, "[vvar", 5)) + continue; + /* * Confirm whether MAP_CHUNK_SIZE chunk can be found or not. * If write succeeds, no need to check MAP_CHUNK_SIZE - 1