Skip to contentSkip to conversation

Fix 2 more flexfiles issues

PATCH New Trond Myklebust 1 participant 3 messages Dec 7, 2016

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/2 pNFS/flexfiles: Fix ff_layout_add_ds_error_locked()

In reply to Trond Myklebust

When we're merging an old entry into our new entry, we want to ensure that we add the list entry in the correct place.

---
 fs/nfs/flexfilelayout/flexfilelayoutdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfs/flexfilelayout/flexfilelayoutdev.c +2 -1
index eb98395c3651..142bfd0b1663 100644
@@ -254,8 +254,9 @@ ff_layout_add_ds_error_locked(struct nfs4_flexfile_layout *flo,
 		}
 		/* Entries match, so merge "err" into "dserr" */
 		extend_ds_error(dserr, err->offset, err->length);
-		list_del(&err->list);
+		list_replace(&err->list, &dserr->list);
 		kfree(err);
+		return;
 	}
 
 	list_add_tail(&dserr->list, head);
Signature · 1 line
2.9.3
#2 lore raw

PATCH 2/2 pNFS: Layoutreturn must free the layout after the layout-private data

The layout-private data may depend on the layout and/or the inode still existing when it does post-processing and frees its data, so we need to free them after calling lrp->ld_private.ops->free().

This fixes a mirror list corruption issue in the flexfiles driver.

---
 fs/nfs/nfs4proc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4proc.c +2 -2
index d3431ff32662..c5a508669655 100644
@@ -8641,10 +8641,10 @@ static void nfs4_layoutreturn_release(void *calldata)
 	pnfs_layoutreturn_free_lsegs(lo, &lrp->args.stateid, &lrp->args.range,
 			lrp->res.lrs_present ? &lrp->res.stateid : NULL);
 	nfs4_sequence_free_slot(&lrp->res.seq_res);
-	pnfs_put_layout_hdr(lrp->args.layout);
-	nfs_iput_and_deactive(lrp->inode);
 	if (lrp->ld_private.ops && lrp->ld_private.ops->free)
 		lrp->ld_private.ops->free(&lrp->ld_private);
+	pnfs_put_layout_hdr(lrp->args.layout);
+	nfs_iput_and_deactive(lrp->inode);
 	kfree(calldata);
 	dprintk("<-- %s\n", __func__);
 }
Signature · 1 line
2.9.3
#0 lore raw

cover Fix 2 more flexfiles issues

Fix a use-after-free case and a list ordering issue.

Trond Myklebust (2):
pNFS/flexfiles: Fix ff_layout_add_ds_error_locked()
pNFS: Layoutreturn must free the layout after the layout-private data

 fs/nfs/flexfilelayout/flexfilelayoutdev.c | 3 ++-
 fs/nfs/nfs4proc.c                         | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.9.3