]> git.ipfire.org Git - people/ms/linux.git/blobdiff - mm/shmem.c
Importing "grsecurity-3.1-3.19.2-201503201903.patch"
[people/ms/linux.git] / mm / shmem.c
index 993e6ba689ccd442aa33e42489e71f0e558d1943..a962ba314d34ecf1aac762fef2659c1867eee60f 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/swap.h>
 #include <linux/aio.h>
 
-static struct vfsmount *shm_mnt;
+struct vfsmount *shm_mnt;
 
 #ifdef CONFIG_SHMEM
 /*
@@ -80,7 +80,7 @@ static struct vfsmount *shm_mnt;
 #define BOGO_DIRENT_SIZE 20
 
 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
-#define SHORT_SYMLINK_LEN 128
+#define SHORT_SYMLINK_LEN 64
 
 /*
  * shmem_fallocate communicates with shmem_fault or shmem_writepage via
@@ -2558,6 +2558,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
 static int shmem_xattr_validate(const char *name)
 {
        struct { const char *prefix; size_t len; } arr[] = {
+
+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
+               { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
+#endif
+
                { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
                { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
        };
@@ -2613,6 +2618,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
        if (err)
                return err;
 
+#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
+       if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
+               if (strcmp(name, XATTR_NAME_PAX_FLAGS))
+                       return -EOPNOTSUPP;
+               if (size > 8)
+                       return -EINVAL;
+       }
+#endif
+
        return simple_xattr_set(&info->xattrs, name, value, size, flags);
 }
 
@@ -2996,8 +3010,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
        int err = -ENOMEM;
 
        /* Round up to L1_CACHE_BYTES to resist false sharing */
-       sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
-                               L1_CACHE_BYTES), GFP_KERNEL);
+       sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
        if (!sbinfo)
                return -ENOMEM;