Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp2529268rwb; Thu, 27 Jul 2023 08:21:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlFktxEFzLJ5xFP8Na0vjLiyU/gejWQFkJHaisbN3F5IkdQTfSQH3JQnRHkk6maY/kP707cR X-Received: by 2002:a17:90a:6344:b0:263:e423:5939 with SMTP id v4-20020a17090a634400b00263e4235939mr4478871pjs.28.1690471307645; Thu, 27 Jul 2023 08:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690471307; cv=none; d=google.com; s=arc-20160816; b=aAaNoQm1iXqw0GoN/hmCBtEQka56If4R3HWhIOO5N7FGZsukqss8GV+QwcyAJSpu8T XfTidnym6z9qaGLgq/gFTPtqUfP34e4Th3GlnRnyAukBzknvP97gFxFETjLfUX+/W4uT wghIvUwlzZ04Gfc4KtWPCE0YIiPPx4/k/a+OpAFRRQls7buN1nLCRRx3P7JY0NwBFElO no7qrF9aarjsKpAG/kmiESZMP+lkKqEmMJLnGH3IANxq37SZPY+EFFRx2560WuKSgjuh o5dSl1IW59MLxExf8LqHl7kjG75yowTbiw5bZPfJb34aYe2tml27lcd9YF+k+O6qqSdN yL5Q== 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; bh=HcUNUY2fo1qoUVRe/fYE5Pac2Pk5zv4UHqgt2oG2u/M=; fh=G/SBPjMfZxXxejgWhTJVYox/NKCVH6eYBRSCpYJNInA=; b=Bbi48pRFdXU/fxZ6z0Kh0eRkx6gD2TthIf2y8EkZy0MSuwRkmBz/9PHAa+udMN0aMK 69HK4r/PluqSefLjfkKuUVucYVT3RZ4j3V0vcRggKe+1PA0KYtPx6+f78FuR8CJFPizx 8sBtxDW74FprmlWjJ0xT8H3WWxpOgx0/1q1/GRg3XeCemA2XKee6qd/xY7tduPuJNjku mDwEc29xy1fR3aBqc78qRVGZz8WTC4pd1E2o1cm2LdVWBJr6t9E2oivdO/NZw8CLRBhL 5b5Ux56pVDlEUAc+OsVYTo7fhkFCVeA0NtNUKJbywkUeJuyNhliw24yiXf4FaXdWvHrh yKpA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a17090adb8c00b0025ea4dd9071si1504283pjv.61.2023.07.27.08.21.35; Thu, 27 Jul 2023 08:21:47 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232215AbjG0Omh (ORCPT + 99 others); Thu, 27 Jul 2023 10:42:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232856AbjG0Ome (ORCPT ); Thu, 27 Jul 2023 10:42:34 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 8418235A6 for ; Thu, 27 Jul 2023 07:42:18 -0700 (PDT) Received: (qmail 1967770 invoked by uid 1000); 27 Jul 2023 10:42:17 -0400 Date: Thu, 27 Jul 2023 10:42:17 -0400 From: Alan Stern To: liulongfang Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] USB:bugfix a controller halt error Message-ID: <73b58ff7-2a0a-43f7-bda9-52b9437f5bc0@rowland.harvard.edu> References: <20230721100015.27124-1-liulongfang@huawei.com> <77a8ecb4-8099-1826-abd8-4f080d80b07d@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <77a8ecb4-8099-1826-abd8-4f080d80b07d@huawei.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 On Thu, Jul 27, 2023 at 03:03:57PM +0800, liulongfang wrote: > On 2023/7/26 22:20, Alan Stern wrote: > >> It may be that the handling solution for ECC errors is different from that > >> of the OS platform. On the test platform, after usb_control_msg() fails, > >> reading the memory data of buf will directly lead to kernel crash: > > > > All right, then here's a proposal for a different way to solve the > > problem: Change the kernel's handler for the ECC error notification. > > Have it clear the affected parts of memory, so that the kernel can go > > ahead and use them without crashing. > > > > It seems to me that something along these lines must be necessary in > > any case. Unless the bad memory is cleared somehow, it would never be > > usable again. The kernel might deallocate it, then reallocate for > > another purpose, and then crash when the new user tries to access it. > > > > In fact, this scenario could still happen even with your patch, which > > means the patch doesn't really fix the problem. > > > > This patch is only used to prevent data in the buffer from being accessed. > As long as the data is not accessed, the kernel does not crash. I still don't understand. You haven't provided nearly enough information. You should start by answering the questions that Oliver asked. Then answer this question: The code you are concerned about is this: r = usb_control_msg(udev, usb_rcvaddr0pipe(), USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, USB_DT_DEVICE << 8, 0, buf, GET_DESCRIPTOR_BUFSIZE, initial_descriptor_timeout); switch (buf->bMaxPacketSize0) { You're worried that if an ECC memory error occurs during the usb_control_msg transfer, the kernel will crash when the "switch" statement tries to read the value of buf->bMaxPacketSize0. That's a reasonable thing to worry about. Now think about what will happen if usb_control_msg works successfully but an ECC memory error occurs when the return code from the function call is stored in r? Won't the kernel crash then? Or if not then, when it reads the value of r a few lines later? So why bother to handle the first kind of ECC error but not the second? What makes one ECC error more important than another? Alan Stern