Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp995405pxj; Fri, 21 May 2021 04:08:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6PIyPQ5qZfGWqQCayX93L0dIGcOD7e5JditnYXI5zci+myZG/cg0Uz26NHkA/ACj/avpu X-Received: by 2002:a17:906:2504:: with SMTP id i4mr9649473ejb.297.1621595308857; Fri, 21 May 2021 04:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621595308; cv=none; d=google.com; s=arc-20160816; b=CHaIZY44+KtmwW914vSd4q3aPnzn4tCDoiNKGI9yJ+8yc6ghhevi8IQ0JY15fcko9s fyv4/GmqeIDAqKWOpLHPa0PlPUYkZqjLPhvLZjRLvsv5PRWZxYmIMnhXAIZ9HazrwqJg KBudvyDp8xYBvpcHI0v7Qotp2jIXHq9lqB/SQGwVbFantu+YnP3lqTzj42MGUXhNUeAB QXpwZb9nRSMXgMZr3pddbHq3yjpThxs/zdHjiOBVFoSCkZxLU+xAYGrYUtjSaVLklhvd UEHAVnh3M8tN6g7GJEyYVKvr/KY3VbXe3hDjcY3cov4nNDJ5n80uGo08snKq87mhYPoL 4k0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1I8foG06rEXlhMwld0O8rH07GAVgSOgPSPCkjvHDyZw=; b=ARQIVzDjryEvHypnluCK5HRPwuM2fmvEIgLeCQX/bJ0jj/fJ/cXoqc/TbWRedbBY/2 5MufyX45ZEued1KPeKA1Pz1PwI7SIp+MkZrT0h4DfXZt5JUF9FYPTpVHUi1yuUTmhulM qbRqt+GJOUJldDoFAKnIuiOG+ue3Fn/7Bxbi2kLu7nO2r/kVV2w+8fgA7WKjcUjn0z5N OjzQnmIKU+dhR1cxcv1q8xlfwByJupi0syXMBEgmvO1vibzNBen3wc62ZsBovysWVk+C jNFDJllYqBFDSRFT4c/ipmWp06XQAO7bNdjTWI6MN0yWeaz8qCT7r3tZzKWKMN3Mtv9F atDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="bEONvf/o"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a4si2317059ejc.644.2021.05.21.04.07.55; Fri, 21 May 2021 04:08:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="bEONvf/o"; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236557AbhEUJh5 (ORCPT + 99 others); Fri, 21 May 2021 05:37:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:34426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232672AbhEUJh4 (ORCPT ); Fri, 21 May 2021 05:37:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9E2B2613BB for ; Fri, 21 May 2021 09:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1621589307; bh=1I8foG06rEXlhMwld0O8rH07GAVgSOgPSPCkjvHDyZw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=bEONvf/o+jtIegvQCRc9Ha1tRRuKZgeRXKPolNAJDr0xVpSV2OG22BDpOX/R/j1RT YI6kmHB1VkXWc2iDH4rWofshyP7VFAi/xoCJcAD3lxd+J1Kpv/erTX3WS+BSCzLNdV 4XSkIWBCNQPsZeiu8ob5HWqzFGiq7YzoGjZ2Y+RbnADimc/QU8p17qkJOl0leofnN/ 7RvJY99rBy5na4PROovh+mXrVK46GXOASc2/ukuw8w0TyMOO3d5Nsu/0pkc01uTVPe 9CoLlNdE/TtnupIOUwp9Z9WCPN6D/1r1wBPeDiEpENw/j0Ypvs1hc0hYJhycsbzqBF fYCrF45x59C5A== Received: by mail-oo1-f42.google.com with SMTP id q17-20020a4a33110000b029020ebab0e615so2510501ooq.8 for ; Fri, 21 May 2021 02:28:27 -0700 (PDT) X-Gm-Message-State: AOAM531VnnTuhwSVpd+AKN3UvuZgo8Px+cmLSTn9T96dzRA5DBJ/5dYK e+SEyhBhbBnbIXxRgeLzchyDj6XqbUn6RdncJmI= X-Received: by 2002:a4a:300b:: with SMTP id q11mr4954517oof.45.1621589306096; Fri, 21 May 2021 02:28:26 -0700 (PDT) MIME-Version: 1.0 References: <20210512184439.8778-1-ardb@kernel.org> <20210512184439.8778-2-ardb@kernel.org> <20210521075544.kywxswbfyoauvhmg@gondor.apana.org.au> In-Reply-To: <20210521075544.kywxswbfyoauvhmg@gondor.apana.org.au> From: Ard Biesheuvel Date: Fri, 21 May 2021 11:28:14 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/7] crypto: handle zero sized AEAD inputs correctly To: Herbert Xu Cc: Eric Biggers , Linux Crypto Mailing List , Linux ARM , Will Deacon , Android Kernel Team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, 21 May 2021 at 09:55, Herbert Xu wrote: > > On Wed, May 12, 2021 at 11:24:09PM +0200, Ard Biesheuvel wrote: > > > > The difference is that zero sized inputs never make sense for > > skciphers, but for AEADs, they could occur, even if they are uncommon > > (the AEAD could have associated data only, and no plain/ciphertext) > > I don't see what a zero-sized input has to do with this though. > When the walk->nbytes is zero, that means that you must never > call the done function, because the walk state could be in error > in which case everything would have been freed already and calling > the done function may potentially cause a double-free. > > I don't understand why in the case of AEAD you cannot structure > your code such that the done function is not called when nbytes > is zero. > OK.