From patchwork Tue Aug 12 14:19:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 4712871 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 549A29F319 for ; Tue, 12 Aug 2014 14:20:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 38BC02014A for ; Tue, 12 Aug 2014 14:20:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 017EB20125 for ; Tue, 12 Aug 2014 14:20:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752541AbaHLOUE (ORCPT ); Tue, 12 Aug 2014 10:20:04 -0400 Received: from mail-qa0-f45.google.com ([209.85.216.45]:63178 "EHLO mail-qa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752240AbaHLOUD (ORCPT ); Tue, 12 Aug 2014 10:20:03 -0400 Received: by mail-qa0-f45.google.com with SMTP id cm18so8888807qab.32 for ; Tue, 12 Aug 2014 07:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=PwJ+pQJHalGvi3YM+/ot/yRakSfWxvPMrpCyXi6+UrU=; b=bNcC2vumxMeLkXJ+DCEdQuDMFiAbXgZtTfzjx/UV6z/GmMF3Y3jtBbBhaXniKcAnko mmK6vKCAQqwD57nR958NTGYftgGzl61tNaAzsUGF2/5KqceVxuRD/HfXt4ZWkMinHtIK 6Nf+QO8dCboYS9e/yuJFdOhWbEXelGXuUvawkLryfo8Qg9uMWuzMR1QqqGVpRk6YlZKR t4P9VVfhVHB2Zf9xgRo68ZcskywgUopW+sNuAuZc266a/Xyp17jNcgOsWbwvbQhYEC5n Jjnpe/1H3tCFcV0965YB7XNVgrU3CXl+yLigE0ht6oh9Mh9xbOE37Rvpj1E1LCOM/x+Z HXug== X-Received: by 10.224.95.6 with SMTP id b6mr7323668qan.17.1407853202861; Tue, 12 Aug 2014 07:20:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.101.107 with HTTP; Tue, 12 Aug 2014 07:19:42 -0700 (PDT) From: Steve French Date: Tue, 12 Aug 2014 09:19:42 -0500 Message-ID: Subject: [PATCH][CIFS] Workaround MacOS server problem with SMB2.1 write response To: "linux-cifs@vger.kernel.org" , linux-fsdevel , samba-technical Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Writes fail to Mac servers with SMB2.1 mounts (works with cifs though) due to them sending an incorrect RFC1001 length. Workaround this problem. MacOS server sends a write response with 3 bytes of pad beyond the end of the SMB itself. The RFC1001 length is 3 bytes more than the sum of the SMB2.1 header length + the write reponse. Since we have seen a few other examples where servers have padded responses strangely (oplock break and create), allow servers to send a padded SMB2/SMB3 response to allow for rounding (up to 15 bytes). Signed-off-by: Steve French --- fs/cifs/smb2misc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c index f2e6ac2..da05beb 100644 --- a/fs/cifs/smb2misc.c +++ b/fs/cifs/smb2misc.c @@ -181,6 +181,12 @@ smb2_check_message(char *buf, unsigned int length) /* server can return one byte more */ if (clc_len == 4 + len + 1) return 0; + + /* MacOS server pads after SMB2.1 write response with 3 bytes */ + /* of junk. Allow server to pad up to 15 bytes of junk at end */ + if ((clc_len < 4 + len) && (clc_len > 4 + len - 16)) + return 0; + return 1; } return 0;