From nobody Tue Jan 02 01:13:03 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 4T3vww2H9Sz5638x; Tue, 2 Jan 2024 01:13:04 +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 4T3vww187Yz3ZxD; Tue, 2 Jan 2024 01:13:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704157984; 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=xbgQ7zese76EkqrRjZqseIhTOwdEPmNcBMEyoZMtUUA=; b=n7n6Y3x6ZuKchnEOWmS0nyD2BMHGURQOdHgCZrLWpP5jPqLY4l9NqL2l7GtFei/MXEVIhz 0U1FPxfYcGd2oaBNrbGodO+OccrlFkEqJBKjcqwAQbMZzOKoBS4w2/x9p7qKlL9MiLgu+1 ku+wfjKh7qqAF2dGENb8ct/BB4jS3sdSoZnhL9py1hqJvO9RN0fdOvCTeIawcPnYdRHcri I6NN3SyNlj1xo9JXJ1R9DM4EwzEXvlAT9bxY2CgNWOL132eP0PJ4jwqXi7qpElWjJYZDjn 0MnuQn/iOKXwamovvNcHGjYE79heKJgiedzqCYrHqPBfSBnYnr/xHafjlco0Yw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704157984; a=rsa-sha256; cv=none; b=JU2VC9fPc501r7r3pTsS+xNV5PdocTJLo/l5uRM0kZFvYAKYqYhISf022eN0ZvItvgsbWM nfgUCJ90VLVHr77oiKbYLaBjFZ3PkBqDRHav7UYRcg0iNNyGNUm5NyzAgsEgC5z7Ans5rC uL5lzisep0e27+xFeYmliMJwYIQ3apuYoUyqM23tpmGNZe+Pt7m83nOsf/NAgA+QEbbcUM Wgxc1oykIeajX/10mfpkbi/FnyjZ0V+OahSnSq4vbsrkCnQsUqHhQfIFJbDlICWGyFZxnz YL4ln9Gc4XLzZFvHc3Y1Z+FOWa2PveXrIaJylzREETGSlRZTq63cKEl0hynOBA== 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=1704157984; 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=xbgQ7zese76EkqrRjZqseIhTOwdEPmNcBMEyoZMtUUA=; b=i6GbUIZ9B+FF/XzPZk7si4VREGvr5ERVSIeiMvpc7BpASQF11eu2V8kXfEEKFFBlCXx5/+ 1igt5lIRvxPXeMA9xO7WNDc6JlOPsRNhFz20PckNrUXQvlwZ9MCbXLYUO1r0edVZfoOdMp otZnroBVYo4JyWGldYaMSs/aeO288SN4BQciFRHxBzeikluXA/RJfDfZ8+mLFxnpFpQgHF qQfcjjSgWzZVns/ZgOh/i3hUG1Z0CRDjrBr8aoeiZXBWV8Lvh+pRcHNuLlC6a/0C5j1K9Z 84eC5l3GqqdBMCWREv+jYH8yGqfLhTvTzw2p0QRe7e0BN3HkMZyK3rYncluYHA== 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 4T3vwv75M8zgLm; Tue, 2 Jan 2024 01:13:03 +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 4021D3fF054986; Tue, 2 Jan 2024 01:13:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4021D3dP054983; Tue, 2 Jan 2024 01:13:03 GMT (envelope-from git) Date: Tue, 2 Jan 2024 01:13:03 GMT Message-Id: <202401020113.4021D3dP054983@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: 8276e3d3f8f3 - stable/13 - ses: Add error checking for copyout() calls 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 8276e3d3f8f3cb5ed5258ea39a9423bfb38e3bdb Auto-Submitted: auto-generated The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8276e3d3f8f3cb5ed5258ea39a9423bfb38e3bdb commit 8276e3d3f8f3cb5ed5258ea39a9423bfb38e3bdb Author: Mark Johnston AuthorDate: 2023-12-26 01:40:33 +0000 Commit: Mark Johnston CommitDate: 2024-01-02 01:12:45 +0000 ses: Add error checking for copyout() calls This is in preparation for annotating copyin() and related functions with __result_use_check. Reviewed by: mav, imp, asomers Tested by: asomers MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43130 (cherry picked from commit 771501e96ffd7e314c338300a351ad76d28a2f69) --- sys/cam/scsi/scsi_enc_ses.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sys/cam/scsi/scsi_enc_ses.c b/sys/cam/scsi/scsi_enc_ses.c index bc480dbb0fd7..df06a8a4c22e 100644 --- a/sys/cam/scsi/scsi_enc_ses.c +++ b/sys/cam/scsi/scsi_enc_ses.c @@ -2808,8 +2808,8 @@ ses_get_elm_desc(enc_softc_t *enc, encioc_elm_desc_t *elmd) } if (elmd->elm_desc_len > elmpriv->descr_len) elmd->elm_desc_len = elmpriv->descr_len; - copyout(elmpriv->descr, elmd->elm_desc_str, elmd->elm_desc_len); - return (0); + return (copyout(elmpriv->descr, elmd->elm_desc_str, + elmd->elm_desc_len)); } /** @@ -2825,7 +2825,7 @@ static int ses_get_elm_devnames(enc_softc_t *enc, encioc_elm_devnames_t *elmdn) { struct sbuf sb; - int len; + int error, len; len = elmdn->elm_names_size; if (len < 0) @@ -2837,10 +2837,13 @@ ses_get_elm_devnames(enc_softc_t *enc, encioc_elm_devnames_t *elmdn) ses_elmdevname_callback, &sb); sbuf_finish(&sb); elmdn->elm_names_len = sbuf_len(&sb); - copyout(sbuf_data(&sb), elmdn->elm_devnames, elmdn->elm_names_len + 1); + error = copyout(sbuf_data(&sb), elmdn->elm_devnames, + elmdn->elm_names_len + 1); sbuf_delete(&sb); cam_periph_lock(enc->periph); - return (elmdn->elm_names_len > 0 ? 0 : ENODEV); + if (error == 0 && elmdn->elm_names_len == 0) + error = ENODEV; + return (error); } /** @@ -2919,9 +2922,9 @@ ses_handle_string(enc_softc_t *enc, encioc_string_t *sstr, unsigned long ioc) size = rsize; if (size > sstr->bufsiz) size = sstr->bufsiz; - copyout(str, sstr->buf, size); + ret = copyout(str, sstr->buf, size); sstr->bufsiz = rsize; - return (size == rsize ? 0 : ENOMEM); + return (ret != 0 ? ret : (size == rsize ? 0 : ENOMEM)); case ENCIOC_GETENCID: if (ses_cache->ses_nsubencs < 1) return (ENODEV); @@ -2933,9 +2936,9 @@ ses_handle_string(enc_softc_t *enc, encioc_string_t *sstr, unsigned long ioc) size = rsize; if (size > sstr->bufsiz) size = sstr->bufsiz; - copyout(str, sstr->buf, size); + ret = copyout(str, sstr->buf, size); sstr->bufsiz = rsize; - return (size == rsize ? 0 : ENOMEM); + return (ret != 0 ? ret : (size == rsize ? 0 : ENOMEM)); default: return (EINVAL); }