Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3521961pxf; Mon, 15 Mar 2021 11:25:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZcrO6zFfwWSOlLfjLjeXnkXnizEBPcfFyuLNj58QOfNWQ8yhGV/0IBt0WTFSSYQGD8hvD X-Received: by 2002:a17:906:8147:: with SMTP id z7mr24227465ejw.436.1615832719212; Mon, 15 Mar 2021 11:25:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832719; cv=none; d=google.com; s=arc-20160816; b=jRR+TVkYSrsh6yzDNmvX1Og0c2VduOtIydMRbQ/EtuT6GFBTaCtkZHld5ldMXk+R/x OUlY/e8ohyXO3EeCygyy/5aR+Gz8eLwK9dCOoj/B29pGTJrfkRCkVrJ3tLC388WuilTW Vf6oxOcKiwfPLIw5dfdO3HgtNQVWkO9dQj0ZZ+jAEA5lKbXbVgFE9y1FBrdQw5e7hQg1 VnILNgNEe1brL35MRE+NA4UVXv5PlalMlk3u2GZkuX+07IPFqpdVOPPxQ7PXcrIMpX7U NjKzRfVhYkD1f90dcpeE7abd+em5NEkjEZ09v2kfkobvsqTsMP24oR08p0wvYleLXc60 lIQQ== 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=BKK5N9LPcj5VeRaOUOde5b+VU1VVOIbFLotglpYCT+BAPRgmM3nWAKoBfT2Kpd+YjM pyAUDQapf7wjztpP9O6VDWB5a5lo6x3X2P9uBmwukX2oxvI1eLmKtINJmY2YE71AbqY/ ugpKkSr6I2+VvJGNmN+necoUHjTEgtYTBFYswM96qoXeZgRsQB0bW2VMMxlTOpuwTV2H Gggz3M+EzytIw0Z5gp2U6Xl+DDl3s4FqIQwnRGxsJblPV+f2s+xXDpN2jEl0KLCd8qlf nA5xNpKWetDfe0KxtfGkziwBS7NLQqntLDA7XA3qLie0sS2h2CbTjW7YoPDOT4yOB+wT /cNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tztV26tu; 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 g19si11527014ejk.400.2021.03.15.11.24.57; Mon, 15 Mar 2021 11:25:19 -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=tztV26tu; 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 S233997AbhCOOZQ (ORCPT + 99 others); Mon, 15 Mar 2021 10:25:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:37476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbhCOOAT (ORCPT ); Mon, 15 Mar 2021 10:00:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A8D8464F00; Mon, 15 Mar 2021 14:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816803; bh=Z6zOcIPe8C4x6d3GhlWcunOtUQl88DPN2oo6keWNqv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tztV26tuwzvgureWDt+t+aSllJXl+VTWwRB4xCBBxsFOmAHf5au38c0VrxUWoo+S4 t4iK6zArSoSB9hEV8yBfGfA0sbHi072xHOgvTnDmswh261f3d8WCJOxTcmYbSCIMub BqZFiXZn4XmwdSygY6LOnw4BNoNCR5/+BEmfA/3g= 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.4 121/168] usbip: fix vudc to check for stream socket Date: Mon, 15 Mar 2021 14:55:53 +0100 Message-Id: <20210315135554.335733010@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@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: