Bug 14569 - BCC_LE macro in cifspdu.h
Summary: BCC_LE macro in cifspdu.h
Status: RESOLVED DUPLICATE of bug 11115
Alias: None
Product: File System
Classification: Unclassified
Component: CIFS (show other bugs)
Hardware: All Linux
: P1 high
Assignee: Jeff Layton
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-09 18:16 UTC by Juro
Modified: 2011-01-15 13:16 UTC (History)
1 user (show)

See Also:
Kernel Version: 2.6.31
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Juro 2009-11-09 18:16:23 UTC
BCC_LE macro in "cifspdu.h" is not well defined. The sizeof(structure smb_hdr)
is odd (go ahead, count the bytes) and the BCC_LE attempts to do a 16 bit
access from an odd address. This renders the whole CIFS pretty much unusable on
all CPUs that cannot handle misaligned accesses.
The macro should use "unaligned" access.
Comment 1 Jeff Layton 2009-11-09 18:58:37 UTC
No objection to fixing it so that it works better on such architectures. Care to offer up a patch or explanation of how you think it should work?
Comment 2 Juro 2009-11-09 20:14:52 UTC
(In reply to comment #1)
> No objection to fixing it so that it works better on such architectures. Care
> to offer up a patch or explanation of how you think it should work?

The macro BCC_LE is used in several files, sometimes to read and sometimes to write a 16 bit le value.
The best I could come was to split the macro into two macros:

#define BCC_LE_GET(smb_var) get_unaligned_le16((char*)smb_var + sizeof(struct smb_hdr)+(2*smb_var->WordCount))


#define BCC_LE_PUT(smb_var) put_unaligned_le16((char*)smb_var + sizeof(struct smb_hdr)+(2*smb_var->WordCount))

and change the files "connect.c","netmisc.c","transport.c" and "sess.c" to
use the new macros.

It is quite likely there is a better way to do this.
Comment 3 Jeff Layton 2010-09-03 12:11:58 UTC
If you're still interested in fixing this, could you spin up patches against recent mainline git (or even better, against Steve French's tree). Then please post them to linux-cifs@vger.kernel.org so we can review them. Thanks!
Comment 4 Jeff Layton 2011-01-15 13:16:49 UTC

*** This bug has been marked as a duplicate of bug 11115 ***

Note You need to log in before you can comment on or make changes to this bug.