Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3354365pxf; Mon, 15 Mar 2021 07:50:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztcgckuBycfSmsu7+vATRY8KawPQbEomKCrHR1QcBKlnBLEYU12l1kMk1QXPpYI5KQ5dAs X-Received: by 2002:a05:6402:2552:: with SMTP id l18mr29885628edb.71.1615819816664; Mon, 15 Mar 2021 07:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615819816; cv=none; d=google.com; s=arc-20160816; b=uj+7tFp9K0ThGlLduuCdgpcmMnSbdmT/3/lQx3X2Y8msUNlWxAEyzUFEDGKsqbVHVc +r7bh/gPbRgbnyoXc7OUUomCE0hfoTVN9c0wHuFDYIGCgTj+KrOuLCnoJ0v4xp8rqD9O nQRMW689l/f5+A1P97nvu+AV5OsX0txyLD090y9YZ2lKgkiB/m7+NlR/Zan5x1NdsWVg wz8Fa3tTNninfL9Ql0Fz7ptYgXhuVWeUv8CCrs96yFlBxHOP630S05Yx1pBfnD+EfGXa tp1nTKzm6Jv5Bth2SB+/OH6uQcJJRTvDWnE0tOSS9WecY/Fc7l/qadhBmECjArkHaNci 6vzA== 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=0r9gFcaHsd4bbNXvpHPHCizqWGACvgfr1l8tALss8uZtT17WTOqQDBTHx9HraSNtDg 6lzZjcg4czfI2TGbSt4gTp2jz+deGx9fjV5rG/fyRwBrFHafyievzMkT8XWED46Ack/D eSaR2JHRhX95OyvI58avGd5ZMmr1Rajyg+q2P4SGCc9wK0LfWJiqbBEFbbzVD86bEH2e ozfzQ5V7HgZCrWhkQls705VrPJveXMIlU2rqMWMRwqvth+DDp6qW7xGljYRJnxk8a4SV u3nALpPw3Jk4tvt3cHeVPtecbUe2hJpVo1Qj8uZhcsqMTKWOXb9QuHoaQYwC/oO2w7oE tckQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rGbTlBke; 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 co27si11338909edb.376.2021.03.15.07.49.53; Mon, 15 Mar 2021 07:50:16 -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=rGbTlBke; 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 S240747AbhCOOsC (ORCPT + 99 others); Mon, 15 Mar 2021 10:48:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:49274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233987AbhCOOCq (ORCPT ); Mon, 15 Mar 2021 10:02:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1A6DD64EFC; Mon, 15 Mar 2021 14:02:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816966; bh=F54PcwDAnn2FMWaao0DWhknqEzjDpPH545XJu/fYX0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rGbTlBke8R984vjDDsy/0+pdVZQHCNd/Ynv4G9dgZWajOcLZom5Op6Yz97i8wkr7z lNkvPdpariqBBGAKKNu7G905QGLGpkJRljsTK2+9GK0mHhQpT1fNJ23mQ8yMOSNTj9 tivLW5Dowfn89s+GlKZ4SI+mO37ok+8jrXajxQgY= 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 217/290] usbip: fix vhci_hcd to check for stream socket Date: Mon, 15 Mar 2021 14:55:10 +0100 Message-Id: <20210315135549.301771731@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 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 */