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 8154333E348; Thu, 2 Jul 2026 16:34:24 +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=1783010065; cv=none; b=PM1xqfklSUp47j4ZROKlYKaG6SKBocp+xKuPcyvEUHLdkDe+P9HlL8Z8JejEHwcwymU/g2n8O2otD7/EBW/Pes/ozBLTKu8/tHWUfzqeybPpSL3qklXs0hoXeS63I1/eVXIQ7kHiXl/sRfNE905/YL16c+ZCoyOhF5EiyjixvBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783010065; c=relaxed/simple; bh=AC6WsFRmG0KCbaHiHHCpsxsRHSJ76uWOy5i3Ir3U/B0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CLGZ+y/UEmKX2W0t4HK3vab0/I0SaMiMxJyLXTVigikWk+sjbbMi6rts4Mhnx7qFwLBpEYyILzpnuXcc1/q3I/gEVYFujTgwNvGC9Ypnz2QuZP/G/awRPKrIOb7ufEhufwhe8rW3LsC+URRfbbJ5t2zhkg1ee1134ypGLGWcIsY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fEsYaWeJ; 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="fEsYaWeJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E720C1F00A3A; Thu, 2 Jul 2026 16:34:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783010064; bh=P5M3i3mc1e97uh1A7FEgoQ0aVNaMMt5+l+/pu9B7MnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fEsYaWeJMSRDkqDi3o9ORnbpgZSxcwijFUeShcZlzsUV2cbuxL0QkEzElA/B0zU4s 7psWu4NwOiR8EV0D4+0TwqT22tlBZ884U25+ArBJyPckAt1tWwLzPBYLBRF2L91uGn /wD7zaMRlWmXJKwuiQsTK7M+of2+z7JGvNPTfRJM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wentao Liang , Anna Schumaker Subject: [PATCH 6.1 096/129] pNFS: Fix use-after-free in pnfs_update_layout() Date: Thu, 2 Jul 2026 18:20:15 +0200 Message-ID: <20260702155114.128996129@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155112.163984240@linuxfoundation.org> References: <20260702155112.163984240@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.1-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 @@ -2070,11 +2070,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,