Message ID | 20231107141044.24058-1-clin@suse.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:aa0b:0:b0:403:3b70:6f57 with SMTP id k11csp259528vqo; Tue, 7 Nov 2023 06:11:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbI1ZVLj1uqw75PCr7xa4c10Z4TuJoN3/FyFsTZuC4B6O/dhRMegK1pRy7JTX9E1VyXMxb X-Received: by 2002:a05:6358:1983:b0:168:e592:f8d2 with SMTP id v3-20020a056358198300b00168e592f8d2mr37783055rwn.25.1699366285789; Tue, 07 Nov 2023 06:11:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699366285; cv=pass; d=google.com; s=arc-20160816; b=PIpJGh/cFL/lg0//FdAmLaj5aKsNOraxpNHAT4fFSjKZjH+r9NufJftkLYyG6nDJ2k r0hp8zpwGEtlXM79uw4lMtx1LZk75ARktpGjOv0QzotOyrdfiOwqvJwDgFBEmXiArVSX usH8PzWvIETDElJtgHCUBBpRyN5yfDmy0PKuxFH804Swz4fpb3xEFBqVvCAMiSmQSyhc fQaOof4Itql+0v2TSHgElww0K+IVxb+5V9dvpz+AdYUgDVWU3+H5+0lwQ4zjaCxvQbNJ SnStFHWjkoxY4AoQUCVU4ayrS6j7/nnU1jbqp1a3sxsScdSLGcHfY8agrqFqUtrlRnL7 7QrQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=ie6tBhSMP6s9UfSqo93DQGR6qJa+OrY5Wx2hnvkYjJk=; fh=5WdxOiPicnhD7b+NZNAMIfOL5rvhGlHgRuZsSDNMTWA=; b=0ipWpYXKPBGoFAOg6Lmff6o6rDc3P5hKODSqd+YMfgs0IXSRv3/d1sCu+Uj+40g/8o vMrMipRH4ekduyaeuKAOM/YWWZ93GzkGdpFFYHAoJ+49JD1P7lhXHC3AsSS1bHNRxC5H H/cXeWiw4/l3V0e6DvZReUlIwEy5++QEcBqU9zw1d8X1cudR0X/hAYcI+BJh9OoOAG5z BDhs/XzSFTXR0qDNSIwFau9ZOhgJz/WvGV/isTca0koyxaWXdtU4ov14hWGEiOmzCLWW VxsJ3c6O9sYcMRL2XSqmD9CKIuiDFRlHXmyLOV5V+xdkozTVBTAn4XSfAg4IAuepgRbg FQSg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=gE29Npfw; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id c70-20020a633549000000b005b91192c628si2061392pga.369.2023.11.07.06.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 06:11:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=selector1 header.b=gE29Npfw; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8695A8021395; Tue, 7 Nov 2023 06:11:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234244AbjKGOLC (ORCPT <rfc822;lhua1029@gmail.com> + 32 others); Tue, 7 Nov 2023 09:11:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbjKGOLB (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 7 Nov 2023 09:11:01 -0500 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2072.outbound.protection.outlook.com [40.107.8.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AFD4C2; Tue, 7 Nov 2023 06:10:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G5q0N0hwCh5abC9IZSpLGvIWQyzcmrhr9DX9jgFDNMtoy2/Zk8uERAxEWUkLF2qX02Q14BYZZgM6phaGKYiEckiXLI83CJeVwF1FQJahqcyLU/y7yWI9MLSVqCY7gZHH5XL7PrimJlT8E8u/h24ev9+3wE+de9Gxw/o0Qh4eVQmBSebdW66aGCyHZ1xCWYFs6Q2GLGdruNHgDhoKdFjoN39JbjwbZVzGCQ3jQ60PB1phgWlqjemg+9qLigrIrVThzlvrUFBSOp5Yq4OpYKRFj1PowiqN7Ahc64pzRpTU8VxslSZkVfe7pYxGvEidc8rNnvicsj5lh7uuexjYZfpkaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ie6tBhSMP6s9UfSqo93DQGR6qJa+OrY5Wx2hnvkYjJk=; b=OMG/2stvdyJgB4NJrfcDrF+R6r+3tmfrET+nEjrXyGZVvOw8EWaRIbrbosRvZ/3koq8EMExOmLWbz+PxNAVQr4pslLZkSFBZfPlMWeb/wpWl8WZ8u4/06Xssa0CluszHmDCwONPDoQs4eVQ0fyA2LrTiM2xEjf+i4frnzX2s9teSKIau1Yp1BqzkvCbs0Up3LylZJhvDyLC+uuZ+m1jMqnrTkAcmAKmc46DXqrwxPzMCoEmfwAwwtcViQHMbJzJ+0LBDHOGxzsfedG2iuxghcdBLtPMy8pBOYBT6iLgXq7qZmkU6jLOxNvzG0aqdHoREPDQx8ezhXl/s/qpq7K/2kw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ie6tBhSMP6s9UfSqo93DQGR6qJa+OrY5Wx2hnvkYjJk=; b=gE29Npfw4wJNgjg2UW9EaRe3Zu7cvfC4K8Gu6hCDjWGAMix+sgx4AEUL0R7OlZazNU1q3ljdg1cchc9xDrNacLN5LG8oS6bGk7aD/fl1qMjajjy7ho3obbLXIB5Mf/eT4hTEvqb0eaXMAigcWguKjaLKO9r7Jyh2i/g6oSemyN10SZnlkgm+n3w8xaURNE/6yM2bspvQgQUn5YH38oEDvAWBifbmZKB9uPVvzg4Or1qT2id18sClZmt5OHyYhz48Lj6aDUO0rOkrrAwAyYKKciMKBtPEto0D3TRyRcl0PlX7GJ5wvPeoEiqVp5JBYnQfcoZRdOUmofbWomwfe7hxlg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) by AM9PR04MB8180.eurprd04.prod.outlook.com (2603:10a6:20b:3e2::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.17; Tue, 7 Nov 2023 14:10:54 +0000 Received: from VI1PR0402MB3439.eurprd04.prod.outlook.com ([fe80::eeb0:9b32:19a2:8e12]) by VI1PR0402MB3439.eurprd04.prod.outlook.com ([fe80::eeb0:9b32:19a2:8e12%6]) with mapi id 15.20.6977.015; Tue, 7 Nov 2023 14:10:53 +0000 From: Chester Lin <clin@suse.com> To: Chester Lin <clin@suse.com>, NXP S32 Linux Team <s32@nxp.com>, Linus Walleij <linus.walleij@linaro.org> Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot <lkp@intel.com> Subject: [PATCH] pinctrl: s32cc: Avoid possible string truncation Date: Tue, 7 Nov 2023 22:10:44 +0800 Message-Id: <20231107141044.24058-1-clin@suse.com> X-Mailer: git-send-email 2.40.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TYCPR01CA0001.jpnprd01.prod.outlook.com (2603:1096:405::13) To VI1PR0402MB3439.eurprd04.prod.outlook.com (2603:10a6:803:4::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR0402MB3439:EE_|AM9PR04MB8180:EE_ X-MS-Office365-Filtering-Correlation-Id: 73d5e5ea-1c30-41d3-c580-08dbdf9b5a9b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s4SX1HQcHIma0kTo6L3ZsknbxFz9XSh3LVBCaZynG0QLzX0vZLL7y0pEqsYJ8nWTP56Lbd/7RtXtU7jKFsDfs8rn+KzUjEfnxw4PuMN5Pzhc5jelD7OxyvVVHAJvcr3qVbcHM5CUut/X3RkIYtyDMEwFwPzKpZ2eyiURBV0bGzCDdJVmdup1qOMxXlIpD+g4Q89n9xIVneog0U4A/SSZwigcdXWI48G220p4c7kLksOdRqqGwleabTwdx7jS+Ncp+ufBAPbeSVpQUn53R9zvK+kD4+SYNfzqZUUgsCj7FXVij/EMgry9JBI70X1BCLBcJvohHPyGLoSpaEelG0kClgP30r6U7a59qL9/EL0OXGamfmC8exkeOb52GNXEjF5jni2zaT7/z2L+P1MZl3uBcTp/pkK1/lreeThysw0K9jyoTyaC9TDOBLTCArs7tH6NZwxbA/I6qs6iBzOwh8D9vldJz4fEPhjfoJ9rREMKeS2qJuZt4hwaxJNKfMGt76NplqaqgPSF58di99qCVy4Byo4VOO0xUSfEIC/86OjJ3b1BLNM8F4roVLPwf86qsUCMTVqQFk5auqT8yX4p+4sPtdDhhCI/7MJVvbf+ZDnz060Brit707FRYm4zJdOs0La0 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR0402MB3439.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(396003)(376002)(136003)(366004)(346002)(230922051799003)(230273577357003)(230173577357003)(1800799009)(186009)(64100799003)(451199024)(6486002)(966005)(6506007)(478600001)(6666004)(66476007)(66556008)(110136005)(26005)(66946007)(6512007)(41300700001)(2616005)(1076003)(2906002)(8676002)(8936002)(316002)(4326008)(5660300002)(36756003)(86362001)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Heb2vjvFPf6jYTJTSBx3H9dRCEtRu1tZyhAxv19bs1uRl1inqJqQC8LPWlsmGjvOKMz8r42W4pdtNtIkIw51jYDVvTIp295gqN6XFzwyfHuCyoiVGpQsKfl2a7yOC3zAzFXPc0rVJxQNMmRnZ7Kb7iDlhha6Coftp4IXI9flTAEIgfFXIh9tAiUbMuao9I+8DxlBKP6euZN8qHJnxktRDLjtyk4xvLEmVoZ3QEiMZkBUQSeSS+U3DiglpmbLfCio59dnMiAbAjB6pEhSxlUPOTG0gBcX82ycIBED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GfhRM6eptDf5qENVUdiFA04VkZs9UYizgW+BXC7vNxdvidOSbNbH8/1LMlykv6kzjHZDJYVGcrO3fswdv407bdYEllbLDKY1JTIVE9sg1MxPb5poEOvLYTv5mvzheC2jJGNyVy7HUuQWXoLRV8ZlCAXtZm1rQQhkI2yBrDK3LP5eFo1Dd244zEvO5ySmR/vCaMgWylk0hjQ5rZvQngpIaDjr4= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73d5e5ea-1c30-41d3-c580-08dbdf9b5a9b X-MS-Exchange-CrossTenant-AuthSource: VI1PR0402MB3439.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Nov 2023 14:10:53.8214 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jV/tcLKIGH+SrvLk4kitW9cyw/plof8JtMn05ewgfzhQcRBmKFO0wzIdZ9HqHnWx X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8180 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 07 Nov 2023 06:11:22 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781914702492375932 X-GMAIL-MSGID: 1781914702492375932 |
Series |
pinctrl: s32cc: Avoid possible string truncation
|
|
Commit Message
Chester Lin
Nov. 7, 2023, 2:10 p.m. UTC
With "W=1" and "-Wformat-truncation" build options, the kernel test robot
found a possible string truncation warning in pinctrl-s32cc.c, which uses
an 8-byte char array to hold a memory region name "map%u". Since the
maximum number of digits that a u32 value can present is 10, and the "map"
string occupies 3 bytes with a termination '\0', which means the rest 4
bytes cannot fully present the integer "X" that exceeds 4 digits.
Here we check if the number >= 10000, which is the lowest value that
contains more than 4 digits.
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202311030159.iyUGjNGF-lkp@intel.com/
Signed-off-by: Chester Lin <clin@suse.com>
---
drivers/pinctrl/nxp/pinctrl-s32cc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Tue, Nov 7, 2023 at 3:10 PM Chester Lin <clin@suse.com> wrote: > With "W=1" and "-Wformat-truncation" build options, the kernel test robot > found a possible string truncation warning in pinctrl-s32cc.c, which uses > an 8-byte char array to hold a memory region name "map%u". Since the > maximum number of digits that a u32 value can present is 10, and the "map" > string occupies 3 bytes with a termination '\0', which means the rest 4 > bytes cannot fully present the integer "X" that exceeds 4 digits. > > Here we check if the number >= 10000, which is the lowest value that > contains more than 4 digits. > > Reported-by: kernel test robot <lkp@intel.com> > Closes: https://lore.kernel.org/oe-kbuild-all/202311030159.iyUGjNGF-lkp@intel.com/ > Signed-off-by: Chester Lin <clin@suse.com> Thanks for fixing this! Patch applied for fixes. Yours, Linus Walleij
diff --git a/drivers/pinctrl/nxp/pinctrl-s32cc.c b/drivers/pinctrl/nxp/pinctrl-s32cc.c index 7daff9f186cd..7735d30f2be3 100644 --- a/drivers/pinctrl/nxp/pinctrl-s32cc.c +++ b/drivers/pinctrl/nxp/pinctrl-s32cc.c @@ -843,8 +843,8 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev, if (!np) return -ENODEV; - if (mem_regions == 0) { - dev_err(&pdev->dev, "mem_regions is 0\n"); + if (mem_regions == 0 || mem_regions >= 10000) { + dev_err(&pdev->dev, "mem_regions is invalid: %u\n", mem_regions); return -EINVAL; }