Message ID | 7f97bb62c4e8137c5d7f7a7a30789440a5102b3f.1698183837.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 p9csp2220621vqx; Tue, 24 Oct 2023 14:48:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE4DaGMhuUj5mHkHir9CVzygLN/fcnOGif8GcVLdzoL5yGJqETea1fMqlwnvuzFr2ktxOBL X-Received: by 2002:a05:6a20:9153:b0:171:c88a:891e with SMTP id x19-20020a056a20915300b00171c88a891emr4097623pzc.55.1698184125182; Tue, 24 Oct 2023 14:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698184125; cv=none; d=google.com; s=arc-20160816; b=L5zl0so3lCgnItpODrSIVJ1/LIalBKwI18ccYar/pTu2OTc3ob3vjnh+vN3BcMPCbg i4HHbxiO320/T8ZfraC6qfrRxavobZ8M6D5Uh3hBTuEn5HJuBsf0gbmwS9LdDbzxKnbE uLps/v/ihTG8hxYK268BHu68G/enwGkqMZdQ85dkG0Do1ZIt0m7OPTXkV9C+dTN2i2Zs /qYmhm6ll4LdFVYe9wGwUlGEh4/KTgPTOvs2sTNC29U6ZbLki3QO59JH9/hS2pqQOOgX o1xYhQV+1ND6KY535Q27J5BDfqhK3e7DPPLWacX4+9PYO8+6csPwcIBQuCuh/FIQyAzp +6NA== 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=1yYR+ID0Mz0XbBfGN+NzNx5JNviXZsmBmncVbRmUG7g=; fh=mY31ttKDWWj/IT+NY+t91VKN4xGEonHANg3nBqyAwZs=; b=awBqmvwcpoMha+8u9XhOwfbc4MU0sD8rj9Clw8xuwfigH9MDs9qksGbQVAjX/iqAIW hZouun+85mY4gQYrDmtJlQBZO7RsFSp6/6geJqWJnkRUaFlt2zMIrBi+Rn01lmPfgspw an9Ln4uDgN7BRpUExJ6Aw771+1l3WqFecV2YVkvAZBd1Vp/I2oIsmurLCYih9Clqp4n0 KUfkQyF48ARwD7mXi1812oXAAAYSAq9fRSVac7tW1C8Pw6ajaF0IrFaUBNCprz84D+Bg LtHQdB+Btv5BvVBFU4UW9QC/iyeKlvSufofuJ6L+jv4xr0djpTFaqzvqNNtg7d59BMtg 29Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=RyiQB+iF; 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 q5-20020aa79825000000b006bf537ce976si6422256pfl.260.2023.10.24.14.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 14:48:45 -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=RyiQB+iF; 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 0B1588020A3A; Tue, 24 Oct 2023 14:48:43 -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 S1344410AbjJXVsb (ORCPT <rfc822;aposhian.dev@gmail.com> + 27 others); Tue, 24 Oct 2023 17:48:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234971AbjJXVsa (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 24 Oct 2023 17:48:30 -0400 Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B8791B3 for <linux-kernel@vger.kernel.org>; Tue, 24 Oct 2023 14:48:27 -0700 (PDT) Received: from localhost.localdomain ([141.170.221.62]) by smtp.orange.fr with ESMTPA id vPGBqZo62QRiPvPGBqyjSG; Tue, 24 Oct 2023 23:48:25 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1698184105; bh=1yYR+ID0Mz0XbBfGN+NzNx5JNviXZsmBmncVbRmUG7g=; h=From:To:Cc:Subject:Date; b=RyiQB+iFm3iOfwasBnQWnJn1ove8eCS7mgflHV15KRBlHBVJtSCA4HkPhL1LZTQ3E VxHDWNKDd+hpHmWlDx9ATTHXlVRRieE4SDUaHYD93pzWE00pvmJf9+O5fPAXr4zAdm GwhCULy2kBImzbQsRMHIo7tdR9ws4d+DvbitdaXzei91gkp8rmxwUdqodV82z0smqX nJKGQM8MpNFoUuV2lgLH0CGyyJK9JjLnK06mSQvHuyaCFMvV7QJXJOrfZqqJs2u67z Q5uKZvCXF9fZscpRJw22480bt5mkw0d1dfSPinDZjX8k7sodRCUdAfuiUAKY0B6+6j 8OZasVVLpv4rg== X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 24 Oct 2023 23:48:25 +0200 X-ME-IP: 141.170.221.62 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: trond.myklebust@hammerspace.com, anna@kernel.org, chuck.lever@oracle.com Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr> Subject: [PATCH] NFS: Fix an off by one in root_nfs_cat() Date: Tue, 24 Oct 2023 23:47:42 +0200 Message-Id: <7f97bb62c4e8137c5d7f7a7a30789440a5102b3f.1698183837.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 fry.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 (fry.vger.email [0.0.0.0]); Tue, 24 Oct 2023 14:48:43 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780675117253159634 X-GMAIL-MSGID: 1780675117253159634 |
Series |
NFS: Fix an off by one in root_nfs_cat()
|
|
Commit Message
Christophe JAILLET
Oct. 24, 2023, 9:47 p.m. UTC
The intent is to check if the 'dest' is truncated or not. So, >+ should be
used instead of >, because strlcat() returns the length of 'dest' and 'src'
excluding the trailing NULL.
Fixes: 56463e50d1fc ("NFS: Use super.c for NFSROOT mount option parsing")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
fs/nfs/nfsroot.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 24 Oct 2023, at 17:47, Christophe JAILLET wrote: > The intent is to check if the 'dest' is truncated or not. So, >+ should be > used instead of >, because strlcat() returns the length of 'dest' and 'src' > excluding the trailing NULL. > > Fixes: 56463e50d1fc ("NFS: Use super.c for NFSROOT mount option parsing") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Minor typo in the body: >+ should be >=, otherwise looks right. Reviewed-by: Benjamin Coddington <bcodding@redhat.com> Ben
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index 7600100ba26f..432612d22437 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c @@ -175,10 +175,10 @@ static int __init root_nfs_cat(char *dest, const char *src, size_t len = strlen(dest); if (len && dest[len - 1] != ',') - if (strlcat(dest, ",", destlen) > destlen) + if (strlcat(dest, ",", destlen) >= destlen) return -1; - if (strlcat(dest, src, destlen) > destlen) + if (strlcat(dest, src, destlen) >= destlen) return -1; return 0; }