From patchwork Thu Jul 2 03:32:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 1320951 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::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) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49y3cy3YJCz9sQt for ; Thu, 2 Jul 2020 13:34:58 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gondor.apana.org.au Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49y3cy2dfXzDqvy for ; Thu, 2 Jul 2020 13:34:58 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gondor.apana.org.au (client-ip=216.24.177.18; helo=fornost.hmeau.com; envelope-from=herbert@gondor.apana.org.au; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=gondor.apana.org.au Received: from fornost.hmeau.com (helcar.hmeau.com [216.24.177.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49y3bN0cwmzDqlD for ; Thu, 2 Jul 2020 13:33:34 +1000 (AEST) Received: from gwarestrin.arnor.me.apana.org.au ([192.168.0.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1jqpxV-0008AS-FA; Thu, 02 Jul 2020 13:32:22 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Thu, 02 Jul 2020 13:32:21 +1000 Date: Thu, 2 Jul 2020 13:32:21 +1000 From: Herbert Xu To: Naresh Kamboju Subject: [v2 PATCH] crypto: af_alg - Fix regression on empty requests Message-ID: <20200702033221.GA19367@gondor.apana.org.au> References: <20200622224920.GA4332@42.do-not-panic.com> <20200623064056.GA8121@gondor.apana.org.au> <20200623170217.GB150582@gmail.com> <20200626062948.GA25285@gondor.apana.org.au> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sachin Sant , David Howells , "David S. Miller" , Jarkko Sakkinen , Luis Chamberlain , lkft-triage@lists.linaro.org, open list , Eric Biggers , Linux Next Mailing List , linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, Linux Crypto Mailing List , chrubis , linux- stable , James Morris , linuxppc-dev , Jan Stancek , LTP List , "Serge E. Hallyn" Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Tue, Jun 30, 2020 at 02:18:11PM +0530, Naresh Kamboju wrote: > > Since we are on this subject, > LTP af_alg02 test case fails on stable 4.9 and stable 4.4 > This is not a regression because the test case has been failing from > the beginning. > > Is this test case expected to fail on stable 4.9 and 4.4 ? > or any chance to fix this on these older branches ? > > Test output: > af_alg02.c:52: BROK: Timed out while reading from request socket. > > ref: > https://qa-reports.linaro.org/lkft/linux-stable-rc-4.9-oe/build/v4.9.228-191-g082e807235d7/testrun/2884917/suite/ltp-crypto-tests/test/af_alg02/history/ > https://qa-reports.linaro.org/lkft/linux-stable-rc-4.9-oe/build/v4.9.228-191-g082e807235d7/testrun/2884606/suite/ltp-crypto-tests/test/af_alg02/log Actually this test really is broken. Even though empty requests are legal, they should never be done with no write(2) at all. Because this fundamentally breaks the use of a blocking read(2) to wait for more data. Granted this has been broken since 2017 but I'm not going to reintroduce this just because of a broken test case. So please either remove af_alg02 or fix it by adding a control message through sendmsg(2). Thanks, ---8<--- Some user-space programs rely on crypto requests that have no control metadata. This broke when a check was added to require the presence of control metadata with the ctx->init flag. This patch fixes the regression by setting ctx->init as long as one sendmsg(2) has been made, with or without a control message. Reported-by: Sachin Sant Reported-by: Naresh Kamboju Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when...") Signed-off-by: Herbert Xu diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 9fcb91ea10c41..5882ed46f1adb 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -851,6 +851,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size, err = -EINVAL; goto unlock; } + ctx->init = true; if (init) { ctx->enc = enc; @@ -858,7 +859,6 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size, memcpy(ctx->iv, con.iv->iv, ivsize); ctx->aead_assoclen = con.aead_assoclen; - ctx->init = true; } while (size) {