Commit 0753ca7b authored by Steve French's avatar Steve French

[CIFS] Change pragma pack(1) to attribute(packed) to allow cifs on arm to access

unaligned structures coming in off the wire

gcc on arm processors generates very odd code with pragma pack specified -
although it does pack the structures in some sense - it does not allow you
to access unaligned elements in nested structures at the right offset as other
architectures do.  Oddly enough though, specifying the structures as packed
the long way - one by one with the packed attribute does work.  Rather than
fighting over whether this is a gcc bug or some obscure side effect
of pragma pack, it is easier to do what most (all but 96 other places in
the kernel) do - and replace pragma pack with dozens of attribute(packed)
structure qualifiers.  Much more verbose ... but at least it works.
Signed-off-by: default avatarDavid Kleikamp <shaggy@austin.ibm.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>  CG: -----------------------------------------------------------------------
parent 04290949
This diff is collapsed.
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#pragma pack(1)
#define NTLMSSP_SIGNATURE "NTLMSSP" #define NTLMSSP_SIGNATURE "NTLMSSP"
/* Message Types */ /* Message Types */
#define NtLmNegotiate cpu_to_le32(1) #define NtLmNegotiate cpu_to_le32(1)
...@@ -63,7 +61,7 @@ typedef struct _SECURITY_BUFFER { ...@@ -63,7 +61,7 @@ typedef struct _SECURITY_BUFFER {
__le16 Length; __le16 Length;
__le16 MaximumLength; __le16 MaximumLength;
__le32 Buffer; /* offset to buffer */ __le32 Buffer; /* offset to buffer */
} SECURITY_BUFFER; } __attribute__((packed)) SECURITY_BUFFER;
typedef struct _NEGOTIATE_MESSAGE { typedef struct _NEGOTIATE_MESSAGE {
__u8 Signature[sizeof (NTLMSSP_SIGNATURE)]; __u8 Signature[sizeof (NTLMSSP_SIGNATURE)];
...@@ -73,7 +71,7 @@ typedef struct _NEGOTIATE_MESSAGE { ...@@ -73,7 +71,7 @@ typedef struct _NEGOTIATE_MESSAGE {
SECURITY_BUFFER WorkstationName; /* RFC 1001 and ASCII */ SECURITY_BUFFER WorkstationName; /* RFC 1001 and ASCII */
char DomainString[0]; char DomainString[0];
/* followed by WorkstationString */ /* followed by WorkstationString */
} NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE; } __attribute__((packed)) NEGOTIATE_MESSAGE, *PNEGOTIATE_MESSAGE;
typedef struct _CHALLENGE_MESSAGE { typedef struct _CHALLENGE_MESSAGE {
__u8 Signature[sizeof (NTLMSSP_SIGNATURE)]; __u8 Signature[sizeof (NTLMSSP_SIGNATURE)];
...@@ -83,7 +81,7 @@ typedef struct _CHALLENGE_MESSAGE { ...@@ -83,7 +81,7 @@ typedef struct _CHALLENGE_MESSAGE {
__u8 Challenge[CIFS_CRYPTO_KEY_SIZE]; __u8 Challenge[CIFS_CRYPTO_KEY_SIZE];
__u8 Reserved[8]; __u8 Reserved[8];
SECURITY_BUFFER TargetInfoArray; SECURITY_BUFFER TargetInfoArray;
} CHALLENGE_MESSAGE, *PCHALLENGE_MESSAGE; } __attribute__((packed)) CHALLENGE_MESSAGE, *PCHALLENGE_MESSAGE;
typedef struct _AUTHENTICATE_MESSAGE { typedef struct _AUTHENTICATE_MESSAGE {
__u8 Signature[sizeof (NTLMSSP_SIGNATURE)]; __u8 Signature[sizeof (NTLMSSP_SIGNATURE)];
...@@ -96,6 +94,4 @@ typedef struct _AUTHENTICATE_MESSAGE { ...@@ -96,6 +94,4 @@ typedef struct _AUTHENTICATE_MESSAGE {
SECURITY_BUFFER SessionKey; SECURITY_BUFFER SessionKey;
__le32 NegotiateFlags; __le32 NegotiateFlags;
char UserString[0]; char UserString[0];
} AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE; } __attribute__((packed)) AUTHENTICATE_MESSAGE, *PAUTHENTICATE_MESSAGE;
#pragma pack() /* resume default structure packing */
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#pragma pack(1)
/* NB: unlike smb/cifs packets, the RFC1002 structures are big endian */ /* NB: unlike smb/cifs packets, the RFC1002 structures are big endian */
/* RFC 1002 session packet types */ /* RFC 1002 session packet types */
...@@ -48,17 +46,17 @@ struct rfc1002_session_packet { ...@@ -48,17 +46,17 @@ struct rfc1002_session_packet {
__u8 calling_len; __u8 calling_len;
__u8 calling_name[32]; __u8 calling_name[32];
__u8 scope2; /* null */ __u8 scope2; /* null */
} session_req; } __attribute__((packed)) session_req;
struct { struct {
__u32 retarget_ip_addr; __u32 retarget_ip_addr;
__u16 port; __u16 port;
} retarget_resp; } __attribute__((packed)) retarget_resp;
__u8 neg_ses_resp_error_code; __u8 neg_ses_resp_error_code;
/* POSITIVE_SESSION_RESPONSE packet does not include trailer. /* POSITIVE_SESSION_RESPONSE packet does not include trailer.
SESSION_KEEP_ALIVE packet also does not include a trailer. SESSION_KEEP_ALIVE packet also does not include a trailer.
Trailer for the SESSION_MESSAGE packet is SMB/CIFS header */ Trailer for the SESSION_MESSAGE packet is SMB/CIFS header */
} trailer; } __attribute__((packed)) trailer;
}; } __attribute__((packed));
/* Negative Session Response error codes */ /* Negative Session Response error codes */
#define RFC1002_NOT_LISTENING_CALLED 0x80 /* not listening on called name */ #define RFC1002_NOT_LISTENING_CALLED 0x80 /* not listening on called name */
...@@ -74,6 +72,3 @@ server netbios name). Currently server names are resolved only via DNS ...@@ -74,6 +72,3 @@ server netbios name). Currently server names are resolved only via DNS
(tcp name) or ip address or an /etc/hosts equivalent mapping to ip address.*/ (tcp name) or ip address or an /etc/hosts equivalent mapping to ip address.*/
#define DEFAULT_CIFS_CALLED_NAME "*SMBSERVER " #define DEFAULT_CIFS_CALLED_NAME "*SMBSERVER "
#pragma pack() /* resume default structure packing */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment