Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3522146pxf; Mon, 15 Mar 2021 11:25:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjwMsgCDgRg4aD7996xOGcRF7rDt/NBWVp4+lf23vvh5SLHBgWqp4jmNgRYvHketlCb68P X-Received: by 2002:a05:6402:1342:: with SMTP id y2mr31782387edw.285.1615832734420; Mon, 15 Mar 2021 11:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832734; cv=none; d=google.com; s=arc-20160816; b=eOhFHFjtmWaGoY4A7aD0jUyDOTzoEzKm5Ckw4Piu+tVzR5dNoxUQF24E7755SpPLfO U5m0xaubwRG5Mq3ho3k/NREqcLvtqr3J1ydIVdQCIgqbkGrRjsfbJTd4B4o1uM3njcBn 60LifatD5W//6UuL/74LoPNCdtsvd8l/in6BL9xk5+GfmjvBa+U2MZv0WeSTkKhEfXx3 3ppaGgtFqViRD38rrRilyCBFpnQAnt8BZnkbZpyy7Pwo97rXoW5jzixd1kUBjCPZzjMF sc3F0Hp48BwCYvwr7oIYsR0syir0QA5XT3onHEJuhayY7ih/Wj442WsWNPfYVqpFBXZf zXPQ== 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=KrpRL2ACQjkacXDMDMA7/P4GbSnEFtpbMjwfk6gGoT4=; b=EnanGk39P76SWK2Jyn7JOHXVcnSiYDHA0iKzDp0NlyFtAAYjMNSTN/jr0axdRlvVCk JIhfmgGpnN5/17tZBaoKQdfvtqQkS42tb5XsHBIefdUnJ5ROOGRbkuDyekIkyW814xaS 3sZP73XJd/cMBqMVW2uKpsuA6CIeDbNkcdqApJ6Q5xNb/J1VYyAfbtIdMvgsDIngiOXp nD1drhBoD2QE6Nv3Q9jurxuqrC28ZDHPbU3+kFSv8VSkXf9O5c+G3P1V3WNCSUAa61xv HCYXk0UAxID+BJM1LFeTgrvPE5tTHoac90qqK67fYp0kuGCBxpklMyRaJpIemMHvHHsA oJJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bvZdVIn8; 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 v18si11973941ejy.223.2021.03.15.11.25.12; Mon, 15 Mar 2021 11:25:34 -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=bvZdVIn8; 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 S238526AbhCOOX0 (ORCPT + 99 others); Mon, 15 Mar 2021 10:23:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:36764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232638AbhCOOAQ (ORCPT ); Mon, 15 Mar 2021 10:00:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A2F864EFC; Mon, 15 Mar 2021 14:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816802; bh=F54PcwDAnn2FMWaao0DWhknqEzjDpPH545XJu/fYX0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bvZdVIn85ggmmkzSUBkyPwJJLU/FQvoTi9GQkJSRL6C/4CccUw99XrpXY+eHxWbPp bybu5ATydSl4jw2Xlwji67dtAePzRxeO1p3kVWs7Mo8xEBikn6MN4cde7lXGbuJcko 5d6bhZCTmNe+DK2LkVVGlerHsSk1sLW6d9kJ8AOo= 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 120/168] usbip: fix vhci_hcd to check for stream socket Date: Mon, 15 Mar 2021 14:55:52 +0100 Message-Id: <20210315135554.305303546@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 f55a0571690c4aae03180e001522538c0927432f upstream. Fix attach_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/52712aa308915bda02cece1589e04ee8b401d1f3.1615171203.git.skhan@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usbip/vhci_sysfs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) --- a/drivers/usb/usbip/vhci_sysfs.c +++ b/drivers/usb/usbip/vhci_sysfs.c @@ -349,8 +349,16 @@ static ssize_t attach_store(struct devic /* Extract socket from fd. */ socket = sockfd_lookup(sockfd, &err); - if (!socket) + if (!socket) { + dev_err(dev, "failed to lookup sock"); return -EINVAL; + } + if (socket->type != SOCK_STREAM) { + dev_err(dev, "Expecting SOCK_STREAM - found %d", + socket->type); + sockfd_put(socket); + return -EINVAL; + } /* now need lock until setting vdev status as used */