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 349C64DB566; Thu, 2 Jul 2026 16:24:52 +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=1783009496; cv=none; b=Kj41BqGlKBN4RsyG1s2C2WBsQB8BwcECnM5Fro6eRzU1VXUOhXw+9rOo98okDcqn5grM6Qp/faZ/fF9IV92g3w04+DQbf9MMOPHlbvKStKO2oS7aVdpvSbcY51rEv8DwjeoEHp4SOw0bZSW6jAyLTLODcn8JHkroKzmUauFHMqY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783009496; c=relaxed/simple; bh=hIVeEKEZyXdDpX93Hikz+9p6/q4yldUmBWqQvwwAnxk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cv5zGKwJCvO5EOdYkmOZDzJya0cWpeE8CmZfBkNMV0bsmIiCoEMSLkXScnQCKK0ZSveikUByl/xfeQhDQZ7LmJ9FJV9dM3pR/yWOV5zN7Ufku26GrU9ecC8iux+9SPT9WaebRMzYzrG0vbh4ml6GBd9iwkZ6xH7EpAaG9kEiYfs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Z1b0OvVE; 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="Z1b0OvVE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98EDA1F000E9; Thu, 2 Jul 2026 16:24:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783009492; bh=wH8gv9PMgCjGqMgd3W6qVEzeEsijTHG3KOFLw/wNeEM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Z1b0OvVEgnkIGNwlHzMSR/58JM8YxmaFuoCQAVUP60mvqiAq9SxcGKMCx6Vz6ubRq 9e1NCD0zx2bN7mjySSaumX/5W0owpu8IQ6vLlWtwtTae5BKsJdwGrk3RqY322mFCx9 dJVUDyrxbEnbKBqmp11WgWrM3Gmjj+vBrzbBPGI8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wentao Liang , Anna Schumaker Subject: [PATCH 5.10 72/96] pNFS: Fix use-after-free in pnfs_update_layout() Date: Thu, 2 Jul 2026 18:20:04 +0200 Message-ID: <20260702155110.496559174@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155108.949633242@linuxfoundation.org> References: <20260702155108.949633242@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 5.10-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 @@ -2074,11 +2074,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,