Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1103030pxm; Wed, 23 Feb 2022 18:12:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5EnQWKA1kniFdga5BB8cyPeDG9FXdwj9CHIAasS5CQwryKJpcmnc5YOzSGdGfxxkbPgG2 X-Received: by 2002:a63:8748:0:b0:35e:d94:7b79 with SMTP id i69-20020a638748000000b0035e0d947b79mr555202pge.81.1645668775658; Wed, 23 Feb 2022 18:12:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645668775; cv=none; d=google.com; s=arc-20160816; b=yfp+/njj63wYvPRll0ADG8fVy0ot4U6T5ueZTGjEaCXChHMkzBGQlbMUCy8whUnT/V ak/k86jbG6iFx7ZJanloyWoz7JXKMhJe/cRXcf9NMYzV88c+wVNn4qi3m7n+retDmSjR Fve+4xmdysmUNIseyVseqXotmNPXK4+lOzmCjH7XGAbHFgHi0gGoHbR/pvBBgZMGrQG5 aCX4DPrDy+1FXB0OryCiNWrkaOv47OfN3Gugz8hZ/1gYZYuJ69szOwtqAw2AdoyyvXtq Hxz1tG4U92ycHiFHMJligiRsf5RjxSWhGZ2FlXSaNMx6pHW8DHA3aRIfXclCynFWs2kg AKNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=SlxsHUrMA6JFfABfy/Bybe2SWzgUhsQ5DHRRgjui2XQ=; b=XnMtsXPTVIAqZI+eC5X33jyFHuiyU+QXbd2BlKREmFK38BYWh3g5U9a5jlUnLc9xhZ nQhuKQNM2e1n9KIfRczjvCUrAcMuLbkkTqtyCyVSN+R+g8I140vL0KhP+Eg5SPtXL9QR CaOGzpXCHjrQd4cvmF/5KbLtiG+0jbb2TyMTJsvKcDjTIFUUljPD/G+G13DS43rUXKDA UFfJ/wjjQ4o3MiKoVeqS5k6Pa2zWHGnJEpdbyKM3Hq3lZJ9bDJHo2J6bgAxWlHBoYxyu RSfkq6yf4uMSXEbkpGKrEfWYhw9y5fGpM7c2FNykPCi/dPXUSNTJE9Hzl6+IyXZzEqfS MSXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ur7EyzAH; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x124si1218667pgb.868.2022.02.23.18.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 18:12:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ur7EyzAH; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6A0B525C7C; Wed, 23 Feb 2022 17:47:34 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229775AbiBXBsA (ORCPT + 99 others); Wed, 23 Feb 2022 20:48:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbiBXBr5 (ORCPT ); Wed, 23 Feb 2022 20:47:57 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 301851A3A9; Wed, 23 Feb 2022 17:47:28 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id DDAD2B82355; Thu, 24 Feb 2022 01:47:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BC8BC340E7; Thu, 24 Feb 2022 01:47:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645667245; bh=sCX7LzdLIdSqvaigD4FToB9/z+1YgqNv/qwnaTVAbHI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ur7EyzAH9ZcNYgRVcmNTzBDaXF5XSMZ0PuMiWeSmdccrs2mrnd/enBEJLSDLaq+zB 6ZpJxBIWbnsRADPgWRUR5snmpdCNpCbR4avXXvIqd4GNWTxqLEDH0AmK/Gzn8fmsXP /gCfMavgBiJ45ajtxHpJrPNQrthzejKzSE4YhEsPDpvw8LmbMX+rkMuuV0P86tZmvc qMG+w0LFVuIkHVvEUqB7bTIfUf+G5O0UXw+rvkGY4YThRdstdRlWsLaHLOrtxVwoQh JZMg1xolqUI74KINDObCAmqOBlDZmKazxkkWZaORpwK1UfmisPEqX0Ner9dIcf3elh pxXH+wSLIqmfg== Date: Wed, 23 Feb 2022 17:47:23 -0800 From: Eric Biggers To: Gilad Ben-Yossef Cc: Herbert Xu , "David S. Miller" , Ofir Drang , Corentin Labbe , stable@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] crypto: drbg: fix crypto api abuse Message-ID: References: <20220223080400.139367-1-gilad@benyossef.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220223080400.139367-1-gilad@benyossef.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-crypto@vger.kernel.org On Wed, Feb 23, 2022 at 10:04:00AM +0200, Gilad Ben-Yossef wrote: > the drbg code was binding the same buffer to two different > scatter gather lists and submitting those as source and > destination to a crypto api operation, thus potentially > causing HW crypto drivers to perform overlapping DMA > mappings which are not aware it is the same buffer. > > This can have serious consequences of data corruption of > internal DRBG buffers and wrong RNG output. > > Fix this by reusing the same scatter gatther list for both > src and dst. > > Signed-off-by: Gilad Ben-Yossef > Reported-by: Corentin Labbe > Tested-by: Corentin Labbe > Tested-on: r8a7795-salvator-x > Tested-on: xilinx-zc706 > Fixes: 43490e8046b5d ("crypto: drbg - in-place cipher operation for CTR") > Cc: stable@vger.kernel.org Where is it documented and tested that the API doesn't allow this? I wasn't aware of this case; it sounds perfectly allowed to me. There might be a lot of other users who do this, not just drbg.c. - Eric