From patchwork Sat Mar 23 01:01:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 10866687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 325EB925 for ; Sat, 23 Mar 2019 01:01:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BC4D2AA3A for ; Sat, 23 Mar 2019 01:01:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0051D2AA42; Sat, 23 Mar 2019 01:01:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98C782AA3A for ; Sat, 23 Mar 2019 01:01:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727526AbfCWBB5 (ORCPT ); Fri, 22 Mar 2019 21:01:57 -0400 Received: from mail-pf1-f177.google.com ([209.85.210.177]:42198 "EHLO mail-pf1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727512AbfCWBB4 (ORCPT ); Fri, 22 Mar 2019 21:01:56 -0400 Received: by mail-pf1-f177.google.com with SMTP id r15so2604282pfn.9 for ; Fri, 22 Mar 2019 18:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=08a8WZ5tv1n5kaK1zgbkhVuInfOhmCeXnWIJ9t7CUEc=; b=HIX64bNb8K3+Jd8bpxLZnXGWGupXyA+H9Qm63/Xz2v2kUEUzcCZKVjXC3HL63pQCUE ivZLIpGPt23qQUOmrO/ogImiCDKf/WziRQGOiZ86CB4KsIRwEFOaLvhFo97J17IlHhqm M59UW6JFA2ig4JERf2HuPoM+peZhmNVEgx14n9RbrXjJMDYmyWtokNucB+zAAO8G3bj9 ei5i+q55hIpkAwBgBhvH4LjQB2YYT3hMMaa99iflqSiJqQ55k6L4/mG0VnQKCgvTMSFZ UCuHQ8Tw3x+IBBcwK60uqqAlmgNxWdOM1JAwjnrOii2nERqPweFqnLWFZ6e3SXjz8vKd W43g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=08a8WZ5tv1n5kaK1zgbkhVuInfOhmCeXnWIJ9t7CUEc=; b=GuT6ysAHho5f/37J7IFKsJwWDjWvwIhCSloBnqjpdIclNsDtXBF7TX8UIQi0UeNLIo WkDkzCRu6VDkoUKBHuAPpKgwpYtfn/owq0eVDzjLrfn+g/SpeTTl2Qv3cPoFDF4WJey+ mwLNmGBB4uCH5DX6dmp8IkZnqbK0pVhGgRoH78/qAAKoC3b0ZonahVA88p6Nx3OjOezz JfNvYeq9B9tIYNHQHsvGFjKx/wbjR7n+rjnQqlsldWGveZWeU+bXc6trZzFZDUZcbteV 5tIb1IdD+p0VVJXHnltxwtTI8/5pGtJbYBvpV1CFyMIBLFcq5j0maJxOTR949dhbgQ1b h9Pg== X-Gm-Message-State: APjAAAWt9JuVZY5zm2okWfTFrr47ROPUDePf1OeGLaszT3wKGBx0jvS9 +ruCc0tZ7S7Kh2KWhg4VNelPb/B9t+ugsgUmzwY= X-Google-Smtp-Source: APXvYqwa1bJfPmIosCWnLwIvjCjGQOyS+4Hpxl/Q0nIZPsIQmf/A4a54SDVygFo3lBceEoI4AMGH4z+K8JxcCyhT4/E= X-Received: by 2002:a63:c06:: with SMTP id b6mr11824672pgl.440.1553302915519; Fri, 22 Mar 2019 18:01:55 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Fri, 22 Mar 2019 20:01:43 -0500 Message-ID: Subject: [PATCH] Fix guest smb3.1.1 mounts to Samba To: ronnie sahlberg , CIFS Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add to Ronnie's patch check for null user so we can handle guest mounts for 3.1.1 to Samba as well From 5f377dd082fe24ced7fd5a8d31d7fac3af5686b9 Mon Sep 17 00:00:00 2001 From: Steve French Date: Fri, 22 Mar 2019 19:52:29 -0500 Subject: [PATCH] SMB3: Fix SMB3.1.1 guest mounts to Samba Workaround problem with Samba responses to SMB3.1.1 null user (guest) mounts. The server doesn't set the expected flag in the session setup response so we have to do a similar check to what is done in smb3_validate_negotiate where we also check if the user is a null user. Note that the commit below tightened the conditions and forced signing for the SMB2-TreeConnect commands as per MS-SMB2. However, this should only apply to normal user sessions and not for cases where there is no user (even if server forgets to set the flag in the response) since we don't have anything useful to sign with. This is especially important now that the more secure SMB3.1.1 protocol is in the default dialect list. An earlier patch ("cifs: allow guest mounts to work for smb3.11") fixed the guest mounts to Windows. Fixes: 6188f28bf608 ("Tree connect for SMB3.1.1 must be signed for non-encrypted shares") Reviewed-by: Ronnie Sahlberg CC: Stable Signed-off-by: Steve French --- fs/cifs/smb2pdu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 8e4a1da95418..4cdf26e39426 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1631,10 +1631,13 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, /* * 3.11 tcon req must be signed if not encrypted. See MS-SMB2 3.2.4.1.1 * unless it is guest or anonymous user. See MS-SMB2 3.2.5.3.1 + * (Samba servers don't always set the flag so also check if null user) */ if ((ses->server->dialect == SMB311_PROT_ID) && !smb3_encryption_required(tcon) && - !(ses->session_flags & (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL))) + !(ses->session_flags & + (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL)) && + (ses->user_name != NULL)) req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED; memset(&rqst, 0, sizeof(struct smb_rqst)); -- 2.17.1