lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 30 Jun 2022 14:48:56 +0200
From:   Ben Hutchings <ben@...adent.org.uk>
To:     Liu Shixin <liushixin2@...wei.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Halil Pasic <pasic@...ux.ibm.com>,
        Christoph Hellwig <hch@....de>,
        Ovidiu Panait <ovidiu.panait@...driver.com>
Cc:     linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH stable 4.19] swiotlb: skip swiotlb_bounce when orig_addr
 is zero

On Thu, 2022-06-30 at 19:33 +0800, Liu Shixin wrote:
> 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.

Thanks for fixing this.  I tried to test the backports by forcing use
of swiotlb, but apparently it still didn't get used.

Ben.

> Fixes: ddbd89deb7d3 ("swiotlb: fix info leak with DMA_FROM_DEVICE")
> Signed-off-by: Liu Shixin <liushixin2@...wei.com>
> ---
>  kernel/dma/swiotlb.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
> index 8b1360772fc5..b1e2ce2f9c2d 100644
> --- a/kernel/dma/swiotlb.c
> +++ b/kernel/dma/swiotlb.c
> @@ -594,7 +594,8 @@ phys_addr_t swiotlb_tbl_map_single(struct device *hwdev,
>  	 * 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;
>  }
>  

-- 
Ben Hutchings
Nothing is ever a complete failure;
it can always serve as a bad example.

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ