From mboxrd@z Thu Jan 1 00:00:00 1970 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 49FD6C001DC for ; Thu, 27 Jul 2023 15:31:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232455AbjG0Pbt (ORCPT ); Thu, 27 Jul 2023 11:31:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231325AbjG0Pbr (ORCPT ); Thu, 27 Jul 2023 11:31:47 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2059.outbound.protection.outlook.com [40.107.15.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75CEA1BD5; Thu, 27 Jul 2023 08:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nHdfk7LwtcpCQtxIPX3NkQBvNeCgNmreKAd1cl/q9TDebtfufSpQmBbob4TR/6kHLFb9fL4g27LJr299pTh3tKcb+qA41ZpE1baFDrkBWBv/YYDgOY+M/aDPTVynYRInEZ5vDYalCwKpTsEJrkwGI4xjoVEe0CTU1mW6yQjSmlSDJcQi4zLLGoyBKDV43WKkZE/vvOj67Qt92723q5V3lhXDPW4SsPK/TRwOQRlJTS1wrrp0wf+WWTEEYQzAWzYTYdc+rUj5AqRZ2hu/cNZfmHoxG45NLjypwgWoVhxME7h8G48XQLnqAXi2LTAZ4Gc2F5L9zG+wBxDoMoT1wMsDWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EobOP04o5EcD7tS0rIyaTcsft2NMc1/zbnec6cF/Ci4=; b=ST+2kFtjg4wGXRJf62mBy2qvRB/BvLqoZEEQg1hWIpkOQ2hwQjTMYjo48m2ems0XpHC995328Rt0kIqO+WnRP+GagQ5DjhzxRRLzDKBinlZx7pdhPJ6KrS16z3tJMZZLyuNl2gOezu/z8DtKZr3ZWjkKuoNGiXCTFmm7ZAVxaYmoScOe6VpAhnJg93TEb2uprXga9vr+VfEX6ZUQnDrNsjv9cKfUiY4mxLx9j91E9gFRCPZlvz1tIbFg9YpMZUO5koZqfiGpZSaydNzDCVBOwYQIDNQIGHMxwXjjNTAIyAjsl2Opdz/ZNJ05sW3wyXCx5tohfeMohqSxryp/MITxEw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EobOP04o5EcD7tS0rIyaTcsft2NMc1/zbnec6cF/Ci4=; b=pfxDinrnZJ8VrMg7Hs3uRBxMQjS/WV44CA5zM7+3fylYbWl/IdJ/l0dxDeV6c7+BoejnG6++DFl5e8ZPoZNMipf7p4jtBhNbqKXWk9YMUpBdnf/wRguNO7MfGl1A3ob3vEE3xIqxm+rHlfrDwvuLYRY98PZjXfbmeNGJ0sn89kUAk1YXqKMYwZG/tESGjcUsBbS1JIHL+y7AJtLtbDBdsaxzDQykkldijf69niamKfyS6um7wZKhUZUJ9exhfMKUHwUBoB5jv7npZ+k+ZdhStG6Hwr52PXY1flUpA5JfkyK/61QZ6UR55kQhKX8bZSeS+sFekM0K+JxPmJ6FiBVdZg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from VI1PR04MB7104.eurprd04.prod.outlook.com (2603:10a6:800:126::9) by AM8PR04MB7777.eurprd04.prod.outlook.com (2603:10a6:20b:236::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.33; Thu, 27 Jul 2023 15:31:43 +0000 Received: from VI1PR04MB7104.eurprd04.prod.outlook.com ([fe80::7ef4:97ef:66d5:f5b3]) by VI1PR04MB7104.eurprd04.prod.outlook.com ([fe80::7ef4:97ef:66d5:f5b3%2]) with mapi id 15.20.6631.026; Thu, 27 Jul 2023 15:31:43 +0000 Message-ID: Date: Thu, 27 Jul 2023 17:31:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] USB:bugfix a controller halt error To: Alan Stern , liulongfang Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230721100015.27124-1-liulongfang@huawei.com> <77a8ecb4-8099-1826-abd8-4f080d80b07d@huawei.com> <73b58ff7-2a0a-43f7-bda9-52b9437f5bc0@rowland.harvard.edu> Content-Language: en-US From: Oliver Neukum In-Reply-To: <73b58ff7-2a0a-43f7-bda9-52b9437f5bc0@rowland.harvard.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR2P281CA0002.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::12) To VI1PR04MB7104.eurprd04.prod.outlook.com (2603:10a6:800:126::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB7104:EE_|AM8PR04MB7777:EE_ X-MS-Office365-Filtering-Correlation-Id: 44818e8d-3eb6-4da2-b9d5-08db8eb694b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U0D2xUGDg3qD8GeECtfAd/OzgBkDwQq42pjjFC6q6fN+GpGCT18CMBqCpimQlD2lJzjwdlXX2FMO+FO3ZV/CphD5OovkV1qqcCd3brZ1uFAuipEaIDZ60GAmcLSNRbwbznVlU8sLZw4484SJQURiiWX/C6dggWCEVmJQHyJUbO4l4aA4IVaIKuOdMbNWHQGdtnw9yP3T8Lphn3VJzqisUzb8Znyx6psxdtIXuPSSUj3SBVcAO8Qj4Fc3U4zwJ9bKvHRq6D7mELqdl8yORqtpmfL61OMq/xhlofvelUahC45v1NAN2odggeytubemOiOmrhKZEmAxDBqZL1AoOo6EvIbCtHmCxjJr9DoDCqtL2fPJMLw064JtulAtXfg9h5ug1oP1uPPnEbujPHCvoVDuYTpWHMvMzRQGrd1NJ71NpcFXQ1GxRJwUsjs14jjeFY9Y61xpCMStIyctJ5eWya4f+BFP8LyBqLukFY9973ZNyU0LgtfNAxO+56eueWtu1txr3dEAh+ZR56VpELXyXvuZUw8CkxbN05mwSYj7cLyqXViGbZjq+oRna/cVOUVCE0oSlAeKSqM/3B6+i3OCYuuxZqLohuxzgZP7r6vZPkeeCDQW4Yp2OutY7bFvCFa7fX7M/8FwgmJIVetT+mKlJ6ASDw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB7104.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(366004)(396003)(376002)(346002)(39860400002)(136003)(451199021)(110136005)(6512007)(6486002)(38100700002)(478600001)(41300700001)(5660300002)(316002)(2616005)(4326008)(8676002)(66946007)(66556008)(66476007)(8936002)(83380400001)(186003)(6506007)(53546011)(86362001)(31696002)(2906002)(36756003)(31686004)(66899021)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TjA2Wm1MMkh2b0RJOERhOEx5ZzcyaFJWb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JseWZ6aXBVZ3ovZCtUOENZVVd4TitlaDBTNUNIczNYUThuK01YNlpS?= =?utf-8?B?WUZNeFUwYnZ2eEI1K285VDB0Z3ZnRy9BdGxQMWpBYVNlTGpXNTQxZU9rNTRG?= =?utf-8?B?TEE3TjV0WWNCaWtSUEhwdmZ3bzZyOGh5V0g4Tk9IM3puLzBuZVpwbVdyMEM2?= =?utf-8?B?NGJsTlRiN0kyYjBjQXE5ZDBLVXcxUWJzRnhYSmxUNFlITFZGQWZRamZ5UHB3?= =?utf-8?B?L01KQ0o4RFVzUW5yZG9ZMTFlbnVnTS91Z1dENGZrSjFRcnVuSlBrTmVnQlcw?= =?utf-8?B?ejhzTUtNYWg5ZkhYOVZDS1pGZ2hkZnlON0ttaXR4TnR6bmNlY0QxNXdvWEVY?= =?utf-8?Q?jThpag+D4hNCF1UXCiHYx+s=3D?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 44818e8d-3eb6-4da2-b9d5-08db8eb694b2 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB7104.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jul 2023 15:31:43.4675 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DchgO1zfXDn80MSq9wFBFmCGguU0phmlYD6KEdw4p3fXlZ5BDbpa50R3D9QN84dfMWeO91KIlD8y7EEQ8+75Jg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7777 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On 27.07.23 16:42, Alan Stern wrote: > On Thu, Jul 27, 2023 at 03:03:57PM +0800, liulongfang wrote: >> On 2023/7/26 22:20, Alan Stern wrote: >>> 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. I suppose in theory you could have something like a bad blocks list just for RAM, but that would really hurt. You'd have to do something about every DMA operation in every driver in theory. Error handling would basically be an intentional memory leak. >> 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. Albeit unlikely. If the hardware and implementation are reasonable you'd return a specific error code from the HCD and clean up the RAM in your ecc driver. The fix for USB would then conceptually be something like retryio: r = usb_control_msg() if (r == -EMEMORYCORRUPTION) goto retryio; Regards Oliver