Skip to content

Commit 200e763

Browse files
ISCAS-Vulabgregkh
authored andcommitted
pNFS: Fix use-after-free in pnfs_update_layout()
commit 13e198a 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: 2c8d5fc ("pNFS: Stricter ordering of layoutget and layoutreturn") Cc: stable@vger.kernel.org Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 90e254f commit 200e763

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/nfs/pnfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2217,11 +2217,11 @@ pnfs_update_layout(struct inode *ino,
22172217
dprintk("%s wait for layoutreturn\n", __func__);
22182218
lseg = ERR_PTR(pnfs_prepare_to_retry_layoutget(lo));
22192219
if (!IS_ERR(lseg)) {
2220-
pnfs_put_layout_hdr(lo);
22212220
dprintk("%s retrying\n", __func__);
22222221
trace_pnfs_update_layout(ino, pos, count, iomode, lo,
22232222
lseg,
22242223
PNFS_UPDATE_LAYOUT_RETRY);
2224+
pnfs_put_layout_hdr(lo);
22252225
goto lookup_again;
22262226
}
22272227
trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg,

0 commit comments

Comments
 (0)