Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp663677iog; Thu, 30 Jun 2022 07:58:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t5Le3kQWWLwRqWm9/CP+XHlMPtSZXfmbjuPDXsNCRI3bhbLK0qH9yLjgcLQ0/vKq2HOYxE X-Received: by 2002:a17:90b:3e86:b0:1ec:fc46:9e1b with SMTP id rj6-20020a17090b3e8600b001ecfc469e1bmr12592429pjb.155.1656601080467; Thu, 30 Jun 2022 07:58:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656601080; cv=none; d=google.com; s=arc-20160816; b=yNYHPXK1QJsSrHKbm9q0b5C0/N68ue1Ji7kT7ltnjeOIDEZhLGmeZl0w/xKcn/DPwG 4PXU3373LcpE6hCPQi8sZsjV30KCP2hDU+x5bdGcygoTgMnv5asz6q046/STMAq/CBR2 mZ6sT0ki/+8EpaUN/RDiswut9PRrlN51cRn2QnmUZ1cMGyFrXnYq/DfaGBSV17aOvlyy 72McoSDKP2fys4NSNBYi4XQ0/skSTUhJn1GO6V3wrbPg0maF47MlzOXUY7q9nPsGV+hw V6YeRrUccDJIl8Hnj3qL8lZzKYPSeZaXuimuYy8lEq9pIELMyg3I4pi5iCKCHrSlKe4e rhFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oCPTN6Eal3XYpw7DYQtR83HAX7bwzs7SOA3A7RVh8Zw=; b=QT/v8xGJpXNCvB5/C/kqivaAX/3qbWdr2SHgg/G+pyZnMRMBEnsUb1YM+EkyBbflHk DDMtDLcJUJntsDCeR+fDG0IYzTNRX8bXcif0gWOmqvN9LItMLbSYNrN2OqhxcPe2/A0w 7aOGq/qgFieRQFh7az3uvlRg2w7OhxaPKx7TGjhVNgOw4gF3FJCRUpmO3L9xS+Fm8F2q v31UOGtuGHgcFmZ9Pzc93jS76kMbgHSqrAnbR70pcovnsn4uZ/kV38PyLT48jLOIovWR 4tmo/GPDvRCeT+XoGoOPhiSJBtM6BVn2iDSGMdH3RCw5XeXdxF3+JFoMmIi6WnsqC/fR E2sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uQZb4lJa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s24-20020a170902a51800b00163bad6ec7bsi25089448plq.613.2022.06.30.07.57.49; Thu, 30 Jun 2022 07:58:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uQZb4lJa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236105AbiF3ODV (ORCPT + 99 others); Thu, 30 Jun 2022 10:03:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236380AbiF3OCM (ORCPT ); Thu, 30 Jun 2022 10:02:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 749DA4506C; Thu, 30 Jun 2022 06:52:50 -0700 (PDT) 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 85FC4B82AEE; Thu, 30 Jun 2022 13:52:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E856BC34115; Thu, 30 Jun 2022 13:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656597166; bh=ROIp5lZCFo+ioynwx0XiisiwiQ8VO4TOq9K1OHbLQCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uQZb4lJasOfaXieZNVnxX0nK172Ckzj4aU/V2H0yX0dkkIjby18ubyJrqEKsHkGM5 D5icYI7TrdjrgPaVdMpYtUEAO1MF+pZhUyvxlix2HP21QspeJt6N8+PfmLD/rptZbg Vq1IDMOPSTijPy4e7vqzkbKWqfp3Mv3ulCj8/JIs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Liu Shixin Subject: [PATCH 4.19 49/49] swiotlb: skip swiotlb_bounce when orig_addr is zero Date: Thu, 30 Jun 2022 15:47:02 +0200 Message-Id: <20220630133235.317860776@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220630133233.910803744@linuxfoundation.org> References: <20220630133233.910803744@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-kernel@vger.kernel.org From: Liu Shixin After patch ddbd89deb7d3 ("swiotlb: fix info leak with DMA_FROM_DEVICE"), swiotlb_bounce will be called in swiotlb_tbl_map_single unconditionally. This requires that the physical address must be valid, which is not always true on stable-4.19 or earlier version. On stable-4.19, swiotlb_alloc_buffer will call swiotlb_tbl_map_single with orig_addr equal to zero, which cause such a panic: Unable to handle kernel paging request at virtual address ffffb77a40000000 ... pc : __memcpy+0x100/0x180 lr : swiotlb_bounce+0x74/0x88 ... Call trace: __memcpy+0x100/0x180 swiotlb_tbl_map_single+0x2c8/0x338 swiotlb_alloc+0xb4/0x198 __dma_alloc+0x84/0x1d8 ... On stable-4.9 and stable-4.14, swiotlb_alloc_coherent wille call map_single with orig_addr equal to zero, which can cause same panic. Fix this by skipping swiotlb_bounce when orig_addr is zero. Fixes: ddbd89deb7d3 ("swiotlb: fix info leak with DMA_FROM_DEVICE") Signed-off-by: Liu Shixin Signed-off-by: Greg Kroah-Hartman --- kernel/dma/swiotlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -594,7 +594,8 @@ found: * unconditional bounce may prevent leaking swiotlb content (i.e. * kernel memory) to user-space. */ - swiotlb_bounce(orig_addr, tlb_addr, size, DMA_TO_DEVICE); + if (orig_addr) + swiotlb_bounce(orig_addr, tlb_addr, size, DMA_TO_DEVICE); return tlb_addr; }