diff options
author | Al Viro <viro@ftp.linux.org.uk> | 2007-12-05 03:24:38 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-12-05 12:25:19 -0500 |
commit | 9b5e6857b3f3acc8ab434e565b7ec87bf9f9b53c (patch) | |
tree | e4acfece76f0a6de5a34b89703ccbd02551b4688 /fs | |
parent | ecaf18c15aac8bb9bed7b7aa0e382fe252e275d5 (diff) |
regression: cifs endianness bug
access_flags_to_mode() gets on-the-wire data (little-endian) and treats
it as host-endian.
Introduced in commit e01b64001359034d04c695388870936ed3d1b56b ("[CIFS]
enable get mode from ACL when cifsacl mount option specified")
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/cifs/cifsacl.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index f02fdef463a7..c312adcba4fc 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c | |||
@@ -134,9 +134,10 @@ int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid) | |||
134 | pmode is the existing mode (we only want to overwrite part of this | 134 | pmode is the existing mode (we only want to overwrite part of this |
135 | bits to set can be: S_IRWXU, S_IRWXG or S_IRWXO ie 00700 or 00070 or 00007 | 135 | bits to set can be: S_IRWXU, S_IRWXG or S_IRWXO ie 00700 or 00070 or 00007 |
136 | */ | 136 | */ |
137 | static void access_flags_to_mode(__u32 ace_flags, int type, umode_t *pmode, | 137 | static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode, |
138 | umode_t *pbits_to_set) | 138 | umode_t *pbits_to_set) |
139 | { | 139 | { |
140 | __u32 flags = le32_to_cpu(ace_flags); | ||
140 | /* the order of ACEs is important. The canonical order is to begin with | 141 | /* the order of ACEs is important. The canonical order is to begin with |
141 | DENY entries followed by ALLOW, otherwise an allow entry could be | 142 | DENY entries followed by ALLOW, otherwise an allow entry could be |
142 | encountered first, making the subsequent deny entry like "dead code" | 143 | encountered first, making the subsequent deny entry like "dead code" |
@@ -146,17 +147,17 @@ static void access_flags_to_mode(__u32 ace_flags, int type, umode_t *pmode, | |||
146 | /* For deny ACEs we change the mask so that subsequent allow access | 147 | /* For deny ACEs we change the mask so that subsequent allow access |
147 | control entries do not turn on the bits we are denying */ | 148 | control entries do not turn on the bits we are denying */ |
148 | if (type == ACCESS_DENIED) { | 149 | if (type == ACCESS_DENIED) { |
149 | if (ace_flags & GENERIC_ALL) { | 150 | if (flags & GENERIC_ALL) { |
150 | *pbits_to_set &= ~S_IRWXUGO; | 151 | *pbits_to_set &= ~S_IRWXUGO; |
151 | } | 152 | } |
152 | if ((ace_flags & GENERIC_WRITE) || | 153 | if ((flags & GENERIC_WRITE) || |
153 | ((ace_flags & FILE_WRITE_RIGHTS) == FILE_WRITE_RIGHTS)) | 154 | ((flags & FILE_WRITE_RIGHTS) == FILE_WRITE_RIGHTS)) |
154 | *pbits_to_set &= ~S_IWUGO; | 155 | *pbits_to_set &= ~S_IWUGO; |
155 | if ((ace_flags & GENERIC_READ) || | 156 | if ((flags & GENERIC_READ) || |
156 | ((ace_flags & FILE_READ_RIGHTS) == FILE_READ_RIGHTS)) | 157 | ((flags & FILE_READ_RIGHTS) == FILE_READ_RIGHTS)) |
157 | *pbits_to_set &= ~S_IRUGO; | 158 | *pbits_to_set &= ~S_IRUGO; |
158 | if ((ace_flags & GENERIC_EXECUTE) || | 159 | if ((flags & GENERIC_EXECUTE) || |
159 | ((ace_flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS)) | 160 | ((flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS)) |
160 | *pbits_to_set &= ~S_IXUGO; | 161 | *pbits_to_set &= ~S_IXUGO; |
161 | return; | 162 | return; |
162 | } else if (type != ACCESS_ALLOWED) { | 163 | } else if (type != ACCESS_ALLOWED) { |
@@ -165,25 +166,25 @@ static void access_flags_to_mode(__u32 ace_flags, int type, umode_t *pmode, | |||
165 | } | 166 | } |
166 | /* else ACCESS_ALLOWED type */ | 167 | /* else ACCESS_ALLOWED type */ |
167 | 168 | ||
168 | if (ace_flags & GENERIC_ALL) { | 169 | if (flags & GENERIC_ALL) { |
169 | *pmode |= (S_IRWXUGO & (*pbits_to_set)); | 170 | *pmode |= (S_IRWXUGO & (*pbits_to_set)); |
170 | #ifdef CONFIG_CIFS_DEBUG2 | 171 | #ifdef CONFIG_CIFS_DEBUG2 |
171 | cFYI(1, ("all perms")); | 172 | cFYI(1, ("all perms")); |
172 | #endif | 173 | #endif |
173 | return; | 174 | return; |
174 | } | 175 | } |
175 | if ((ace_flags & GENERIC_WRITE) || | 176 | if ((flags & GENERIC_WRITE) || |
176 | ((ace_flags & FILE_WRITE_RIGHTS) == FILE_WRITE_RIGHTS)) | 177 | ((flags & FILE_WRITE_RIGHTS) == FILE_WRITE_RIGHTS)) |
177 | *pmode |= (S_IWUGO & (*pbits_to_set)); | 178 | *pmode |= (S_IWUGO & (*pbits_to_set)); |
178 | if ((ace_flags & GENERIC_READ) || | 179 | if ((flags & GENERIC_READ) || |
179 | ((ace_flags & FILE_READ_RIGHTS) == FILE_READ_RIGHTS)) | 180 | ((flags & FILE_READ_RIGHTS) == FILE_READ_RIGHTS)) |
180 | *pmode |= (S_IRUGO & (*pbits_to_set)); | 181 | *pmode |= (S_IRUGO & (*pbits_to_set)); |
181 | if ((ace_flags & GENERIC_EXECUTE) || | 182 | if ((flags & GENERIC_EXECUTE) || |
182 | ((ace_flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS)) | 183 | ((flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS)) |
183 | *pmode |= (S_IXUGO & (*pbits_to_set)); | 184 | *pmode |= (S_IXUGO & (*pbits_to_set)); |
184 | 185 | ||
185 | #ifdef CONFIG_CIFS_DEBUG2 | 186 | #ifdef CONFIG_CIFS_DEBUG2 |
186 | cFYI(1, ("access flags 0x%x mode now 0x%x", ace_flags, *pmode)); | 187 | cFYI(1, ("access flags 0x%x mode now 0x%x", flags, *pmode)); |
187 | #endif | 188 | #endif |
188 | return; | 189 | return; |
189 | } | 190 | } |