Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3526795pxf; Mon, 15 Mar 2021 11:31:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwnUYMM3/dPkPb3Ewemtm1GRh0Bi6udyQQ6/7aMYhozW6IoudLKTPNA+9rLynxvMncLBMH X-Received: by 2002:a05:6402:3595:: with SMTP id y21mr31372243edc.233.1615833108083; Mon, 15 Mar 2021 11:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833108; cv=none; d=google.com; s=arc-20160816; b=sfisZKXBv8o0T1uGBVHP1wgCQR18PtuIcUIiBR5CyY3itqDAIr4o2yZ+ayXzAXTK6k oYbpUKKsXP1PNhaTWH3AON/xOcPsG8zKdmJFRS/XriRZi65LonVDbnb7l6tITMQXqQ1X R1726ssWP9iAIB9xsF16QY1Zce+bDC8Csawl5vn9/LZq2iIe5b71ydhR9cS/uqKV6LdA XTLEYixox7+TF61ygmubuj8aYpcLvu+fkVKc66ca+1zTJZsDsFwFBqlKh6tvoyMrpeWO simUP74Z2RA9XjYd0bkxM/RQjMdCJqTsqcDoRm3YHjYwipQ75dngOTCtIdqiA7b3VKg1 qvkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=waP6ojvxcdlzY8rRNYz+acPfCI1v0zNts70V+yx7vhI=; b=J7kIumt1LLfI9l2l3QHFYwcgD4rSrfd3WF2Kooyjzk8QQ5+9nrhhFyIzY7hOiHtpBz 3p2/LBhCJ8POqNkYLOej+ODVNIPV+ebowjky9XiZ22CwUC/TLruGcoF5yVB7QM/EL7R1 4VEIswn5/wgC7+wOXPK/Q5IbG7CRgaquhRa3MJ//pf4mNrkv/hoYfj0ZKV0ZYRn6zG4I TVIq/Em9PdA4CYrC7cDwROlburRaRU8MF+AzLouYuwaXxl7ES9W1OEZCy8bvlKg0Xcz/ 70nIGhWZkNod05yNR+XbUrExR1jbcYMqv5QcxId7SuYg93/uqe79/Sl8LmVTtZABfvXU 6joA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=amHIrClU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qh20si11124002ejb.749.2021.03.15.11.31.26; Mon, 15 Mar 2021 11:31:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=amHIrClU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236444AbhCOOjn (ORCPT + 99 others); Mon, 15 Mar 2021 10:39:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:48766 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233679AbhCOOCS (ORCPT ); Mon, 15 Mar 2021 10:02:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F2ACE64F2B; Mon, 15 Mar 2021 14:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816937; bh=Z6zOcIPe8C4x6d3GhlWcunOtUQl88DPN2oo6keWNqv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=amHIrClUF419Q5HSZYyLuKXemZLHAsy0GGrekxtjQ7wsn9EenSADEUgZ6J/Avgrrq KMD6Vl+pxylCPbw6Gr1hfz8hSZhPI0h5GPwW3QxTFVT3JndWd1vy8wvyPoS0j8E0g2 vbhJh4TC4MTLfcWSVuK9BAHocCr7GmkCTRQqOOdc= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , Shuah Khan Subject: [PATCH 5.11 214/306] usbip: fix vudc to check for stream socket Date: Mon, 15 Mar 2021 14:54:37 +0100 Message-Id: <20210315135514.857456498@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Shuah Khan commit 6801854be94fe8819b3894979875ea31482f5658 upstream. Fix usbip_sockfd_store() to validate the passed in file descriptor is a stream socket. If the file descriptor passed was a SOCK_DGRAM socket, sock_recvmsg() can't detect end of stream. Cc: stable@vger.kernel.org Suggested-by: Tetsuo Handa Signed-off-by: Shuah Khan Link: https://lore.kernel.org/r/387a670316002324113ac7ea1e8b53f4085d0c95.1615171203.git.skhan@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usbip/vudc_sysfs.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/drivers/usb/usbip/vudc_sysfs.c +++ b/drivers/usb/usbip/vudc_sysfs.c @@ -138,6 +138,13 @@ static ssize_t usbip_sockfd_store(struct goto unlock_ud; } + if (socket->type != SOCK_STREAM) { + dev_err(dev, "Expecting SOCK_STREAM - found %d", + socket->type); + ret = -EINVAL; + goto sock_err; + } + udc->ud.tcp_socket = socket; spin_unlock_irq(&udc->ud.lock); @@ -177,6 +184,8 @@ static ssize_t usbip_sockfd_store(struct return count; +sock_err: + sockfd_put(socket); unlock_ud: spin_unlock_irq(&udc->ud.lock); unlock: