From patchwork Wed Aug 26 13:29:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 253114 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 928AFC433E1 for ; Wed, 26 Aug 2020 13:32:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 71D6221741 for ; Wed, 26 Aug 2020 13:32:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730322AbgHZNc1 (ORCPT ); Wed, 26 Aug 2020 09:32:27 -0400 Received: from helcar.hmeau.com ([216.24.177.18]:33154 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730289AbgHZNa5 (ORCPT ); Wed, 26 Aug 2020 09:30:57 -0400 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.0.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1kAvUu-00052u-Ib; Wed, 26 Aug 2020 23:29:53 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Wed, 26 Aug 2020 23:29:52 +1000 Date: Wed, 26 Aug 2020 23:29:52 +1000 From: Herbert Xu To: Andrew Zaborowski Cc: Ard Biesheuvel , Paul Menzel , Caleb Jorden , Sasha Levin , iwd@lists.01.org, "# 3.4.x" , Greg KH , LKML , "David S. Miller" , Linux Crypto Mailing List Subject: [PATCH] crypto: af_alg - Work around empty control messages without MSG_MORE Message-ID: <20200826132952.GA4752@gondor.apana.org.au> References: <20200826055150.2753.90553@ml01.vlan13.01.org> <20200826114952.GA2375@gondor.apana.org.au> <20200826120832.GA2996@gondor.apana.org.au> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org The iwd daemon uses libell which sets up the skcipher operation with two separate control messages. This is fine by itself but the first control message is sent without MSG_MORE. This means that the first control message is interpreted as an empty request. While libell should be fixed to use MSG_MORE where appropriate, this patch works around the bug in the kernel so that existing binaries continue to work. We will print a warning however. Reported-by: Caleb Jorden Fixes: f3c802a1f300 ("crypto: algif_aead - Only wake up when...") Cc: Signed-off-by: Herbert Xu diff --git a/crypto/af_alg.c b/crypto/af_alg.c index a6f581ab200c..3da21cadc326 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -846,8 +847,14 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size, lock_sock(sk); if (ctx->init && (init || !ctx->more)) { - err = -EINVAL; - goto unlock; + if (ctx->used) { + err = -EINVAL; + goto unlock; + } + + pr_info_once( + "%s sent an empty control message without MSG_MORE.\n", + current->comm); } ctx->init = true;