diff options
Diffstat (limited to 'fs/hugetlbfs/inode.c')
| -rw-r--r-- | fs/hugetlbfs/inode.c | 25 | 
1 files changed, 18 insertions, 7 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index a93b885311d8..eba6d552d9c9 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c  | |||
| @@ -31,12 +31,10 @@ | |||
| 31 | #include <linux/statfs.h> | 31 | #include <linux/statfs.h> | 
| 32 | #include <linux/security.h> | 32 | #include <linux/security.h> | 
| 33 | #include <linux/ima.h> | 33 | #include <linux/ima.h> | 
| 34 | #include <linux/magic.h> | ||
| 34 | 35 | ||
| 35 | #include <asm/uaccess.h> | 36 | #include <asm/uaccess.h> | 
| 36 | 37 | ||
| 37 | /* some random number */ | ||
| 38 | #define HUGETLBFS_MAGIC 0x958458f6 | ||
| 39 | |||
| 40 | static const struct super_operations hugetlbfs_ops; | 38 | static const struct super_operations hugetlbfs_ops; | 
| 41 | static const struct address_space_operations hugetlbfs_aops; | 39 | static const struct address_space_operations hugetlbfs_aops; | 
| 42 | const struct file_operations hugetlbfs_file_operations; | 40 | const struct file_operations hugetlbfs_file_operations; | 
| @@ -507,6 +505,13 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb, uid_t uid, | |||
| 507 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 505 | inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 
| 508 | INIT_LIST_HEAD(&inode->i_mapping->private_list); | 506 | INIT_LIST_HEAD(&inode->i_mapping->private_list); | 
| 509 | info = HUGETLBFS_I(inode); | 507 | info = HUGETLBFS_I(inode); | 
| 508 | /* | ||
| 509 | * The policy is initialized here even if we are creating a | ||
| 510 | * private inode because initialization simply creates an | ||
| 511 | * an empty rb tree and calls spin_lock_init(), later when we | ||
| 512 | * call mpol_free_shared_policy() it will just return because | ||
| 513 | * the rb tree will still be empty. | ||
| 514 | */ | ||
| 510 | mpol_shared_policy_init(&info->policy, NULL); | 515 | mpol_shared_policy_init(&info->policy, NULL); | 
| 511 | switch (mode & S_IFMT) { | 516 | switch (mode & S_IFMT) { | 
| 512 | default: | 517 | default: | 
| @@ -931,13 +936,19 @@ static struct file_system_type hugetlbfs_fs_type = { | |||
| 931 | 936 | ||
| 932 | static struct vfsmount *hugetlbfs_vfsmount; | 937 | static struct vfsmount *hugetlbfs_vfsmount; | 
| 933 | 938 | ||
| 934 | static int can_do_hugetlb_shm(void) | 939 | static int can_do_hugetlb_shm(int creat_flags) | 
| 935 | { | 940 | { | 
| 936 | return capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group); | 941 | if (creat_flags != HUGETLB_SHMFS_INODE) | 
| 942 | return 0; | ||
| 943 | if (capable(CAP_IPC_LOCK)) | ||
| 944 | return 1; | ||
| 945 | if (in_group_p(sysctl_hugetlb_shm_group)) | ||
| 946 | return 1; | ||
| 947 | return 0; | ||
| 937 | } | 948 | } | 
| 938 | 949 | ||
| 939 | struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag, | 950 | struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag, | 
| 940 | struct user_struct **user) | 951 | struct user_struct **user, int creat_flags) | 
| 941 | { | 952 | { | 
| 942 | int error = -ENOMEM; | 953 | int error = -ENOMEM; | 
| 943 | struct file *file; | 954 | struct file *file; | 
| @@ -949,7 +960,7 @@ struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag, | |||
| 949 | if (!hugetlbfs_vfsmount) | 960 | if (!hugetlbfs_vfsmount) | 
| 950 | return ERR_PTR(-ENOENT); | 961 | return ERR_PTR(-ENOENT); | 
| 951 | 962 | ||
| 952 | if (!can_do_hugetlb_shm()) { | 963 | if (!can_do_hugetlb_shm(creat_flags)) { | 
| 953 | *user = current_user(); | 964 | *user = current_user(); | 
| 954 | if (user_shm_lock(size, *user)) { | 965 | if (user_shm_lock(size, *user)) { | 
| 955 | WARN_ONCE(1, | 966 | WARN_ONCE(1, | 
