Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2686986pxj; Mon, 31 May 2021 08:15:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjS37CPSRw0z2WmRXJrEU8POlf5J3/0AXX+creiR5ER+3z7D7u4zENSrouHjlLrPvhw7qH X-Received: by 2002:a02:b084:: with SMTP id v4mr8705482jah.130.1622474138229; Mon, 31 May 2021 08:15:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622474138; cv=none; d=google.com; s=arc-20160816; b=c7IhNgqeGB1xs9JsiJvrkY7253bhS+x0+dUj5hXM/rF7DpWdVVFrNmWv/ce/5Xu/Bp frGu8jRJvFQB+wZC6FgPxB5fZResTX669wAcG02x7irCQ45mqOdKxf9qeexJO4C1ShyB IqGXcSEsh3+sJv+jurS07Q+RPYs3hDbDkAsr4OGpsTdXDsO/9E4/KOvd6qh2J+H2k6EH N7dcfLEmAQbhz9d6lJzvIi/x7snwDQbal40Kwe157pYFhIWRK2AGnsW7XCypW1QYU1+W XJ47ifQbwrCt7iNk84UmjPARDYGQ+Ln244akcjz/NxBQEvxd+WkkOp+mFcCX8x1l2KOL h83Q== 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=pMptgVWWhSoJUDRw1lBvD77jTFUzNMQbMZYBox6TuvE=; b=dxL3+of45DIxbFLYnBEQ4izq9Q8qILvO9lZtwOoFkJJ79Zyenz/SKSo2PLLIk0E2Dj g/3fuic8jbFXtOZWTHmFmmBl+DN01yRiq1i9coBlrV/0Jnx8pqXbEM6zHLVfpnZBimtB Vg346+olbl/yt+sL9CqomihYEKvhy+5c16cCr/qEhdkrP+vMDcEwKnr7ztpn+6tQ7iJm GCSSx5P4/1tyySp1KhRY2lqYEfRTp0wGDAjBEYrjyvCQxwUTEKxIsK9SPfWLmLGEiRtR QmD+KNuBXh4JKDOCZns1YA1GyyUAp9F1NBFoU9qOgmkSbekNKoWGftCFJ3QGPKGXToPx r2uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Lmv2Pylx; 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 c1si385094ilm.49.2021.05.31.08.15.23; Mon, 31 May 2021 08:15:38 -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=Lmv2Pylx; 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 S233238AbhEaPPW (ORCPT + 99 others); Mon, 31 May 2021 11:15:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:40810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233249AbhEaOMm (ORCPT ); Mon, 31 May 2021 10:12:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0C928613CB; Mon, 31 May 2021 13:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468500; bh=/SOqs7tI79XyTZ4L9Qld6vWOfhdLjxec5g19gpzLVY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lmv2PylxPp93yHO4pMXcyq7Tx9rPUrWe33ZrlxtzsoJEQDb1I0HSj+fXHua+loYTD zIs8CCoyFHjWEN/YGJzAa1k2n6JUFhSlSMyNWSazUF4GMhNQzmsLn/olyeWdqWqJm3 MKawHkRQ4wRUg+0A/hrd0mt5aerw1ro4VJ8DRgjE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anna Schumaker , Trond Myklebust Subject: [PATCH 5.4 005/177] NFSv4: Fix a NULL pointer dereference in pnfs_mark_matching_lsegs_return() Date: Mon, 31 May 2021 15:12:42 +0200 Message-Id: <20210531130648.085132103@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@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: Anna Schumaker commit a421d218603ffa822a0b8045055c03eae394a7eb upstream. Commit de144ff4234f changes _pnfs_return_layout() to call pnfs_mark_matching_lsegs_return() passing NULL as the struct pnfs_layout_range argument. Unfortunately, pnfs_mark_matching_lsegs_return() doesn't check if we have a value here before dereferencing it, causing an oops. I'm able to hit this crash consistently when running connectathon basic tests on NFS v4.1/v4.2 against Ontap. Fixes: de144ff4234f ("NFSv4: Don't discard segments marked for return in _pnfs_return_layout()") Cc: stable@vger.kernel.org Signed-off-by: Anna Schumaker Signed-off-by: Trond Myklebust Signed-off-by: Greg Kroah-Hartman --- fs/nfs/pnfs.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1285,6 +1285,11 @@ _pnfs_return_layout(struct inode *ino) { struct pnfs_layout_hdr *lo = NULL; struct nfs_inode *nfsi = NFS_I(ino); + struct pnfs_layout_range range = { + .iomode = IOMODE_ANY, + .offset = 0, + .length = NFS4_MAX_UINT64, + }; LIST_HEAD(tmp_list); nfs4_stateid stateid; int status = 0; @@ -1311,16 +1316,10 @@ _pnfs_return_layout(struct inode *ino) } valid_layout = pnfs_layout_is_valid(lo); pnfs_clear_layoutcommit(ino, &tmp_list); - pnfs_mark_matching_lsegs_return(lo, &tmp_list, NULL, 0); + pnfs_mark_matching_lsegs_return(lo, &tmp_list, &range, 0); - if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) { - struct pnfs_layout_range range = { - .iomode = IOMODE_ANY, - .offset = 0, - .length = NFS4_MAX_UINT64, - }; + if (NFS_SERVER(ino)->pnfs_curr_ld->return_range) NFS_SERVER(ino)->pnfs_curr_ld->return_range(lo, &range); - } /* Don't send a LAYOUTRETURN if list was initially empty */ if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags) ||