|
12 | 12 | #include <linux/security.h> |
13 | 13 | #include <linux/cdev.h> |
14 | 14 | #include <linux/memblock.h> |
15 | | -#include <linux/fscrypt.h> |
16 | 15 | #include <linux/fsnotify.h> |
17 | 16 | #include <linux/mount.h> |
18 | 17 | #include <linux/posix_acl.h> |
@@ -2314,89 +2313,3 @@ struct timespec64 current_time(struct inode *inode) |
2314 | 2313 | return timestamp_truncate(now, inode); |
2315 | 2314 | } |
2316 | 2315 | EXPORT_SYMBOL(current_time); |
2317 | | - |
2318 | | -/* |
2319 | | - * Generic function to check FS_IOC_SETFLAGS values and reject any invalid |
2320 | | - * configurations. |
2321 | | - * |
2322 | | - * Note: the caller should be holding i_mutex, or else be sure that they have |
2323 | | - * exclusive access to the inode structure. |
2324 | | - */ |
2325 | | -int vfs_ioc_setflags_prepare(struct inode *inode, unsigned int oldflags, |
2326 | | - unsigned int flags) |
2327 | | -{ |
2328 | | - /* |
2329 | | - * The IMMUTABLE and APPEND_ONLY flags can only be changed by |
2330 | | - * the relevant capability. |
2331 | | - * |
2332 | | - * This test looks nicer. Thanks to Pauline Middelink |
2333 | | - */ |
2334 | | - if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL) && |
2335 | | - !capable(CAP_LINUX_IMMUTABLE)) |
2336 | | - return -EPERM; |
2337 | | - |
2338 | | - return fscrypt_prepare_setflags(inode, oldflags, flags); |
2339 | | -} |
2340 | | -EXPORT_SYMBOL(vfs_ioc_setflags_prepare); |
2341 | | - |
2342 | | -/* |
2343 | | - * Generic function to check FS_IOC_FSSETXATTR values and reject any invalid |
2344 | | - * configurations. |
2345 | | - * |
2346 | | - * Note: the caller should be holding i_mutex, or else be sure that they have |
2347 | | - * exclusive access to the inode structure. |
2348 | | - */ |
2349 | | -int vfs_ioc_fssetxattr_check(struct inode *inode, const struct fsxattr *old_fa, |
2350 | | - struct fsxattr *fa) |
2351 | | -{ |
2352 | | - /* |
2353 | | - * Can't modify an immutable/append-only file unless we have |
2354 | | - * appropriate permission. |
2355 | | - */ |
2356 | | - if ((old_fa->fsx_xflags ^ fa->fsx_xflags) & |
2357 | | - (FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND) && |
2358 | | - !capable(CAP_LINUX_IMMUTABLE)) |
2359 | | - return -EPERM; |
2360 | | - |
2361 | | - /* |
2362 | | - * Project Quota ID state is only allowed to change from within the init |
2363 | | - * namespace. Enforce that restriction only if we are trying to change |
2364 | | - * the quota ID state. Everything else is allowed in user namespaces. |
2365 | | - */ |
2366 | | - if (current_user_ns() != &init_user_ns) { |
2367 | | - if (old_fa->fsx_projid != fa->fsx_projid) |
2368 | | - return -EINVAL; |
2369 | | - if ((old_fa->fsx_xflags ^ fa->fsx_xflags) & |
2370 | | - FS_XFLAG_PROJINHERIT) |
2371 | | - return -EINVAL; |
2372 | | - } |
2373 | | - |
2374 | | - /* Check extent size hints. */ |
2375 | | - if ((fa->fsx_xflags & FS_XFLAG_EXTSIZE) && !S_ISREG(inode->i_mode)) |
2376 | | - return -EINVAL; |
2377 | | - |
2378 | | - if ((fa->fsx_xflags & FS_XFLAG_EXTSZINHERIT) && |
2379 | | - !S_ISDIR(inode->i_mode)) |
2380 | | - return -EINVAL; |
2381 | | - |
2382 | | - if ((fa->fsx_xflags & FS_XFLAG_COWEXTSIZE) && |
2383 | | - !S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) |
2384 | | - return -EINVAL; |
2385 | | - |
2386 | | - /* |
2387 | | - * It is only valid to set the DAX flag on regular files and |
2388 | | - * directories on filesystems. |
2389 | | - */ |
2390 | | - if ((fa->fsx_xflags & FS_XFLAG_DAX) && |
2391 | | - !(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode))) |
2392 | | - return -EINVAL; |
2393 | | - |
2394 | | - /* Extent size hints of zero turn off the flags. */ |
2395 | | - if (fa->fsx_extsize == 0) |
2396 | | - fa->fsx_xflags &= ~(FS_XFLAG_EXTSIZE | FS_XFLAG_EXTSZINHERIT); |
2397 | | - if (fa->fsx_cowextsize == 0) |
2398 | | - fa->fsx_xflags &= ~FS_XFLAG_COWEXTSIZE; |
2399 | | - |
2400 | | - return 0; |
2401 | | -} |
2402 | | -EXPORT_SYMBOL(vfs_ioc_fssetxattr_check); |
0 commit comments