From patchwork Tue Oct 24 21:58:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 157713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2224166vqx; Tue, 24 Oct 2023 14:58:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfjSngDeDE07UB9B5iUpPN3EDowdkwLWIFmDBluUcZFpGr6ht0/F6tKKKOfwej2+2Muna/ X-Received: by 2002:a05:6a21:7784:b0:17a:7c2:d4a6 with SMTP id bd4-20020a056a21778400b0017a07c2d4a6mr3886482pzc.55.1698184733068; Tue, 24 Oct 2023 14:58:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698184733; cv=none; d=google.com; s=arc-20160816; b=B4JfGEegUngBr/72WJLpagK3dUumZSMD0NcXxLe1IJuaAUtf0QZzm4tewO6wkzRjtr uqhgybKesBtpk2dHmnfpoll4oCjZKa0JdqOHBblG0Qg4sArleS+ah+0RlVnBektTMx/D KhebmV+Ksf5YKzOLK05uSfg+VpCw1DSWwF9/gudvyBGXxAbrYx+rVLVmlg9HoELIgUKv vjrc/8ISpdkXXXinBSIRlWm1KJbu8qYCSWfP3EWj8dECylg66NKqBF+OI3A8R8ingcFO vIzmX076n5h4/Z90gMPmfn9rgoJfWLtA4bdRYjoHsGAjtdUDjY4/NpPwQcekv8jcP9RS SeBA== 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=CxvDITTYWkbVF3erY431KvtkoAIB2u79w80t/0Puphk=; fh=tjjmbP6txKOPXRqOv8dsL9LdmJ4EJqOYxml9dKpTntM=; b=0U7xe9kFC3Z5eLc7Odk/9XZv342YAw6MHQDek+HYsNk2OHZ/YWUAnYyS27/TSU7JaD ysWrQ1AI8JbfIkIloE9fpNwUN9+9Z1Wdl4HrV4mK8e1YSOqQ1VtkjTQm6JOHHrzgoeDq TLDSoltVhYiUcERiizVQnCAlqj5dq+uNsXsdm7QMBh7X8CmhJVw0mnhg4fV3FIRdExzh mhpgWmQ0NDafjahWm2OTAS5kDhr84BMDPsKBFmrOgqxFltz6M73slfwMZBOdHEc8ZNUf k+8FnEjzgVGZl2smjKr0MQkh2F696FJzm3vz30v0clBicU4C/Vn8/Yfw2d0r4nWio3GD QnDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="bfAt2zU/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id cb7-20020a056a02070700b005b2d044af28si9830370pgb.257.2023.10.24.14.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 14:58:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b="bfAt2zU/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id D687680A9B1A; Tue, 24 Oct 2023 14:58:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344408AbjJXV6b (ORCPT + 27 others); Tue, 24 Oct 2023 17:58:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234965AbjJXV6a (ORCPT ); Tue, 24 Oct 2023 17:58:30 -0400 Received: from smtp.smtpout.orange.fr (smtp-29.smtpout.orange.fr [80.12.242.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2325BD7A for ; Tue, 24 Oct 2023 14:58:28 -0700 (PDT) Received: from localhost.localdomain ([141.170.221.62]) by smtp.orange.fr with ESMTPA id vPPuqJHBw1FecvPPuqURbW; Tue, 24 Oct 2023 23:58:27 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1698184707; bh=CxvDITTYWkbVF3erY431KvtkoAIB2u79w80t/0Puphk=; h=From:To:Cc:Subject:Date; b=bfAt2zU/U5AFUmH1D1n1lI5TdIRFOhOYxVQrrCy1n21xgIA8oAbl0E7GEcV0J31t4 2dNamly3ACkpzHZXMY6i3Jj/BeZ9W8lJaVTUr1GQ9A4JoIM5A9y2EPgkfKQhOnhjAT cVXQVj18euEh+SGpRScXfLE4CTLDjSe1mUZkqHYTWenzHCawJsNdSDRfg5opbWDif3 Ee3nNVaQxzyzu+5oThrra2CV6NJOh86HGhTeHlklONpAx/+Hxu8T0Vt0frpX6Q2OQ7 mklUw9VRu+ePWscJ1QhuyME3BGWJ2JjNaYHHIGG9+INTE0QTHHovEoEqlPdOLSOqoT r8V4jRMmwu9Lg== X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 24 Oct 2023 23:58:27 +0200 X-ME-IP: 141.170.221.62 From: Christophe JAILLET To: chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, kolga@netapp.com, Dai.Ngo@oracle.com, tom@talpey.com, trond.myklebust@hammerspace.com, anna@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH net v2] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr() Date: Tue, 24 Oct 2023 23:58:20 +0200 Message-Id: <31b27c8e54f131b7eabcbd78573f0b5bfe380d8c.1698184674.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Tue, 24 Oct 2023 14:58:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780675754253341841 X-GMAIL-MSGID: 1780675754253341841 The intent is to check if the strings' are truncated or not. So, >= should be used instead of >, because strlcat() and snprintf() return the length of the output, excluding the trailing NULL. Fixes: a02d69261134 ("SUNRPC: Provide functions for managing universal addresses") Signed-off-by: Christophe JAILLET Reviewed-by: Benjamin Coddington --- v2: Fix cut'n'paste typo in subject Add net in [PATCH...] --- net/sunrpc/addr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/addr.c b/net/sunrpc/addr.c index d435bffc6199..97ff11973c49 100644 --- a/net/sunrpc/addr.c +++ b/net/sunrpc/addr.c @@ -284,10 +284,10 @@ char *rpc_sockaddr2uaddr(const struct sockaddr *sap, gfp_t gfp_flags) } if (snprintf(portbuf, sizeof(portbuf), - ".%u.%u", port >> 8, port & 0xff) > (int)sizeof(portbuf)) + ".%u.%u", port >> 8, port & 0xff) >= (int)sizeof(portbuf)) return NULL; - if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) > sizeof(addrbuf)) + if (strlcat(addrbuf, portbuf, sizeof(addrbuf)) >= sizeof(addrbuf)) return NULL; return kstrdup(addrbuf, gfp_flags);