Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp7433282rwd; Tue, 20 Jun 2023 00:52:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Ae+NFw6X0kvaKl4bwsRjwNPdhU7DS3dNa/SZrSfT73KwmEiqHt2LO7HQKanZWKrMU/W2m X-Received: by 2002:a17:903:24e:b0:1b1:e6a4:2797 with SMTP id j14-20020a170903024e00b001b1e6a42797mr7866229plh.45.1687247563118; Tue, 20 Jun 2023 00:52:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687247563; cv=none; d=google.com; s=arc-20160816; b=uu0dwIRwdcKQ/NDguo3SLMRHFtgeHy0vqwWKlao/Q89V33DOhbfae5cZuIn8Aoxk3o UPXq/cHcPppKXiY2rK22MEv500lyOPIARiq92TzYtwD2Yu469wYXgTDNhSMEtvFORIh7 Ya+ziCOItjwXrd6q+xXH3Yju2iOCIWyEVdUoGkUjTtHUEiTKrpcT5/lonRy7RcoBTxrI m0MBALxBcHD0FrZDGuyGjUMIIeb5fVuq/+iKfrvmEqGWym0sDfuaHRKedzsm/2lovoDd JSYlDH/sKh2Uux+R2auehfx65h0LUXVfVKOo9DhS5Q4eQHmlJ2850vb7Ya4goBIV+B2N 11Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-id:mime-version:subject :cc:to:references:in-reply-to:from:organization:dkim-signature; bh=+92FxVTjgy7f+sZL0/WEWN3/mD2r8Rpsadm+H0B45no=; b=aDNom9xUafelPxo5LwY+NPQQYxXF8Q2MQSrAZukYHYxpvhBM+GUJgmis8GpbUpaFlO elcBuae8sXKShtMvOgFLCILO61XquG/VY1FHU5cDoUI8rXJf332c01hUT5O61pgzZGur tmMHSZVV/Kk21OesL4wdQFOnHolm8LMvD4T3uIJIl2KICN95/t3Uz8d714TP0JhjC0JK 74U2e9k7QCHAHtU8hZ/vK2r0TB6NGCBYZeVzy9HfKdOnUcFAgLOdhpk5I+gfZx5TLmBS ur/gNoIfwsMCQiQev9nd11L+csrH9wWHmCMVtxfRDPRKdCUO661sDh4/FPlUCeLZHrsv 1FKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bRtYiPbe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e12-20020a170902ef4c00b001b54856820esi1615335plx.79.2023.06.20.00.52.21; Tue, 20 Jun 2023 00:52:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bRtYiPbe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230115AbjFTHnk (ORCPT + 99 others); Tue, 20 Jun 2023 03:43:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbjFTHnN (ORCPT ); Tue, 20 Jun 2023 03:43:13 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FDA4E68 for ; Tue, 20 Jun 2023 00:42:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687246942; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+92FxVTjgy7f+sZL0/WEWN3/mD2r8Rpsadm+H0B45no=; b=bRtYiPbeZlYCfAzLM1wd3uAoB8s0biMwBUqFDV1FB0id90e3cYsmT2hz13VRYM6U11X+zh Lk7eaiMp0ill/T3l2TssbQo/iQKZewJT8Q21Glba5sy/oiKM0p9MLPzzoY5nz5XyuEUTG4 tOIVd2Z8wSERB4+kT3rxu1wj6O7FeGg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-7mogXHEzOlejoLY2g7uzpg-1; Tue, 20 Jun 2023 03:42:19 -0400 X-MC-Unique: 7mogXHEzOlejoLY2g7uzpg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3AB02811E9E; Tue, 20 Jun 2023 07:42:18 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91756492CA6; Tue, 20 Jun 2023 07:42:16 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <427646.1686913832@warthog.procyon.org.uk> To: Herbert Xu Cc: dhowells@redhat.com, netdev@vger.kernel.org, syzbot+13a08c0bf4d212766c3c@syzkaller.appspotmail.com, syzbot+14234ccf6d0ef629ec1a@syzkaller.appspotmail.com, syzbot+4e2e47f32607d0f72d43@syzkaller.appspotmail.com, syzbot+472626bb5e7c59fb768f@syzkaller.appspotmail.com, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jens Axboe , Matthew Wilcox , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next v2] crypto: af_alg/hash: Fix recvmsg() after sendmsg(MSG_MORE) MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1220920.1687246935.1@warthog.procyon.org.uk> Date: Tue, 20 Jun 2023 08:42:15 +0100 Message-ID: <1220921.1687246935@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Herbert Xu wrote: > > + hash_free_result(sk, ctx); > > Please revert this change as I explained in the other message. > > > + if (!msg_data_left(msg)) > > + goto done; /* Zero-length; don't start new req */ > > This is still broken in the case of a zero-length message with > MSG_MORE set. Here you will short-circuit out without ever calling > crypto_ahash_init. However, hash_recvmsg will directly call > crypto_ahash_final on this, which is undefined. Not so. hash_recvmsg() will call crypto_ahash_init() first because ctx->more is false (hence why we came down this branch in hash_sendmsg()) and the result was released on the previous line (which you're objecting to). If it goes to the "done" label, it will skip setting ctx->more to true if MSG_MORE is passed. However, given you want sendmsg() to do the init->digest cycle on zero length data, I think we should revert to the previous version of the patch that makes a pass of the loop even with no data. David