From patchwork Sat Sep 23 06:15:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 143935 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp248653vqu; Sat, 23 Sep 2023 08:48:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEzwdIdkuk29hjJcARLXoykEjBB5VA2XNN52qxjzKOA7MtjfPgDod28diF7I75S6qEVwyTe X-Received: by 2002:a17:903:1252:b0:1c3:e5bf:a9f8 with SMTP id u18-20020a170903125200b001c3e5bfa9f8mr3037250plh.19.1695484092063; Sat, 23 Sep 2023 08:48:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695484092; cv=none; d=google.com; s=arc-20160816; b=jtKykNmvrTC6S/E7v7je3gHqCtd33MHXSvAMz5bvxKV9XeUyxpFpoNhIf5Ga/tYhC9 wxzWawFOB0zu3a8TxIVcWfVf219lqGq0ZKzw++v8CsIA7t/T18NzYc3MiKylLyEatasS Tg7ViSOEa5s6FjmkLza4OqhchwhgAZaSwN9xosP6qCU6W9tYeateeL1nEwnCcBk4gqid l+Fl0Pgyget/Lc/dqI+dI08ulxvpb3TYjhncXjtTtDiACApdsFNjhUufpG3js/B8Hhnz oSJAdo/nkyVa1c1BUhzp/HN4CLQoSXCe372wHJ4Wq/OsN0DnnnvjiJpGPIY83j15Xbyw ZcSg== 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=G7tAIoMWyx5SK/7lnnnDHZQxV+76Lbl3kc2YAXhhFds=; fh=2yufRnxVgDB6E00E0CYoMk9ra1uIpQAW/eEdwwY1QIU=; b=LeAZ99EbRMI9spOTHjjUO63XVoU3gYGh+x1vt2Dl9ARsRiTOjg0Lx8y7QDLbKLYMCb 1Bl1+BVOLhRR+kdI++Vw2xC8EQzibWIsgoRhogDpnB9O1Uf19BHHRcaMoS4Dn0xATUJn QSKefx62SZ5ZrbeBMtwddQjgsMeBw1KEwCfpnVkTaOQNL08lvDge8zZI5k6Pg9rBnH72 M93bdFMds3KbTqgEa1dO/YBfLZxiYH5WTUpUx/Cddn0kxmeA5JoYLZYPMZEH+j7fwNw4 GxcOyC4Gidsj5QuX66YpJjbRRKX7puQ16f3KYgtWEOJYcPLbX2QLSBwT3p+ZddKrQOql BNYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=MGzImVvY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id d14-20020a170902cece00b001bc674914b0si6947174plg.472.2023.09.23.08.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 08:48:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=MGzImVvY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 6407383A6A18; Fri, 22 Sep 2023 23:15:53 -0700 (PDT) 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 S229863AbjIWGPf (ORCPT + 29 others); Sat, 23 Sep 2023 02:15:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjIWGPf (ORCPT ); Sat, 23 Sep 2023 02:15:35 -0400 Received: from smtp.smtpout.orange.fr (smtp-28.smtpout.orange.fr [80.12.242.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8DC119E for ; Fri, 22 Sep 2023 23:15:28 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id jvvKqieqFqQHijvvKqqbog; Sat, 23 Sep 2023 08:15:27 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1695449727; bh=G7tAIoMWyx5SK/7lnnnDHZQxV+76Lbl3kc2YAXhhFds=; h=From:To:Cc:Subject:Date; b=MGzImVvYYc5cHEX3tVkaysSdw4wuTrxD6R7sWHjIOZ2qws4JYxELVTHhdQ4eNkF+Y FSRNHfwED57IwVmOLTRF9Jfe4ckoQ5aYFsB8IOx6mhkvSeTpNkEL0Qk9NpdkInRH4k xL920sfyYWK6wUVTAY1hCvKm+Lx2oND0wzQM9br3tNBn0l8hmSb9WbbmPThSL6NBI8 6QWE3aRnarN3FP4mEBH+G6AgJZ9k6rzZGNRX3qjNowyYmX8ZyEVtqJ01UyQ/xHjVo4 S/UKjvIG4UCmOcp47MV3BK29U2pJvgV7P/rhm7tFO2jlJXDvNDRHdb+9oHdNdr6Hid ntKvus+7XzSxQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 23 Sep 2023 08:15:27 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Jason Gunthorpe , Leon Romanovsky , Matan Barak , Doug Ledford Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-rdma@vger.kernel.org Subject: [PATCH] RDMA/cma: Fix the size of a buffer in add_port_entries() Date: Sat, 23 Sep 2023 08:15:25 +0200 Message-Id: <91395b73a64c13dfe45c3fd3b088b216ba0c9332.1695449697.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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: 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]); Fri, 22 Sep 2023 23:15:53 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777843927585984844 X-GMAIL-MSGID: 1777843927585984844 In order to be sure that 'buff' is never truncated, its size should be 11, not 10. When building with W=1, this fixes the following warnings: drivers/infiniband/core/cma_configfs.c: In function ‘make_cma_ports’: drivers/infiniband/core/cma_configfs.c:223:57: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 223 | snprintf(port_str, sizeof(port_str), "%u", i + 1); | ^ drivers/infiniband/core/cma_configfs.c:223:17: note: ‘snprintf’ output between 2 and 11 bytes into a destination of size 10 223 | snprintf(port_str, sizeof(port_str), "%u", i + 1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: 045959db65c67 ("IB/cma: Add configfs for rdma_cm") Signed-off-by: Christophe JAILLET --- drivers/infiniband/core/cma_configfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cma_configfs.c b/drivers/infiniband/core/cma_configfs.c index 7b68b3ea979f..f2fb2d8a6597 100644 --- a/drivers/infiniband/core/cma_configfs.c +++ b/drivers/infiniband/core/cma_configfs.c @@ -217,7 +217,7 @@ static int make_cma_ports(struct cma_dev_group *cma_dev_group, return -ENOMEM; for (i = 0; i < ports_num; i++) { - char port_str[10]; + char port_str[11]; ports[i].port_num = i + 1; snprintf(port_str, sizeof(port_str), "%u", i + 1);