From patchwork Tue Oct 24 21:47:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13435312 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BFF67C07545 for ; Tue, 24 Oct 2023 21:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234958AbjJXVz7 (ORCPT ); Tue, 24 Oct 2023 17:55:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230458AbjJXVz7 (ORCPT ); Tue, 24 Oct 2023 17:55:59 -0400 Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 79294E8 for ; Tue, 24 Oct 2023 14:55:57 -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 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 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 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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 Reviewed-by: Benjamin Coddington --- fs/nfs/nfsroot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; }