From patchwork Wed Aug 21 03:50:03 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: 13770760 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 D2B26C52D7C for ; Wed, 21 Aug 2024 03:50:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 46B516B0092; Tue, 20 Aug 2024 23:50:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 41B6D6B0093; Tue, 20 Aug 2024 23:50:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 294966B0095; Tue, 20 Aug 2024 23:50:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 0BB796B0092 for ; Tue, 20 Aug 2024 23:50:24 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 950B81407A0 for ; Wed, 21 Aug 2024 03:50:23 +0000 (UTC) X-FDA: 82474875126.27.EA76D4E Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2040.outbound.protection.outlook.com [40.107.215.40]) by imf15.hostedemail.com (Postfix) with ESMTP id 80CD5A0012 for ; Wed, 21 Aug 2024 03:50:20 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=TFofwUmD; spf=pass (imf15.hostedemail.com: domain of yang.ruibin@vivo.com designates 40.107.215.40 as permitted sender) smtp.mailfrom=yang.ruibin@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724212158; 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=E8GoXfIIezXxwkNH+nkc/lKd5ti2Jm64EnlOqYLDm70=; b=GFRMrB5QXAuKmnB8zQTidggTKsG8plkfILJpKBbh8ZrA4WpkxSr4X31dyoDuCQNQI6sYpY OoLkbjNcP/KxqLyqs4JEvoPqpA2sFCedyHXhLzqzmz3T0DLpKz/7nUs1tLJn73dD5Qee+M RgCWRAcNil+176Aq+Z89QlWag5y7uUM= ARC-Authentication-Results: i=2; imf15.hostedemail.com; dkim=pass header.d=vivo.com header.s=selector2 header.b=TFofwUmD; spf=pass (imf15.hostedemail.com: domain of yang.ruibin@vivo.com designates 40.107.215.40 as permitted sender) smtp.mailfrom=yang.ruibin@vivo.com; dmarc=pass (policy=quarantine) header.from=vivo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1724212158; a=rsa-sha256; cv=pass; b=xRaQaOQX5I92wAlYGAq9SEBASXl/Go00TaVEwagy9GlGvOnq8uX7Y6yNB8YpReQSpHiUao czkn2u4x9AbyOqHN4jjs4u+1t+pdX6t5AVwKuSGkkAoiWaGCeqWpMOSBNfc298U1CPewnw KnGSjcUkHiwdXumBz8lxr/Dd3I6EQYI= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ImyjLixW52PGs19ayeNzic5YRyJqN9jYf3q+T1qfdmTnVtacJiVlR6p0RXA9UhW4TzS3YwnWrabKrNSXbyH8ySodATFIhBAfOq4wL9T8k5F513pWXVhqnU9rLgFTNrUehjlIYZuPHM+XySilj9ovV2lqRfDqRhxO8lO9nT/V2ns6zVhBCHrER7Cu9X7WuSTKhQ6js63TFmn8ttoeq+6kj9DL7/gqITAPy/ImgLTJotSgoo2/g8xsPxIH6bMOU1sIbGGTtrEmSrIlErFA+PbcAq7Db4loH1gMxkITKnW6ppjSh/fteWCqqoXntQtudUAcM7PpyRBjkcTUh4ESkJlJGQ== 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=E8GoXfIIezXxwkNH+nkc/lKd5ti2Jm64EnlOqYLDm70=; b=w/O8iSfU26mJqKgGwznCDy86UBtyzW2JEKFuxgpOWktfilDWFD2fQDMUP7UIbncl4em8iE6xXKM3dWy2gIXfgRw5P8ybjllFSg53fuf4W9ZLSVpn3zekJCZT02XexPa66S5oKO6GhKYM1jo0C878CXqvoPWQuwVwDw9FD6HGFCPuWZ8nfUfqWHQb5nrQyiMz6798x/ygWm3yg3y3drLcRgpzwiDlL94r/x15Vtys34v1F9AKvbMfVqCOeJ68qJOqbGbLze5gDGEQVcJCft1oTRQ5WRXV7malXANbJGc5S32iBm2sEIzK3UQkHn8G+keGfVJURAXZVUDJXikfX5l7Mg== 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=E8GoXfIIezXxwkNH+nkc/lKd5ti2Jm64EnlOqYLDm70=; b=TFofwUmDrQ9nqegVhQDJQup67feBGt0y09v6+mLsT5Ohbt+VUIR2d7+auiZJBXAFchd4ccGJ/Q1KqPgKpooNNW2G/u4MLSF35fCy4RiGKz7c14tUSdgBt5Qee2hV04m/2ll52HhwjeUNJDzBpUlD0WkOru9q4cYiI4Fd/ktY++HoS/oODT7h6jjr8YVqwQ2PD8PcaiKfpuVGJQV2+959Wo44orYwGkNAbCnVywaU74PCEcu7vysoQeZYc2cHngHg/Fd9LPeemNUfjss7A1I7+g+zRXwfH8J40orJ0IWyk8BNnkEVSbHrIUIqQyg/cIr2EMdeuBVo8l+uwbE8z09YSQ== Received: from TYZPR06MB6263.apcprd06.prod.outlook.com (2603:1096:400:33d::14) by SI6PR06MB7241.apcprd06.prod.outlook.com (2603:1096:4:246::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.18; Wed, 21 Aug 2024 03:50:14 +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; Wed, 21 Aug 2024 03:50:14 +0000 From: Yang Ruibin <11162571@vivo.com> To: Andrew Morton , Shuah Khan , linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Yang Ruibin <11162571@vivo.com> Subject: [PATCH v1] tools:mm:Check mmap based on return values Date: Tue, 20 Aug 2024 23:50:03 -0400 Message-Id: <20240821035005.4423-1-11162571@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: TYCP286CA0221.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c5::7) To TYZPR06MB6263.apcprd06.prod.outlook.com (2603:1096:400:33d::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB6263:EE_|SI6PR06MB7241:EE_ X-MS-Office365-Filtering-Correlation-Id: 747f817b-6af4-4543-807f-08dcc1945d2d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: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itDWdg/XJBo6q4njzYh5z5G2hT1Vit3e2JfwsMgSo+oYoVnOxb/yxL6NXZK7md08QUR/CUgiiaY0iOf4mHB5q5wcKl2GGVpjS9zck5OEFTDhqmL7VRW79iOZcLzirL/iVzlpnXLYStsqiLA6jQYaC2sHMdqfCtKpiNCJD/uIntOZqraNZuxfsKLmJ8ITMewvEjLnN0yU08jWIdAYlNz1nxssvaZ8M1OAGBZlxuZ+0TDF/6cnJXxdpVMTN/GJbITfwbT6jwGuxZQiWcW8mV7JV/1IdYqydQ+oBM5p60oVFY5wAAgZo9bGcUmNf009NJj+frhEvjoDMFwQPM3qWTVi+fLG67bHg1ldX5u6HSq5APBoLKXUQIU9zucpF/rnbp+dDY2mRGaJogxGKb+K0lP8pChUleRJXdw8tE5gPe2uJqGVs4uO+sEuJD6vKtocYHxnKQqrdl5oHFP54= 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: 4rN4mEa3Q010KM1cD6FMHrlmnNheVvsuq7ejueo6YliqTtnkIJwO3AZOZphqSpaHv3MLKuCnVDOVq3bY6mvUpPnmLQVaDd2rVU6piebGHT6qwojpCufrZhOnxNk/683cBrOHF1sjOfYe/GIrIESF64duA5p7nFNdWquYvdvL0VQp5P6kLUJQr1AFlGOTfecRtmp8dYOQZK5sISRYekjaI8dM94fiH9zHV+E8DH39lqe92oMXNcXUxhu1X9LkqPAvb2qr0+LdSFP3oTi02Kf+RzK0xtLbUReRilq7fukzcFKFuqnCzT2CfHtOEY05olKmYvKJmTgzAxgImI0s0btp6TvGjZwFHBJfoM6T/vDMAR4MAdXeha3GQEJu/zTegis28RN0iNAm1OufS6f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rnqtoq6Ugem0TzsLvQ4o5oVRjQVl1UIyb/M7pR/bu6gtv9Kvxl3sgEmf2PaAVOBimrrjP0nbjDWg0x4FaEFu/at9rd5kSaO0FmRyjLsiolCS/PBIgIUwSE5Iv5VbgE5XyT X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 747f817b-6af4-4543-807f-08dcc1945d2d X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB6263.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2024 03:50:14.3726 (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: L42MH1r3gsDx2Jf+W9kD0PHzJUNLnugy+IeMa/sCFruxlnCEEpzpIqbP/xdl+/nWS3hNh8PCu4kcY5vAtxqpkQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SI6PR06MB7241 X-Stat-Signature: 63m3a6gitsbru6p7qcd8uwheio8auooj X-Rspam-User: X-Rspamd-Queue-Id: 80CD5A0012 X-Rspamd-Server: rspam02 X-HE-Tag: 1724212220-389424 X-HE-Meta: U2FsdGVkX1/DaRzbzQv8owzM3lqAEQALefhaI03Ji1+hoBeWsmXJ2oOlwg+DBPaCTBc1oHie+1cd1r1TOOkPj/GbkmPfIeg/qUcHAq4b9l3yLX54Cv2NYbwRV9eVkfiHqwTXoG+B70AbFe9RMTmw/X8xZ9x/NrsmzrILFd1JdV/DHgbJgTuoRRNXJtBnNQm5p+B9K/AUVnUeWfRRu9zFY4iTpqzR0Gp+0FZBHmi0u6Z4MEWQ2mae00SMpXbuQobobX5Ow6ZU46t+zOsNBVbCDf84DaaHz2jz02gPZJW0xX/8LYnuV8v1+50JieEDp7XVJlVm0u4iC0JFyyZ76dWrc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7OBSWI7e3VaVlxw== 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. Signed-off-by: Yang Ruibin <11162571@vivo.com> Reviewed-by: Shuah Khan --- 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 b748c48908d9..dad54840f32e 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 ef7d911da13e..b89cb83ca5c5 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 bdfa5d085f00..4ccbc053bcce 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);