Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1443283ybm; Sat, 30 May 2020 09:01:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5szHYPs/kbcepmQ0Ii2JgUNe+VczcQi0Shr79gBQ5trEPkVx7k8hWNzDRJ0O6EOxaZpfo X-Received: by 2002:a17:906:ae85:: with SMTP id md5mr6652851ejb.213.1590854507299; Sat, 30 May 2020 09:01:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590854507; cv=none; d=google.com; s=arc-20160816; b=oZgMLBXYIFsX/HyEn2OjQY2/68KGbI+4X2D5Ly38JGQx+/0ffARTHzkv3NWQeKs5qx E9STrGIa4Ozir21rQq+D/jUrw5mqz2QCMh7TlPZjNKcakMAjrx2jigZlb4TmqKHZwyqX KgJr3vbI5dZiiovtZTmtvQVvGnx1UHx/fbzqQg6/F7J2EKpP0yIQ35WLSt1PpRMNP1ZY XB0Gka/sbkQE7tITB8/q6CpqsfWSyQoITUGQ/cB6Q/dj1tYMx6CihdE8H9I22NkKyXuX CF9/xt6H69rz321/ooahbVpYftQ8qGgQZUJSdsrYpZb3tjV24bUPgjSHW3fDGRNz2bup iETg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=TS3FPLdwegYomEtqTxo9uKImHgR38EcfF7l0v6lqQyE=; b=Pe0cEmnGnTeNmlXyEhPe8g+KoOz76Q2EPqH3a5yPEguc5hbihm2AA3nOstTQSNIVnU U0hpNq68XzJCm/TZTMhAJ42QBJ4ZYeMUf4msiWdke6oyNYk9ZqA5VTqxcnGRwq5Ph0fW JNewgzQqF5rGenyV82mOcQc9VYNtmBxGYIEAUeHkaHJKT9gZZfDVdnVfclufQSc7anm7 6mJnWYem+IDzFECGD2YxCHoOVqWb1nIrQr+LPBP/4b6wLTcDoQFZ9ZBWV2M7Y3NEQIdR WW7szUd7sD9hyXIKg1PtQhNFEcCXkrZMzpQ5q5KSvu9jnHRJRZ2xzP/Q7URiLWaVcHm4 SBEw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n4si7592529ejz.569.2020.05.30.09.01.23; Sat, 30 May 2020 09:01:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729154AbgE3P72 (ORCPT + 99 others); Sat, 30 May 2020 11:59:28 -0400 Received: from netrider.rowland.org ([192.131.102.5]:39239 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1729029AbgE3P72 (ORCPT ); Sat, 30 May 2020 11:59:28 -0400 Received: (qmail 30265 invoked by uid 1000); 30 May 2020 11:59:27 -0400 Date: Sat, 30 May 2020 11:59:27 -0400 From: Alan Stern To: Jia-Ju Bai Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: Re: [PATCH] usb: storage: alauda: fix possible buffer overflow casued by bad DMA value in alauda_read_map() Message-ID: <20200530155927.GC29298@rowland.harvard.edu> References: <20200530144230.3550-1-baijiaju@tsinghua.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200530144230.3550-1-baijiaju@tsinghua.edu.cn> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 30, 2020 at 10:42:30PM +0800, Jia-Ju Bai wrote: > From: Jia-Ju Bai > > The value us->iobuf is stored in DMA memory, and it is assigned to data, > so data[6] and data[7] can be modified at anytime by malicious hardware. > In this case, data[6] ^ data[7] can be a quite large number, which may > cause buffer overflow when the code "parity[data[6] ^ data[7]]" is > executed. > > To fix this possible bug, data[6] ^ data[7] is assigned to a local > variable, and then this variable is checked before being used. There are much worse problems than this in the alauda driver. For example, alauda_get_redu_data() does I/O from a data buffer on the stack; this is not allowed. That's just the example I noticed; there may very well be others. If you want to fix something, fix that. If you're still worried about malicious hardware, the way to fix the problem is not to change this one location. Instead, you should modify the driver so that us->iobuf is not stored in DMA memory. Alan Stern