hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/f2fs/acl.c
....@@ -29,6 +29,7 @@
2929 static inline int f2fs_acl_count(size_t size)
3030 {
3131 ssize_t s;
32
+
3233 size -= sizeof(struct f2fs_acl_header);
3334 s = size - 4 * sizeof(struct f2fs_acl_entry_short);
3435 if (s < 0) {
....@@ -160,7 +161,7 @@
160161 return (void *)f2fs_acl;
161162
162163 fail:
163
- kvfree(f2fs_acl);
164
+ kfree(f2fs_acl);
164165 return ERR_PTR(-EINVAL);
165166 }
166167
....@@ -190,7 +191,7 @@
190191 acl = NULL;
191192 else
192193 acl = ERR_PTR(retval);
193
- kvfree(value);
194
+ kfree(value);
194195
195196 return acl;
196197 }
....@@ -198,6 +199,27 @@
198199 struct posix_acl *f2fs_get_acl(struct inode *inode, int type)
199200 {
200201 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;
201223 }
202224
203225 static int __f2fs_set_acl(struct inode *inode, int type,
....@@ -213,7 +235,7 @@
213235 case ACL_TYPE_ACCESS:
214236 name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS;
215237 if (acl && !ipage) {
216
- error = posix_acl_update_mode(inode, &mode, &acl);
238
+ error = f2fs_acl_update_mode(inode, &mode, &acl);
217239 if (error)
218240 return error;
219241 set_acl_inode(inode, mode);
....@@ -240,7 +262,7 @@
240262
241263 error = f2fs_setxattr(inode, name_index, "", value, size, ipage, 0);
242264
243
- kvfree(value);
265
+ kfree(value);
244266 if (!error)
245267 set_cached_acl(inode, type, acl);
246268
....@@ -384,7 +406,7 @@
384406 struct page *dpage)
385407 {
386408 struct posix_acl *default_acl = NULL, *acl = NULL;
387
- int error = 0;
409
+ int error;
388410
389411 error = f2fs_acl_create(dir, &inode->i_mode, &default_acl, &acl, dpage);
390412 if (error)