Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3527805pxf; Mon, 15 Mar 2021 11:33:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzx2/d9yHG80vhOZb1/EDjELd5AEK3NU4qdorNSQAwW7NbIT26NXKUbJgdwO5p9eGc4BMKu X-Received: by 2002:a05:6402:c11:: with SMTP id co17mr32266611edb.246.1615833189146; Mon, 15 Mar 2021 11:33:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833189; cv=none; d=google.com; s=arc-20160816; b=uvlwymENTCbfcS/A+XNGq+09JAIYkBq/CRRUNxQstQGXYHPycYUH30gHR3iS69ZPG3 eoMyzEUlCzXh0Jj9oNIQAOUIUcdYRdEhmGPlHOG/b+x8iPQ+/9L5d3N2l/XDe87RV4YK V1CaLSAbxikMnGiD/DjBMiaWjYgOQDONgX7ziNkb7C/AB876pwzW0kdk0DIF5gJ6LFaC Edc1nqNh/V5FS7ilIG3A7uqUBnvLuaJvChUCQuNH4LXOeRcl9z+G2rCD34KINmBPihYI qiFeDFPXv4R3HPfap+zXTyvCiRCiZBU0UscC4McyO9Wwh7tcq98JGjYfTWDNg4QLQm5p kHtA== 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=vfTphZNQy+i/7IJoD3u3KNex9QOfQPjGMVTq/jkGeGZn1iFN99RJY6tOvv7omzhmht IIbMnyAt6/PWDi26BDR8H2JzXRr2uMo8ToHSsoFjULlpk6XRKZrcEk5RXRYh787W4TWh V83Fk7sD327+lrPrGH+g+GHUa6HkUhdJ7GxA6PZfdOAfJAxWybQzQpW4Pfl4JovlZn8J pmrwZIce9Y8JBJPHi7A/s/87JC4hGu/z5TVX9dWVxSreoGM1eClLyF3GfTkjU2EM2GWh RRVoS6CW0zrMM05JCe4Yh7476BIXWaR72cHw0PmjoXz47ccqdcHItfTNnPyJmG/is0A8 sgGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IIOPrjVp; 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 s18si12435800ejj.88.2021.03.15.11.32.46; Mon, 15 Mar 2021 11:33:09 -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=IIOPrjVp; 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 S237900AbhCOOld (ORCPT + 99 others); Mon, 15 Mar 2021 10:41:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:49294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234015AbhCOOCs (ORCPT ); Mon, 15 Mar 2021 10:02:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9778464E83; Mon, 15 Mar 2021 14:02:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816967; bh=Z6zOcIPe8C4x6d3GhlWcunOtUQl88DPN2oo6keWNqv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IIOPrjVp7vjRI+9TPFdnVMtKqR8l5PXYUVc5tGPu1Od/czavIOYD+TXeZHTf95L7m fkpc+dRNb7oyYLSENn09W57r73G8TKaBvGq6VtNBpxxp4CuZwJPfjsitWYaGqHT4Dt CryFDHFYq8FZTbfp3NNBjiDhRTO19cb8gc0pSP8Q= 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.10 218/290] usbip: fix vudc to check for stream socket Date: Mon, 15 Mar 2021 14:55:11 +0100 Message-Id: <20210315135549.336845919@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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: