From nobody Mon Jan 01 19:00:06 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T3lfZ6m86z55Khq; Mon, 1 Jan 2024 19:00:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T3lfZ6Fz7z3VLH; Mon, 1 Jan 2024 19:00:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704135606; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oGJkxtyMnQhR6VImmG+gJMHNvKik9WmTI3PjYI9MXiE=; b=Ft21wGZLQ2B+hlg0Y/HTl2DWl8FyrR9GGCmPPWIu5Oo/lzHiPUwQa3xFAmTBRe0Y/S97OM qyKVrj5jeJ2Y728L/P9NIqjDQ6affCosNVnvQ9hz+oBpEbAky7kuqEGWHlnhVKRQSm3wsj /psu0xSQsnKQ31C4Or1th+2ljR/vCtnPCPtOGyAqAY9JWgNQABwl8nsUOYzyXwknd6/cXt 2HIm9JR2UH6xLCpw690r8livnFEcRlsbYB2Z8+l0b7t5kqMa1bElLrjsPbnP5SSv+f0z0l hrSYsPI4hnSw5B1vem0Dt8+jwDRqhm1Rfz4MiP8qJzemxWvDMzYAtqzZwoVLXQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704135606; a=rsa-sha256; cv=none; b=uzc+vZHIwEyvLIsTrS5XmP/SUGW3u1va7lN5zi8B4ofIFuboc3HmRXx3v9MJAnlZ60q7b9 lb0eEFweEJxZ7WaJX5srRccogVqlEIUc23ovTD9RxxEfKKRlfHo3Cxy+2I997/6f77Hbmv FVGEHkWtbWP1bxexrIeX2EwU2pF3ZZC2HoKyFnM4uP7i18PSK8GQ/3uhcVyT4SDk8M0Wcu wD94nvwoSxLBJh/vaFaSsq5BdWA9loVMf+24uG6yglwPSjMw+6nXJCKBCok+8zs+AeiOk5 //j0Lr/zgRSDxEkLZYWeHt+cJGQXlRZpxDoNL9A9ezA0JxpQXJ6f9ARIB5V8JA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704135606; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=oGJkxtyMnQhR6VImmG+gJMHNvKik9WmTI3PjYI9MXiE=; b=CQLjhDut3WRMKDeaiZRjAPL2axO6YZ01ZQnLweEy5JpjpLEqq3XBFRFMDVguu5Hkjb6Is1 75QiXHSpcOCp/kMX67bRWgkd/J03Ri+wEpoIwzZEY1GyvuIzLFUP/BfNhbmiIjp7ZXy0nM KpesqiqGK4Kvrhz4xqWKPCHLINZOv2Gb9FaKwv9hwPvSPmNAOuCBHUdzp4Tegf4v6rVboi KBx0qlR4kpwTiMfh6LZJAyLFXOBMeXeN39n95+ztl+sUnl2E20Okk+1195397mmhXsbb0x 8FFH+5JI7P5om0pA/tn/ARu3mkrteLfncAVhVNBUAKErDrovM/pcawrDQAaT3Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T3lfZ5JhGzTvv; Mon, 1 Jan 2024 19:00:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 401J06n3015961; Mon, 1 Jan 2024 19:00:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 401J065s015955; Mon, 1 Jan 2024 19:00:06 GMT (envelope-from git) Date: Mon, 1 Jan 2024 19:00:06 GMT Message-Id: <202401011900.401J065s015955@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 09af4bf2c987 - main - zfs: Fix SPA sysctl handlers List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 09af4bf2c987f6f57804162cef8aeee05575ad1d Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=09af4bf2c987f6f57804162cef8aeee05575ad1d commit 09af4bf2c987f6f57804162cef8aeee05575ad1d Author: Mark Johnston AuthorDate: 2024-01-01 18:54:15 +0000 Commit: Mark Johnston CommitDate: 2024-01-01 18:59:03 +0000 zfs: Fix SPA sysctl handlers sbuf_cpy() resets the sbuf state, which is wrong for sbufs allocated by sbuf_new_for_sysctl(). In particular, this code triggers an assertion failure in sbuf_clear(). Simplify by just using sysctl_handle_string() for both reading and setting the tunable. Apply to FreeBSD directly since this bug causes "sysctl -a" to crash the kernel. PR: 276039 Reported by: pho Reviewed by: mav Pull Request: https://github.com/openzfs/zfs/pull/15719 --- sys/contrib/openzfs/module/zfs/spa.c | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/sys/contrib/openzfs/module/zfs/spa.c b/sys/contrib/openzfs/module/zfs/spa.c index a21b0decf6a3..dc8a99e7bd25 100644 --- a/sys/contrib/openzfs/module/zfs/spa.c +++ b/sys/contrib/openzfs/module/zfs/spa.c @@ -1445,8 +1445,6 @@ spa_taskq_write_param_get(char *buf, zfs_kernel_param_t *kp) return (spa_taskq_param_get(ZIO_TYPE_WRITE, buf)); } #else -#include - /* * On FreeBSD load-time parameters can be set up before malloc() is available, * so we have to do all the parsing work on the stack. @@ -1457,19 +1455,11 @@ static int spa_taskq_read_param(ZFS_MODULE_PARAM_ARGS) { char buf[SPA_TASKQ_PARAM_MAX]; - int err = 0; - - if (req->newptr == NULL) { - int len = spa_taskq_param_get(ZIO_TYPE_READ, buf); - struct sbuf *s = sbuf_new_for_sysctl(NULL, NULL, len+1, req); - sbuf_cpy(s, buf); - err = sbuf_finish(s); - sbuf_delete(s); - return (err); - } + int err; + (void) spa_taskq_param_get(ZIO_TYPE_READ, buf); err = sysctl_handle_string(oidp, buf, sizeof (buf), req); - if (err) + if (err || req->newptr == NULL) return (err); return (spa_taskq_param_set(ZIO_TYPE_READ, buf)); } @@ -1478,19 +1468,11 @@ static int spa_taskq_write_param(ZFS_MODULE_PARAM_ARGS) { char buf[SPA_TASKQ_PARAM_MAX]; - int err = 0; - - if (req->newptr == NULL) { - int len = spa_taskq_param_get(ZIO_TYPE_WRITE, buf); - struct sbuf *s = sbuf_new_for_sysctl(NULL, NULL, len+1, req); - sbuf_cpy(s, buf); - err = sbuf_finish(s); - sbuf_delete(s); - return (err); - } + int err; + (void) spa_taskq_param_get(ZIO_TYPE_WRITE, buf); err = sysctl_handle_string(oidp, buf, sizeof (buf), req); - if (err) + if (err || req->newptr == NULL) return (err); return (spa_taskq_param_set(ZIO_TYPE_WRITE, buf)); }