Received: by 10.192.165.156 with SMTP id m28csp1146125imm; Wed, 11 Apr 2018 13:17:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx48IuZWVjVh9VS4dXRGf2O1dh88j8H8n6jEWXu7OdlcbE87lIdlx+CR+ieTWXg8N3T25zWV+ X-Received: by 10.99.190.75 with SMTP id g11mr4468293pgo.127.1523477875588; Wed, 11 Apr 2018 13:17:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523477875; cv=none; d=google.com; s=arc-20160816; b=c5F/Gf6hIoa66En3m+jjVZDC6uXLbA2A6wPhOIJxY/hMRqN/YPGmvV4KU7y5NdAklX Cyco9MztC741sU1TVx06wyQIePHnFK5Q80aYemzbVkjXF5DaZwN258fcCUHjjYOvxsBy Mihb/fCix8jYp1bM+33Wy9VKgePFMDTeEiFXy2nSFvDyC7jdrE6S2wchoiREHp/DscPt Ej8gW2ikH9qMcIhaHCCLqaVYqlcq21K2FQgANl34pwBDRbuU00GnAk/CQWPoM2WgKZus Rdbb9keDa+FULRr92vyXdv1iD1Tdfzqv8uXRFT3cJuoYKk+YeFA2/1yix7ia9BWeaLNJ SFWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=nX1r9WX35Nh4mHRZHLUJB5DTr+SF40zf0nRzHhz2FvQ=; b=g5CHTHuu5kryYZcDXM04mO40StS1kHjEiVj1TtCfho4ieuLkHMipuPNU3PzFja9ruY pcT3kZkfhClwwkNGR3cadpfeQe4pX1NuRqSRqdT+uGZM1uIj5WHhE7+idvASBIB5S9TU 6P9I3nkxdmkzE3d2bsecLg4N9Ek1fT/T1Gv/lm2hYeFe/GHt61DNxqFQI/+7JH8C+gc4 XJp7gK3JkNYc2o7CamlLWoL+4DLA32j8ooOj1Hjgnznzu406hmz4AtiBHzqBbxQPGp44 XaUOQM5TVH+UB7qPnARim7QYzSvU5KOq0HMtLUBldDm/o29sJOmJLIvfpEHVJB+kVD1V JMSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n4si1214214pgt.450.2018.04.11.13.17.18; Wed, 11 Apr 2018 13:17:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757093AbeDKUML (ORCPT + 99 others); Wed, 11 Apr 2018 16:12:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34120 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933422AbeDKSyJ (ORCPT ); Wed, 11 Apr 2018 14:54:09 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7E731EBE; Wed, 11 Apr 2018 18:54:08 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Aurelien Aptel , Steve French , Sasha Levin Subject: [PATCH 4.9 039/310] SMB2: Fix share type handling Date: Wed, 11 Apr 2018 20:32:58 +0200 Message-Id: <20180411183623.957255701@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christophe JAILLET [ Upstream commit cd1230070ae1c12fd34cf6a557bfa81bf9311009 ] In fs/cifs/smb2pdu.h, we have: #define SMB2_SHARE_TYPE_DISK 0x01 #define SMB2_SHARE_TYPE_PIPE 0x02 #define SMB2_SHARE_TYPE_PRINT 0x03 Knowing that, with the current code, the SMB2_SHARE_TYPE_PRINT case can never trigger and printer share would be interpreted as disk share. So, test the ShareType value for equality instead. Fixes: faaf946a7d5b ("CIFS: Add tree connect/disconnect capability for SMB2") Signed-off-by: Christophe JAILLET Acked-by: Aurelien Aptel Signed-off-by: Steve French Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/cifs/smb2pdu.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1151,15 +1151,19 @@ SMB2_tcon(const unsigned int xid, struct goto tcon_exit; } - if (rsp->ShareType & SMB2_SHARE_TYPE_DISK) + switch (rsp->ShareType) { + case SMB2_SHARE_TYPE_DISK: cifs_dbg(FYI, "connection to disk share\n"); - else if (rsp->ShareType & SMB2_SHARE_TYPE_PIPE) { + break; + case SMB2_SHARE_TYPE_PIPE: tcon->ipc = true; cifs_dbg(FYI, "connection to pipe share\n"); - } else if (rsp->ShareType & SMB2_SHARE_TYPE_PRINT) { - tcon->print = true; + break; + case SMB2_SHARE_TYPE_PRINT: + tcon->ipc = true; cifs_dbg(FYI, "connection to printer\n"); - } else { + break; + default: cifs_dbg(VFS, "unknown share type %d\n", rsp->ShareType); rc = -EOPNOTSUPP; goto tcon_error_exit;