From 4885b7272a01672bdba46e9e778c345af053e539 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Thu, 3 Oct 2013 14:35:00 -0500 Subject: [PATCH] LU-4056 hsm: reorder MDT proc cleanup In mdt_procfs_init() remove the call to ptlrpc_lprocfs_register_obd(). The single file that this provides (../mdt/*/stats) is backed by the MDT OBD's obd_svc_stats which are not tallied. In mdt_procfs_fini() remove the corresponding call to ptlrpc_lprocfs_unregister_obd() and move the call to hsm_cdt_procfs_fini() to before lprocfs_obd_cleanup(). This prevents a use after free of the entries in the MDT's hsm subdirectory. Signed-off-by: John L. Hammond Change-Id: Iad6e7738047377660f0077c9368f79d96f903d02 Reviewed-on: http://review.whamcloud.com/7846 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Faccini Bruno Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_lproc.c | 8 ++++---- lustre/tests/sanity-sec.sh | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 6953802..4bdf984 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -229,13 +229,13 @@ int mdt_procfs_init(struct mdt_device *mdt, const char *name) mdt_obd_name(mdt), rc); return rc; } + rc = hsm_cdt_procfs_init(mdt); if (rc) { CERROR("%s: cannot create hsm proc entries: rc = %d\n", mdt_obd_name(mdt), rc); return rc; } - ptlrpc_lprocfs_register_obd(obd); obd->obd_proc_exports_entry = proc_mkdir("exports", obd->obd_proc_entry); @@ -263,14 +263,14 @@ void mdt_procfs_fini(struct mdt_device *mdt) { struct obd_device *obd = mdt2obd_dev(mdt); - if (obd->obd_proc_exports_entry) { + if (obd->obd_proc_exports_entry != NULL) { lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry); obd->obd_proc_exports_entry = NULL; } + lprocfs_free_per_client_stats(obd); - lprocfs_obd_cleanup(obd); hsm_cdt_procfs_fini(mdt); - ptlrpc_lprocfs_unregister_obd(obd); + lprocfs_obd_cleanup(obd); lprocfs_free_md_stats(obd); lprocfs_free_obd_stats(obd); lprocfs_job_stats_fini(obd); diff --git a/lustre/tests/sanity-sec.sh b/lustre/tests/sanity-sec.sh index 70e1114..03ac2cc 100644 --- a/lustre/tests/sanity-sec.sh +++ b/lustre/tests/sanity-sec.sh @@ -74,7 +74,8 @@ else echo "without GSS support" fi -MDT="`do_facet $SINGLEMDS "lctl get_param -N mdt.\*MDT\*.stats 2>/dev/null | cut -d"." -f2" || true`" +MDT=$(do_facet $SINGLEMDS lctl get_param -N "mdt.\*MDT0000" | + cut -d. -f2 || true) [ -z "$MDT" ] && error "fail to get MDT device" && exit 1 do_facet $SINGLEMDS "mkdir -p $CONFDIR" IDENTITY_FLUSH=mdt.$MDT.identity_flush -- 1.8.3.1