From patchwork Mon Dec 8 22:46:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 5459551 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 5058D9F30B for ; Mon, 8 Dec 2014 22:47:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 49ADB2011E for ; Mon, 8 Dec 2014 22:47:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 391A62010C for ; Mon, 8 Dec 2014 22:46:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755257AbaLHWq6 (ORCPT ); Mon, 8 Dec 2014 17:46:58 -0500 Received: from mail-qa0-f47.google.com ([209.85.216.47]:56239 "EHLO mail-qa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755157AbaLHWq5 (ORCPT ); Mon, 8 Dec 2014 17:46:57 -0500 Received: by mail-qa0-f47.google.com with SMTP id s7so3962659qap.20 for ; Mon, 08 Dec 2014 14:46:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=sjJUyrowi4atBrbjM6tr4KZ15wglxw8KJ4PsOFk4SdM=; b=c4Jy19PwVPoWSB9fbhHb9yempxkvzm5mQPj65Wj2JFwAK7I8MBcGeaRiMdlACUf8M2 /EaBIYkI078Cld/5uqFumaLO9xVunpki9M4fbE4+F4Vor+YIhpr1YncRQL5JeiliOvOJ gTUNKKtgPm8ku+8lwIaqBY4E5YJeaf8L3oJ3vj0FQSzetP2Zy01GiFB/UJtTYXlJDpAS y1SMGqApR8pmm3dqAlUHK6YJ2UmgXb6BRqCF5rfvF+NhmE555DmmAUv2uNW3bEerP3T+ ZyDZcgrjYHSf2LzXt+jUpPu7aSNVlTM3fpiYNk7H3SjdooKMDVN7E8PbBx+FusoEZ+wj 2JdA== X-Received: by 10.140.32.38 with SMTP id g35mr53716451qgg.3.1418078817197; Mon, 08 Dec 2014 14:46:57 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.18.137 with HTTP; Mon, 8 Dec 2014 14:46:36 -0800 (PST) In-Reply-To: References: From: Steve French Date: Mon, 8 Dec 2014 16:46:36 -0600 Message-ID: Subject: Re: Revised patch to convert MessageID in smb2_hdr to LE To: "linux-cifs@vger.kernel.org" , Sachin Prabhu Cc: Shirish Pargaonkar Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, T_TVD_MIME_EPI,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 Resending (attaching patch) Redhat had encountered a problem with the SMB2/SMB3 message id (mid) on PPC - the message id was being considered opaque and endian neutral. Change the SMB2/SMB3 message id to be le64 on the wire (as we already do with cifs). Signed-off-by: Steve French CC: Sachin Prabhu --- fs/cifs/smb2misc.c | 12 +++++++----- fs/cifs/smb2ops.c | 2 +- fs/cifs/smb2pdu.h | 2 +- fs/cifs/smb2transport.c | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) get_next_mid(server); @@ -490,7 +490,7 @@ smb2_mid_entry_alloc(const struct smb2_hdr *smb_buffer, return temp; else { memset(temp, 0, sizeof(struct mid_q_entry)); - temp->mid = smb_buffer->MessageId; /* always LE */ + temp->mid = le64_to_cpu(smb_buffer->MessageId); temp->pid = current->pid; temp->command = smb_buffer->Command; /* Always LE */ temp->when_alloc = jiffies; From 5f8dedf52a787fa90dcbb7b450a715e3aa487621 Mon Sep 17 00:00:00 2001 From: Steve French Date: Mon, 8 Dec 2014 16:39:49 -0600 Subject: [PATCH] [SMB2] Fix SMB2/SMB3 endianness on PPC Redhat had encountered a problem with the SMB2/SMB3 message id (mid) on PPC - the message id was being considered opaque and endian neutral. Change the SMB2/SMB3 message id to be le64 on the wire (as we already do with cifs). Signed-off-by: Steve French CC: Sachin Prabhu --- fs/cifs/smb2misc.c | 12 +++++++----- fs/cifs/smb2ops.c | 2 +- fs/cifs/smb2pdu.h | 2 +- fs/cifs/smb2transport.c | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c index 1a08a34..6e01933 100644 --- a/fs/cifs/smb2misc.c +++ b/fs/cifs/smb2misc.c @@ -32,12 +32,14 @@ static int check_smb2_hdr(struct smb2_hdr *hdr, __u64 mid) { + __u64 wire_mid = le64_to_cpu(hdr->MessageId); + /* * Make sure that this really is an SMB, that it is a response, * and that the message ids match. */ if ((*(__le32 *)hdr->ProtocolId == SMB2_PROTO_NUMBER) && - (mid == hdr->MessageId)) { + (mid == wire_mid)) { if (hdr->Flags & SMB2_FLAGS_SERVER_TO_REDIR) return 0; else { @@ -51,11 +53,11 @@ check_smb2_hdr(struct smb2_hdr *hdr, __u64 mid) if (*(__le32 *)hdr->ProtocolId != SMB2_PROTO_NUMBER) cifs_dbg(VFS, "Bad protocol string signature header %x\n", *(unsigned int *) hdr->ProtocolId); - if (mid != hdr->MessageId) + if (mid != wire_mid) cifs_dbg(VFS, "Mids do not match: %llu and %llu\n", - mid, hdr->MessageId); + mid, wire_mid); } - cifs_dbg(VFS, "Bad SMB detected. The Mid=%llu\n", hdr->MessageId); + cifs_dbg(VFS, "Bad SMB detected. The Mid=%llu\n", wire_mid); return 1; } @@ -95,7 +97,7 @@ smb2_check_message(char *buf, unsigned int length) { struct smb2_hdr *hdr = (struct smb2_hdr *)buf; struct smb2_pdu *pdu = (struct smb2_pdu *)hdr; - __u64 mid = hdr->MessageId; + __u64 mid = le64_to_cpu(hdr->MessageId); __u32 len = get_rfc1002_length(buf); __u32 clc_len; /* calculated length */ int command; diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 568f323..e5b33d0 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -179,7 +179,7 @@ smb2_find_mid(struct TCP_Server_Info *server, char *buf) spin_lock(&GlobalMid_Lock); list_for_each_entry(mid, &server->pending_mid_q, qhead) { - if ((mid->mid == hdr->MessageId) && + if ((mid->mid == le64_to_cpu(hdr->MessageId)) && (mid->mid_state == MID_REQUEST_SUBMITTED) && (mid->command == hdr->Command)) { spin_unlock(&GlobalMid_Lock); diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index d84f46c..2d6d388 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -110,7 +110,7 @@ struct smb2_hdr { __le16 CreditRequest; /* CreditResponse */ __le32 Flags; __le32 NextCommand; - __u64 MessageId; /* opaque - so can stay little endian */ + __le64 MessageId; /* opaque - so can stay little endian */ __le32 ProcessId; __u32 TreeId; /* opaque - so do not make little endian */ __u64 SessionId; /* opaque - so do not make little endian */ diff --git a/fs/cifs/smb2transport.c b/fs/cifs/smb2transport.c index 5111e72..6bdee1b5 100644 --- a/fs/cifs/smb2transport.c +++ b/fs/cifs/smb2transport.c @@ -468,7 +468,7 @@ smb2_seq_num_into_buf(struct TCP_Server_Info *server, struct smb2_hdr *hdr) { unsigned int i, num = le16_to_cpu(hdr->CreditCharge); - hdr->MessageId = get_next_mid64(server); + hdr->MessageId = cpu_to_le64(get_next_mid64(server)); /* skip message numbers according to CreditCharge field */ for (i = 1; i < num; i++) get_next_mid(server); @@ -490,7 +490,7 @@ smb2_mid_entry_alloc(const struct smb2_hdr *smb_buffer, return temp; else { memset(temp, 0, sizeof(struct mid_q_entry)); - temp->mid = smb_buffer->MessageId; /* always LE */ + temp->mid = le64_to_cpu(smb_buffer->MessageId); temp->pid = current->pid; temp->command = smb_buffer->Command; /* Always LE */ temp->when_alloc = jiffies; -- 2.1.0