From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 9061FC433ED for ; Wed, 12 May 2021 21:26:52 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 07ACC613B5 for ; Wed, 12 May 2021 21:26:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 07ACC613B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VrTFuXgsaKbskbc4oszuDwA85C/BpsCWBasIf7E0TxM=; b=lsH8KQIVpi4USN3KCi+Pvi0pm A7Ije3mmZ8a0DM5fp8naQioDHNICmTJycK9N+42pYZFktiM7rNtNUJAX6LgXSZHdKnNLfy4+VDlqO USjOntBV/zizU8yYKkIxL620XobJ8cg4ajHmRn+JBndJIMTw2lbJ3oJKPjQwPYBAPICmzReL7QOCk smbZc4gH1XnOmd8QtZusTdwfGBZth2G/ap1Yl9miF4kpgoBvvaZ6RIBS92P0ahFPwirlNhK4BUPOX DfKvEZVQjsPg4Rs1hh/1fvRLkNpz7jGLxSaUmGy2cfcSnM/qWW1LmSC759WFT0netixhSgovVH6DI 2wjEy2E2w==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgwLG-0042M0-Vt; Wed, 12 May 2021 21:24:31 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgwLB-0042LQ-TV for linux-arm-kernel@desiato.infradead.org; Wed, 12 May 2021 21:24:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=D3eJIgdItqTUP2qMFnudnlnPv0M/eA1KecvC1Livn8g=; b=fPcO4rcajgWza4Lqot4R+UEYNs jSbiKfZ0V+/Tyk48JqRP0FvYfl4muX2YYlnB1LibvncgubYVxOPn+C6pDcpVasHbtv2yq0p4ySUjk jZIkLyMb4d8VJsi5aXs8ut394FknDE+CNej2k0NtIcOyRemwWIUGH34SvT6eaR6Q/s9jGUWNzkQQc 3uEY6naXYtI2rey5hYPDzJ4K6ydUp3Sr3fZdArsOIGjj5ek/1KaLd7BSpsN8+gFoO7qBnxiK0XXzk T4SMZIQdmP1JOhPDWRC/WGBNeRA0YoyWcaz9n02S7kTPlcUZw8hicARG+zqc5UvWOcaeXvahqPacs qdhUREtg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgwL7-00Apyv-Nw for linux-arm-kernel@lists.infradead.org; Wed, 12 May 2021 21:24:24 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1A878613B5 for ; Wed, 12 May 2021 21:24:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620854661; bh=dpMpwE/+0xsrNEBWSrB3F2tfcXWYhcQJFd7Iugffe4g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=TI6i2pnrjixOQ0EjSlyqNi776kSVB26wcmAwfSxkf8IAT8tjTGYETNOmQmVmIOozX uElNWaC2sIgq0uigB5eT9PK8DK5BlntjroQBeTrYDvFZighVUHMzI+pgjcrW6vnRfe zZ7avYbmJc5WDFYGTgU0KarRQRGSapYh6LcQALob12EIRLzIf8ZZJxG5DUpz6kyWZI luOwi9Bh/G6PbEEuKz6M3QEvh1k30qsZvjrcXNbjLRPmyVrNfN23pJozx0+UMq6hu2 2uY2gXVqyEqafogjKgEXn2MURj5cOj6RcEMU2DYvGFde3MC+BkfQL8UZq5ZiBpR7Pc g5gfo45WZU7CQ== Received: by mail-ot1-f41.google.com with SMTP id q7-20020a9d57870000b02902a5c2bd8c17so21890752oth.5 for ; Wed, 12 May 2021 14:24:21 -0700 (PDT) X-Gm-Message-State: AOAM533slgQ/ykVskb4ICeccfQNwhuyeVefhyDMMAhHFaY+wmG3gwVSJ L+4qZppfgkGXWnsu/ikjRwsJwQAP9MHERkMDDZw= X-Google-Smtp-Source: ABdhPJz1crGpZ2a/Nstlgsq6mSlP9NuQT6jz7eZ0TUXDgP1IP3cYsDpVaNhe/4teRWkhB86fF1AT2AoSZl5bA/LQBAQ= X-Received: by 2002:a9d:7cd8:: with SMTP id r24mr20523715otn.90.1620854660323; Wed, 12 May 2021 14:24:20 -0700 (PDT) MIME-Version: 1.0 References: <20210512184439.8778-1-ardb@kernel.org> <20210512184439.8778-2-ardb@kernel.org> In-Reply-To: From: Ard Biesheuvel Date: Wed, 12 May 2021 23:24:09 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 1/7] crypto: handle zero sized AEAD inputs correctly To: Eric Biggers Cc: Linux Crypto Mailing List , Linux ARM , Herbert Xu , Will Deacon , Android Kernel Team X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210512_142421_830974_2EA791A3 X-CRM114-Status: GOOD ( 24.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 12 May 2021 at 22:04, Eric Biggers wrote: > > On Wed, May 12, 2021 at 08:44:33PM +0200, Ard Biesheuvel wrote: > > There are corner cases where skcipher_walk_aead_[en|de]crypt() may be > > invoked with a zero sized input, which is not rejected by the walker > > code, but results in the skcipher_walk structure to not be fully > > initialized. This will leave stale values in its page and buffer > > members, which will be subsequently passed to kfree() or free_page() by > > skcipher_walk_done(), resulting in a crash if those routines fail to > > identify them as in valid inputs. > > > > Fix this by setting page and buffer to NULL even if the size of the > > input is zero. > > > > Signed-off-by: Ard Biesheuvel > > Is this fixing an existing bug, or only a bug that got exposed by this patchset? > It would be helpful to make that clear (and if it fixes an existing bug, include > a Fixes tag). > The CCM change in the last patch uncovers this issue, and I don't think it is likely we would ever hit it anywhere else. > Also, skcipher_walk_virt() doesn't set page and buffer to NULL, as it is > currently expected that skcipher_walk_done() is only called when > walk.nbytes != 0. Is something different for skcipher_walk_aead_[en|de]crypt()? > 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) But in the general case, I would assume that skcipher_walk_done() can be called on a walk that was successfully started with skcipher_walk_virt() without crashing, even if the scatterlist has size zero, so perhaps we should fix that one as well. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel