Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 1 | /* |
| 2 | * fs/cifs/cifsacl.c |
| 3 | * |
Steve French | 8b1327f | 2008-03-14 22:37:16 +0000 | [diff] [blame] | 4 | * Copyright (C) International Business Machines Corp., 2007,2008 |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 5 | * Author(s): Steve French (sfrench@us.ibm.com) |
| 6 | * |
| 7 | * Contains the routines for mapping CIFS/NTFS ACLs |
| 8 | * |
| 9 | * This library is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU Lesser General Public License as published |
| 11 | * by the Free Software Foundation; either version 2.1 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This library is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 17 | * the GNU Lesser General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Lesser General Public License |
| 20 | * along with this library; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | */ |
| 23 | |
Steve French | 6587400 | 2007-09-25 19:53:44 +0000 | [diff] [blame] | 24 | #include <linux/fs.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 25 | #include <linux/slab.h> |
Steve French | 6587400 | 2007-09-25 19:53:44 +0000 | [diff] [blame] | 26 | #include "cifspdu.h" |
| 27 | #include "cifsglob.h" |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 28 | #include "cifsacl.h" |
Steve French | 6587400 | 2007-09-25 19:53:44 +0000 | [diff] [blame] | 29 | #include "cifsproto.h" |
| 30 | #include "cifs_debug.h" |
Steve French | 6587400 | 2007-09-25 19:53:44 +0000 | [diff] [blame] | 31 | |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 32 | |
Steve French | af6f461 | 2007-10-16 18:40:37 +0000 | [diff] [blame] | 33 | static struct cifs_wksid wksidarr[NUM_WK_SIDS] = { |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 34 | {{1, 0, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0} }, "null user"}, |
| 35 | {{1, 1, {0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0} }, "nobody"}, |
Jeff Layton | 536abdb | 2008-07-12 13:48:00 -0700 | [diff] [blame] | 36 | {{1, 1, {0, 0, 0, 0, 0, 5}, {__constant_cpu_to_le32(11), 0, 0, 0, 0} }, "net-users"}, |
| 37 | {{1, 1, {0, 0, 0, 0, 0, 5}, {__constant_cpu_to_le32(18), 0, 0, 0, 0} }, "sys"}, |
| 38 | {{1, 2, {0, 0, 0, 0, 0, 5}, {__constant_cpu_to_le32(32), __constant_cpu_to_le32(544), 0, 0, 0} }, "root"}, |
| 39 | {{1, 2, {0, 0, 0, 0, 0, 5}, {__constant_cpu_to_le32(32), __constant_cpu_to_le32(545), 0, 0, 0} }, "users"}, |
| 40 | {{1, 2, {0, 0, 0, 0, 0, 5}, {__constant_cpu_to_le32(32), __constant_cpu_to_le32(546), 0, 0, 0} }, "guest"} } |
Steve French | 44093ca | 2007-10-23 21:22:55 +0000 | [diff] [blame] | 41 | ; |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 42 | |
| 43 | |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 44 | /* security id for everyone */ |
Shirish Pargaonkar | e01b640 | 2007-10-30 04:45:14 +0000 | [diff] [blame] | 45 | static const struct cifs_sid sid_everyone = { |
| 46 | 1, 1, {0, 0, 0, 0, 0, 1}, {0} }; |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 47 | /* group users */ |
Steve French | ad7a292 | 2008-02-07 23:25:02 +0000 | [diff] [blame] | 48 | static const struct cifs_sid sid_user = {1, 2 , {0, 0, 0, 0, 0, 5}, {} }; |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 49 | |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 50 | |
| 51 | int match_sid(struct cifs_sid *ctsid) |
| 52 | { |
| 53 | int i, j; |
| 54 | int num_subauth, num_sat, num_saw; |
| 55 | struct cifs_sid *cwsid; |
| 56 | |
| 57 | if (!ctsid) |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 58 | return -1; |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 59 | |
| 60 | for (i = 0; i < NUM_WK_SIDS; ++i) { |
| 61 | cwsid = &(wksidarr[i].cifssid); |
| 62 | |
| 63 | /* compare the revision */ |
| 64 | if (ctsid->revision != cwsid->revision) |
| 65 | continue; |
| 66 | |
| 67 | /* compare all of the six auth values */ |
| 68 | for (j = 0; j < 6; ++j) { |
| 69 | if (ctsid->authority[j] != cwsid->authority[j]) |
| 70 | break; |
| 71 | } |
| 72 | if (j < 6) |
| 73 | continue; /* all of the auth values did not match */ |
| 74 | |
| 75 | /* compare all of the subauth values if any */ |
Dave Kleikamp | ce51ae1 | 2007-10-16 21:35:39 +0000 | [diff] [blame] | 76 | num_sat = ctsid->num_subauth; |
| 77 | num_saw = cwsid->num_subauth; |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 78 | num_subauth = num_sat < num_saw ? num_sat : num_saw; |
| 79 | if (num_subauth) { |
| 80 | for (j = 0; j < num_subauth; ++j) { |
| 81 | if (ctsid->sub_auth[j] != cwsid->sub_auth[j]) |
| 82 | break; |
| 83 | } |
| 84 | if (j < num_subauth) |
| 85 | continue; /* all sub_auth values do not match */ |
| 86 | } |
| 87 | |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 88 | cFYI(1, "matching sid: %s\n", wksidarr[i].sidname); |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 89 | return 0; /* sids compare/match */ |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 92 | cFYI(1, "No matching sid"); |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 93 | return -1; |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 94 | } |
| 95 | |
Steve French | a750e77 | 2007-10-17 22:50:39 +0000 | [diff] [blame] | 96 | /* if the two SIDs (roughly equivalent to a UUID for a user or group) are |
| 97 | the same returns 1, if they do not match returns 0 */ |
Steve French | 630f3f0 | 2007-10-25 21:17:17 +0000 | [diff] [blame] | 98 | int compare_sids(const struct cifs_sid *ctsid, const struct cifs_sid *cwsid) |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 99 | { |
| 100 | int i; |
| 101 | int num_subauth, num_sat, num_saw; |
| 102 | |
| 103 | if ((!ctsid) || (!cwsid)) |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 104 | return 0; |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 105 | |
| 106 | /* compare the revision */ |
| 107 | if (ctsid->revision != cwsid->revision) |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 108 | return 0; |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 109 | |
| 110 | /* compare all of the six auth values */ |
| 111 | for (i = 0; i < 6; ++i) { |
| 112 | if (ctsid->authority[i] != cwsid->authority[i]) |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 113 | return 0; |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | /* compare all of the subauth values if any */ |
Steve French | adbc035 | 2007-10-17 02:12:46 +0000 | [diff] [blame] | 117 | num_sat = ctsid->num_subauth; |
Steve French | adddd49 | 2007-10-17 02:48:17 +0000 | [diff] [blame] | 118 | num_saw = cwsid->num_subauth; |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 119 | num_subauth = num_sat < num_saw ? num_sat : num_saw; |
| 120 | if (num_subauth) { |
| 121 | for (i = 0; i < num_subauth; ++i) { |
| 122 | if (ctsid->sub_auth[i] != cwsid->sub_auth[i]) |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 123 | return 0; |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 124 | } |
| 125 | } |
| 126 | |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 127 | return 1; /* sids compare/match */ |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 128 | } |
| 129 | |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 130 | |
| 131 | /* copy ntsd, owner sid, and group sid from a security descriptor to another */ |
| 132 | static void copy_sec_desc(const struct cifs_ntsd *pntsd, |
| 133 | struct cifs_ntsd *pnntsd, __u32 sidsoffset) |
| 134 | { |
| 135 | int i; |
| 136 | |
| 137 | struct cifs_sid *owner_sid_ptr, *group_sid_ptr; |
| 138 | struct cifs_sid *nowner_sid_ptr, *ngroup_sid_ptr; |
| 139 | |
| 140 | /* copy security descriptor control portion */ |
| 141 | pnntsd->revision = pntsd->revision; |
| 142 | pnntsd->type = pntsd->type; |
| 143 | pnntsd->dacloffset = cpu_to_le32(sizeof(struct cifs_ntsd)); |
| 144 | pnntsd->sacloffset = 0; |
| 145 | pnntsd->osidoffset = cpu_to_le32(sidsoffset); |
| 146 | pnntsd->gsidoffset = cpu_to_le32(sidsoffset + sizeof(struct cifs_sid)); |
| 147 | |
| 148 | /* copy owner sid */ |
| 149 | owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + |
| 150 | le32_to_cpu(pntsd->osidoffset)); |
| 151 | nowner_sid_ptr = (struct cifs_sid *)((char *)pnntsd + sidsoffset); |
| 152 | |
| 153 | nowner_sid_ptr->revision = owner_sid_ptr->revision; |
| 154 | nowner_sid_ptr->num_subauth = owner_sid_ptr->num_subauth; |
| 155 | for (i = 0; i < 6; i++) |
| 156 | nowner_sid_ptr->authority[i] = owner_sid_ptr->authority[i]; |
| 157 | for (i = 0; i < 5; i++) |
| 158 | nowner_sid_ptr->sub_auth[i] = owner_sid_ptr->sub_auth[i]; |
| 159 | |
| 160 | /* copy group sid */ |
| 161 | group_sid_ptr = (struct cifs_sid *)((char *)pntsd + |
| 162 | le32_to_cpu(pntsd->gsidoffset)); |
| 163 | ngroup_sid_ptr = (struct cifs_sid *)((char *)pnntsd + sidsoffset + |
| 164 | sizeof(struct cifs_sid)); |
| 165 | |
| 166 | ngroup_sid_ptr->revision = group_sid_ptr->revision; |
| 167 | ngroup_sid_ptr->num_subauth = group_sid_ptr->num_subauth; |
| 168 | for (i = 0; i < 6; i++) |
| 169 | ngroup_sid_ptr->authority[i] = group_sid_ptr->authority[i]; |
| 170 | for (i = 0; i < 5; i++) |
Shirish Pargaonkar | b1910ad | 2008-07-24 14:53:20 +0000 | [diff] [blame] | 171 | ngroup_sid_ptr->sub_auth[i] = group_sid_ptr->sub_auth[i]; |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 172 | |
| 173 | return; |
| 174 | } |
| 175 | |
| 176 | |
Steve French | 630f3f0 | 2007-10-25 21:17:17 +0000 | [diff] [blame] | 177 | /* |
| 178 | change posix mode to reflect permissions |
| 179 | pmode is the existing mode (we only want to overwrite part of this |
| 180 | bits to set can be: S_IRWXU, S_IRWXG or S_IRWXO ie 00700 or 00070 or 00007 |
| 181 | */ |
Al Viro | 9b5e685 | 2007-12-05 08:24:38 +0000 | [diff] [blame] | 182 | static void access_flags_to_mode(__le32 ace_flags, int type, umode_t *pmode, |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 183 | umode_t *pbits_to_set) |
Steve French | 4879b44 | 2007-10-19 21:57:39 +0000 | [diff] [blame] | 184 | { |
Al Viro | 9b5e685 | 2007-12-05 08:24:38 +0000 | [diff] [blame] | 185 | __u32 flags = le32_to_cpu(ace_flags); |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 186 | /* the order of ACEs is important. The canonical order is to begin with |
Steve French | ce06c9f | 2007-11-08 21:12:01 +0000 | [diff] [blame] | 187 | DENY entries followed by ALLOW, otherwise an allow entry could be |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 188 | encountered first, making the subsequent deny entry like "dead code" |
Steve French | ce06c9f | 2007-11-08 21:12:01 +0000 | [diff] [blame] | 189 | which would be superflous since Windows stops when a match is made |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 190 | for the operation you are trying to perform for your user */ |
| 191 | |
| 192 | /* For deny ACEs we change the mask so that subsequent allow access |
| 193 | control entries do not turn on the bits we are denying */ |
| 194 | if (type == ACCESS_DENIED) { |
Steve French | ad7a292 | 2008-02-07 23:25:02 +0000 | [diff] [blame] | 195 | if (flags & GENERIC_ALL) |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 196 | *pbits_to_set &= ~S_IRWXUGO; |
Steve French | ad7a292 | 2008-02-07 23:25:02 +0000 | [diff] [blame] | 197 | |
Al Viro | 9b5e685 | 2007-12-05 08:24:38 +0000 | [diff] [blame] | 198 | if ((flags & GENERIC_WRITE) || |
| 199 | ((flags & FILE_WRITE_RIGHTS) == FILE_WRITE_RIGHTS)) |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 200 | *pbits_to_set &= ~S_IWUGO; |
Al Viro | 9b5e685 | 2007-12-05 08:24:38 +0000 | [diff] [blame] | 201 | if ((flags & GENERIC_READ) || |
| 202 | ((flags & FILE_READ_RIGHTS) == FILE_READ_RIGHTS)) |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 203 | *pbits_to_set &= ~S_IRUGO; |
Al Viro | 9b5e685 | 2007-12-05 08:24:38 +0000 | [diff] [blame] | 204 | if ((flags & GENERIC_EXECUTE) || |
| 205 | ((flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS)) |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 206 | *pbits_to_set &= ~S_IXUGO; |
| 207 | return; |
| 208 | } else if (type != ACCESS_ALLOWED) { |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 209 | cERROR(1, "unknown access control type %d", type); |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 210 | return; |
| 211 | } |
| 212 | /* else ACCESS_ALLOWED type */ |
Steve French | 44093ca | 2007-10-23 21:22:55 +0000 | [diff] [blame] | 213 | |
Al Viro | 9b5e685 | 2007-12-05 08:24:38 +0000 | [diff] [blame] | 214 | if (flags & GENERIC_ALL) { |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 215 | *pmode |= (S_IRWXUGO & (*pbits_to_set)); |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 216 | cFYI(DBG2, "all perms"); |
Steve French | d61e580 | 2007-10-26 04:32:43 +0000 | [diff] [blame] | 217 | return; |
| 218 | } |
Al Viro | 9b5e685 | 2007-12-05 08:24:38 +0000 | [diff] [blame] | 219 | if ((flags & GENERIC_WRITE) || |
| 220 | ((flags & FILE_WRITE_RIGHTS) == FILE_WRITE_RIGHTS)) |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 221 | *pmode |= (S_IWUGO & (*pbits_to_set)); |
Al Viro | 9b5e685 | 2007-12-05 08:24:38 +0000 | [diff] [blame] | 222 | if ((flags & GENERIC_READ) || |
| 223 | ((flags & FILE_READ_RIGHTS) == FILE_READ_RIGHTS)) |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 224 | *pmode |= (S_IRUGO & (*pbits_to_set)); |
Al Viro | 9b5e685 | 2007-12-05 08:24:38 +0000 | [diff] [blame] | 225 | if ((flags & GENERIC_EXECUTE) || |
| 226 | ((flags & FILE_EXEC_RIGHTS) == FILE_EXEC_RIGHTS)) |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 227 | *pmode |= (S_IXUGO & (*pbits_to_set)); |
Steve French | d61e580 | 2007-10-26 04:32:43 +0000 | [diff] [blame] | 228 | |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 229 | cFYI(DBG2, "access flags 0x%x mode now 0x%x", flags, *pmode); |
Steve French | 630f3f0 | 2007-10-25 21:17:17 +0000 | [diff] [blame] | 230 | return; |
| 231 | } |
| 232 | |
Steve French | ce06c9f | 2007-11-08 21:12:01 +0000 | [diff] [blame] | 233 | /* |
| 234 | Generate access flags to reflect permissions mode is the existing mode. |
| 235 | This function is called for every ACE in the DACL whose SID matches |
| 236 | with either owner or group or everyone. |
| 237 | */ |
| 238 | |
| 239 | static void mode_to_access_flags(umode_t mode, umode_t bits_to_use, |
| 240 | __u32 *pace_flags) |
| 241 | { |
| 242 | /* reset access mask */ |
| 243 | *pace_flags = 0x0; |
| 244 | |
| 245 | /* bits to use are either S_IRWXU or S_IRWXG or S_IRWXO */ |
| 246 | mode &= bits_to_use; |
| 247 | |
| 248 | /* check for R/W/X UGO since we do not know whose flags |
| 249 | is this but we have cleared all the bits sans RWX for |
| 250 | either user or group or other as per bits_to_use */ |
| 251 | if (mode & S_IRUGO) |
| 252 | *pace_flags |= SET_FILE_READ_RIGHTS; |
| 253 | if (mode & S_IWUGO) |
| 254 | *pace_flags |= SET_FILE_WRITE_RIGHTS; |
| 255 | if (mode & S_IXUGO) |
| 256 | *pace_flags |= SET_FILE_EXEC_RIGHTS; |
| 257 | |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 258 | cFYI(DBG2, "mode: 0x%x, access flags now 0x%x", mode, *pace_flags); |
Steve French | ce06c9f | 2007-11-08 21:12:01 +0000 | [diff] [blame] | 259 | return; |
| 260 | } |
| 261 | |
Al Viro | 2b210ad | 2008-03-29 03:09:18 +0000 | [diff] [blame] | 262 | static __u16 fill_ace_for_sid(struct cifs_ace *pntace, |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 263 | const struct cifs_sid *psid, __u64 nmode, umode_t bits) |
| 264 | { |
| 265 | int i; |
| 266 | __u16 size = 0; |
| 267 | __u32 access_req = 0; |
| 268 | |
| 269 | pntace->type = ACCESS_ALLOWED; |
| 270 | pntace->flags = 0x0; |
| 271 | mode_to_access_flags(nmode, bits, &access_req); |
| 272 | if (!access_req) |
| 273 | access_req = SET_MINIMUM_RIGHTS; |
| 274 | pntace->access_req = cpu_to_le32(access_req); |
| 275 | |
| 276 | pntace->sid.revision = psid->revision; |
| 277 | pntace->sid.num_subauth = psid->num_subauth; |
| 278 | for (i = 0; i < 6; i++) |
| 279 | pntace->sid.authority[i] = psid->authority[i]; |
| 280 | for (i = 0; i < psid->num_subauth; i++) |
| 281 | pntace->sid.sub_auth[i] = psid->sub_auth[i]; |
| 282 | |
| 283 | size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth * 4); |
| 284 | pntace->size = cpu_to_le16(size); |
| 285 | |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 286 | return size; |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 287 | } |
| 288 | |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 289 | |
Steve French | 953f868 | 2007-10-31 04:54:42 +0000 | [diff] [blame] | 290 | #ifdef CONFIG_CIFS_DEBUG2 |
| 291 | static void dump_ace(struct cifs_ace *pace, char *end_of_acl) |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 292 | { |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 293 | int num_subauth; |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 294 | |
| 295 | /* validate that we do not go past end of acl */ |
Steve French | 297647c | 2007-10-12 04:11:59 +0000 | [diff] [blame] | 296 | |
Steve French | 44093ca | 2007-10-23 21:22:55 +0000 | [diff] [blame] | 297 | if (le16_to_cpu(pace->size) < 16) { |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 298 | cERROR(1, "ACE too small %d", le16_to_cpu(pace->size)); |
Steve French | 44093ca | 2007-10-23 21:22:55 +0000 | [diff] [blame] | 299 | return; |
| 300 | } |
| 301 | |
| 302 | if (end_of_acl < (char *)pace + le16_to_cpu(pace->size)) { |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 303 | cERROR(1, "ACL too small to parse ACE"); |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 304 | return; |
Steve French | 44093ca | 2007-10-23 21:22:55 +0000 | [diff] [blame] | 305 | } |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 306 | |
Steve French | 44093ca | 2007-10-23 21:22:55 +0000 | [diff] [blame] | 307 | num_subauth = pace->sid.num_subauth; |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 308 | if (num_subauth) { |
Steve French | 8f18c13 | 2007-10-12 18:54:12 +0000 | [diff] [blame] | 309 | int i; |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 310 | cFYI(1, "ACE revision %d num_auth %d type %d flags %d size %d", |
Steve French | 44093ca | 2007-10-23 21:22:55 +0000 | [diff] [blame] | 311 | pace->sid.revision, pace->sid.num_subauth, pace->type, |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 312 | pace->flags, le16_to_cpu(pace->size)); |
Steve French | d12fd12 | 2007-10-03 19:43:19 +0000 | [diff] [blame] | 313 | for (i = 0; i < num_subauth; ++i) { |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 314 | cFYI(1, "ACE sub_auth[%d]: 0x%x", i, |
| 315 | le32_to_cpu(pace->sid.sub_auth[i])); |
Steve French | d12fd12 | 2007-10-03 19:43:19 +0000 | [diff] [blame] | 316 | } |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 317 | |
Steve French | d12fd12 | 2007-10-03 19:43:19 +0000 | [diff] [blame] | 318 | /* BB add length check to make sure that we do not have huge |
| 319 | num auths and therefore go off the end */ |
Steve French | d12fd12 | 2007-10-03 19:43:19 +0000 | [diff] [blame] | 320 | } |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 321 | |
Steve French | d12fd12 | 2007-10-03 19:43:19 +0000 | [diff] [blame] | 322 | return; |
| 323 | } |
Steve French | 953f868 | 2007-10-31 04:54:42 +0000 | [diff] [blame] | 324 | #endif |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 325 | |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 326 | |
Steve French | a750e77 | 2007-10-17 22:50:39 +0000 | [diff] [blame] | 327 | static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, |
Steve French | d61e580 | 2007-10-26 04:32:43 +0000 | [diff] [blame] | 328 | struct cifs_sid *pownersid, struct cifs_sid *pgrpsid, |
Jeff Layton | 0b8f18e | 2009-07-09 01:46:37 -0400 | [diff] [blame] | 329 | struct cifs_fattr *fattr) |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 330 | { |
| 331 | int i; |
| 332 | int num_aces = 0; |
| 333 | int acl_size; |
| 334 | char *acl_base; |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 335 | struct cifs_ace **ppace; |
| 336 | |
| 337 | /* BB need to add parm so we can store the SID BB */ |
| 338 | |
Steve French | 2b83457 | 2007-11-25 10:01:00 +0000 | [diff] [blame] | 339 | if (!pdacl) { |
| 340 | /* no DACL in the security descriptor, set |
| 341 | all the permissions for user/group/other */ |
Jeff Layton | 0b8f18e | 2009-07-09 01:46:37 -0400 | [diff] [blame] | 342 | fattr->cf_mode |= S_IRWXUGO; |
Steve French | 2b83457 | 2007-11-25 10:01:00 +0000 | [diff] [blame] | 343 | return; |
| 344 | } |
| 345 | |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 346 | /* validate that we do not go past end of acl */ |
Steve French | af6f461 | 2007-10-16 18:40:37 +0000 | [diff] [blame] | 347 | if (end_of_acl < (char *)pdacl + le16_to_cpu(pdacl->size)) { |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 348 | cERROR(1, "ACL too small to parse DACL"); |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 349 | return; |
| 350 | } |
| 351 | |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 352 | cFYI(DBG2, "DACL revision %d size %d num aces %d", |
Steve French | af6f461 | 2007-10-16 18:40:37 +0000 | [diff] [blame] | 353 | le16_to_cpu(pdacl->revision), le16_to_cpu(pdacl->size), |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 354 | le32_to_cpu(pdacl->num_aces)); |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 355 | |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 356 | /* reset rwx permissions for user/group/other. |
| 357 | Also, if num_aces is 0 i.e. DACL has no ACEs, |
| 358 | user/group/other have no permissions */ |
Jeff Layton | 0b8f18e | 2009-07-09 01:46:37 -0400 | [diff] [blame] | 359 | fattr->cf_mode &= ~(S_IRWXUGO); |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 360 | |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 361 | acl_base = (char *)pdacl; |
| 362 | acl_size = sizeof(struct cifs_acl); |
| 363 | |
Steve French | adbc035 | 2007-10-17 02:12:46 +0000 | [diff] [blame] | 364 | num_aces = le32_to_cpu(pdacl->num_aces); |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 365 | if (num_aces > 0) { |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 366 | umode_t user_mask = S_IRWXU; |
| 367 | umode_t group_mask = S_IRWXG; |
| 368 | umode_t other_mask = S_IRWXO; |
| 369 | |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 370 | ppace = kmalloc(num_aces * sizeof(struct cifs_ace *), |
| 371 | GFP_KERNEL); |
| 372 | |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 373 | for (i = 0; i < num_aces; ++i) { |
Steve French | 44093ca | 2007-10-23 21:22:55 +0000 | [diff] [blame] | 374 | ppace[i] = (struct cifs_ace *) (acl_base + acl_size); |
Steve French | 953f868 | 2007-10-31 04:54:42 +0000 | [diff] [blame] | 375 | #ifdef CONFIG_CIFS_DEBUG2 |
| 376 | dump_ace(ppace[i], end_of_acl); |
| 377 | #endif |
Shirish Pargaonkar | e01b640 | 2007-10-30 04:45:14 +0000 | [diff] [blame] | 378 | if (compare_sids(&(ppace[i]->sid), pownersid)) |
| 379 | access_flags_to_mode(ppace[i]->access_req, |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 380 | ppace[i]->type, |
Jeff Layton | 0b8f18e | 2009-07-09 01:46:37 -0400 | [diff] [blame] | 381 | &fattr->cf_mode, |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 382 | &user_mask); |
Shirish Pargaonkar | e01b640 | 2007-10-30 04:45:14 +0000 | [diff] [blame] | 383 | if (compare_sids(&(ppace[i]->sid), pgrpsid)) |
| 384 | access_flags_to_mode(ppace[i]->access_req, |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 385 | ppace[i]->type, |
Jeff Layton | 0b8f18e | 2009-07-09 01:46:37 -0400 | [diff] [blame] | 386 | &fattr->cf_mode, |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 387 | &group_mask); |
Shirish Pargaonkar | e01b640 | 2007-10-30 04:45:14 +0000 | [diff] [blame] | 388 | if (compare_sids(&(ppace[i]->sid), &sid_everyone)) |
| 389 | access_flags_to_mode(ppace[i]->access_req, |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 390 | ppace[i]->type, |
Jeff Layton | 0b8f18e | 2009-07-09 01:46:37 -0400 | [diff] [blame] | 391 | &fattr->cf_mode, |
Steve French | 15b0395 | 2007-11-08 17:57:40 +0000 | [diff] [blame] | 392 | &other_mask); |
Shirish Pargaonkar | e01b640 | 2007-10-30 04:45:14 +0000 | [diff] [blame] | 393 | |
Steve French | 44093ca | 2007-10-23 21:22:55 +0000 | [diff] [blame] | 394 | /* memcpy((void *)(&(cifscred->aces[i])), |
Steve French | d12fd12 | 2007-10-03 19:43:19 +0000 | [diff] [blame] | 395 | (void *)ppace[i], |
| 396 | sizeof(struct cifs_ace)); */ |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 397 | |
Steve French | 44093ca | 2007-10-23 21:22:55 +0000 | [diff] [blame] | 398 | acl_base = (char *)ppace[i]; |
| 399 | acl_size = le16_to_cpu(ppace[i]->size); |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | kfree(ppace); |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 403 | } |
| 404 | |
| 405 | return; |
| 406 | } |
| 407 | |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 408 | |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 409 | static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid, |
| 410 | struct cifs_sid *pgrpsid, __u64 nmode) |
| 411 | { |
Al Viro | 2b210ad | 2008-03-29 03:09:18 +0000 | [diff] [blame] | 412 | u16 size = 0; |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 413 | struct cifs_acl *pnndacl; |
| 414 | |
| 415 | pnndacl = (struct cifs_acl *)((char *)pndacl + sizeof(struct cifs_acl)); |
| 416 | |
| 417 | size += fill_ace_for_sid((struct cifs_ace *) ((char *)pnndacl + size), |
| 418 | pownersid, nmode, S_IRWXU); |
| 419 | size += fill_ace_for_sid((struct cifs_ace *)((char *)pnndacl + size), |
| 420 | pgrpsid, nmode, S_IRWXG); |
| 421 | size += fill_ace_for_sid((struct cifs_ace *)((char *)pnndacl + size), |
| 422 | &sid_everyone, nmode, S_IRWXO); |
| 423 | |
| 424 | pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl)); |
Shirish Pargaonkar | d9f382e | 2008-02-12 20:46:26 +0000 | [diff] [blame] | 425 | pndacl->num_aces = cpu_to_le32(3); |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 426 | |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 427 | return 0; |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 428 | } |
| 429 | |
| 430 | |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 431 | static int parse_sid(struct cifs_sid *psid, char *end_of_acl) |
| 432 | { |
| 433 | /* BB need to add parm so we can store the SID BB */ |
| 434 | |
Steve French | b9c7a2b | 2007-10-26 23:40:20 +0000 | [diff] [blame] | 435 | /* validate that we do not go past end of ACL - sid must be at least 8 |
| 436 | bytes long (assuming no sub-auths - e.g. the null SID */ |
| 437 | if (end_of_acl < (char *)psid + 8) { |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 438 | cERROR(1, "ACL too small to parse SID %p", psid); |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 439 | return -EINVAL; |
| 440 | } |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 441 | |
Steve French | af6f461 | 2007-10-16 18:40:37 +0000 | [diff] [blame] | 442 | if (psid->num_subauth) { |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 443 | #ifdef CONFIG_CIFS_DEBUG2 |
Steve French | 8f18c13 | 2007-10-12 18:54:12 +0000 | [diff] [blame] | 444 | int i; |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 445 | cFYI(1, "SID revision %d num_auth %d", |
| 446 | psid->revision, psid->num_subauth); |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 447 | |
Steve French | af6f461 | 2007-10-16 18:40:37 +0000 | [diff] [blame] | 448 | for (i = 0; i < psid->num_subauth; i++) { |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 449 | cFYI(1, "SID sub_auth[%d]: 0x%x ", i, |
| 450 | le32_to_cpu(psid->sub_auth[i])); |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 451 | } |
| 452 | |
Steve French | d12fd12 | 2007-10-03 19:43:19 +0000 | [diff] [blame] | 453 | /* BB add length check to make sure that we do not have huge |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 454 | num auths and therefore go off the end */ |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 455 | cFYI(1, "RID 0x%x", |
| 456 | le32_to_cpu(psid->sub_auth[psid->num_subauth-1])); |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 457 | #endif |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 458 | } |
| 459 | |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 460 | return 0; |
| 461 | } |
| 462 | |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 463 | |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 464 | /* Convert CIFS ACL to POSIX form */ |
Steve French | 630f3f0 | 2007-10-25 21:17:17 +0000 | [diff] [blame] | 465 | static int parse_sec_desc(struct cifs_ntsd *pntsd, int acl_len, |
Jeff Layton | 0b8f18e | 2009-07-09 01:46:37 -0400 | [diff] [blame] | 466 | struct cifs_fattr *fattr) |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 467 | { |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 468 | int rc; |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 469 | struct cifs_sid *owner_sid_ptr, *group_sid_ptr; |
| 470 | struct cifs_acl *dacl_ptr; /* no need for SACL ptr */ |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 471 | char *end_of_acl = ((char *)pntsd) + acl_len; |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 472 | __u32 dacloffset; |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 473 | |
Jeff Layton | 0b8f18e | 2009-07-09 01:46:37 -0400 | [diff] [blame] | 474 | if (pntsd == NULL) |
Steve French | b9c7a2b | 2007-10-26 23:40:20 +0000 | [diff] [blame] | 475 | return -EIO; |
| 476 | |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 477 | owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + |
Steve French | af6f461 | 2007-10-16 18:40:37 +0000 | [diff] [blame] | 478 | le32_to_cpu(pntsd->osidoffset)); |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 479 | group_sid_ptr = (struct cifs_sid *)((char *)pntsd + |
Steve French | af6f461 | 2007-10-16 18:40:37 +0000 | [diff] [blame] | 480 | le32_to_cpu(pntsd->gsidoffset)); |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 481 | dacloffset = le32_to_cpu(pntsd->dacloffset); |
Steve French | 63d2583 | 2007-11-05 21:46:10 +0000 | [diff] [blame] | 482 | dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset); |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 483 | cFYI(DBG2, "revision %d type 0x%x ooffset 0x%x goffset 0x%x " |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 484 | "sacloffset 0x%x dacloffset 0x%x", |
Steve French | af6f461 | 2007-10-16 18:40:37 +0000 | [diff] [blame] | 485 | pntsd->revision, pntsd->type, le32_to_cpu(pntsd->osidoffset), |
| 486 | le32_to_cpu(pntsd->gsidoffset), |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 487 | le32_to_cpu(pntsd->sacloffset), dacloffset); |
Steve French | b9c7a2b | 2007-10-26 23:40:20 +0000 | [diff] [blame] | 488 | /* cifs_dump_mem("owner_sid: ", owner_sid_ptr, 64); */ |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 489 | rc = parse_sid(owner_sid_ptr, end_of_acl); |
| 490 | if (rc) |
| 491 | return rc; |
| 492 | |
| 493 | rc = parse_sid(group_sid_ptr, end_of_acl); |
| 494 | if (rc) |
| 495 | return rc; |
| 496 | |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 497 | if (dacloffset) |
| 498 | parse_dacl(dacl_ptr, end_of_acl, owner_sid_ptr, |
Jeff Layton | 0b8f18e | 2009-07-09 01:46:37 -0400 | [diff] [blame] | 499 | group_sid_ptr, fattr); |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 500 | else |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 501 | cFYI(1, "no ACL"); /* BB grant all or default perms? */ |
Shirish Pargaonkar | d0d66c4 | 2007-10-03 18:22:19 +0000 | [diff] [blame] | 502 | |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 503 | /* cifscred->uid = owner_sid_ptr->rid; |
| 504 | cifscred->gid = group_sid_ptr->rid; |
| 505 | memcpy((void *)(&(cifscred->osid)), (void *)owner_sid_ptr, |
Steve French | 630f3f0 | 2007-10-25 21:17:17 +0000 | [diff] [blame] | 506 | sizeof(struct cifs_sid)); |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 507 | memcpy((void *)(&(cifscred->gsid)), (void *)group_sid_ptr, |
Steve French | 630f3f0 | 2007-10-25 21:17:17 +0000 | [diff] [blame] | 508 | sizeof(struct cifs_sid)); */ |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 509 | |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 510 | return 0; |
Steve French | bcb0203 | 2007-09-25 16:17:24 +0000 | [diff] [blame] | 511 | } |
Steve French | b9c7a2b | 2007-10-26 23:40:20 +0000 | [diff] [blame] | 512 | |
| 513 | |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 514 | /* Convert permission bits from mode to equivalent CIFS ACL */ |
| 515 | static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, |
Steve French | cce246e | 2008-04-09 20:55:31 +0000 | [diff] [blame] | 516 | struct inode *inode, __u64 nmode) |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 517 | { |
| 518 | int rc = 0; |
| 519 | __u32 dacloffset; |
| 520 | __u32 ndacloffset; |
| 521 | __u32 sidsoffset; |
| 522 | struct cifs_sid *owner_sid_ptr, *group_sid_ptr; |
| 523 | struct cifs_acl *dacl_ptr = NULL; /* no need for SACL ptr */ |
| 524 | struct cifs_acl *ndacl_ptr = NULL; /* no need for SACL ptr */ |
| 525 | |
| 526 | if ((inode == NULL) || (pntsd == NULL) || (pnntsd == NULL)) |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 527 | return -EIO; |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 528 | |
| 529 | owner_sid_ptr = (struct cifs_sid *)((char *)pntsd + |
| 530 | le32_to_cpu(pntsd->osidoffset)); |
| 531 | group_sid_ptr = (struct cifs_sid *)((char *)pntsd + |
| 532 | le32_to_cpu(pntsd->gsidoffset)); |
| 533 | |
| 534 | dacloffset = le32_to_cpu(pntsd->dacloffset); |
| 535 | dacl_ptr = (struct cifs_acl *)((char *)pntsd + dacloffset); |
| 536 | |
| 537 | ndacloffset = sizeof(struct cifs_ntsd); |
| 538 | ndacl_ptr = (struct cifs_acl *)((char *)pnntsd + ndacloffset); |
| 539 | ndacl_ptr->revision = dacl_ptr->revision; |
| 540 | ndacl_ptr->size = 0; |
| 541 | ndacl_ptr->num_aces = 0; |
| 542 | |
| 543 | rc = set_chmod_dacl(ndacl_ptr, owner_sid_ptr, group_sid_ptr, nmode); |
| 544 | |
| 545 | sidsoffset = ndacloffset + le16_to_cpu(ndacl_ptr->size); |
| 546 | |
| 547 | /* copy security descriptor control portion and owner and group sid */ |
| 548 | copy_sec_desc(pntsd, pnntsd, sidsoffset); |
| 549 | |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 550 | return rc; |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 551 | } |
| 552 | |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 553 | static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, |
| 554 | __u16 fid, u32 *pacllen) |
Steve French | b9c7a2b | 2007-10-26 23:40:20 +0000 | [diff] [blame] | 555 | { |
Steve French | b9c7a2b | 2007-10-26 23:40:20 +0000 | [diff] [blame] | 556 | struct cifs_ntsd *pntsd = NULL; |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 557 | int xid, rc; |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 558 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); |
| 559 | |
| 560 | if (IS_ERR(tlink)) |
Shirish Pargaonkar | 987b21d | 2010-11-10 07:50:35 -0600 | [diff] [blame] | 561 | return ERR_CAST(tlink); |
Steve French | b9c7a2b | 2007-10-26 23:40:20 +0000 | [diff] [blame] | 562 | |
| 563 | xid = GetXid(); |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 564 | rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), fid, &pntsd, pacllen); |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 565 | FreeXid(xid); |
Steve French | 8b1327f | 2008-03-14 22:37:16 +0000 | [diff] [blame] | 566 | |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 567 | cifs_put_tlink(tlink); |
Steve French | b9c7a2b | 2007-10-26 23:40:20 +0000 | [diff] [blame] | 568 | |
Shirish Pargaonkar | 987b21d | 2010-11-10 07:50:35 -0600 | [diff] [blame] | 569 | cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen); |
| 570 | if (rc) |
| 571 | return ERR_PTR(rc); |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 572 | return pntsd; |
| 573 | } |
| 574 | |
| 575 | static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, |
| 576 | const char *path, u32 *pacllen) |
| 577 | { |
| 578 | struct cifs_ntsd *pntsd = NULL; |
| 579 | int oplock = 0; |
| 580 | int xid, rc; |
| 581 | __u16 fid; |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 582 | struct cifsTconInfo *tcon; |
| 583 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 584 | |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 585 | if (IS_ERR(tlink)) |
Shirish Pargaonkar | 987b21d | 2010-11-10 07:50:35 -0600 | [diff] [blame] | 586 | return ERR_CAST(tlink); |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 587 | |
| 588 | tcon = tlink_tcon(tlink); |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 589 | xid = GetXid(); |
| 590 | |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 591 | rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, 0, |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 592 | &fid, &oplock, NULL, cifs_sb->local_nls, |
| 593 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
Shirish Pargaonkar | 987b21d | 2010-11-10 07:50:35 -0600 | [diff] [blame] | 594 | if (!rc) { |
| 595 | rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen); |
| 596 | CIFSSMBClose(xid, tcon, fid); |
Steve French | b9c7a2b | 2007-10-26 23:40:20 +0000 | [diff] [blame] | 597 | } |
| 598 | |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 599 | cifs_put_tlink(tlink); |
Steve French | b9c7a2b | 2007-10-26 23:40:20 +0000 | [diff] [blame] | 600 | FreeXid(xid); |
Shirish Pargaonkar | 987b21d | 2010-11-10 07:50:35 -0600 | [diff] [blame] | 601 | |
| 602 | cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen); |
| 603 | if (rc) |
| 604 | return ERR_PTR(rc); |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 605 | return pntsd; |
| 606 | } |
| 607 | |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 608 | /* Retrieve an ACL from the server */ |
Shirish Pargaonkar | fbeba8b | 2010-11-27 11:37:54 -0600 | [diff] [blame] | 609 | struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb, |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 610 | struct inode *inode, const char *path, |
| 611 | u32 *pacllen) |
| 612 | { |
| 613 | struct cifs_ntsd *pntsd = NULL; |
| 614 | struct cifsFileInfo *open_file = NULL; |
| 615 | |
| 616 | if (inode) |
Jeff Layton | 6508d90 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 617 | open_file = find_readable_file(CIFS_I(inode), true); |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 618 | if (!open_file) |
| 619 | return get_cifs_acl_by_path(cifs_sb, path, pacllen); |
| 620 | |
| 621 | pntsd = get_cifs_acl_by_fid(cifs_sb, open_file->netfid, pacllen); |
Dave Kleikamp | 6ab409b | 2009-08-31 11:07:12 -0400 | [diff] [blame] | 622 | cifsFileInfo_put(open_file); |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 623 | return pntsd; |
| 624 | } |
| 625 | |
Christoph Hellwig | b96d31a | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 626 | static int set_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, __u16 fid, |
| 627 | struct cifs_ntsd *pnntsd, u32 acllen) |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 628 | { |
Christoph Hellwig | b96d31a | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 629 | int xid, rc; |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 630 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); |
| 631 | |
| 632 | if (IS_ERR(tlink)) |
| 633 | return PTR_ERR(tlink); |
Christoph Hellwig | b96d31a | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 634 | |
| 635 | xid = GetXid(); |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 636 | rc = CIFSSMBSetCIFSACL(xid, tlink_tcon(tlink), fid, pnntsd, acllen); |
Christoph Hellwig | b96d31a | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 637 | FreeXid(xid); |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 638 | cifs_put_tlink(tlink); |
Christoph Hellwig | b96d31a | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 639 | |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 640 | cFYI(DBG2, "SetCIFSACL rc = %d", rc); |
Christoph Hellwig | b96d31a | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 641 | return rc; |
| 642 | } |
| 643 | |
| 644 | static int set_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, const char *path, |
| 645 | struct cifs_ntsd *pnntsd, u32 acllen) |
| 646 | { |
| 647 | int oplock = 0; |
| 648 | int xid, rc; |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 649 | __u16 fid; |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 650 | struct cifsTconInfo *tcon; |
| 651 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 652 | |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 653 | if (IS_ERR(tlink)) |
| 654 | return PTR_ERR(tlink); |
| 655 | |
| 656 | tcon = tlink_tcon(tlink); |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 657 | xid = GetXid(); |
| 658 | |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 659 | rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, WRITE_DAC, 0, |
Christoph Hellwig | b96d31a | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 660 | &fid, &oplock, NULL, cifs_sb->local_nls, |
| 661 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
| 662 | if (rc) { |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 663 | cERROR(1, "Unable to open file to set ACL"); |
Christoph Hellwig | b96d31a | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 664 | goto out; |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 665 | } |
| 666 | |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 667 | rc = CIFSSMBSetCIFSACL(xid, tcon, fid, pnntsd, acllen); |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 668 | cFYI(DBG2, "SetCIFSACL rc = %d", rc); |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 669 | |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 670 | CIFSSMBClose(xid, tcon, fid); |
| 671 | out: |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 672 | FreeXid(xid); |
Jeff Layton | 7ffec37 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 673 | cifs_put_tlink(tlink); |
Christoph Hellwig | b96d31a | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 674 | return rc; |
| 675 | } |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 676 | |
Christoph Hellwig | b96d31a | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 677 | /* Set an ACL on the server */ |
| 678 | static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, |
| 679 | struct inode *inode, const char *path) |
| 680 | { |
| 681 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
| 682 | struct cifsFileInfo *open_file; |
| 683 | int rc; |
| 684 | |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 685 | cFYI(DBG2, "set ACL for %s from mode 0x%x", path, inode->i_mode); |
Christoph Hellwig | b96d31a | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 686 | |
Jeff Layton | 6508d90 | 2010-09-29 19:51:11 -0400 | [diff] [blame] | 687 | open_file = find_readable_file(CIFS_I(inode), true); |
Christoph Hellwig | b96d31a | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 688 | if (!open_file) |
| 689 | return set_cifs_acl_by_path(cifs_sb, path, pnntsd, acllen); |
| 690 | |
| 691 | rc = set_cifs_acl_by_fid(cifs_sb, open_file->netfid, pnntsd, acllen); |
Dave Kleikamp | 6ab409b | 2009-08-31 11:07:12 -0400 | [diff] [blame] | 692 | cifsFileInfo_put(open_file); |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 693 | return rc; |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 694 | } |
| 695 | |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 696 | /* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ |
Shirish Pargaonkar | 987b21d | 2010-11-10 07:50:35 -0600 | [diff] [blame] | 697 | int |
Jeff Layton | 0b8f18e | 2009-07-09 01:46:37 -0400 | [diff] [blame] | 698 | cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, |
| 699 | struct inode *inode, const char *path, const __u16 *pfid) |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 700 | { |
| 701 | struct cifs_ntsd *pntsd = NULL; |
| 702 | u32 acllen = 0; |
| 703 | int rc = 0; |
| 704 | |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 705 | cFYI(DBG2, "converting ACL to mode for %s", path); |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 706 | |
| 707 | if (pfid) |
| 708 | pntsd = get_cifs_acl_by_fid(cifs_sb, *pfid, &acllen); |
| 709 | else |
| 710 | pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen); |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 711 | |
| 712 | /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ |
Shirish Pargaonkar | 987b21d | 2010-11-10 07:50:35 -0600 | [diff] [blame] | 713 | if (IS_ERR(pntsd)) { |
| 714 | rc = PTR_ERR(pntsd); |
| 715 | cERROR(1, "%s: error %d getting sec desc", __func__, rc); |
| 716 | } else { |
Jeff Layton | 0b8f18e | 2009-07-09 01:46:37 -0400 | [diff] [blame] | 717 | rc = parse_sec_desc(pntsd, acllen, fattr); |
Shirish Pargaonkar | 987b21d | 2010-11-10 07:50:35 -0600 | [diff] [blame] | 718 | kfree(pntsd); |
| 719 | if (rc) |
| 720 | cERROR(1, "parse sec desc failed rc = %d", rc); |
| 721 | } |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 722 | |
Shirish Pargaonkar | 987b21d | 2010-11-10 07:50:35 -0600 | [diff] [blame] | 723 | return rc; |
Steve French | b9c7a2b | 2007-10-26 23:40:20 +0000 | [diff] [blame] | 724 | } |
Steve French | 953f868 | 2007-10-31 04:54:42 +0000 | [diff] [blame] | 725 | |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 726 | /* Convert mode bits to an ACL so we can update the ACL on the server */ |
Shirish Pargaonkar | 78415d2 | 2010-11-27 11:37:26 -0600 | [diff] [blame] | 727 | int mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode) |
Steve French | 953f868 | 2007-10-31 04:54:42 +0000 | [diff] [blame] | 728 | { |
| 729 | int rc = 0; |
Steve French | cce246e | 2008-04-09 20:55:31 +0000 | [diff] [blame] | 730 | __u32 secdesclen = 0; |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 731 | struct cifs_ntsd *pntsd = NULL; /* acl obtained from server */ |
| 732 | struct cifs_ntsd *pnntsd = NULL; /* modified acl to be sent to server */ |
Steve French | 953f868 | 2007-10-31 04:54:42 +0000 | [diff] [blame] | 733 | |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 734 | cFYI(DBG2, "set ACL from mode for %s", path); |
Steve French | 953f868 | 2007-10-31 04:54:42 +0000 | [diff] [blame] | 735 | |
| 736 | /* Get the security descriptor */ |
Christoph Hellwig | 1bf4072 | 2009-05-27 09:37:33 -0400 | [diff] [blame] | 737 | pntsd = get_cifs_acl(CIFS_SB(inode->i_sb), inode, path, &secdesclen); |
Steve French | 953f868 | 2007-10-31 04:54:42 +0000 | [diff] [blame] | 738 | |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 739 | /* Add three ACEs for owner, group, everyone getting rid of |
| 740 | other ACEs as chmod disables ACEs and set the security descriptor */ |
Steve French | 953f868 | 2007-10-31 04:54:42 +0000 | [diff] [blame] | 741 | |
Shirish Pargaonkar | 987b21d | 2010-11-10 07:50:35 -0600 | [diff] [blame] | 742 | if (IS_ERR(pntsd)) { |
| 743 | rc = PTR_ERR(pntsd); |
| 744 | cERROR(1, "%s: error %d getting sec desc", __func__, rc); |
| 745 | } else { |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 746 | /* allocate memory for the smb header, |
| 747 | set security descriptor request security descriptor |
| 748 | parameters, and secuirty descriptor itself */ |
Steve French | 953f868 | 2007-10-31 04:54:42 +0000 | [diff] [blame] | 749 | |
Steve French | cce246e | 2008-04-09 20:55:31 +0000 | [diff] [blame] | 750 | secdesclen = secdesclen < DEFSECDESCLEN ? |
| 751 | DEFSECDESCLEN : secdesclen; |
| 752 | pnntsd = kmalloc(secdesclen, GFP_KERNEL); |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 753 | if (!pnntsd) { |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 754 | cERROR(1, "Unable to allocate security descriptor"); |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 755 | kfree(pntsd); |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 756 | return -ENOMEM; |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 757 | } |
Steve French | 7505e05 | 2007-11-01 18:03:01 +0000 | [diff] [blame] | 758 | |
Steve French | cce246e | 2008-04-09 20:55:31 +0000 | [diff] [blame] | 759 | rc = build_sec_desc(pntsd, pnntsd, inode, nmode); |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 760 | |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 761 | cFYI(DBG2, "build_sec_desc rc: %d", rc); |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 762 | |
| 763 | if (!rc) { |
| 764 | /* Set the security descriptor */ |
Steve French | cce246e | 2008-04-09 20:55:31 +0000 | [diff] [blame] | 765 | rc = set_cifs_acl(pnntsd, secdesclen, inode, path); |
Joe Perches | b6b38f7 | 2010-04-21 03:50:45 +0000 | [diff] [blame] | 766 | cFYI(DBG2, "set_cifs_acl rc: %d", rc); |
Steve French | 9783758 | 2007-12-31 07:47:21 +0000 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | kfree(pnntsd); |
| 770 | kfree(pntsd); |
| 771 | } |
| 772 | |
Shirish Pargaonkar | ef571ca | 2008-07-24 15:56:05 +0000 | [diff] [blame] | 773 | return rc; |
Steve French | 953f868 | 2007-10-31 04:54:42 +0000 | [diff] [blame] | 774 | } |