From patchwork Tue Jul 12 05:34:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1655190 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=pZjMKJL1; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by bilbo.ozlabs.org (Postfix) with ESMTP id 4LhqFV1svNz9s07 for ; Tue, 12 Jul 2022 15:34:38 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229515AbiGLFef (ORCPT ); Tue, 12 Jul 2022 01:34:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229731AbiGLFee (ORCPT ); Tue, 12 Jul 2022 01:34:34 -0400 Received: from mail-vs1-xe2d.google.com (mail-vs1-xe2d.google.com [IPv6:2607:f8b0:4864:20::e2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 052AD193ED for ; Mon, 11 Jul 2022 22:34:33 -0700 (PDT) Received: by mail-vs1-xe2d.google.com with SMTP id 189so6864160vsh.2 for ; Mon, 11 Jul 2022 22:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to:cc; bh=LGs9JyoVpvCiq2kVkyuR1T4N2KrkXSFfXc1vKiYlBUw=; b=pZjMKJL1y+hW5NBl8ezagz/tDW6wST8LZ6Ly9iVT2VOcjbYSaYUkAfSu6hJr6IZbuk ENrx5D+6R480CP6BC9OWUmzG+QX45HB1WZ8Wa9kVh5UTaL4+t1KpNJFcbv9TU2wXz/Z5 wi3BZdMaQPhI6fdEU5g6cPy5wiJElsPScqmnmFog+Rwmg/FiwKijBQeWnQMFdMIQR97f cpelQDlWRDwwg2MCMemv4GacM/xr5lVXjcis+gx+TWTNzsmpUke5UI+BylWhyzQzh/LS BHj9iDf5dujYOTrehxe44itVEcwgss5JP85/dw52qDMsqQnvpbBpSrVWN5oyt9agYgO2 /CAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=LGs9JyoVpvCiq2kVkyuR1T4N2KrkXSFfXc1vKiYlBUw=; b=yy8uVVK5EOsj1ZGrIJBgzfnNw2Mm+SIWXLaExf/Z6wZW6FwLvYzpM72zZertY0St6q RH7LiWJKd1BtZKrJLpjcIop+el7yXW3KSgfgV7B15bV5+VUynJDJayXAMKhI4ksB4qW9 Dh7sherF1LSRH4cUVptdH4x3O5NabiwkpLTtZR5+uN8u+uYy4nYZXLQAd7E13trgIUJq coy4WDE2JAPWMrg/deH/yzVjJNj72TktR6aNEhLhGEkgpFXhw55p5b8AOoZqjLbW+DHg UMMuOSz6dWrTJUIA48a8NZtSFbtQk5QGbTsBvRcwmGHLfVgv7IzkUDqy89r4uCBpG8Dh zeEQ== X-Gm-Message-State: AJIora+BeLkx1PhFwy75+9PNrNTHazog1ap51GlpoDQ1ZPpnuHllzYsd nRexRJDLOKp1cYOJ4LIRHO9be5IGWIdY1xQkfPOFVXMW+pE4vw== X-Google-Smtp-Source: AGRyM1tuc1bOmS5NfSmyHLMQgHxXONpP1zjOIaaUQg0QsSlhadPuiPtNsxdBPtW0lYod8X1A8tu8Dpzijurv3Fq4ijk= X-Received: by 2002:a67:6d86:0:b0:357:3d99:ec77 with SMTP id i128-20020a676d86000000b003573d99ec77mr6931141vsc.6.1657604071919; Mon, 11 Jul 2022 22:34:31 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Tue, 12 Jul 2022 00:34:21 -0500 Message-ID: Subject: [PATCH][SMB3] workaround negprot bug in some Samba servers by changing order of negcontexts sent by Linux kernel client To: CIFS , samba-technical Cc: Paulo Alcantara , Shyam Prasad N , "Stefan (metze) Metzmacher" , Julian Sikorski , Brian Caine X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Starting with 5.18.8 (and 5.19-rc4) mount can now fail to older Samba servers due to a server bug handling padding at the end of the last negotiate context (negotiate contexts typically round up to 8 byte lengths by adding padding if needed). This server bug can be avoided by switching the order of negotiate contexts, placing a negotiate context at the end that does not require padding (prior to the recent netname context fix this was the case on the client). Fixes: 73130a7b1ac9 ("smb3: fix empty netname context on secondary channels") See attached fix to cifs.ko Tested-by: Julian Sikorski From a8d8532e4c335f0a31dd213abe4e31682f34647c Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 12 Jul 2022 00:11:42 -0500 Subject: [PATCH] smb3: workaround negprot bug in some Samba servers Mount can now fail to older Samba servers due to a server bug handling padding at the end of the last negotiate contexts (negotiate contexts typically round up to 8 byte lengths by adding padding if needed). This server bug can be avoided by switching the order of negotiate contexts, placing a negotiate context at the end that does not require padding (prior to the recent netname context fix this was the case on the client). Fixes: 73130a7b1ac9 ("smb3: fix empty netname context on secondary channels") Reported-by: Julian Sikorski Signed-off-by: Steve French --- fs/cifs/smb2pdu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 12b4dddaedb0..c705de32e225 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -571,10 +571,6 @@ assemble_neg_contexts(struct smb2_negotiate_req *req, *total_len += ctxt_len; pneg_ctxt += ctxt_len; - build_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt); - *total_len += sizeof(struct smb2_posix_neg_context); - pneg_ctxt += sizeof(struct smb2_posix_neg_context); - /* * secondary channels don't have the hostname field populated * use the hostname field in the primary channel instead @@ -586,9 +582,14 @@ assemble_neg_contexts(struct smb2_negotiate_req *req, hostname); *total_len += ctxt_len; pneg_ctxt += ctxt_len; - neg_context_count = 4; - } else /* second channels do not have a hostname */ neg_context_count = 3; + } else + neg_context_count = 2; + + build_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt); + *total_len += sizeof(struct smb2_posix_neg_context); + pneg_ctxt += sizeof(struct smb2_posix_neg_context); + neg_context_count++; if (server->compress_algorithm) { build_compression_ctxt((struct smb2_compression_capabilities_context *) -- 2.34.1