From patchwork Thu Dec 21 02:42:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 181947 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp147649dyi; Wed, 20 Dec 2023 18:43:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjwpUG7QAwBu7X0qtqwNkdAmlKg9v0FDLMmatqPF5Try9sLITMs78gPV/S+jaEwTkO9vRs X-Received: by 2002:a05:620a:44c1:b0:77f:2e48:df7e with SMTP id y1-20020a05620a44c100b0077f2e48df7emr28252217qkp.70.1703126597811; Wed, 20 Dec 2023 18:43:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703126597; cv=none; d=google.com; s=arc-20160816; b=i2WY7ZCi+XfmnuUlnQjmsBksfSMZ5y7ImFTAbMHJNgDGm+H0aPOX1zDpfx7n2Oawkn K6sa+LEuc0n2S3n2GitaymiE2sDXgiOwn4Qb7ZtXq/lMR6NCn1tUpwRTqr4bOivagelw GfBhSUXXWByo6m0eT2RMDIZGimt7kA+ywhnVhXUSh29nEBdF+HSrvJtOTS7nMHEt020F 2fRXGjtT1f0T1Q0Dzmnm9RMaaa+VyetkehbE1i5lDJEjDz14htfUYJVf+BBm2vLwAi8k IoUpdsyrW1qtUDcsRt8fvCxgWsY0SgX/QYFddMbGGrTpgmttshq/xac8orojhhy81sNL Ei4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=RvOybpHR8VWa05FA0wwhEBCtD8Trjj5n1vYsA8WsJQ4=; fh=tkD33rSmOU/3NKpuG4rWPParPN1QCe1fD07XGoiu0tY=; b=B2a2RP5M2e9c20d9HSRs6/2KABHgSLRAqTSQy2LzEyfvFxTLj0CBe4WYTHyWvXsqAE QSogeDOrrqmPSgTs/xbMG78lYKWfWDzL8slPvYzCIWRElUApXjz1GD5CUI8iWM+gTRyn u5et4/wdOHyTUEAY+xdgNQ0BQ9aFiQg4kuDVpvI17LK0+PIugF30a+pJaQFFSxf3/jRC 57Fa+J3xLoj/+WMv68di/L5mGY39p5R2zN+MGNBtQVIdwJ19JIetYR4CG5YZ5k/EtoBw yUD75ZJurSD+Lv7x6EbCnB9N2VC/tuyDcah41Hrj9HCwCe5kkE41iUao1cp+4D3u72lZ FMMw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7757-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7757-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id de16-20020a05620a371000b007810937d327si1285511qkb.548.2023.12.20.18.43.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 18:43:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7757-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-7757-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7757-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9971B1C22FBB for ; Thu, 21 Dec 2023 02:43:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 05DCD525F; Thu, 21 Dec 2023 02:43:04 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from abb.hmeau.com (abb.hmeau.com [144.6.53.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7D044416; Thu, 21 Dec 2023 02:42:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gondor.apana.org.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gondor.apana.org.au Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1rG91K-00DGnB-B3; Thu, 21 Dec 2023 10:42:47 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Thu, 21 Dec 2023 10:42:57 +0800 Date: Thu, 21 Dec 2023 10:42:57 +0800 From: Herbert Xu To: syzbot Cc: davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Edward Adam Davis Subject: [PATCH] crypto: skcipher - Pass statesize for simple lskcipher instances Message-ID: References: <000000000000d52e14060cc9c551@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <000000000000d52e14060cc9c551@google.com> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785857675719246725 X-GMAIL-MSGID: 1785857675719246725 On Mon, Dec 18, 2023 at 06:43:27AM -0800, syzbot wrote: > > syzbot found the following issue on: > > HEAD commit: 17cb8a20bde6 Add linux-next specific files for 20231215 > git tree: linux-next > console+strace: https://syzkaller.appspot.com/x/log.txt?x=1129f3b6e80000 > kernel config: https://syzkaller.appspot.com/x/.config?x=ec104439b5dbc583 > dashboard link: https://syzkaller.appspot.com/bug?extid=8ffb0839a24e9c6bfa76 > compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17d23c01e80000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14cfe021e80000 ---8<--- When ecb is used to wrap an lskcipher, the statesize isn't set correctly. Fix this by making the simple instance creator set the statesize. Reported-by: syzbot+8ffb0839a24e9c6bfa76@syzkaller.appspotmail.com Reported-by: Edward Adam Davis Fixes: 662ea18d089b ("crypto: skcipher - Make use of internal state") Signed-off-by: Herbert Xu diff --git a/crypto/lskcipher.c b/crypto/lskcipher.c index a06008e112f3..0b6dd8aa21f2 100644 --- a/crypto/lskcipher.c +++ b/crypto/lskcipher.c @@ -642,6 +642,7 @@ struct lskcipher_instance *lskcipher_alloc_instance_simple( inst->alg.co.min_keysize = cipher_alg->co.min_keysize; inst->alg.co.max_keysize = cipher_alg->co.max_keysize; inst->alg.co.ivsize = cipher_alg->co.base.cra_blocksize; + inst->alg.co.statesize = cipher_alg->co.statesize; /* Use struct crypto_lskcipher * by default, can be overridden */ inst->alg.co.base.cra_ctxsize = sizeof(struct crypto_lskcipher *);