Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2968482rdb; Mon, 4 Dec 2023 12:33:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IHUzXi35PsQ8f/xikSSiR2DOjZ/fDsB2TeoTBWufDiQe+N7IRn4mlmfmqcWNp1ui2p4A1x8 X-Received: by 2002:a05:6a20:3d1b:b0:18b:556b:6d54 with SMTP id y27-20020a056a203d1b00b0018b556b6d54mr2210052pzi.55.1701722008333; Mon, 04 Dec 2023 12:33:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701722008; cv=none; d=google.com; s=arc-20160816; b=FuSa6RINIqQXeYlxyCtEVP63Y05sc58wBzNUX+/cijcclAOuJKDNBn45VJz4zoUDbn vCv4Kwrh85HHkJf8cwmjqsIx/RjagnZT7s6R7hpMt0/0gi4YytG74mOs/5LptyhdYoxn MPYUK2AkOJ9RcuMmuI+1za7LqB28Wiusb8JJ4pw8RwgfGOLuXcwspvzQAwQQt9wazev6 6FN2K8zrYYmmwCEzQ6JnGTTWHtdfsv0YMN1Ns7d8a81jMR0R5vBGdeFsDSNSuZe4WWvM a7oImfz6O7WcrWDbJ/sk1Ew3oTWUn6QoLAa2PSCH8kfZZMDp1p/06eh3vdM1j5j2WICT LjmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=STKf5FtmK9oy4yMchoRmLGGtAreEpmlFVIEIqwK86jE=; fh=hiL6x9Y6H6jjdKcTa7ZxCJh1fuqCVrh8d55dSU7tRwk=; b=xdx2sR5VeGo7q2c1HK+9ygt9Zp5vlb8CYoxlGMSrovJq0IJlIjb6cetWOfK6fAsP0f SFK6AIwqRH72snCjnTP4rjhe+9hhEsaNdQGT9VPQy5nGdEjZVc6eF+rxxXKnZqLwUe8m KHLw8yGatlISb+hnrTlwZLoiUdkBdsTU8arPihGlsex5l+MHuN+vSnQGweBPHM86qdmq mx09Fgabq8LOlg9mAs1X+R5jRWZ6VoGje2EaAeR4rgiy34v4o2XJTePh8c8GclsulghJ KqdHwAwJb+rcqUn00oKLhXsIYRWSQtClNjQ/4KPKs0Zbn+6fYKKj83gKADTMvURov7as IDrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FqaCNQo4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l6-20020a63ba46000000b005c67bf3805fsi3231147pgu.309.2023.12.04.12.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 12:33:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FqaCNQo4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 69F9580ABFE3; Mon, 4 Dec 2023 12:33:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235338AbjLDUdQ (ORCPT + 99 others); Mon, 4 Dec 2023 15:33:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229983AbjLDUdP (ORCPT ); Mon, 4 Dec 2023 15:33:15 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3ADF7B2 for ; Mon, 4 Dec 2023 12:33:22 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBF78C433C9; Mon, 4 Dec 2023 20:33:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701722001; bh=rd8BmPu27v75Rg65UrLZRuh/0JMkbcbIdVmUTxGWlAw=; h=From:To:Cc:Subject:Date:From; b=FqaCNQo45I5cJ3LSoXcYJKE0oPQ9fE/zDsLrlPWRCeaCD51yNAhsDmEMIcATtGOGp 4pPNrz7NYtJqQTBPj28SlwV3WihMCUgSst1F/I/nZDYH96H9dRR+0fUrIMOwj/pRNq pkzhCvl9/HucnKEhrvuN7x/W1m5OrAILKaQeeET6qhKq7JmB3c+J926ofZ2jQnlODf V0r4HauDLPI5V1Os+1aPlLkwsXpPnB2r8bGhyblsDdWLDdQVcdCn3/23uR6v0eJ8pb L5c0DpyUtXNq4FPHMpnWSO6N7kBTQ4Ay1x7g/C9VpLrhKB7qAuovp3nrjg5ncITwUR NhfiuNvGI9iww== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Chester Lin , kernel test robot , Linus Walleij , Sasha Levin , linux-gpio@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 01/32] pinctrl: s32cc: Avoid possible string truncation Date: Mon, 4 Dec 2023 15:32:21 -0500 Message-ID: <20231204203317.2092321-1-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.4 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 12:33:26 -0800 (PST) From: Chester Lin [ Upstream commit 08e8734d877a9a0fb8af1254a4ce58734fbef296 ] 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 Closes: https://lore.kernel.org/oe-kbuild-all/202311030159.iyUGjNGF-lkp@intel.com/ Signed-off-by: Chester Lin Link: https://lore.kernel.org/r/20231107141044.24058-1-clin@suse.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/pinctrl/nxp/pinctrl-s32cc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/nxp/pinctrl-s32cc.c b/drivers/pinctrl/nxp/pinctrl-s32cc.c index 7daff9f186cd8..f0cad2c501f76 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; } -- 2.42.0