From nobody Fri Jul 15 16:34:03 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 4Lkxkz5N9Hz4T4kr; Fri, 15 Jul 2022 16:34:03 +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 4Lkxkz4mpzz3GtL; Fri, 15 Jul 2022 16:34:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657902843; 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=Yf4XIL4H4Ao16XAHa7ELK5w90+MpDvUESITltLwma9E=; b=qIrcUqIw48Ev0yOoGsSL7OGNUxcXCQ4YLvYfKRvPsio4S1cEzZF2TKtqyBHbg5QsSOpNGP 0Ou0pfpnVMCwIW4avuw7KegKhspc1zQz474cuSeS+J1pFN/0CbXDP8S+02xaxdvtXX0d8Z YpYs0rclN/ExvhvzXvb94IjWAafgi4v9C5s6jNPHpydXIN6i569+oY2/llozQUQohnfdS6 tLs6Dt7uOQjbQ372W9Sask7fp7LCiJwhizSzvUO+7Y1pbqG845uGuh/MsFlMcIpFsfKIVG UEAzHNcHQMdMrTYX/gfGmhdC0Mlfbxoi390qh+QKsOG+rFP4AcapLaqzOTn+gQ== 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 4Lkxkz3tKpzpj6; Fri, 15 Jul 2022 16:34:03 +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 26FGY3pR038132; Fri, 15 Jul 2022 16:34:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26FGY3GH038131; Fri, 15 Jul 2022 16:34:03 GMT (envelope-from git) Date: Fri, 15 Jul 2022 16:34:03 GMT Message-Id: <202207151634.26FGY3GH038131@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: 8191ad0c0302 - stable/13 - crypto: Validate return values from CRYPTODEV_PROCESS() 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: 8191ad0c03023872a59354a8c542453273a06da8 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657902843; 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=Yf4XIL4H4Ao16XAHa7ELK5w90+MpDvUESITltLwma9E=; b=ULg/LwLyFKUobiVLbIEtG00Zobt4XbxlWfpK/hGo29j6nTCXh+sALlGpzw1VuqG9umQfDm jozcesjvWqD+YQtuXeHXNQ03QxdXes1H7d0f7s3Cg5InBvS6SsT90hwb7mTkZiI5PbmRrx JkMn3PyQjUcT4/qJ1t5GTdBEEZCHllqyrlInAPT/pyjvaed5WWyEg5dEvranTqaNV0p+5P 7kQmqxkFduovAAx8sRe1PIdl6DtZOs+gNT4FyyrhezDQ0py85pQGybErfoAcyGSEwzSJWt FqlB/kkMwFn+jqwtFy67oALuRAC1KzF301VOYg9356+wTvHA5ytTjwXatU67XQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657902843; a=rsa-sha256; cv=none; b=rOu7vzq+GGKMdVWjXoN2waDOHV5jeOq3ALD7aei4om+vFb2HjLPjJwMw3eP/1kiwkid8NG Td/d294oDclmOhc0uyuyoLaN3yWiYfavXgrHPYI0ljy+d/v1cmawgX9Y6R3fp/wZAyyez8 MDC19opNtzaTDH1gA4/86wvrYI+SEFLRYaEMayLXqFbE5MGCMW0M6Nchxb0nLchdzTAunS izvGUPLUDm7To1T+F/J/chrLCjYO3O03Q+05dMV4R1Nafg25Pu04ypZBF2K7KtgL7NE82L eAda/q12/oRDRTuyIwTMnLPZUwlJsmXAuXiq3Gn2+vgMYwlU1RI8Ru9PBpftjg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8191ad0c03023872a59354a8c542453273a06da8 commit 8191ad0c03023872a59354a8c542453273a06da8 Author: Mark Johnston AuthorDate: 2022-07-01 15:09:39 +0000 Commit: Mark Johnston CommitDate: 2022-07-15 16:33:49 +0000 crypto: Validate return values from CRYPTODEV_PROCESS() Errors are always handled by the completion callback, so we should check that they're not also passed back to the caller. No functional change intended. Reviewed by: kp, mav, jhb Sponsored by: The FreeBSD Foundation (cherry picked from commit 99df914899f56efe63afd9e0fef79148fa6ca162) --- sys/opencrypto/crypto.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c index c9ba66650807..c28f0ff72a43 100644 --- a/sys/opencrypto/crypto.c +++ b/sys/opencrypto/crypto.c @@ -1731,6 +1731,7 @@ crypto_task_invoke(void *ctx, int pending) static int crypto_invoke(struct cryptocap *cap, struct cryptop *crp, int hint) { + int error; KASSERT(crp != NULL, ("%s: crp == NULL", __func__)); KASSERT(crp->crp_callback != NULL, @@ -1779,13 +1780,19 @@ crypto_invoke(struct cryptocap *cap, struct cryptop *crp, int hint) crp->crp_etype = EAGAIN; crypto_done(crp); - return 0; + error = 0; } else { /* - * Invoke the driver to process the request. + * Invoke the driver to process the request. Errors are + * signaled by setting crp_etype before invoking the completion + * callback. */ - return CRYPTODEV_PROCESS(cap->cc_dev, crp, hint); + error = CRYPTODEV_PROCESS(cap->cc_dev, crp, hint); + KASSERT(error == 0 || error == ERESTART, + ("%s: invalid error %d from CRYPTODEV_PROCESS", + __func__, error)); } + return (error); } void