From nobody Tue Jan 02 01:13:13 2024 X-Original-To: dev-commits-src-branches@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 4T3vx53dVMz5635N; Tue, 2 Jan 2024 01:13:13 +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 4T3vx526mrz3b9J; Tue, 2 Jan 2024 01:13:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704157993; 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=7H319WPR5U1umV1A6fexL4bmslnw5DqEAJQFqfiEFHw=; b=nfR2kcLM4W+BRuASDU4DiuvdVsEQE8aV09RCyD5O8uFQaHCqWVII0/j66Zr+s8ximW5VQ/ HSs/R1IX6BZUNFzBuoRHg3qMDF+bv+270o+/jK2NI2J0Pau7vfvE2ThJf7GegmK+da1T+1 P/T6dTBs6vGMxG9L6JQck+LcDdHX9xuxqVgjqjaCfx3d3SucGaRvordLlof+l+wisK0XWx 7SXGY1G1jQlpE/y/GJ3jOxAwhMltPCDd/DYm9kjFz4wQEY2Jhp8r6BFamxoWibG8habGBl YeoZMhJlYkPxmcHCtEs2aVjqfzcuwpx0J9oO4S6goCjCNia+BXsB+6S7ulN6xA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704157993; a=rsa-sha256; cv=none; b=je7UvvOj+Kw3ZS/tvhRQPyayPfLJlqgYUz8KKNyV156k/4e9Ew0t/q+9t5Tzm06D3VKhGj aPhru74gI6GkeEjYjK+8wuijLrCx3awQUN6mbvQZTO6yG0SaZcByaCgecLU+rjqh4E4E+V OsPzApzmjyNrtSd++YSzFF/KV+Ny8HTnMPVgjPLUGKVBOyVOiR6gLM+rSLtZa25aEv+v1a 5qqp6G2qq5hIH0M54w6mj7mwfMyFcypdxewqFV0bVh6pGzE4vyLoZiyZRJUXtHynbDK8dP YyTusNBGlrUC42CAlo7yFFz1EVhYoAYQuF3E0J+6C4IigMtKxmz57GLC15vvoQ== 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=1704157993; 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=7H319WPR5U1umV1A6fexL4bmslnw5DqEAJQFqfiEFHw=; b=HHPeqPTR88Sh3XxSoPWXJUwPplqdN0f99MNzKri6rueo9Ns1I6R2vAnkJqn653wcjuscn+ 1wxGfeDg7Re4iwUsJ6BYoz56njrnlDcgoHiwpaXt5MwP6JylPfbPtuCfKTMhW/9d2B28kA tWJlVGWoTMmDd4U4INh+1tq33IwHak1c0v8ZR0BBmdiT80Bk5Z43xEdVO06wn+rUwsaWJ/ OX3CbuqFk3EC4K5dznti8rk+ZmTcUPGABXEZLDrABjMI/jp/77e/UwV1wIilC4facDnHh6 SXOPu1WtovZIiwsU0H0BKaoCKBXktWj+wwYHFcIoSAXOuRa+NVk44PeDMcy7GA== 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 4T3vx510bkzgc3; Tue, 2 Jan 2024 01:13:13 +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 4021DDKE055383; Tue, 2 Jan 2024 01:13:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4021DDGc055380; Tue, 2 Jan 2024 01:13:13 GMT (envelope-from git) Date: Tue, 2 Jan 2024 01:13:13 GMT Message-Id: <202401020113.4021DDGc055380@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: bd8a789e3c28 - stable/13 - geom: Report copyout() errors in g_ctl_ioctl_ctl() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: bd8a789e3c28e4f2debf0c511c89fadbc29a34f9 Auto-Submitted: auto-generated The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=bd8a789e3c28e4f2debf0c511c89fadbc29a34f9 commit bd8a789e3c28e4f2debf0c511c89fadbc29a34f9 Author: Mark Johnston AuthorDate: 2023-12-26 01:43:06 +0000 Commit: Mark Johnston CommitDate: 2024-01-02 01:12:45 +0000 geom: Report copyout() errors in g_ctl_ioctl_ctl() Despite the name, req->serror is used in some cases to copy non-error messages to userspace. So, report errors when copying out so long as they don't clobber an earlier error. Reviewed by: mav, imp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43146 (cherry picked from commit bbf221e3e822d15dafb37bd8e200a9864f2636b4) --- sys/geom/geom_ctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c index 33ec28dcd371..bf029e749102 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -556,8 +556,10 @@ g_ctl_ioctl_ctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, struct th } } if (sbuf_done(req->serror)) { - copyout(sbuf_data(req->serror), req->error, + nerror = copyout(sbuf_data(req->serror), req->error, imin(req->lerror, sbuf_len(req->serror) + 1)); + if (nerror != 0 && req->nerror == 0) + req->nerror = nerror; } nerror = req->nerror;