Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp460588pxj; Thu, 20 May 2021 13:29:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuYBS/mBRDy4/JAXXFfpvGuwN3vcgvm8/dr5qKGEwc7B4ltglDL2YKjzHR4BvrY4GIFa+f X-Received: by 2002:a92:520a:: with SMTP id g10mr7066214ilb.108.1621542565659; Thu, 20 May 2021 13:29:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621542565; cv=none; d=google.com; s=arc-20160816; b=spTNcwp0lcr73nkjA4uKgGbWeiRs1unmqc3fs3A80CqWFSaA3NO5RkOVUXbDfC0gvy 9eljbLgtyhbAa/dghwCqCMKlCcjNCdeMBWYaVT6PtPsF7KLdlspIzJc3/ldRe+2AcYUt 9nA48OTsTB4e/gvjm28qfWUXbOOwwLL9FzMhjP20l2nWUmqdTflRVvpHLCFKNAMOdkzR tiGbLh0C/ZbbgBlpoHL6eN4exZzEbTthFXN56eFPXBMFbwvpL6uSgYdiFdB+efkrJOvb i8IBxG56o9UlXuUJzQ7b41MAK3FqKAWGZU6cBg8UYHJAe2oqMjQnbRhNzjxQucqrmFT1 PJvA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LycuYShRTaeA60nspfbFRBb7PnR38K3UhpVtk+bht8w=; b=xUlYF28Ei37TavVEvzrDhvRI4bjWy4EX61TYtbx54+WgtzVJl7Ba93DHtWnTpklhRc hsUJjmDSefr0AwZzop3Y0uv0IQqL5TkotVuJGpN1EUITwClLT+y8imTVP6fYLAGkuP2Z 3PovFfO70ex/lh+XHsJYsIq74r5galC/PauiAlYLqttmxgT+11c8NUTLZBsUxgI6sTV7 LN0HODxnYIKcounVsRo/lG8gxn5nkAf0S30eMu6fPi88/AmMl64x7UxksSEkUHwRmqCg LjMUKXM4j6KHBZt1dt1xpFY1JZxdRMUGdrsydIOrPywKJRb9OrpX/m6KHS+94F/CaGN0 7DJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E+O4DOy0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d2si3033932ios.97.2021.05.20.13.29.12; Thu, 20 May 2021 13:29:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E+O4DOy0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239055AbhETKyZ (ORCPT + 99 others); Thu, 20 May 2021 06:54:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:39950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237413AbhETKiF (ORCPT ); Thu, 20 May 2021 06:38:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7A14D61C78; Thu, 20 May 2021 09:54:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504481; bh=mfU49GYTZqOw/I7JKuvZr88Pd7fKmif0/zfVAt6DikE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E+O4DOy0wIvynLraAetdkoKq/gbGdJ1FYFNGrRQsR2gY/2C4BRLs2W5SjFsHCVsZx Z2+OhSRscYEFL5vPRCqpdkk1M2nyqtBLPVA0EjJ8rfnLQt+B9kF21D4ap8nplVKwIj eUwVouv4EYWGpddJkp+WAnzhfBasb0csTCfv/p3g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikola Livic , Dan Carpenter , Trond Myklebust , Sasha Levin Subject: [PATCH 4.14 265/323] pNFS/flexfiles: fix incorrect size check in decode_nfs_fh() Date: Thu, 20 May 2021 11:22:37 +0200 Message-Id: <20210520092129.302664881@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikola Livic [ Upstream commit ed34695e15aba74f45247f1ee2cf7e09d449f925 ] We (adam zabrocki, alexander matrosov, alexander tereshkin, maksym bazalii) observed the check: if (fh->size > sizeof(struct nfs_fh)) should not use the size of the nfs_fh struct which includes an extra two bytes from the size field. struct nfs_fh { unsigned short size; unsigned char data[NFS_MAXFHSIZE]; } but should determine the size from data[NFS_MAXFHSIZE] so the memcpy will not write 2 bytes beyond destination. The proposed fix is to compare against the NFS_MAXFHSIZE directly, as is done elsewhere in fs code base. Fixes: d67ae825a59d ("pnfs/flexfiles: Add the FlexFile Layout Driver") Signed-off-by: Nikola Livic Signed-off-by: Dan Carpenter Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/flexfilelayout/flexfilelayout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index 74f15498c9bf..9d99e19d98bd 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c @@ -101,7 +101,7 @@ static int decode_nfs_fh(struct xdr_stream *xdr, struct nfs_fh *fh) if (unlikely(!p)) return -ENOBUFS; fh->size = be32_to_cpup(p++); - if (fh->size > sizeof(struct nfs_fh)) { + if (fh->size > NFS_MAXFHSIZE) { printk(KERN_ERR "NFS flexfiles: Too big fh received %d\n", fh->size); return -EOVERFLOW; -- 2.30.2