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 X-Spam-Level: X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62565C2BBD1 for ; Thu, 17 Sep 2020 15:41:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A11C2224F for ; Thu, 17 Sep 2020 15:41:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600357309; bh=Ek7j0W7fZJOyj5quMmPpneD18e0d2JvWRQ+kGtkl3F8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-ID:From; b=04f7UYK4dR/sWUjP2DZ9YRlwVWp2JaEXzbYuATfZPSkkJfCza0DyBUfeIryW6Tmhk CWokfyHizSKCHyiDrn4cyHJjL6qJDFu16dxwZq7JSQzmMxlxYVt8rnPuJ+AfCvjSmb w05Dy8trP1mNT+ayJ8PpTSr3L4kclpcoaFBlE+N0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728134AbgIQPlh (ORCPT ); Thu, 17 Sep 2020 11:41:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728120AbgIQPVM (ORCPT ); Thu, 17 Sep 2020 11:21:12 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA958C06174A for ; Thu, 17 Sep 2020 08:21:11 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id c10so2215283otm.13 for ; Thu, 17 Sep 2020 08:21:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=MTVVCrJVa8GUaPAcJjmBPCpJDItiRuSaBMYiXKb62FU=; b=iYZlm72Rmim58xVUQGXw4xVLjxW8sc4ZJsks9PXXs9yKAWaFXAGBJyn1wVZoptvzSf 546VR0MJqQn9jICAjPJspzktWQDV5PatKrdTpU3x2Ur4Fyv54fMqoPGds/BIi56gaMtF C6a+WBjlxkuIRPDK1rhR0jKN85MFZyNUHYgPg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=MTVVCrJVa8GUaPAcJjmBPCpJDItiRuSaBMYiXKb62FU=; b=cZpmer6YGZuvjnD0SMjshJjc/SWiQEG+/LJ8LKs1SoUQV9u2CX2iAPHP5EaGO+6NsC Py86SVG+EPbk1N4NukL06mIAOX9tIPMz+YgU2kgnmTL+tBX0qW8DNXWcHxdUUBv1Logd gSBV2JYsameSZga5jXwxReqS5J+9pgHFxoCA3w9qc6kvp2KPy7wjSHif3B5LGb5ZuB+a utL096QMKiGJSLfogSMDAy32KLn3TjQdmUT+oOqbq2iQDRA9Ems0SD6BVlvfNr0a4iKx H6rogbx1gD3CsbNJ8loKYgMCD9jgI+GrOWhnHwJhK16r2sh2JGPFYy1NBp+EF8WifDcv ZOQA== X-Gm-Message-State: AOAM530ph1iu8L/NKsTg8cBHGuscXMIYZXP00FOCVld7dEZp9tKHsFKe 2kxBKT+MeeXs/tYLk85XlGcn/g== X-Google-Smtp-Source: ABdhPJyYyPOcQ0DOIqvmXsmP4TVnPt7Wz94HKJTHhcrEzgh+sw123ahOhmwlWS3JMchquydogOZugQ== X-Received: by 2002:a9d:2d87:: with SMTP id g7mr963838otb.320.1600356069612; Thu, 17 Sep 2020 08:21:09 -0700 (PDT) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id s20sm107133oot.15.2020.09.17.08.21.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Sep 2020 08:21:09 -0700 (PDT) Subject: Re: [PATCH 3/3] usbip: Make the driver's match function specific To: "M. Vefa Bicakci" , linux-usb@vger.kernel.org Cc: Andrey Konovalov , stable@vger.kernel.org, Bastien Nocera , Valentina Manea , Shuah Khan , Greg Kroah-Hartman , Alan Stern , syzkaller@googlegroups.com, Shuah Khan References: <20200917144151.355848-1-m.v.b@runbox.com> <20200917144151.355848-3-m.v.b@runbox.com> From: Shuah Khan Message-ID: <45badff8-53e9-359d-4bf2-b0f71b910b2f@linuxfoundation.org> Date: Thu, 17 Sep 2020 09:21:06 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200917144151.355848-3-m.v.b@runbox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org On 9/17/20 8:41 AM, M. Vefa Bicakci wrote: > Prior to this commit, the USB-IP subsystem's USB device driver match > function used to match all USB devices (by returning true > unconditionally). Unfortunately, this is not correct behaviour and is > likely the root cause of the bug reported by Andrey Konovalov. > > USB-IP should only match USB devices that the user-space asked the kernel > to handle via USB-IP, by writing to the match_busid sysfs file, which is > what this commit aims to achieve. This is done by making the match > function check that the passed in USB device was indeed requested by the > user-space to be handled by USB-IP. > I see two patches 2/2 and 3/3 back to back. What is the difference between 2/2 and 3/3 versions? They look identical. Please include changes if any from version to version to make it easier for me to review. > Reported-by: Andrey Konovalov > Fixes: 7a2f2974f2 ("usbip: Implement a match function to fix usbip") > Link: https://lore.kernel.org/linux-usb/CAAeHK+zOrHnxjRFs=OE8T=O9208B9HP_oo8RZpyVOZ9AJ54pAA@mail.gmail.com/ > Cc: # 5.8 > Cc: Bastien Nocera > Cc: Valentina Manea > Cc: Shuah Khan > Cc: Greg Kroah-Hartman > Cc: Alan Stern > Cc: > Signed-off-by: M. Vefa Bicakci > --- > drivers/usb/usbip/stub_dev.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c > index 9d7d642022d1..3d9c8ff6762e 100644 > --- a/drivers/usb/usbip/stub_dev.c > +++ b/drivers/usb/usbip/stub_dev.c > @@ -463,7 +463,20 @@ static void stub_disconnect(struct usb_device *udev) > > static bool usbip_match(struct usb_device *udev) > { > - return true; > + bool match; > + struct bus_id_priv *busid_priv; > + const char *udev_busid = dev_name(&udev->dev); > + > + busid_priv = get_busid_priv(udev_busid); > + if (!busid_priv) > + return false; > + > + match = (busid_priv->status != STUB_BUSID_REMOV && > + busid_priv->status != STUB_BUSID_OTHER); > + > + put_busid_priv(busid_priv); > + > + return match; > } > > #ifdef CONFIG_PM > Did you happen to run the usbip test on this patch? If not, can you please run tools/testing/selftests/drivers/usb/usbip/usbip_test.sh and make sure there are no regressions. thanks, -- Shuah