Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2622752pxj; Mon, 31 May 2021 06:47:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6A9WF9+zGJJ9HfjhiQvwT31PShECeCqb9ckU6P0pwQCo37CUGSDWRMWRfv8rD/M/QtZoU X-Received: by 2002:a17:906:560c:: with SMTP id f12mr760721ejq.503.1622468873962; Mon, 31 May 2021 06:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622468873; cv=none; d=google.com; s=arc-20160816; b=Y9YAcxPZKqyZsqBFv82leA2hc1y41z78FNrJjZWgbddCeuF2+w3OAs6+meNmmCKYuB D3+dsidObjvUsN+F974h7BnMFGVOWOid8LxPhof21tKLrvithyAbWlXFJKoiDCO0UgFG QwYYDpbzCYDZ3XnTmHkCsPvY23Fo53PiEgVIIdGtzyZR8ZEaJWvxK6YHKD36B61OqiYE U11UReybGuQfmbI/uhXwsj3BzRmVVAN2YgFkHx8poXWZSt0N124blGJuLc62FpKdQHPg tj0ksFdU5De5BMaSf+3lGmq3BUqHfxxRqNkHNvEygCcnHJxO3dxxZi+YPt5HkiAjM/Au lYCA== 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=4sz1x5KmZnXYSViAUtOu8JuMm4p9nKv97zzOOeuqQQY=; b=VxMhbOyqZo9ebJfQwOzCfQWbjYoCIkom+4wRzlsmvGlZXHj7ceysjnYgkjQ2CVQNyp 2oE+VelZ32S0eoMOFbhJj99JF+4mNP5eRm8cp/HxN0VZKubSKwFkMDjIlAAWzCCm+SkQ Waq+qyxmMVlGF/AvIqjzajJNHM3cTecM2nGtlQFvbKnY6G+7mcZgOMnaWX6q+CfQCUNF ByRJWE+otk1WJc2hZ+KprMGpHfgrgT0vKpwkGB2UNJ0VtAIwqdiUk6UUdlCKZJJvjPLh L52jKTQg36E6grW+HXy5Qa39oV16jdgshlmL5Np7Llg/SS2hVN4dvRf0QlXvjHjUL2am 4BDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Hi3gi/CL"; 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 b19si13162582edx.198.2021.05.31.06.47.31; Mon, 31 May 2021 06:47:53 -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="Hi3gi/CL"; 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 S232655AbhEaNr1 (ORCPT + 99 others); Mon, 31 May 2021 09:47:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:40216 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231690AbhEaNc3 (ORCPT ); Mon, 31 May 2021 09:32:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 14891613DD; Mon, 31 May 2021 13:23:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467435; bh=2uHQSuBtQrpPAeM3h7B7iaCFgz3x0WTe7FSIOTqt+Us=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hi3gi/CLQTteS2jrUvir9c5SpLqqsdudZHfjWMZsjeFyf0uEGbTrMFcGJtj9698Gs AiUKZB7HwhNcSeJPB0AZ2AwwVu7+MgkdkFFWC84VEmjtC47L5RwL9l4Cjln6U+aWG/ vYsanlkOid7nX94uG5QJjrnS55OZy4UQuVuNQmsI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Trond Myklebust Subject: [PATCH 4.19 063/116] NFS: fix an incorrect limit in filelayout_decode_layout() Date: Mon, 31 May 2021 15:13:59 +0200 Message-Id: <20210531130642.301511141@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130640.131924542@linuxfoundation.org> References: <20210531130640.131924542@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: Dan Carpenter commit 769b01ea68b6c49dc3cde6adf7e53927dacbd3a8 upstream. The "sizeof(struct nfs_fh)" is two bytes too large and could lead to memory corruption. It should be NFS_MAXFHSIZE because that's the size of the ->data[] buffer. I reversed the size of the arguments to put the variable on the left. Fixes: 16b374ca439f ("NFSv4.1: pnfs: filelayout: add driver's LAYOUTGET and GETDEVICEINFO infrastructure") Signed-off-by: Dan Carpenter Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- fs/nfs/filelayout/filelayout.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/nfs/filelayout/filelayout.c +++ b/fs/nfs/filelayout/filelayout.c @@ -717,7 +717,7 @@ filelayout_decode_layout(struct pnfs_lay if (unlikely(!p)) goto out_err; fl->fh_array[i]->size = be32_to_cpup(p++); - if (sizeof(struct nfs_fh) < fl->fh_array[i]->size) { + if (fl->fh_array[i]->size > NFS_MAXFHSIZE) { printk(KERN_ERR "NFS: Too big fh %d received %d\n", i, fl->fh_array[i]->size); goto out_err;