From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D8DE395AF6; Thu, 2 Jul 2026 16:51:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783011082; cv=none; b=ZZ6ql/S5HXkh22TdMENqXKu5kPF+dYAtdZp+HLfr8f31w/uOqERUHgQ74/NlWXZRxSlKG+AH0mottsdDmVjx0uAC/KMauCpABHLYksor0mUX6LcgYqGdBUElZa9egr/KVmuAWvxInOUxB36h6dxOCwx+CHzB8e/GP2k1YCJ79No= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783011082; c=relaxed/simple; bh=0y5ZQGunK913KSaZwTw33LRPfwod+CHv+YV8n4YaYX4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nsWaxao+WQN1aLXQV0UGuPNNjdSfaTk10t7TD20p8ExAp2Y56A1O4nCZN/mcS8hxIjIbm5Ce6L3h0zfggq2V44+6460Q0sjRZOOBU6cWaR/EbFmE0OwMJcDiQW0REIdFd00ZpczMHwO6sPTLhLBsbZvcblULRW2HKgCYtE0cQPg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=iMbQ+lrg; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="iMbQ+lrg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B49911F000E9; Thu, 2 Jul 2026 16:51:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783011081; bh=uU0TA50DKpwEWF9ylOlnJnUBWwJTv7NpxCfCTU1w3Sw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=iMbQ+lrgacc1rf1+d6iEdX/JihXjU72MRwWLdmUCj+X8Jgsr3LIB6LNfAQNCd0qcH DsD6sJp9vqfpOjyWmz/uOqWTh+1RAEchwv19mXXxnazIYVnNkTru0E6IQHMgGARgdw HJi1g3oOEvd9PS8qp0TaZffRdaiFTFln2LJl7dhY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wentao Liang , Anna Schumaker Subject: [PATCH 6.6 150/175] pNFS: Fix use-after-free in pnfs_update_layout() Date: Thu, 2 Jul 2026 18:20:51 +0200 Message-ID: <20260702155118.962412147@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155115.766838875@linuxfoundation.org> References: <20260702155115.766838875@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wentao Liang commit 13e198a90ca4050f4bee8a3f23680389a6563ccc upstream. When hitting the NFS_LAYOUT_RETURN branch in pnfs_update_layout(), the code calls pnfs_prepare_to_retry_layoutget(lo). If it succeeds, pnfs_put_layout_hdr(lo) is called before trace_pnfs_update_layout(), which still references 'lo'. This results in a use-after-free when the tracepoint accesses lo's fields. Fix this by moving the tracepoint call before pnfs_put_layout_hdr(lo). Fixes: 2c8d5fc37fe2 ("pNFS: Stricter ordering of layoutget and layoutreturn") Cc: stable@vger.kernel.org Signed-off-by: Wentao Liang Signed-off-by: Anna Schumaker Signed-off-by: Greg Kroah-Hartman --- fs/nfs/pnfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -2094,11 +2094,11 @@ lookup_again: dprintk("%s wait for layoutreturn\n", __func__); lseg = ERR_PTR(pnfs_prepare_to_retry_layoutget(lo)); if (!IS_ERR(lseg)) { - pnfs_put_layout_hdr(lo); dprintk("%s retrying\n", __func__); trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, PNFS_UPDATE_LAYOUT_RETRY); + pnfs_put_layout_hdr(lo); goto lookup_again; } trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg,