hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/include/linux/fs.h
....@@ -716,7 +716,7 @@
716716 struct block_device *i_bdev;
717717 struct cdev *i_cdev;
718718 char *i_link;
719
- unsigned __i_dir_seq;
719
+ unsigned i_dir_seq;
720720 };
721721
722722 __u32 i_generation;
....@@ -1179,6 +1179,7 @@
11791179 extern int vfs_test_lock(struct file *, struct file_lock *);
11801180 extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *);
11811181 extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
1182
+bool vfs_inode_has_locks(struct inode *inode);
11821183 extern int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl);
11831184 extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type);
11841185 extern void lease_get_mtime(struct inode *, struct timespec64 *time);
....@@ -1291,6 +1292,11 @@
12911292 return 0;
12921293 }
12931294
1295
+static inline bool vfs_inode_has_locks(struct inode *inode)
1296
+{
1297
+ return false;
1298
+}
1299
+
12941300 static inline int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl)
12951301 {
12961302 return -ENOLCK;
....@@ -1376,29 +1382,29 @@
13761382 * sb->s_flags. Note that these mirror the equivalent MS_* flags where
13771383 * represented in both.
13781384 */
1379
-#define SB_RDONLY 1 /* Mount read-only */
1380
-#define SB_NOSUID 2 /* Ignore suid and sgid bits */
1381
-#define SB_NODEV 4 /* Disallow access to device special files */
1382
-#define SB_NOEXEC 8 /* Disallow program execution */
1383
-#define SB_SYNCHRONOUS 16 /* Writes are synced at once */
1384
-#define SB_MANDLOCK 64 /* Allow mandatory locks on an FS */
1385
-#define SB_DIRSYNC 128 /* Directory modifications are synchronous */
1386
-#define SB_NOATIME 1024 /* Do not update access times. */
1387
-#define SB_NODIRATIME 2048 /* Do not update directory access times */
1388
-#define SB_SILENT 32768
1389
-#define SB_POSIXACL (1<<16) /* VFS does not apply the umask */
1390
-#define SB_INLINECRYPT (1<<17) /* Use blk-crypto for encrypted files */
1391
-#define SB_KERNMOUNT (1<<22) /* this is a kern_mount call */
1392
-#define SB_I_VERSION (1<<23) /* Update inode I_version field */
1393
-#define SB_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */
1385
+#define SB_RDONLY BIT(0) /* Mount read-only */
1386
+#define SB_NOSUID BIT(1) /* Ignore suid and sgid bits */
1387
+#define SB_NODEV BIT(2) /* Disallow access to device special files */
1388
+#define SB_NOEXEC BIT(3) /* Disallow program execution */
1389
+#define SB_SYNCHRONOUS BIT(4) /* Writes are synced at once */
1390
+#define SB_MANDLOCK BIT(6) /* Allow mandatory locks on an FS */
1391
+#define SB_DIRSYNC BIT(7) /* Directory modifications are synchronous */
1392
+#define SB_NOATIME BIT(10) /* Do not update access times. */
1393
+#define SB_NODIRATIME BIT(11) /* Do not update directory access times */
1394
+#define SB_SILENT BIT(15)
1395
+#define SB_POSIXACL BIT(16) /* VFS does not apply the umask */
1396
+#define SB_INLINECRYPT BIT(17) /* Use blk-crypto for encrypted files */
1397
+#define SB_KERNMOUNT BIT(22) /* this is a kern_mount call */
1398
+#define SB_I_VERSION BIT(23) /* Update inode I_version field */
1399
+#define SB_LAZYTIME BIT(25) /* Update the on-disk [acm]times lazily */
13941400
13951401 /* These sb flags are internal to the kernel */
1396
-#define SB_SUBMOUNT (1<<26)
1397
-#define SB_FORCE (1<<27)
1398
-#define SB_NOSEC (1<<28)
1399
-#define SB_BORN (1<<29)
1400
-#define SB_ACTIVE (1<<30)
1401
-#define SB_NOUSER (1<<31)
1402
+#define SB_SUBMOUNT BIT(26)
1403
+#define SB_FORCE BIT(27)
1404
+#define SB_NOSEC BIT(28)
1405
+#define SB_BORN BIT(29)
1406
+#define SB_ACTIVE BIT(30)
1407
+#define SB_NOUSER BIT(31)
14021408
14031409 /* These flags relate to encoding and casefolding */
14041410 #define SB_ENC_STRICT_MODE_FL (1 << 0)
....@@ -1810,6 +1816,7 @@
18101816 extern void inode_init_owner(struct inode *inode, const struct inode *dir,
18111817 umode_t mode);
18121818 extern bool may_open_dev(const struct path *path);
1819
+umode_t mode_strip_sgid(const struct inode *dir, umode_t mode);
18131820
18141821 /*
18151822 * This is the "filldir" function type, used by readdir() to let
....@@ -3021,7 +3028,7 @@
30213028 extern struct inode *new_inode_pseudo(struct super_block *sb);
30223029 extern struct inode *new_inode(struct super_block *sb);
30233030 extern void free_inode_nonrcu(struct inode *inode);
3024
-extern int should_remove_suid(struct dentry *);
3031
+extern int setattr_should_drop_suidgid(struct inode *);
30253032 extern int file_remove_privs(struct file *);
30263033
30273034 extern void __insert_inode_hash(struct inode *, unsigned long hashval);
....@@ -3414,7 +3421,7 @@
34143421 * All attributes contain a text representation of a numeric value
34153422 * that are accessed with the get() and set() functions.
34163423 */
3417
-#define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt) \
3424
+#define DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, __is_signed) \
34183425 static int __fops ## _open(struct inode *inode, struct file *file) \
34193426 { \
34203427 __simple_attr_check_format(__fmt, 0ull); \
....@@ -3425,9 +3432,15 @@
34253432 .open = __fops ## _open, \
34263433 .release = simple_attr_release, \
34273434 .read = simple_attr_read, \
3428
- .write = simple_attr_write, \
3435
+ .write = (__is_signed) ? simple_attr_write_signed : simple_attr_write, \
34293436 .llseek = generic_file_llseek, \
34303437 }
3438
+
3439
+#define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt) \
3440
+ DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, false)
3441
+
3442
+#define DEFINE_SIMPLE_ATTRIBUTE_SIGNED(__fops, __get, __set, __fmt) \
3443
+ DEFINE_SIMPLE_ATTRIBUTE_XSIGNED(__fops, __get, __set, __fmt, true)
34313444
34323445 static inline __printf(1, 2)
34333446 void __simple_attr_check_format(const char *fmt, ...)
....@@ -3443,6 +3456,8 @@
34433456 size_t len, loff_t *ppos);
34443457 ssize_t simple_attr_write(struct file *file, const char __user *buf,
34453458 size_t len, loff_t *ppos);
3459
+ssize_t simple_attr_write_signed(struct file *file, const char __user *buf,
3460
+ size_t len, loff_t *ppos);
34463461
34473462 struct ctl_table;
34483463 int proc_nr_files(struct ctl_table *table, int write,
....@@ -3462,7 +3477,7 @@
34623477
34633478 static inline bool is_sxid(umode_t mode)
34643479 {
3465
- return (mode & S_ISUID) || ((mode & S_ISGID) && (mode & S_IXGRP));
3480
+ return mode & (S_ISUID | S_ISGID);
34663481 }
34673482
34683483 static inline int check_sticky(struct inode *dir, struct inode *inode)