git: af2c2a9cb59d - stable/13 - crypto: Don't assert for empty output buffers.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Fri, 29 Apr 2022 20:55:04 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=af2c2a9cb59dbaf9cd9f227d4a518a5fb05208c3

commit af2c2a9cb59dbaf9cd9f227d4a518a5fb05208c3
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2021-12-09 19:52:41 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-04-29 20:50:04 +0000

    crypto: Don't assert for empty output buffers.
    
    It is always valid for crp_payload_output_start to be 0.  However, if
    an output buffer is empty (e.g. a decryption request with a tag but an
    empty payload), the existing assertion failed since 0 is not less than
    0.
    
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D33193
    
    (cherry picked from commit ec498562b71a5e2baee3556eed7e22947f7abc5d)
---
 sys/opencrypto/crypto.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/opencrypto/crypto.c b/sys/opencrypto/crypto.c
index 5332ab5f07ce..69dd75ab1d0c 100644
--- a/sys/opencrypto/crypto.c
+++ b/sys/opencrypto/crypto.c
@@ -1424,7 +1424,8 @@ crp_sanity(struct cryptop *crp)
 		KASSERT(crp->crp_payload_output_start == 0,
 		    ("payload output start non-zero without output buffer"));
 	} else {
-		KASSERT(crp->crp_payload_output_start < olen,
+		KASSERT(crp->crp_payload_output_start == 0 ||
+		    crp->crp_payload_output_start < olen,
 		    ("invalid payload output start"));
 		KASSERT(crp->crp_payload_output_start +
 		    crp->crp_payload_length <= olen,