From 8c0b16e6e9c33507a0674fada782046e895b06d7 Mon Sep 17 00:00:00 2001 From: Pavel Snajdr Date: Mon, 7 Sep 2020 17:12:17 +0200 Subject: [PATCH] Fix stack frame size: dmu_redact_snap() Reviewed-by: Ryan Moeller Reviewed-by: Brian Behlendorf Signed-off-by: Pavel Snajdr Closes #10879 --- module/zfs/dmu_redact.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/module/zfs/dmu_redact.c b/module/zfs/dmu_redact.c index 1c5f1bd248..b091df9257 100644 --- a/module/zfs/dmu_redact.c +++ b/module/zfs/dmu_redact.c @@ -1006,10 +1006,14 @@ dmu_redact_snap(const char *snapname, nvlist_t *redactnvl, objset_t *os; struct redact_thread_arg *args = NULL; redaction_list_t *new_rl = NULL; + char *newredactbook; if ((err = dsl_pool_hold(snapname, FTAG, &dp)) != 0) return (err); + newredactbook = kmem_zalloc(sizeof (char) * ZFS_MAX_DATASET_NAME_LEN, + KM_SLEEP); + if ((err = dsl_dataset_hold_flags(dp, snapname, DS_HOLD_FLAG_DECRYPT, FTAG, &ds)) != 0) { goto out; @@ -1063,7 +1067,6 @@ dmu_redact_snap(const char *snapname, nvlist_t *redactnvl, goto out; boolean_t resuming = B_FALSE; - char newredactbook[ZFS_MAX_DATASET_NAME_LEN]; zfs_bookmark_phys_t bookmark; (void) strlcpy(newredactbook, snapname, ZFS_MAX_DATASET_NAME_LEN); @@ -1073,6 +1076,8 @@ dmu_redact_snap(const char *snapname, nvlist_t *redactnvl, "#%s", redactbook); if (n >= ZFS_MAX_DATASET_NAME_LEN - (c - newredactbook)) { dsl_pool_rele(dp, FTAG); + kmem_free(newredactbook, + sizeof (char) * ZFS_MAX_DATASET_NAME_LEN); return (SET_ERROR(ENAMETOOLONG)); } err = dsl_bookmark_lookup(dp, newredactbook, NULL, &bookmark); @@ -1145,16 +1150,23 @@ dmu_redact_snap(const char *snapname, nvlist_t *redactnvl, (void) thread_create(NULL, 0, redact_traverse_thread, rta, 0, curproc, TS_RUN, minclsyspri); } - struct redact_merge_thread_arg rmta = { { {0} } }; - (void) bqueue_init(&rmta.q, zfs_redact_queue_ff, + + struct redact_merge_thread_arg *rmta; + rmta = kmem_zalloc(sizeof (struct redact_merge_thread_arg), KM_SLEEP); + + (void) bqueue_init(&rmta->q, zfs_redact_queue_ff, zfs_redact_queue_length, offsetof(struct redact_record, ln)); - rmta.numsnaps = numsnaps; - rmta.spa = os->os_spa; - rmta.thr_args = args; - (void) thread_create(NULL, 0, redact_merge_thread, &rmta, 0, curproc, + rmta->numsnaps = numsnaps; + rmta->spa = os->os_spa; + rmta->thr_args = args; + (void) thread_create(NULL, 0, redact_merge_thread, rmta, 0, curproc, TS_RUN, minclsyspri); - err = perform_redaction(os, new_rl, &rmta); + err = perform_redaction(os, new_rl, rmta); + kmem_free(rmta, sizeof (struct redact_merge_thread_arg)); + out: + kmem_free(newredactbook, sizeof (char) * ZFS_MAX_DATASET_NAME_LEN); + if (new_rl != NULL) { dsl_redaction_list_long_rele(new_rl, FTAG); dsl_redaction_list_rele(new_rl, FTAG);