Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3526057pxf; Mon, 15 Mar 2021 11:30:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxBiTu9lAnps4d75bGu30l72/g/JrempoQ5CsXO5R85Y8+sGQIovJKy/lmLzcg7ncVI2YU X-Received: by 2002:a50:ed96:: with SMTP id h22mr20344518edr.39.1615833050882; Mon, 15 Mar 2021 11:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833050; cv=none; d=google.com; s=arc-20160816; b=zxkJILZbL6cufdFJ2WzNlEz1rYia4fpOktzfVHhAwuhxHa5ZBHNufh21WygJIzbZB6 /JdXeozuYCvd1P7JNW7meBvmzc24XNWMMcCijzjhoaR+F07vl6hcPBEJMpYUVKsVWjAx tew8E5YahQoL2+daX5MdHDrbx/KvIWeNmQnEg0Jl2zSCFP6kZOfVp9JAROnImvGTQkgr QeO+IyFyrgPDnWv6A8K3HRzmv5RfHmZtTkTPjKiwGt5fhtvHgeaVsBVJ1ti33h9qnihh YWx0bSP5/ni7UCirKt0x9NhlEKDR8vsVNiDkRM5zU8S7Caz++hlCxKfBBs803seeB4kC p1dw== 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=2QdlP6qrb+qCMm9BSs+q4jW3nswOwKNGsQ132Hl5n5Y=; b=mxGHaXMoa6TrtKMVGHJ+Po5/HfJEwj2UDotA0ZbJxCA1qnXkvt2wCwUZxxF/exVmW0 uqPCPxudqYk9a2ekE/sWHbr7Zys0uItryXCWOJRs0B95QSTdVxExYmiwuM7YaLV3nKRJ eRQZNFeqBntckTdau4GaQQBb+kByyXdZRiFYjbxr1WWnFoq+9MPbrODOoLc4ODJLUBTu VJhaRSHFAWgio46TfkynlRDXmSr40FCAcqXVobXCSs7G887zwmnvCvEX4cg+LU+7pUvZ 8DpmxB00VKkl8z15BgDCWvElkLgP1pbaTPP13YU/hd4FK398SqfnzFQdTqxKOtBEiYGm X4Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Kg9mzvXB; 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 oz17si12128652ejb.205.2021.03.15.11.30.28; Mon, 15 Mar 2021 11:30:50 -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=Kg9mzvXB; 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 S240033AbhCOOdZ (ORCPT + 99 others); Mon, 15 Mar 2021 10:33:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:35446 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233136AbhCOOAp (ORCPT ); Mon, 15 Mar 2021 10:00:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3961D64F45; Mon, 15 Mar 2021 14:00:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816813; bh=NX9WK/2pq7pVxaxWADhAwZ9yVx6pQzPj+THYddYS6tU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kg9mzvXB5NOIBi+E/KRbgeBF4CW/oDPBHYFbd2KXUemURSJPH9TATa30GMPVgC+sS 0Q9k/GZAoIVYSq3yrQw68DdwTbmsTPZvNLn+WaPZixP3pHYuxM3fMc77+I2Dymm8Ea s3msF56h5nvxXfeq3Fxb69hp0cHofP8ycbfYt8sE= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , Shuah Khan Subject: [PATCH 4.19 085/120] usbip: fix vudc to check for stream socket Date: Mon, 15 Mar 2021 14:57:16 +0100 Message-Id: <20210315135722.746459233@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135720.002213995@linuxfoundation.org> References: <20210315135720.002213995@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 | 10 ++++++++++ 1 file changed, 10 insertions(+) --- a/drivers/usb/usbip/vudc_sysfs.c +++ b/drivers/usb/usbip/vudc_sysfs.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "usbip_common.h" @@ -138,6 +139,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 +185,8 @@ static ssize_t usbip_sockfd_store(struct return count; +sock_err: + sockfd_put(socket); unlock_ud: spin_unlock_irq(&udc->ud.lock); unlock: