Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp2999rdh; Tue, 6 Feb 2024 16:47:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU5vhhnimGyEZOQRMBaaZEsPYiC3wJWBeIHvVcKLMv5/g0anu4lFHbdra3npoKLrGepsZAFXaTEOfBS+i+SuIRm0eLuMsDls/iTqLGdrw== X-Google-Smtp-Source: AGHT+IEVQB9/1OETZeevyYj5UGTJ5JjJmMwxm5Okh0c822clGefZT4o+QdHY7t2bXDG1UwkFAfUR X-Received: by 2002:a05:620a:51cc:b0:785:6215:afbd with SMTP id cx12-20020a05620a51cc00b007856215afbdmr3927888qkb.1.1707266851488; Tue, 06 Feb 2024 16:47:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707266851; cv=pass; d=google.com; s=arc-20160816; b=CxZ5YJChc9RhBm/9x5oGSvJxqQvN19rO/uDxaJeQJWCb5RjosX4DpOd2IZcAFuEvA2 nt8loegip7joXhYaC1eJScZtV91RRJrw6H3Rt+iQjPbOL4gSokolizuMZqm6UQZjeKKD DKjJgNiOJHjcjsD7l57pSTIBrWWlvfF4UkIlxOU4eo+3PuCOgxzAUmI/bAcQeE5qtIfl ZtvdR17ov/WU0tvPBoFOLrw6KSv77Gd1CvuPTLuyOMlPco4p6oeRfnPe0/f8fP58eJO8 bI9dkWzthz6GR67Ca49n0abLukXDBqapPgvo0pzqOgpkvQLBTCMApUPujvDfpBFIpOEu 4qMA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=EYdmqlDhVa6+SsS0221uBp38SNB5XKIwcxHhtnLKgzY=; fh=RF2en5N6qnH9ECgmRySOukZd/yPBuNfWyiCrQDVjkNI=; b=J6adgfL99cNXcf9KIXVY74KJ+0ai84i4bka0QN3Aclo1E7E/SYLLzgLUwIJsqeBBlB n6ESLS29TKm0NO4DorndHiT3sCxrUoepB6Z3QsYewNb2aIa6uC+lr7SeEDBqDtFBbSn3 YTcxFkR+Y0xN1EZI2IIFuRfbQAeznlFx7mn+TnidsWEBFnpxKJXk1CwIyVkK9eO/NvEg /yPodytEnSNYHo2EGEO3ffx5vZ+yQopxF1h1HPuOxNWdZokV33lWSH72ZhQQx02luEd7 EUKSDim3UlSdXQBBv30Tau8ZaelSuKaxnFpRa78Unl4wecEWZxlTv+YkE+Mj30ljWGdR w3QA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IgWpcCRL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-1889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1889-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCWZK4LimmssVADn4dcdr6mUAwbYeJGw9Euwro50nhUJun3J2IUQJIF1UaPfAXb3eAQnPadum7LJZuS31gQAGbWCzveav5YSjNmDjdMNvQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f18-20020a05620a20d200b00783f0a95059si89540qka.363.2024.02.06.16.47.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 16:47:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-1889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IgWpcCRL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-1889-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-1889-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2B4171C24476 for ; Wed, 7 Feb 2024 00:47:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6C3F8F5B; Wed, 7 Feb 2024 00:47:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IgWpcCRL" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D94A8BEE; Wed, 7 Feb 2024 00:47:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707266846; cv=none; b=ZSrz6DYHRz/7HAF71IXARsnYz4gmY6ouCJk+69NY7PjxJYd/FDNhRgzgRwvgUUk9gBGD4Tu59DoecMtgKp7GhiTtMwMgA4WT/cu2o7DHlmByO9U2agqPMiQkmMfrR2jgdeLbi0yMWzm6sBxC432O1ZgPguAHdo4iJgmlA14QZMk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707266846; c=relaxed/simple; bh=iqHxgOHuYFmk9YND73eU0cO+vCD/4trx3LeVLF6gEa0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=hQptI/RFkt8HvpVIdpv3n7rwFvNcCiiW8k0GgrNIhAhmpY/2tbOQfFOlFOGHst7p0ZlhWKiF+PvxMkGch5wbmgRWgh01L+sU+rhB0HhI+0y6QUtzdTJXroiweWxqg00ujJsaMhZ3VHbVZbkVznOEzkzdMsEGCKWFYak0/bpi6yU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IgWpcCRL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DAB3C433F1; Wed, 7 Feb 2024 00:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707266845; bh=iqHxgOHuYFmk9YND73eU0cO+vCD/4trx3LeVLF6gEa0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IgWpcCRLQhkVQtpOkfg/qGEI4J2qtrzW0bdMNunzjROZxeOQ/OD3+soNK+E6gYd6V NU+KW9AHJGg1GSKDukeeoGxEHzefuUZ7ejTpVSPSkucR9/05xrfbrXlsDHXG4xbYCx ZVW8RelbRk88iiGisT8knwuJi4RAOLMpTnABx8vG5xP/o3Hh5ww+zoz6QcvPTFSkuo CGnhSXiEgbdTNom7SBTZN2W2ro54td1SSjbBsLgxOZ0V9cdPi0mMds+dC4FnoB85eu uY6S39REIprg28NgBMrfSbGz5GO/aCy4affm1JBCUHGgrXAGRy4DJ8tfTrOfAaeT9X wKpaEKwOcKN/A== Date: Tue, 6 Feb 2024 16:47:23 -0800 From: Eric Biggers To: Mikulas Patocka Cc: Herbert Xu , "David S. Miller" , linux-crypto@vger.kernel.org, dm-devel@lists.linux.dev Subject: Re: A question about modifying the buffer under authenticated encryption Message-ID: <20240207004723.GA35324@sol.localdomain> References: Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Feb 06, 2024 at 10:46:59PM +0100, Mikulas Patocka wrote: > Hi > > I'm trying to fix some problems in dm-crypt that it may report > authentication failures when the user reads data with O_DIRECT and > modifies the read buffer while it is being read. > > I'd like to ask you: > > 1. If the authenticated encryption encrypts a message, reading from > buffer1 and writing to buffer2 - and buffer1 changes while reading from > it - is it possible that it generates invalid authentication tag? > > 2. If the authenticated encryption decrypts a message, reading from > buffer1 and writing to buffer2 - and buffer2 changes while writing to > it - is is possible that it reports authentication tag mismatch? > Yes, both scenarios are possible. But it depends on the AEAD algorithm and how it happens to be implemented, and on whether the data overlaps or not. This is very much a "don't do that" sort of thing. - Eric