From patchwork Thu Aug 22 12:00:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Ruibin <11162571@vivo.com> X-Patchwork-Id: 13773261 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 7D27AC52D7C for ; Thu, 22 Aug 2024 12:00:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F1CA26B0120; Thu, 22 Aug 2024 08:00:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ECAB96B0125; Thu, 22 Aug 2024 08:00:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1E5F6B0142; Thu, 22 Aug 2024 08:00:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id B85B66B0120 for ; Thu, 22 Aug 2024 08:00:44 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 59373415D7 for ; Thu, 22 Aug 2024 12:00:44 +0000 (UTC) X-FDA: 82479739608.10.17D9EF5 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2074.outbound.protection.outlook.com [40.107.255.74]) by imf19.hostedemail.com (Postfix) with ESMTP id 75DE11A002E for ; Thu, 22 Aug 2024 12:00:39 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=oo99bH4j; spf=pass (imf19.hostedemail.com: domain of yang.ruibin@vivo.com designates 40.107.255.74 as permitted sender) smtp.mailfrom=yang.ruibin@vivo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=quarantine) header.from=vivo.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724328023; 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: references:dkim-signature; bh=zGayROL6megTrakY8HhzrjtmU+vvXIsyVIoKwjoyLWk=; b=eaVooa0OzwduJmVSn2E4t5HzJSUhHFkgA5cPyPMRcwUrcwjk1a3mVbssfMfHIlrEJdPpM2 EPxC/gJ2lsiC9Gx+Wl2fva5e7gVcoN8OClOWJxxpoTJICdx9E0qnKo1YOfrd7vLXXY9Wn9 7bVE/rJrODDtJ/LHFSAn7dYGt/kgWRo= ARC-Authentication-Results: i=2; imf19.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=oo99bH4j; spf=pass (imf19.hostedemail.com: domain of yang.ruibin@vivo.com designates 40.107.255.74 as permitted sender) smtp.mailfrom=yang.ruibin@vivo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=quarantine) header.from=vivo.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724328023; a=rsa-sha256; cv=pass; b=Ge1lMkkhdGafvaJyPM8zsV0Lgior9ybKtd8GfxbhVjdD8/C/DpahtM4NUzywtsDBpzE5Yr mkhAz+t/c2YCP8VkqRc0xgVrZlN9r0pjkxtZTnf4NGRiwYiSTfdnk5zNzqiLSj8hgmL538 HIzgHAaHQu5AC9lecXra5lLyHmTdm4U= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XuwWW3BOFzSbjiMxsNcc9fhD3G3tiQ4w8KkL/Sm0VUle+SVFqtdimVy9isY1xXbUo3FReaHFg2S9rit2zR8XaFiemrA/0wAyNDTWAIhatQoRbicrhQHR45bGQejoNB/+/6f3WyjK51mjINtUA3t9fCm98tam1L3AIrzMGxsF+vXAkWSOEFKwr05offXH2gq74kDK3/S2UryaqAy5climfxUDBKTBKRnvkunAPj2Re/0KXtIgFaah2+saCr3nO2u3AUOHd0K8SR/rfcXB03cfCujzJ977JM9qC3QMkoNxZg0O9ZM6bw9KvOstNR1c0uDBvONyLCqL7trrzAcCq6mn5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zGayROL6megTrakY8HhzrjtmU+vvXIsyVIoKwjoyLWk=; b=hg1GbXPENkf51e7ZkIhrjIi9cC861S1Mboaxa8xieEAlUrG9mRWHpBroAebIBWJ31m4thuCmQ0VImINQamxsQNONe1K/3IGQhRiyb3zW5xQquU1Bo1dQOJ0BuvDhaMj5dgejG5V/Aunoe1jRdp0j325VPs8IFxxxNU/B898OxD/+mgSv/G5mWMan3kz+HhiGihsmJPbAgfCrM5N5xjMMUWuav5e/j9RkaK8vCx91RUBVo3HbY6TWCX2ukaljyEwUqfctKePQp0YyPweXCsE5bPEIkbgCDT9U9iNYJHD01T654+OZJ4kXSKu3HyF2CuUNHnUhHQiFOTGR1BtSVh0BrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zGayROL6megTrakY8HhzrjtmU+vvXIsyVIoKwjoyLWk=; b=oo99bH4jKgSn+m8UfpJ5h97wRj9ZXAzf6wHAWYIBFgwMj5PUpCaTkFlrHU1z10ClGAmMIdMuT5TDIXcc2UfNp7iyGiRD8URj9XbwantRa3xGP5M6AHAPN5Xz1Jty0xPDh+8HB0JLv12CnBvpr6HqjBoLftnGwYt+f3W8gP5DBD++EZ7pTHOMyoipnVS5MpamoQt1G2X+iLPb48vU5cwGeMIBb0JvX7vefs4o0qBE50LvQkLxv6WlG91Imoh2drmaQriPLAG1xdDXK1HY0bgTKb7IkAALJqZoOfFjU/1SpdCWN0zVIbkJ5w7NIxBoKXgkbSStZOuuFrFtGadk6r0DZw== Received: from TYZPR06MB6263.apcprd06.prod.outlook.com (2603:1096:400:33d::14) by TY0PR06MB5730.apcprd06.prod.outlook.com (2603:1096:400:272::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.19; Thu, 22 Aug 2024 12:00:33 +0000 Received: from TYZPR06MB6263.apcprd06.prod.outlook.com ([fe80::bd8:d8ed:8dd5:3268]) by TYZPR06MB6263.apcprd06.prod.outlook.com ([fe80::bd8:d8ed:8dd5:3268%6]) with mapi id 15.20.7875.019; Thu, 22 Aug 2024 12:00:33 +0000 From: Yang Ruibin <11162571@vivo.com> To: Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn , Andrew Morton , Shuah Khan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Cc: opensource.kernel@vivo.com, Yang Ruibin <11162571@vivo.com> Subject: [PATCH v2] selftests:mm: Fix mmap() error paths to check for MAP_FAILED Date: Thu, 22 Aug 2024 20:00:22 +0800 Message-Id: <20240822120022.2095848-1-11162571@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: TYCPR01CA0109.jpnprd01.prod.outlook.com (2603:1096:405:4::25) To TYZPR06MB6263.apcprd06.prod.outlook.com (2603:1096:400:33d::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB6263:EE_|TY0PR06MB5730:EE_ X-MS-Office365-Filtering-Correlation-Id: 52e8f629-45d1-4e3a-220d-08dcc2a20669 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014|38350700014|81742002; X-Microsoft-Antispam-Message-Info: S9U0H5rbsIALzzIK4Ulr62iJwNjnjAl3QHvWNZJ9jha64NXANCxYYmZcyI07Zyq3F52F0n3nRbRGiq5VDkCqzsil6tAsThttX2B3PAWhNNLvWryr3Btn1xCVaW0HTzMRMHLE2LoUaY4Sj9s2hdZ1TLUc4o+9ZxnlYcB/jdyIyHmnXaIJ8sIZpaY26s9PKUIvv5sIcZFo9fB0kNJswJgFkUWvxFNQLOPVwWGTImSAKEVIsYiWnApekJe15bd0HCbcV7GEjP4VPkXJLc6b7B39kxvCZ54AsVV1t8S/dVaGkP0ajo+sXJz+NJ2qJenARpY8HFBj887M72LW/Z6jU/Xa1CLGzzz2yKguR9X3+SyvfX3P0z0ACJqwd0cr2qk4LmN9Ct5y7yCB3Vaj10hlpnj99StINwb5iTimYAmQ7K8W1eUwJznwaUCY2nHcFubM2iwa6iNuJ18mJbPbpGgJCCW44Zlg6uKfN8c1SyOJ09of6LB8mxAbasdqEtyW+CptXTXXzejBHekU6tK3hH0I4mYazatM2V7kLudxAoMeQo6zO0M6EgfxLPCkem9+U1BE1X91y5R0Age0Vwpzt0iEDo9bx44pcgLZv/3YxJi0up/ymcZSoUSj4CqLfgtwlmQYAulvrviTSnHRowbEY9a7ZGqsQ2q1GZFDpzX9tfGOG7ZB18vi6+NZJhgH73NiqriWFzljaO6sOZyGh0jwVbAvQrfByC0ZBRmYafobsRuIJlIXoDx9SU6kH0K8U6aFcF5ans32nAwMBxEfCG6m5a4oz5cUF6+UCSRZK0D7R942Tzd5KOaITo6xfSBAxcB6CkcPYVLqAoxTadYJbW5d988rSaoXkwLEW9R7CfthGXNE9pX/DpaN8J+HMyRN4rI4jMRi18pEGQncR+GUCSc9KUBizfu3uobEYhrUKjGLxLhtcdsP2d4hjTn55sImR3kUf5XHbG31j4iXJMN0/ByFn7zstXtG0Vls/ZEUEvphHL5p/eWIKWnBo/uNMjena4D/B0Of2fp4RaIIgBzFct6N8EvcXShXpHlVA1VKp0iMZCmNqoDydcr/2x2FKHy6eTzTu15LJwKTeLXYL8/0bdg+uibaWZjEduflkgrXefwI7WUaneaD06ed6MUvWghgqhrA+xmuFtvUzAPmPSdTJfIjvzv9suutg9xXU9w59EsUsz93mPXKst2BUHqvnb8ztclbZWIPOqogv8bN07cjo1dzU94VNNvoj+CwKLSbF/Sp3G2uRjqaJhk2vU4s3z7hAay3YF7mSddmPaW4Xj9b8e+gyYgtpHxYPKwazNEgEIbrAYiKhmkwcUoIBMkfzYY9O8cRJ/xR+mqUKHh7MA2MWwfyMxNE3dx7W3sHONC//C1XveHITQdnSYMQxXR+RxD/WxVQvkAJ5AzcA95pMogxxV3XYJCr9HwSb3PwBFs76I3WHdUhEY5L8Cg= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYZPR06MB6263.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014)(38350700014)(81742002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kJNExhu2VaQjkhkm9y/fXx0NBULB8wq7InB+iRSslIof+6EUGW0WAaZt+REkgEOrpQtFLmpuz6grZDsw5wgIWSG/mJ5D1R9cR6RezGdNb8EbunByMYRFUjLIW2E15PSz8ZKi8FsF0q1rPv1MPmVzDK1oRxmxqF+AeRQ8Yo6lNMZnYgdAIlz+G5FckS8xARTHKIdjIeoVhv4j9P3zgCSAesUbA/FS8c79RlEwSvyDoc0YJ6iqtue4WJrZSqamX94BMhGo+k4r95YOStPcwqM1hIjXUfgr887IBvVyiq3aslQfCRErkpdkL0ESdOPo1slKZGKl+LVq+ETERpeMJHzlgQnc0rRykLs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CIrfpuytW7PIJT3A5dBPeJfVwCL3btzEFo86fPdWNAHkb2mNbU1/ihp4lucIc7Lewd6xg/CEy8GqlIeuIe27KrUaNSh2j686D4DSQ47kY+Nk2NeDuwoezKsm9tVt8a5Z8CVY4rDJH3v6HsU2SoBaIWmb4xE/rrrWVv36MNUNUTSavTlu X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 52e8f629-45d1-4e3a-220d-08dcc2a20669 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB6263.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Aug 2024 12:00:32.9810 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RAvH3G7ewUnyNRE1+4Wf6otYZvFHtFSn9/G2zf9fA2yVB4/60SaJHWqrpwI/fCcO2Y7IpEGWUN/DWAYrS6CJmQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5730 X-Rspam-User: X-Stat-Signature: mkr3nx5f88uafkyeghrqx1p5xue1f888 X-Rspamd-Queue-Id: 75DE11A002E X-Rspamd-Server: rspam11 X-HE-Tag: 1724328039-845202 X-HE-Meta: U2FsdGVkX1/kgY3A7RElKweWiYa/mf+AhSPc4VEw8dl2Ln4xwz7kgmWbSjrL0OGRNhpAnCautFZrrtx+Wkx7Mxr1JKb7uPnwiexf37JF0VEfJDJlZMVOt3vtLB6BzS0ZXNszKG/C60023aFbnQcph9zqRjLYv5qZvTBWW0hD2yqNlQBb+Xm0f9utjayPR3qrunlMuX4dlIw0SHOAyedivPmFqG9a2qDSqw29UzF5sdlxpPskjZ9SCNt6Mk+1uH6Hm7yzhXQYvLDBjSqpLnQKOZYpz6madqCqBMuhRhozP5RVhPh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xyuUF+CG09lRoV8Wp5rAAK3RQHF3pG7DUVYR9eE1KWtoMGc0F8J6eHl4LHR1Rdlm+O2aJJKSOFOQJXNaFwXrYfbtp02LDtYgnkskPgXziVSz5I6QF40ASS7Tk7eg3C5TCJjUAX1d3jTC6zaVWzBwAkdK4nqIbTDfm/A/sJAbZjhuFZeDhPqWzNUWE= 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: To correctly detect whether mmap is successful, must use if (map_ptr == MAP_FAILED)to avoid incorrectly handling a valid mapping.Fix mmap() error paths to check for MAP_FAILED. Signed-off-by: Yang Ruibin <11162571@vivo.com> --- tools/testing/selftests/mm/ksm_tests.c | 2 +- tools/testing/selftests/mm/madv_populate.c | 2 +- tools/testing/selftests/mm/soft-dirty.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/mm/ksm_tests.c b/tools/testing/selftests/mm/ksm_tests.c index b748c4890..dad54840f 100644 --- a/tools/testing/selftests/mm/ksm_tests.c +++ b/tools/testing/selftests/mm/ksm_tests.c @@ -201,7 +201,7 @@ static void *allocate_memory(void *ptr, int prot, int mapping, char data, size_ { void *map_ptr = mmap(ptr, map_size, PROT_WRITE, mapping, -1, 0); - if (!map_ptr) { + if (map_ptr == MAP_FAILED) { perror("mmap"); return NULL; } diff --git a/tools/testing/selftests/mm/madv_populate.c b/tools/testing/selftests/mm/madv_populate.c index ef7d911da..b89cb83ca 100644 --- a/tools/testing/selftests/mm/madv_populate.c +++ b/tools/testing/selftests/mm/madv_populate.c @@ -34,7 +34,7 @@ static void sense_support(void) addr = mmap(0, pagesize, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); - if (!addr) + if (addr == MAP_FAILED) ksft_exit_fail_msg("mmap failed\n"); ret = madvise(addr, pagesize, MADV_POPULATE_READ); diff --git a/tools/testing/selftests/mm/soft-dirty.c b/tools/testing/selftests/mm/soft-dirty.c index bdfa5d085..4ccbc053b 100644 --- a/tools/testing/selftests/mm/soft-dirty.c +++ b/tools/testing/selftests/mm/soft-dirty.c @@ -134,7 +134,7 @@ static void test_mprotect(int pagemap_fd, int pagesize, bool anon) if (anon) { map = mmap(NULL, pagesize, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0); - if (!map) + if (map == MAP_FAILED) ksft_exit_fail_msg("anon mmap failed\n"); } else { test_fd = open(fname, O_RDWR | O_CREAT, 0664);