Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp736340rdb; Wed, 1 Nov 2023 00:31:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUs0ByfNK74yRb0nYOVK5R8/pswIQYD3aNpHY/KBJeKxhPPTBLvNoXt6dHRffd+lC5pofP X-Received: by 2002:a05:6830:914:b0:6c0:f451:ab6a with SMTP id v20-20020a056830091400b006c0f451ab6amr13804864ott.8.1698823916195; Wed, 01 Nov 2023 00:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698823916; cv=none; d=google.com; s=arc-20160816; b=xVh3X5eF/p97S6uYb0MV5CoYiYpStCK41gEND8Tpv5NC8GSUtDjXzTcUr6elVsLASZ YLYxBzf+Y6wo/vfgtd5z1MVJz0Xs23mB8Hl0+qRXi2aYIXnw2Gd1DOYJrwyhHihV8jxl aGyQV4YUyyqHOHjeVz96IFKTzz4gHhxX/l5RsVkOWmf1jFOzXH5uqVDJ9BH1glfsPRmL TC+s1tcf81zWLrVoLRgrO+QyiUTNHBnru2xs+17MmonOyPyl0nbkaTh1KJRgVrvPdHYF ilTuBMX/WkV/VE/EOADur6MicIkDL8Eiem6yTOg8IwVYnhh1WUIG/OPsGXcuc/qce/lN y6Zg== 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:dkim-signature; bh=ddQknAAWp+UFtonG+4SiT4Y8GTbDVawRHvoXuEOwvE4=; fh=W1AQjevYMuEXr2hLAXOvgaM4Q+eh5+fe+Df552YS84I=; b=ihwaB7X8nO0e/vKEh17mSm4JxJ8yPfGV+LPB04kkkFvPWORdjx1zxLdd21B0klq0kr 7A24ti1q7YD6fdbY6iwsEYAZu947o4VZrAV4L6p/pn04HJ11nNgxemsEEMhLV1hSPJWS AtCJHscRE+eVvvOaefxNfNlDT+u44Sy31PWPLXy8KJfYunoLB9CmBdap3lQS+iokwGbz NB4wcCi2WB79PHeweBWHQoQ48X7743ikwmGLAvfttPqxcb4s8BdBBkYzk/8R/wLwlIRm BUO0wppfe4S2JeqxOaBA0SRjYZEhyaDuwJVeZrBNbdfxUE8aA+jYXSUFX1fnBQBJF0At FOIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xlU+oaen; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k197-20020a636fce000000b00577f4d85fdbsi2526474pgc.548.2023.11.01.00.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 00:31:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xlU+oaen; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 5B3CC807EB91; Wed, 1 Nov 2023 00:30:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230434AbjKAHaH (ORCPT + 99 others); Wed, 1 Nov 2023 03:30:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230206AbjKAHaF (ORCPT ); Wed, 1 Nov 2023 03:30:05 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6039EC2 for ; Wed, 1 Nov 2023 00:30:00 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D441C433C8; Wed, 1 Nov 2023 07:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698823800; bh=VeAKvTqavtEz9Y6S8VCa+9Li/lCoIJxJGeZcquOfX/Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xlU+oaenAgZ4Pzjkhl//+DWTuWwRTojw7tjHP/L1NUNqK92BVT5p4ya7rzMhNpcaj A2K5IVAXq4p6D0yvLagWX3NSw4UdH/PesM4lhubi+4LbaNDvVpIxBQQaa1MHYuruav rNvz/q49+fkuxIuKaJKypMy9y554SNMSzFNSrMgI= Date: Wed, 1 Nov 2023 08:29:57 +0100 From: Greg KH To: Xingxing Luo Cc: b-liu@ti.com, keescook@chromium.org, nathan@kernel.org, ndesaulniers@google.com, trix@redhat.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev, xingxing0070.luo@gmail.com, Zhiyong.Liu@unisoc.com, Cixi.Geng1@unisoc.com, Orson.Zhai@unisoc.com, zhang.lyra@gmail.com Subject: Re: [PATCH V2] usb: musb: Check requset->buf before use to avoid crash issue Message-ID: <2023110144-sequence-twistable-3580@gregkh> References: <20231101071421.29462-1-xingxing.luo@unisoc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231101071421.29462-1-xingxing.luo@unisoc.com> X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 01 Nov 2023 00:30:34 -0700 (PDT) On Wed, Nov 01, 2023 at 03:14:21PM +0800, Xingxing Luo wrote: > When connecting USB to PC, there is a very low probability of kernel > crash. The reason is that in ep0_txstate(), the buf member of struct > usb_request used may be a null pointer. Therefore, it needs to > determine whether it is null before using it. > > [ 4888.071462][T597@C0] Call trace: > [ 4888.071467][T597@C0] musb_default_write_fifo+0xa0/0x1ac [musb_hdrc] > [ 4888.087190][T597@C0] musb_write_fifo+0x3c/0x90 [musb_hdrc] > [ 4888.099826][T597@C0] ep0_txstate+0x78/0x218 [musb_hdrc] > [ 4888.153918][T597@C0] musb_g_ep0_irq+0x3c4/0xe10 [musb_hdrc] > [ 4888.159663][T597@C0] musb_interrupt+0xab4/0xf1c [musb_hdrc] > [ 4888.165391][T597@C0] sprd_musb_interrupt+0x1e4/0x484 [musb_sprd] > [ 4888.171447][T597@C0] __handle_irq_event_percpu+0xd8/0x2f8 > [ 4888.176901][T597@C0] handle_irq_event+0x70/0xe4 > [ 4888.181487][T597@C0] handle_fasteoi_irq+0x15c/0x230 > [ 4888.186420][T597@C0] handle_domain_irq+0x88/0xfc > [ 4888.191090][T597@C0] gic_handle_irq+0x60/0x138 > [ 4888.195591][T597@C0] call_on_irq_stack+0x40/0x70 > [ 4888.200263][T597@C0] do_interrupt_handler+0x50/0xac > [ 4888.205196][T597@C0] el1_interrupt+0x34/0x64 > [ 4888.209524][T597@C0] el1h_64_irq_handler+0x1c/0x2c > [ 4888.214370][T597@C0] el1h_64_irq+0x7c/0x80 > [ 4888.218525][T597@C0] __check_heap_object+0x1ac/0x1fc > [ 4888.223544][T597@C0] __check_object_size+0x10c/0x20c > [ 4888.228563][T597@C0] simple_copy_to_iter+0x40/0x74 > [ 4888.233410][T597@C0] __skb_datagram_iter+0xa0/0x310 > [ 4888.238343][T597@C0] skb_copy_datagram_iter+0x44/0x110 > [ 4888.243535][T597@C0] netlink_recvmsg+0xdc/0x364 > [ 4888.248123][T597@C0] ____sys_recvmsg.llvm.16749613423860851707+0x358/0x6c0 > [ 4888.255045][T597@C0] ___sys_recvmsg+0xe0/0x1dc > [ 4888.259544][T597@C0] __arm64_sys_recvmsg+0xc4/0x10c > [ 4888.264478][T597@C0] invoke_syscall+0x6c/0x15c > [ 4888.268976][T597@C0] el0_svc_common.llvm.12373701176611417606+0xd4/0x120 > [ 4888.275726][T597@C0] do_el0_svc+0x34/0xac > [ 4888.279795][T597@C0] el0_svc+0x28/0x90 > [ 4888.283603][T597@C0] el0t_64_sync_handler+0x88/0xec > [ 4888.288548][T597@C0] el0t_64_sync+0x1b4/0x1b8 > [ 4888.292956][T597@C0] Code: 540002c3 53027ea8 aa1303e9 71000508 (b840452a) > [ 4888.299789][T597@C0] ---[ end trace 14a301b7253e83cc ]--- > > Fixes: 550a7375fe72 ("USB: Add MUSB and TUSB support") > Signed-off-by: Xingxing Luo > --- > v1 -> v2: - Fixed a spelling error > - Add the fixed commit id > > drivers/usb/musb/musb_gadget_ep0.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c > index 6d7336727388..19eb7a5e1fdc 100644 > --- a/drivers/usb/musb/musb_gadget_ep0.c > +++ b/drivers/usb/musb/musb_gadget_ep0.c > @@ -531,6 +531,11 @@ static void ep0_txstate(struct musb *musb) > > request = &req->request; > > + if (!request->buf) { > + musb_dbg(musb, "request->buf is NULL"); > + return; > + } > + > /* load the data */ > fifo_src = (u8 *) request->buf + request->actual; > fifo_count = min((unsigned) MUSB_EP0_FIFOSIZE, > -- > 2.17.1 > > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documentation/process/stable-kernel-rules.rst file for how to resolve this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot