Message ID | 31b27c8e54f131b7eabcbd78573f0b5bfe380d8c.1698184674.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;aposhian.dev@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <christophe.jaillet@wanadoo.fr> 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 <christophe.jaillet@wanadoo.fr> 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 Content-Transfer-Encoding: 8bit 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: <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 (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 |
Series |
[net,v2] net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr()
|
|
Commit Message
Christophe JAILLET
Oct. 24, 2023, 9:58 p.m. UTC
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 <christophe.jaillet@wanadoo.fr>
---
v2: Fix cut'n'paste typo in subject
Add net in [PATCH...]
---
net/sunrpc/addr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 24 Oct 2023, at 17:58, Christophe JAILLET wrote: > 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 <christophe.jaillet@wanadoo.fr> > --- > v2: Fix cut'n'paste typo in subject > Add net in [PATCH...] > --- Reviewed-by: Benjamin Coddington <bcodding@redhat.com> Ben
On Tue, Oct 24, 2023 at 11:58:20PM +0200, Christophe JAILLET wrote: > 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 <christophe.jaillet@wanadoo.fr> Hi Christophe - Should these two be taken via the NFS client tree or do you intend to include them in some other tree? > --- > 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); > -- > 2.32.0 >
On Wed, 25 Oct 2023 10:30:51 -0400 Chuck Lever wrote: > Should these two be taken via the NFS client tree or do you intend > to include them in some other tree? FWIW we're not intending to take these. If only get_maintainer understood tree designations :(
On Wed, Oct 25, 2023 at 09:28:29AM -0700, Jakub Kicinski wrote: > On Wed, 25 Oct 2023 10:30:51 -0400 Chuck Lever wrote: > > Should these two be taken via the NFS client tree or do you intend > > to include them in some other tree? > > FWIW we're not intending to take these. If only get_maintainer > understood tree designations :( I accidentally markedt his NFS patch as net on Oct 11 as well. :/ https://lore.kernel.org/all/356fb42c-9cf1-45cd-9233-ac845c507fb7@moroto.mountain/ regards, dan carpenter
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);