From patchwork Tue Oct 24 21:55:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 157712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2223500vqx; Tue, 24 Oct 2023 14:56:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6PcEpG0mg8sT91NFDzb+lCox0/qiPGrywn/sXO7kWxqMF1sIO9LHMxSPX9W1Djfh16+qS X-Received: by 2002:a0d:e643:0:b0:5a7:aa65:c536 with SMTP id p64-20020a0de643000000b005a7aa65c536mr14533431ywe.0.1698184609148; Tue, 24 Oct 2023 14:56:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698184609; cv=none; d=google.com; s=arc-20160816; b=r1cS58UMRkmNLzfNVKrZ3fJSIgZv0fRIPo880RuWTh3SuDqtB9y91ua4L14GxiBx6b W6b4D0d7GteEbJn7yB5eHlvOzvAMT/G2aSwHxIJfB/h4S2eiaN6FG1qLvocj7RvyqMms G9GdCRdeX80YIRv0TyJ4yovv3yf0alfGMU7yIUfBOpPdLG534y8AgJMJVjmz2zv2trgI 2ReK7q6BESIYbqID2yGlc+69JLx3Om8it52KsqzAP2Yw1VTwLykosT/LRsUPlKMFc45v ADLHHuCfCjMGp8sARWUUmtK7RYI4uBVmUkItLfm0h1CyvxD/6F/adonoGYwAxjci5jXV BaGQ== 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=PUTDQPvlFyPiEvyDiwi2WaoHEwZQ4gD1D9wjPH22Tg0=; fh=tjjmbP6txKOPXRqOv8dsL9LdmJ4EJqOYxml9dKpTntM=; b=RcwyAzcLUA2S+h8XiFSF9itZL4OKcL+H2HlNp7lE2PqsrY9p4eWcQdKUd3OReEDU4F Zk7nn0AAsvvGnuk1Yw8YWt77elzJFPD8PzSmrLZxA6yZxyZgzEoUqpOmKMeiG9qDGhVN D/TcE3gpcoHvvZaSyYZT7kwQyKyv93AlDu93hgmdj+herK+LN/eknHIw0Sl08ylnx1/d PikykOS66HGuoWv/o7TkhgjcWX9ypeVh3pR1u8SxUoPVDMzj/eReujqsr7XhRsNKbPvH e2R7/O6o+8YoklCWJc48VOtQRk3Wf+QRD4SffDu7T9BBe1wYEanhUFEGXape7YFVDfc/ eVqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=m3a5cy2F; 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 s6-20020a815e06000000b0058d0f8e3d9bsi10457228ywb.228.2023.10.24.14.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 14:56:49 -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=m3a5cy2F; 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 9329980615D1; Tue, 24 Oct 2023 14:56:27 -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 S1344425AbjJXV4G (ORCPT + 27 others); Tue, 24 Oct 2023 17:56:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344403AbjJXV4F (ORCPT ); Tue, 24 Oct 2023 17:56:05 -0400 Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B59210C6 for ; Tue, 24 Oct 2023 14:56:01 -0700 (PDT) Received: from localhost.localdomain ([141.170.221.62]) by smtp.orange.fr with ESMTPA id vPNUqJGNq1FecvPNUqURC8; Tue, 24 Oct 2023 23:56:00 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1698184560; bh=PUTDQPvlFyPiEvyDiwi2WaoHEwZQ4gD1D9wjPH22Tg0=; h=From:To:Cc:Subject:Date; b=m3a5cy2Fq0IFJO5I90Z2OyNKDQtVh1a+EOqxMi1KRWgteOCtrQ7bKPq2vV+1rch2+ BP2NfvJYJPBRumCe4D0AQLFe00sgurSShw3jE7Ju3suGti7jr3UlnrdFpslqZGvRw9 mwk8PAfy3Hx2JBfsFXRY4risyQs+jfH3GrGVftKAk7zYWbKuA0EMsK0vB1RNJw1f2B 8ex1tKMtO/cNL8nYqFkYhJtHs3Opcf4HknbQpIaXmzaLpLLZCqUHKMVbIQ9dk0Ky0G uA4pTg0GzMeXGCi7Sp54hrkiG7LT5pe1VAOoq0ac1NdsNN/ikSDkIvqepcd5BQBe1p DARy2dv72SFow== X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 24 Oct 2023 23:56:00 +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: sunrpc: Fix an off by one in root_nfs_cat() Date: Tue, 24 Oct 2023 23:55:30 +0200 Message-Id: <856a652a7e28dde246b00025da7d4115978ae75f.1698184400.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 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]); Tue, 24 Oct 2023 14:56:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780675624810037226 X-GMAIL-MSGID: 1780675624810037226 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 Reviewed-by: Simon Horman --- 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);