Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59727C433EF for ; Mon, 7 Mar 2022 07:58:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236010AbiCGH7E (ORCPT ); Mon, 7 Mar 2022 02:59:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234793AbiCGH7D (ORCPT ); Mon, 7 Mar 2022 02:59:03 -0500 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187A51BE84; Sun, 6 Mar 2022 23:58:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=SBkufQbkk7WS7cnTX6Fdy468qPhDhtk/GXWCSTup/Tk=; b=xQj49Z6kmfBylR8KA/UdSDpvUz 2HQJ0OZ3qRoMv5IeF0IQ/68p+VdqWxJ4qG7BGTzd6ru4qeiILLEFi3OuVN/MqLS00YT/OG4KJeJoO AR5oik0TyTpTYSTCXokA78CHsVWLIlAqCXVOaWPhQeYx6wJbIlkUdS9Z55Pjkp6PtzDsZSs8kVtK+ f3UYXsB7Hh3XGQqWr+QeIfKuvwVJA3e2H772HR57Q1DJV/B0QAWzzH2zpoTs0n4YeNJZodhYXs6HO mcnivCjVE2R+/Rm+XSDVmJXDdzi/GD1D1SRLhS/wLNhnxtg4wFtY44x2Ts8nxKQOiWN5qBNNXIyzp TAAlsP9Q==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nR8Fo-00GMXh-RF; Mon, 07 Mar 2022 07:58:04 +0000 Date: Sun, 6 Mar 2022 23:58:04 -0800 From: Christoph Hellwig To: Linus Torvalds Cc: Christoph Hellwig , Tom Lendacky , "Martin K. Petersen" , "Michael S. Tsirkin" , "James E.J. Bottomley" , "open list:DOCUMENTATION" , stable , Halil Pasic , Christian Borntraeger , iommu , Doug Gilbert , Anshuman Khandual , Robin Murphy , Thiago Jung Bauermann Subject: Re: [PATCH v2 1/1] swiotlb: rework "fix info leak with DMA_FROM_DEVICE" Message-ID: References: <20220305170714.2043896-1-pasic@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Sun, Mar 06, 2022 at 12:30:55PM -0800, Linus Torvalds wrote: > So I would expect that > > (a) READ/WRITE actually fills the whole buffer > > (b) READ/WRITE are the only ones where we care about performance at a > bounce-buffer level > > so it boils down to "do we still do this horrible memcpy even for > regular IO commands"? Because that would, in my opinion, just be > stupid. For one thing this is not just for block I/O, but for all DMA. Second, "normal" I/O might always fail, including after partial transfers. SCSI even considers that normal. Network devices consider it normal to not fill the entiret receive buffers, etc. In short: anything that operates directly on user memory is a trivial reproducer here. The CVE uses SG_IO, but staying in block land direct I/O will work just the same because swiotlb will copy back the uninitialized data to user memory after an I/O failure. What we've been thinking of is a version of the dma map calls where the unmap gets passed how much data actually was transferred and only copies that out. But that seems like the only sane interface. Now IFF we known that the buffer is never looked at on I/O failure or short I/O we could do away with all this. But without adding new interfaces where the caller guarantees that we can't know that. For userspace memory it is guaranteed to be not true. For kernel memory is most likely is true, but there's some amazingly awful pieces of code that probably still get it wrong.