Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3522571pxf; Mon, 15 Mar 2021 11:26:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzSBq0m860BP8ycDVJTcUGEdwVsbfLTDY+htrXXiRIJpQNYutv4flzEnc286G68h/c3HCG X-Received: by 2002:a05:6402:51d4:: with SMTP id r20mr31545600edd.112.1615832773341; Mon, 15 Mar 2021 11:26:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832773; cv=none; d=google.com; s=arc-20160816; b=anmJUakwZDcBfofFTzQNPmPn0ALKALYG3SkvBCUUPWeQPYkX60pFXubXzkhuWddbzo HT7muzRK+0Oijc4c+FCPKOok3eqQHE1wXckzCDXKr7lDaeCJ+NCfwtqfUeKsSC3CazOJ eCa4rYeK2uR1NB442KXNdnPQJkCm4jKvWMuD0U6VhJK/ROufoApIELPwq4SMqmLoKIHM q7TpRtNPyTZEXN10rDPqfLeKyXrLdvBL3IQJ2YWhHgG/t/Zs5kX7ONGoGAFm3m96PS6J 4lJTZzeJrtAjFh9WMYDuiL6IHnBlNlWGoOcdLOMaDtRJJtUlRqKE+cs1ALeg8Ymy4k+s +FTQ== 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=FDmowDRTclMzeNbI1x8PB+GA7CKdXadmNArFrj9BwXI1dH7odgVbRNq5qRo5WMChOI YtdIbQc7jTDjcios5fY9fG9h8aZqoSMeMygtB4ipj7+22wKRAwACGgBZpBz1+eJ0Phb3 u7H/pi1c0y7CPy6erpQQyCJTr3vmPFuPgGAhbScd1d6gU7csC4IrVL3+IGQxvid6cxQC t1KQ71Yi+7224PMtNPG9zGh8B08k/KmzDu3rka7hHg0qJ/PFbRLPyp2KiPRU+pmTQAri eIXSJiMt3VdmaBzL5VDfdWn9Bm7n2X6MnXa81YptBuPVCkUSJy8U9HlcdNhCxVzIY30M WkOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MhmUj1Nu; 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 a7si13303161edb.607.2021.03.15.11.25.50; Mon, 15 Mar 2021 11:26:13 -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=MhmUj1Nu; 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 S234343AbhCOOZn (ORCPT + 99 others); Mon, 15 Mar 2021 10:25:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:37522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233013AbhCOOAd (ORCPT ); Mon, 15 Mar 2021 10:00:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 88E6864F16; Mon, 15 Mar 2021 14:00:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816811; bh=F54PcwDAnn2FMWaao0DWhknqEzjDpPH545XJu/fYX0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MhmUj1NuBejK6oV+G4Mkesx+t27KGd7bIG7S2cz50L8rPtnQWjFd7UjiIYzhmeMo/ 4enMsAVe5gNaofFJkPixwoX0FVGF7ESvwG9r3nlZ2n7LkJ2ey/mzE2xMjxSytb/TUU pck0IlJMiVeD5Dwsp46PDz9F5/stFtLRjlAOSMMw= 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 084/120] usbip: fix vhci_hcd to check for stream socket Date: Mon, 15 Mar 2021 14:57:15 +0100 Message-Id: <20210315135722.714558186@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 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 */