2323 * testing etc..
2424 */
2525#include <linux/fs.h>
26+ #include <linux/fs_struct.h>
2627#include <linux/init.h>
2728#include <linux/kernel.h>
2829#include <linux/kobject.h>
@@ -492,6 +493,10 @@ struct inode *nullfs_get_inode(struct super_block *sb, const struct inode *dir,
492493 return inode ;
493494}
494495
496+ static inline umode_t nullfs_apply_umask (umode_t mode ) {
497+ return (mode & S_IFMT ) | ((mode & S_IALLUGO ) & ~current_umask ());
498+ }
499+
495500#if LINUX_VERSION_CODE >= KERNEL_VERSION (6 , 3 , 0 )
496501static int nullfs_mknod (struct mnt_idmap * idmap , struct inode * dir ,
497502 struct dentry * dentry , umode_t mode , dev_t dev )
@@ -506,7 +511,8 @@ static int nullfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
506511 struct inode * inode ;
507512 int error = - ENOSPC ;
508513
509- inode = nullfs_get_inode (dir -> i_sb , dir , mode , dev , dentry );
514+ umode_t masked = nullfs_apply_umask (mode );
515+ inode = nullfs_get_inode (dir -> i_sb , dir , masked , dev , dentry );
510516
511517 if (inode ) {
512518 /**
@@ -647,11 +653,12 @@ static int nullfs_tmpfile(struct inode *dir, struct dentry *dentry,
647653 umode_t mode )
648654#endif
649655{
656+ umode_t masked = nullfs_apply_umask (mode );
650657 struct inode * inode ;
651658#if LINUX_VERSION_CODE >= KERNEL_VERSION (6 , 1 , 0 )
652- inode = nullfs_get_inode (dir -> i_sb , dir , mode , 0 , file -> f_path .dentry );
659+ inode = nullfs_get_inode (dir -> i_sb , dir , masked , 0 , file -> f_path .dentry );
653660#else
654- inode = nullfs_get_inode (dir -> i_sb , dir , mode , 0 , dentry );
661+ inode = nullfs_get_inode (dir -> i_sb , dir , masked , 0 , dentry );
655662#endif
656663 if (!inode )
657664 return - ENOSPC ;
0 commit comments