| .. | .. |
|---|
| 29 | 29 | static inline int f2fs_acl_count(size_t size) |
|---|
| 30 | 30 | { |
|---|
| 31 | 31 | ssize_t s; |
|---|
| 32 | + |
|---|
| 32 | 33 | size -= sizeof(struct f2fs_acl_header); |
|---|
| 33 | 34 | s = size - 4 * sizeof(struct f2fs_acl_entry_short); |
|---|
| 34 | 35 | if (s < 0) { |
|---|
| .. | .. |
|---|
| 160 | 161 | return (void *)f2fs_acl; |
|---|
| 161 | 162 | |
|---|
| 162 | 163 | fail: |
|---|
| 163 | | - kvfree(f2fs_acl); |
|---|
| 164 | + kfree(f2fs_acl); |
|---|
| 164 | 165 | return ERR_PTR(-EINVAL); |
|---|
| 165 | 166 | } |
|---|
| 166 | 167 | |
|---|
| .. | .. |
|---|
| 190 | 191 | acl = NULL; |
|---|
| 191 | 192 | else |
|---|
| 192 | 193 | acl = ERR_PTR(retval); |
|---|
| 193 | | - kvfree(value); |
|---|
| 194 | + kfree(value); |
|---|
| 194 | 195 | |
|---|
| 195 | 196 | return acl; |
|---|
| 196 | 197 | } |
|---|
| .. | .. |
|---|
| 198 | 199 | struct posix_acl *f2fs_get_acl(struct inode *inode, int type) |
|---|
| 199 | 200 | { |
|---|
| 200 | 201 | return __f2fs_get_acl(inode, type, NULL); |
|---|
| 202 | +} |
|---|
| 203 | + |
|---|
| 204 | +static int f2fs_acl_update_mode(struct inode *inode, umode_t *mode_p, |
|---|
| 205 | + struct posix_acl **acl) |
|---|
| 206 | +{ |
|---|
| 207 | + umode_t mode = inode->i_mode; |
|---|
| 208 | + int error; |
|---|
| 209 | + |
|---|
| 210 | + if (is_inode_flag_set(inode, FI_ACL_MODE)) |
|---|
| 211 | + mode = F2FS_I(inode)->i_acl_mode; |
|---|
| 212 | + |
|---|
| 213 | + error = posix_acl_equiv_mode(*acl, &mode); |
|---|
| 214 | + if (error < 0) |
|---|
| 215 | + return error; |
|---|
| 216 | + if (error == 0) |
|---|
| 217 | + *acl = NULL; |
|---|
| 218 | + if (!in_group_p(inode->i_gid) && |
|---|
| 219 | + !capable_wrt_inode_uidgid(inode, CAP_FSETID)) |
|---|
| 220 | + mode &= ~S_ISGID; |
|---|
| 221 | + *mode_p = mode; |
|---|
| 222 | + return 0; |
|---|
| 201 | 223 | } |
|---|
| 202 | 224 | |
|---|
| 203 | 225 | static int __f2fs_set_acl(struct inode *inode, int type, |
|---|
| .. | .. |
|---|
| 213 | 235 | case ACL_TYPE_ACCESS: |
|---|
| 214 | 236 | name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS; |
|---|
| 215 | 237 | if (acl && !ipage) { |
|---|
| 216 | | - error = posix_acl_update_mode(inode, &mode, &acl); |
|---|
| 238 | + error = f2fs_acl_update_mode(inode, &mode, &acl); |
|---|
| 217 | 239 | if (error) |
|---|
| 218 | 240 | return error; |
|---|
| 219 | 241 | set_acl_inode(inode, mode); |
|---|
| .. | .. |
|---|
| 240 | 262 | |
|---|
| 241 | 263 | error = f2fs_setxattr(inode, name_index, "", value, size, ipage, 0); |
|---|
| 242 | 264 | |
|---|
| 243 | | - kvfree(value); |
|---|
| 265 | + kfree(value); |
|---|
| 244 | 266 | if (!error) |
|---|
| 245 | 267 | set_cached_acl(inode, type, acl); |
|---|
| 246 | 268 | |
|---|
| .. | .. |
|---|
| 384 | 406 | struct page *dpage) |
|---|
| 385 | 407 | { |
|---|
| 386 | 408 | struct posix_acl *default_acl = NULL, *acl = NULL; |
|---|
| 387 | | - int error = 0; |
|---|
| 409 | + int error; |
|---|
| 388 | 410 | |
|---|
| 389 | 411 | error = f2fs_acl_create(dir, &inode->i_mode, &default_acl, &acl, dpage); |
|---|
| 390 | 412 | if (error) |
|---|