Skip to contentSkip to conversation

Convert MessageID in smb2_hdr to LE

PATCH Superseded Sachin Prabhu 2 participants 3 messages Nov 14, 2014 – Nov 24, 2014 2 messages not in the archive

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Convert MessageID in smb2_hdr to LE

We have encountered failures when When testing smb2 mounts on ppc64 machines when using both Samba as well as Windows 2012.

On poking around, the problem was determined to be caused by the high endian MessageID passed in the header for smb2. On checking the corresponding MID for smb1 is converted to LE before being sent on the wire.

We have tested this using the RHEL 7 kernel where the patch fixes the issue.

---
 fs/cifs/cifsglob.h | 10 ++++++++--
 fs/cifs/smb2pdu.h  |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)
fs/cifs/cifsglob.h +8 -2
index 02a33e5..279fee8 100644
@@ -662,15 +662,21 @@ set_credits(struct TCP_Server_Info *server, const int val)
 }
 
 static inline __u64
-get_next_mid64(struct TCP_Server_Info *server)
+_get_next_mid64(struct TCP_Server_Info *server)
 {
 	return server->ops->get_next_mid(server);
 }
 
+static inline __le64
+get_next_mid64(struct TCP_Server_Info *server)
+{
+	return cpu_to_le64(_get_next_mid64(server));
+}
+
 static inline __le16
 get_next_mid(struct TCP_Server_Info *server)
 {
-	__u16 mid = get_next_mid64(server);
+	__u16 mid = _get_next_mid64(server);
 	/*
 	 * The value in the SMB header should be little endian for easy
 	 * on-the-wire decoding.
fs/cifs/smb2pdu.h +1 -1
index e3188ab..ac27eac 100644
@@ -110,7 +110,7 @@ struct smb2_hdr {
 	__le16 CreditRequest;  /* CreditResponse */
 	__le32 Flags;
 	__le32 NextCommand;
-	__u64  MessageId;	/* opaque - so can stay little endian */
+	__u64  MessageId;
 	__le32 ProcessId;
 	__u32  TreeId;		/* opaque - so do not make little endian */
 	__u64  SessionId;	/* opaque - so do not make little endian */
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1415972511-3150-1-git-send-email-sprabhu-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw

Can get_next_mid() as well as get_next_mid64() call server->ops->get_next_mid(server) directly i.e. cpu_to_le16(server->ops->get_next_mid(server) and

     cpu_to_le64(server->ops->get_next_mid(server) respectively

instead of them calling additional new function__get_next_mid64()?

Quoted 65 lines · Sachin Prabhu

We have encountered failures when When testing smb2 mounts on ppc64 machines when using both Samba as well as Windows 2012.

On poking around, the problem was determined to be caused by the high endian MessageID passed in the header for smb2. On checking the corresponding MID for smb1 is converted to LE before being sent on the wire.

We have tested this using the RHEL 7 kernel where the patch fixes the issue.

---
 fs/cifs/cifsglob.h | 10 ++++++++--
 fs/cifs/smb2pdu.h  |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)
fs/cifs/cifsglob.h +8 -2
index 02a33e5..279fee8 100644
@@ -662,15 +662,21 @@ set_credits(struct TCP_Server_Info *server, const int val)
 }
 
 static inline __u64
-get_next_mid64(struct TCP_Server_Info *server)
+_get_next_mid64(struct TCP_Server_Info *server)
 {
        return server->ops->get_next_mid(server);
 }
 
+static inline __le64
+get_next_mid64(struct TCP_Server_Info *server)
+{
+       return cpu_to_le64(_get_next_mid64(server));
+}
+
 static inline __le16
 get_next_mid(struct TCP_Server_Info *server)
 {
-       __u16 mid = get_next_mid64(server);
+       __u16 mid = _get_next_mid64(server);
        /*
         * The value in the SMB header should be little endian for easy
         * on-the-wire decoding.
fs/cifs/smb2pdu.h +1 -2
index e3188ab..ac27eac 100644
@@ -110,7 +110,7 @@ struct smb2_hdr {
        __le16 CreditRequest;  /* CreditResponse */
        __le32 Flags;
        __le32 NextCommand;
-       __u64  MessageId;       /* opaque - so can stay little endian */
+       __u64  MessageId;
        __le32 ProcessId;
        __u32  TreeId;          /* opaque - so do not make little endian */
        __u64  SessionId;       /* opaque - so do not make little endian */
--

1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): CADT32eLRVyut-c3zAYf=r6CKs=Kz+dH8NXYF32QiuAZS_qcWmw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw
Quoted 5 lines · Shirish Pargaonkar

Can get_next_mid() as well as get_next_mid64() call server->ops->get_next_mid(server) directly i.e. cpu_to_le16(server->ops->get_next_mid(server) and

     cpu_to_le64(server->ops->get_next_mid(server) respectively

instead of them calling additional new function__get_next_mid64()?

Hello Sirish,

Sorry for the delay, I've made the changes proposed by you. I've also changed the type for MessageId from __u64 to __le64.

Sachin Prabhu

Quoted 71 lines · Sachin Prabhu
Quoted 61 lines

We have encountered failures when When testing smb2 mounts on ppc64 machines when using both Samba as well as Windows 2012.

On poking around, the problem was determined to be caused by the high endian MessageID passed in the header for smb2. On checking the corresponding MID for smb1 is converted to LE before being sent on the wire.

We have tested this using the RHEL 7 kernel where the patch fixes the issue.

---
 fs/cifs/cifsglob.h | 10 ++++++++--
 fs/cifs/smb2pdu.h  |  2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)
fs/cifs/cifsglob.h +8 -2
index 02a33e5..279fee8 100644
@@ -662,15 +662,21 @@ set_credits(struct TCP_Server_Info *server, const int val)
 }
 
 static inline __u64
-get_next_mid64(struct TCP_Server_Info *server)
+_get_next_mid64(struct TCP_Server_Info *server)
 {
        return server->ops->get_next_mid(server);
 }
 
+static inline __le64
+get_next_mid64(struct TCP_Server_Info *server)
+{
+       return cpu_to_le64(_get_next_mid64(server));
+}
+
 static inline __le16
 get_next_mid(struct TCP_Server_Info *server)
 {
-       __u16 mid = get_next_mid64(server);
+       __u16 mid = _get_next_mid64(server);
        /*
         * The value in the SMB header should be little endian for easy
         * on-the-wire decoding.
fs/cifs/smb2pdu.h +1 -2
index e3188ab..ac27eac 100644
@@ -110,7 +110,7 @@ struct smb2_hdr {
        __le16 CreditRequest;  /* CreditResponse */
        __le32 Flags;
        __le32 NextCommand;
-       __u64  MessageId;       /* opaque - so can stay little endian */
+       __u64  MessageId;
        __le32 ProcessId;
        __u32  TreeId;          /* opaque - so do not make little endian */
        __u64  SessionId;       /* opaque - so do not make little endian */
--

1.9.3

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html