From nobody Wed Apr 06 02:45:17 2022 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 375B01A806FF; Wed, 6 Apr 2022 02:45:18 +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 4KY84s75KHz4ZdD; Wed, 6 Apr 2022 02:45:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649213118; 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=un6ceLUpJIjl46Kdi0TvzWZdNkke5vnnCACeRvF/A8o=; b=CEDj/55BHJOpx7K0CftkUMgy3D5RFSCopAn1rqbt3AYqxQdXLETO9JgdvrHSi2TvTSojxh T6MgslQgRhxoOPoi1GGpcBy41oRNrgK8obFju0ubATscnb8zInvBBtZV5YA8uVOKbaQb2F bNL9togtJSZGqZeFWT6WnuTkInhe1XR5ppIE2TWPs9yHkfbhS3TmeUHqaA3lNqJ+JVv5Jh U9i3Xj3F6Y0eYCK+RlUAidd8XSXUHOjJVI8o7OJnGQEyTW5sbQvJQEPueKRoJDxMlmSGyh jOBcOCzdq6aUBn8ALITnTte/U8TSME+a4QnGis9HpcO8WdOKpJ4zduJ1ZovdZQ== 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 D347912861; Wed, 6 Apr 2022 02:45:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2362jH0j006440; Wed, 6 Apr 2022 02:45:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2362jHAQ006439; Wed, 6 Apr 2022 02:45:17 GMT (envelope-from git) Date: Wed, 6 Apr 2022 02:45:17 GMT Message-Id: <202204060245.2362jHAQ006439@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: be6abdb25956 - stable/13 - GEOM: Skip copyin() for GCTL_PARAM_WR parameters. 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: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: be6abdb259564d9a8d3d91d486b7ed2331c3bec4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1649213118; 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=un6ceLUpJIjl46Kdi0TvzWZdNkke5vnnCACeRvF/A8o=; b=Hct7anQw8JeAW2Q3jHMJ7UFLbBjI/BYjWaRElgpgQVvRjKVzCtJZzOiAaTKWk3VADIQYGc eUWqn4WTsAt6DOGunPU9wmXCC9BL6/5Ef7o00hCdhiFccCOIxa6xfm96CSjSsiQWN6avKL iOfH9sINjcsA+rzJlzGwjFH2gKzpjZsFBcSTRj0+WnoxbZtVH1e1rkXeuybfKMIuIPIzX/ xF5fJG6Y7wEbsIDxOwfL3WQjK+e4SDwndHS95ZgDLgo/SrlyUE4vtQKNIcS/NLmhlsKyXk 77h6WchhgpmmYr56UovLaWziHN8dIsDNrcTPUFca/Elj46tL2lXHtPC6xdrcdw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1649213118; a=rsa-sha256; cv=none; b=EUl3dehJ6Jr+xtRlLOrRT9Ahd0gYN6aXaqPXPLtQegu4XbbqkfzzEcbBAd8CgnHxqf9UMY XOvYNiyKP/gJZjs87KZkTbhink/GJAwJOzwyvBINROGtEOmYMSLgQj6N697Qag8K53ew5P jKKjZ9bBXEbEMjy1HXbfYlqXNAg2pLHd0a1CqpZOyi4SrqLws3OMt3vXXscyC37d3aWX+Y 89dUZhH/sKgDzToMkDp03BiYMT8CihwC0BqjovuEmR30StiFytEWZ8jU44V1z3p2NBBkkJ M6gkQhlrcPMPJ9ijMowbPHCi0oZyPsaKn6IIzzxnXOZDQbCJqIccf8GD8Y7Tkw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=be6abdb259564d9a8d3d91d486b7ed2331c3bec4 commit be6abdb259564d9a8d3d91d486b7ed2331c3bec4 Author: Alexander Motin AuthorDate: 2022-03-07 15:57:56 +0000 Commit: Alexander Motin CommitDate: 2022-04-06 02:07:39 +0000 GEOM: Skip copyin() for GCTL_PARAM_WR parameters. Kernel does not read those parameters, so copyin is pointless. While there, replace some KASSERT()s with CTASSERT()s. MFC after: 1 month (cherry picked from commit 01b9c48b5dec8d4a1161e0592f04b3301c81a1f8) --- sys/geom/geom_ctl.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c index b0e2673bdc42..5690b857a639 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -63,16 +63,15 @@ static struct cdevsw g_ctl_cdevsw = { .d_name = "g_ctl", }; +CTASSERT(GCTL_PARAM_RD == VM_PROT_READ); +CTASSERT(GCTL_PARAM_WR == VM_PROT_WRITE); + void g_ctl_init(void) { make_dev_credf(MAKEDEV_ETERNAL, &g_ctl_cdevsw, 0, NULL, UID_ROOT, GID_OPERATOR, 0640, PATH_GEOM_CTL); - KASSERT(GCTL_PARAM_RD == VM_PROT_READ, - ("GCTL_PARAM_RD != VM_PROT_READ")); - KASSERT(GCTL_PARAM_WR == VM_PROT_WRITE, - ("GCTL_PARAM_WR != VM_PROT_WRITE")); } /* @@ -169,14 +168,18 @@ gctl_copyin(struct gctl_req *req) gctl_error(req, "negative param length"); break; } - p = geom_alloc_copyin(req, ap[i].value, ap[i].len); - if (p == NULL) - break; - if ((ap[i].flag & GCTL_PARAM_ASCII) && - p[ap[i].len - 1] != '\0') { - gctl_error(req, "unterminated param value"); - g_free(p); - break; + if (ap[i].flag & GCTL_PARAM_RD) { + p = geom_alloc_copyin(req, ap[i].value, ap[i].len); + if (p == NULL) + break; + if ((ap[i].flag & GCTL_PARAM_ASCII) && + p[ap[i].len - 1] != '\0') { + gctl_error(req, "unterminated param value"); + g_free(p); + break; + } + } else { + p = g_malloc(ap[i].len, M_WAITOK | M_ZERO); } ap[i].kvalue = p; ap[i].flag |= GCTL_PARAM_VALUEKERNEL;