Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1471303rdh; Mon, 25 Sep 2023 13:59:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpOQmUyf10fPcBcmuPt8K5jGRWOcn5+hx63pJjxDx/7Dcoz4Hk5YR5E+twFa3J5NxOJl59 X-Received: by 2002:a17:902:8e88:b0:1c5:d747:a124 with SMTP id bg8-20020a1709028e8800b001c5d747a124mr8225238plb.9.1695675581783; Mon, 25 Sep 2023 13:59:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695675581; cv=none; d=google.com; s=arc-20160816; b=O0PlT+L38eHVXElTaf3ex6i+DG7tyvqHLRgHvjt1D9UbH4q7ab1eSjgFG8wW+8PSXG HhUkmGhd9rZC/F/0MrJHNEl1MKjOt6ksEDJ/QX70cAV0Pu5O+ubZE1T7nN3QWS4gwqTx 5nnsHYGMj4PTNL8rhDZK09lFI+XH/zfIEOGRRazdl7WXkDnH9TtY0dgwwm/5Q7KvH+fg Xmq/TDF0ByBTjVdQNvsotciSuvre2VdqGds0oP9WNqJt5n5TcUZVuSo2IH0drxeVrvpO pkq5At+GCXkL3XUdl3pgqsVhEeElUb0cHzEqrzy0KETrcFMeqoo0gKZRqeVtfzlgMj7E I4gA== 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=WVoDJ/ZvbrhqQghXpcTHv9UT9gFGFQnEjaaPZmxjaQk=; fh=g1P5YvDdgVw7WYIuRN7UFAS81spdN2mK/TcEoHenghQ=; b=N8lbkko2mzvbyP94NSVxHKJYAnb7WRv6hYRVGgzpS5kMD2reCUr3rh2o3OXFhoIe+S lVVouCYX+es+ybCfkDONXf8FgyWg3vRljFNSKGXBbPrcynH62OhyCG9M7q40R09ruMhF WNxA5PmXIrqS5cQnwoBRe+anQA6+Ib9qHNJuNvmHaEC4oGyLD/pzHFe6bNJNsT5Ch698 wZjD4bQky0atsz8W1fIrlpE8c+2Y7w26qcmA7Lic3y8NhyC/i/4gkNOSD4IHr+jbGIeg q5l0FhUu2VyKYqWpdAUG73aKFD6FRLD8YT6dSyTiNDdZqDTtLmNaPT+IrSkYotTIEnKC 1Vkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qba3VSvM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id kn3-20020a170903078300b001bc6e60699dsi9914132plb.27.2023.09.25.13.59.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 13:59:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qba3VSvM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 E067781DE3A5; Mon, 25 Sep 2023 05:09:08 -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 S231664AbjIYMJF (ORCPT + 99 others); Mon, 25 Sep 2023 08:09:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231651AbjIYMIq (ORCPT ); Mon, 25 Sep 2023 08:08:46 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B477CCA for ; Mon, 25 Sep 2023 05:08:34 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BA89C433C8; Mon, 25 Sep 2023 12:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695643714; bh=2G0uOhtTT0RICzrpge27cbr0RwESvs2DqRkS9VKgySM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qba3VSvMi4VaMD2PSc5jvYmcYgW/cPnqPjRrFxmM/7jAhWsHixSZF3kFtsuSUP3m9 WsVYwAV7KIkWa+RwWIRSEBdGCRaOyKfrxiYbfe09hkaioJOi50SK0HUrY3ymIJaVRg ffqlnRHks88TbOEf9jViPh2Ocz94SO/W6CO0WijA= Date: Mon, 25 Sep 2023 14:08:30 +0200 From: Greg KH To: Jia-Ju Bai Cc: hminas@synopsys.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] usb: dwc2: fix possible NULL pointer dereference caused by driver concurrency Message-ID: <2023092521-shredder-sublime-97fe@gregkh> References: <20230925100741.799856-1-baijiaju@buaa.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230925100741.799856-1-baijiaju@buaa.edu.cn> X-Spam-Status: No, score=-0.9 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 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]); Mon, 25 Sep 2023 05:09:09 -0700 (PDT) On Mon, Sep 25, 2023 at 06:07:41PM +0800, Jia-Ju Bai wrote: > In _dwc2_hcd_urb_enqueue(), "urb->hcpriv = NULL" is executed without > holding the lock "hsotg->lock". In _dwc2_hcd_urb_dequeue(): > > spin_lock_irqsave(&hsotg->lock, flags); > ... > if (!urb->hcpriv) { > dev_dbg(hsotg->dev, "## urb->hcpriv is NULL ##\n"); > goto out; > } > rc = dwc2_hcd_urb_dequeue(hsotg, urb->hcpriv); // Use urb->hcpriv > ... > out: > spin_unlock_irqrestore(&hsotg->lock, flags); > > When _dwc2_hcd_urb_enqueue() and _dwc2_hcd_urb_dequeue() are > concurrently executed, the NULL check of "urb->hcpriv" can be executed > before "urb->hcpriv = NULL". After urb->hcpriv is NULL, it can be used > in the function call to dwc2_hcd_urb_dequeue(), which can cause a NULL > pointer dereference. > > This possible bug is found by a static tool developed by myself. Because of this please follow the rules for such things as documented in Documentation/process/researcher-guidelines.rst > To fix this possible bug, "urb->hcpriv = NULL" should be executed with > holding the lock "hsotg->lock". Because I have no associated hardware, > I cannot test the patch in real execution, and just verify it according > to the code logic. > > Fixes: 33ad261aa62b ("usb: dwc2: host: spinlock urb_enqueue") > Signed-off-by: Jia-Ju Bai My bot says: ----------- 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 Documetnation/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