Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3526652pxf; Mon, 15 Mar 2021 11:31:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvzni1nYd+30gmaS3DUV1KFCnz6d3t6H7XUtY8V6AdvqWStZRy1xvwRtQLoKIWqXDl7QYd X-Received: by 2002:a17:906:4150:: with SMTP id l16mr25473182ejk.90.1615833099752; Mon, 15 Mar 2021 11:31:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833099; cv=none; d=google.com; s=arc-20160816; b=Zb5PAPKiF8yRtHi1HCQ6jQIrP9GjnS2a2DxWPsBoOrX/SGSqZR2qxVl6weiGXHwHab NuLxsC6FRQuran72By2vkJGGI6+XC8Mdg4LKFQel9BSUvHpDbJVRW2WCO+GjzBEOrPnV z5CnIT89x7Re7XR9eKWkJbARPE/vgA4DZgMXwxl5uGAMLzcgxPvNoU6UYI5IK/eDAGA1 +ZDoGoZWEbQt8wDQFSX3uoMqUqD+v8tWQgMtEtdUC69yrbPS1oSQ3pgZ1WDGQyJwG5Kv v246QPpcLJWowN5VZST/1dhkulfEy8bJlkW78kKqFau4I+W5LfiXVAGjr40ghjKdACut xeww== 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=nn9T1gE4pBm5A3jUbuJQe1T1xzMKJSMaA8R8sWO4A+ukfHO+CuJ3mAtvjwSS3Aygrj 9xsQM99/ylMaiFcA3V7VIMOcmQEwUv5vMzlIsN1cznoLjBAtm5WpJ6tqUH0wtIlSZYGN HZPqOfRIVNc6ghGSHkxSzL1kd8vBmgd0yBj238eVisllkNq8NNvl0Uhyaj4qXIEr/qnX PtSSOt2dmRqfdzXvMo4rT1AxBjIZKuiAegm6snELkd6/3KAOa3tyRCOkzPzVmUcig1KH Ul2NjU/iQTaM5e7Sxh0UkYx/2OWMwGqgOGGuRrS+1nh1UtUBbSbHppXrEoiNvbv5z/RC oOXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1X5A9JY6; 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 a12si12190619ejy.363.2021.03.15.11.31.17; Mon, 15 Mar 2021 11:31:39 -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=1X5A9JY6; 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 S236521AbhCOOjD (ORCPT + 99 others); Mon, 15 Mar 2021 10:39:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:48920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233680AbhCOOCS (ORCPT ); Mon, 15 Mar 2021 10:02:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6C08064F2F; Mon, 15 Mar 2021 14:02:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816935; bh=F54PcwDAnn2FMWaao0DWhknqEzjDpPH545XJu/fYX0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1X5A9JY6ieBoYHC0ESFUD7VvIjD9XPErZ5oth0A5AwrYoQJcsOYmgGQwmgn1Z07Xe soKMAjhxoKinlNXLNWqReHVxgXiKLuT+CtLQZLm7tcR3dTLrKfc9ic0szkCtqBxLtp s/K2e2jlbwMMkdUDBLIsDEL8/F4tSuBR5DIqjBos= 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.11 213/306] usbip: fix vhci_hcd to check for stream socket Date: Mon, 15 Mar 2021 14:54:36 +0100 Message-Id: <20210315135514.826507431@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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 */