The patch titled Subject: mm: use octal not symbolic permissions has been added to the -mm tree. Its filename is mm-use-octal-not-symbolic-permissions.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-use-octal-not-symbolic-permissions.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-use-octal-not-symbolic-permissions.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Joe Perches <joe@xxxxxxxxxxx> Subject: mm: use octal not symbolic permissions mm/*.c files use symbolic and octal styles for permissions. Using octal and not symbolic permissions is preferred by many as more readable. https://lkml.org/lkml/2016/8/2/1945 Prefer the direct use of octal for permissions. Done using $ scripts/checkpatch.pl -f --types=SYMBOLIC_PERMS --fix-inplace mm/*.c and some typing. Before: $ git grep -P -w "0[0-7]{3,3}" mm | wc -l 44 After: $ git grep -P -w "0[0-7]{3,3}" mm | wc -l 86 Miscellanea: o Whitespace neatening around these conversions. Link: http://lkml.kernel.org/r/2e032ef111eebcd4c5952bae86763b541d373469.1522102887.git.joe@xxxxxxxxxxx Signed-off-by: Joe Perches <joe@xxxxxxxxxxx> Acked-by: David Rientjes <rientjes@xxxxxxxxxx> Acked-by: Michal Hocko <mhocko@xxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/cleancache.c | 10 ++++------ mm/cma_debug.c | 25 ++++++++++--------------- mm/compaction.c | 2 +- mm/dmapool.c | 2 +- mm/failslab.c | 2 +- mm/frontswap.c | 11 +++++------ mm/memblock.c | 9 ++++++--- mm/page_alloc.c | 2 +- mm/page_idle.c | 2 +- mm/page_owner.c | 4 ++-- mm/shmem.c | 9 +++++---- mm/slab_common.c | 4 ++-- mm/vmalloc.c | 2 +- mm/zsmalloc.c | 5 +++-- mm/zswap.c | 38 +++++++++++++++++++------------------- 15 files changed, 62 insertions(+), 65 deletions(-) diff -puN mm/cleancache.c~mm-use-octal-not-symbolic-permissions mm/cleancache.c --- a/mm/cleancache.c~mm-use-octal-not-symbolic-permissions +++ a/mm/cleancache.c @@ -307,12 +307,10 @@ static int __init init_cleancache(void) struct dentry *root = debugfs_create_dir("cleancache", NULL); if (root == NULL) return -ENXIO; - debugfs_create_u64("succ_gets", S_IRUGO, root, &cleancache_succ_gets); - debugfs_create_u64("failed_gets", S_IRUGO, - root, &cleancache_failed_gets); - debugfs_create_u64("puts", S_IRUGO, root, &cleancache_puts); - debugfs_create_u64("invalidates", S_IRUGO, - root, &cleancache_invalidates); + debugfs_create_u64("succ_gets", 0444, root, &cleancache_succ_gets); + debugfs_create_u64("failed_gets", 0444, root, &cleancache_failed_gets); + debugfs_create_u64("puts", 0444, root, &cleancache_puts); + debugfs_create_u64("invalidates", 0444, root, &cleancache_invalidates); #endif return 0; } diff -puN mm/cma_debug.c~mm-use-octal-not-symbolic-permissions mm/cma_debug.c --- a/mm/cma_debug.c~mm-use-octal-not-symbolic-permissions +++ a/mm/cma_debug.c @@ -172,23 +172,18 @@ static void cma_debugfs_add_one(struct c tmp = debugfs_create_dir(name, cma_debugfs_root); - debugfs_create_file("alloc", S_IWUSR, tmp, cma, - &cma_alloc_fops); - - debugfs_create_file("free", S_IWUSR, tmp, cma, - &cma_free_fops); - - debugfs_create_file("base_pfn", S_IRUGO, tmp, - &cma->base_pfn, &cma_debugfs_fops); - debugfs_create_file("count", S_IRUGO, tmp, - &cma->count, &cma_debugfs_fops); - debugfs_create_file("order_per_bit", S_IRUGO, tmp, - &cma->order_per_bit, &cma_debugfs_fops); - debugfs_create_file("used", S_IRUGO, tmp, cma, &cma_used_fops); - debugfs_create_file("maxchunk", S_IRUGO, tmp, cma, &cma_maxchunk_fops); + debugfs_create_file("alloc", 0200, tmp, cma, &cma_alloc_fops); + debugfs_create_file("free", 0200, tmp, cma, &cma_free_fops); + debugfs_create_file("base_pfn", 0444, tmp, + &cma->base_pfn, &cma_debugfs_fops); + debugfs_create_file("count", 0444, tmp, &cma->count, &cma_debugfs_fops); + debugfs_create_file("order_per_bit", 0444, tmp, + &cma->order_per_bit, &cma_debugfs_fops); + debugfs_create_file("used", 0444, tmp, cma, &cma_used_fops); + debugfs_create_file("maxchunk", 0444, tmp, cma, &cma_maxchunk_fops); u32s = DIV_ROUND_UP(cma_bitmap_maxno(cma), BITS_PER_BYTE * sizeof(u32)); - debugfs_create_u32_array("bitmap", S_IRUGO, tmp, (u32*)cma->bitmap, u32s); + debugfs_create_u32_array("bitmap", 0444, tmp, (u32 *)cma->bitmap, u32s); } static int __init cma_debugfs_init(void) diff -puN mm/compaction.c~mm-use-octal-not-symbolic-permissions mm/compaction.c --- a/mm/compaction.c~mm-use-octal-not-symbolic-permissions +++ a/mm/compaction.c @@ -1897,7 +1897,7 @@ static ssize_t sysfs_compact_node(struct return count; } -static DEVICE_ATTR(compact, S_IWUSR, NULL, sysfs_compact_node); +static DEVICE_ATTR(compact, 0200, NULL, sysfs_compact_node); int compaction_register_node(struct node *node) { diff -puN mm/dmapool.c~mm-use-octal-not-symbolic-permissions mm/dmapool.c --- a/mm/dmapool.c~mm-use-octal-not-symbolic-permissions +++ a/mm/dmapool.c @@ -105,7 +105,7 @@ show_pools(struct device *dev, struct de return PAGE_SIZE - size; } -static DEVICE_ATTR(pools, S_IRUGO, show_pools, NULL); +static DEVICE_ATTR(pools, 0444, show_pools, NULL); /** * dma_pool_create - Creates a pool of consistent memory blocks, for dma. diff -puN mm/failslab.c~mm-use-octal-not-symbolic-permissions mm/failslab.c --- a/mm/failslab.c~mm-use-octal-not-symbolic-permissions +++ a/mm/failslab.c @@ -42,7 +42,7 @@ __setup("failslab=", setup_failslab); static int __init failslab_debugfs_init(void) { struct dentry *dir; - umode_t mode = S_IFREG | S_IRUSR | S_IWUSR; + umode_t mode = S_IFREG | 0600; dir = fault_create_debugfs_attr("failslab", NULL, &failslab.attr); if (IS_ERR(dir)) diff -puN mm/frontswap.c~mm-use-octal-not-symbolic-permissions mm/frontswap.c --- a/mm/frontswap.c~mm-use-octal-not-symbolic-permissions +++ a/mm/frontswap.c @@ -486,12 +486,11 @@ static int __init init_frontswap(void) struct dentry *root = debugfs_create_dir("frontswap", NULL); if (root == NULL) return -ENXIO; - debugfs_create_u64("loads", S_IRUGO, root, &frontswap_loads); - debugfs_create_u64("succ_stores", S_IRUGO, root, &frontswap_succ_stores); - debugfs_create_u64("failed_stores", S_IRUGO, root, - &frontswap_failed_stores); - debugfs_create_u64("invalidates", S_IRUGO, - root, &frontswap_invalidates); + debugfs_create_u64("loads", 0444, root, &frontswap_loads); + debugfs_create_u64("succ_stores", 0444, root, &frontswap_succ_stores); + debugfs_create_u64("failed_stores", 0444, root, + &frontswap_failed_stores); + debugfs_create_u64("invalidates", 0444, root, &frontswap_invalidates); #endif return 0; } diff -puN mm/memblock.c~mm-use-octal-not-symbolic-permissions mm/memblock.c --- a/mm/memblock.c~mm-use-octal-not-symbolic-permissions +++ a/mm/memblock.c @@ -1803,10 +1803,13 @@ static int __init memblock_init_debugfs( struct dentry *root = debugfs_create_dir("memblock", NULL); if (!root) return -ENXIO; - debugfs_create_file("memory", S_IRUGO, root, &memblock.memory, &memblock_debug_fops); - debugfs_create_file("reserved", S_IRUGO, root, &memblock.reserved, &memblock_debug_fops); + debugfs_create_file("memory", 0444, root, + &memblock.memory, &memblock_debug_fops); + debugfs_create_file("reserved", 0444, root, + &memblock.reserved, &memblock_debug_fops); #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP - debugfs_create_file("physmem", S_IRUGO, root, &memblock.physmem, &memblock_debug_fops); + debugfs_create_file("physmem", 0444, root, + &memblock.physmem, &memblock_debug_fops); #endif return 0; diff -puN mm/page_alloc.c~mm-use-octal-not-symbolic-permissions mm/page_alloc.c --- a/mm/page_alloc.c~mm-use-octal-not-symbolic-permissions +++ a/mm/page_alloc.c @@ -3086,7 +3086,7 @@ static bool should_fail_alloc_page(gfp_t static int __init fail_page_alloc_debugfs(void) { - umode_t mode = S_IFREG | S_IRUSR | S_IWUSR; + umode_t mode = S_IFREG | 0600; struct dentry *dir; dir = fault_create_debugfs_attr("fail_page_alloc", NULL, diff -puN mm/page_idle.c~mm-use-octal-not-symbolic-permissions mm/page_idle.c --- a/mm/page_idle.c~mm-use-octal-not-symbolic-permissions +++ a/mm/page_idle.c @@ -201,7 +201,7 @@ static ssize_t page_idle_bitmap_write(st } static struct bin_attribute page_idle_bitmap_attr = - __BIN_ATTR(bitmap, S_IRUSR | S_IWUSR, + __BIN_ATTR(bitmap, 0600, page_idle_bitmap_read, page_idle_bitmap_write, 0); static struct bin_attribute *page_idle_bin_attrs[] = { diff -puN mm/page_owner.c~mm-use-octal-not-symbolic-permissions mm/page_owner.c --- a/mm/page_owner.c~mm-use-octal-not-symbolic-permissions +++ a/mm/page_owner.c @@ -631,8 +631,8 @@ static int __init pageowner_init(void) return 0; } - dentry = debugfs_create_file("page_owner", S_IRUSR, NULL, - NULL, &proc_page_owner_operations); + dentry = debugfs_create_file("page_owner", 0400, NULL, + NULL, &proc_page_owner_operations); return PTR_ERR_OR_ZERO(dentry); } diff -puN mm/shmem.c~mm-use-octal-not-symbolic-permissions mm/shmem.c --- a/mm/shmem.c~mm-use-octal-not-symbolic-permissions +++ a/mm/shmem.c @@ -3237,7 +3237,8 @@ static int shmem_symlink(struct inode *d if (len > PAGE_SIZE) return -ENAMETOOLONG; - inode = shmem_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0, VM_NORESERVE); + inode = shmem_get_inode(dir->i_sb, dir, S_IFLNK | 0777, 0, + VM_NORESERVE); if (!inode) return -ENOSPC; @@ -3660,7 +3661,7 @@ static int shmem_show_options(struct seq sbinfo->max_blocks << (PAGE_SHIFT - 10)); if (sbinfo->max_inodes != shmem_default_max_inodes()) seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes); - if (sbinfo->mode != (S_IRWXUGO | S_ISVTX)) + if (sbinfo->mode != (0777 | S_ISVTX)) seq_printf(seq, ",mode=%03ho", sbinfo->mode); if (!uid_eq(sbinfo->uid, GLOBAL_ROOT_UID)) seq_printf(seq, ",uid=%u", @@ -3701,7 +3702,7 @@ int shmem_fill_super(struct super_block if (!sbinfo) return -ENOMEM; - sbinfo->mode = S_IRWXUGO | S_ISVTX; + sbinfo->mode = 0777 | S_ISVTX; sbinfo->uid = current_fsuid(); sbinfo->gid = current_fsgid(); sb->s_fs_info = sbinfo; @@ -4144,7 +4145,7 @@ static struct file *__shmem_file_setup(s d_set_d_op(path.dentry, &anon_ops); res = ERR_PTR(-ENOSPC); - inode = shmem_get_inode(sb, NULL, S_IFREG | S_IRWXUGO, 0, flags); + inode = shmem_get_inode(sb, NULL, S_IFREG | 0777, 0, flags); if (!inode) goto put_memory; diff -puN mm/slab_common.c~mm-use-octal-not-symbolic-permissions mm/slab_common.c --- a/mm/slab_common.c~mm-use-octal-not-symbolic-permissions +++ a/mm/slab_common.c @@ -1212,9 +1212,9 @@ void cache_random_seq_destroy(struct kme #if defined(CONFIG_SLAB) || defined(CONFIG_SLUB_DEBUG) #ifdef CONFIG_SLAB -#define SLABINFO_RIGHTS (S_IWUSR | S_IRUSR) +#define SLABINFO_RIGHTS (0600) #else -#define SLABINFO_RIGHTS S_IRUSR +#define SLABINFO_RIGHTS (0400) #endif static void print_slabinfo_header(struct seq_file *m) diff -puN mm/vmalloc.c~mm-use-octal-not-symbolic-permissions mm/vmalloc.c --- a/mm/vmalloc.c~mm-use-octal-not-symbolic-permissions +++ a/mm/vmalloc.c @@ -2769,7 +2769,7 @@ static const struct file_operations proc static int __init proc_vmalloc_init(void) { - proc_create("vmallocinfo", S_IRUSR, NULL, &proc_vmalloc_operations); + proc_create("vmallocinfo", 0400, NULL, &proc_vmalloc_operations); return 0; } module_init(proc_vmalloc_init); diff -puN mm/zsmalloc.c~mm-use-octal-not-symbolic-permissions mm/zsmalloc.c --- a/mm/zsmalloc.c~mm-use-octal-not-symbolic-permissions +++ a/mm/zsmalloc.c @@ -661,8 +661,9 @@ static void zs_pool_stat_create(struct z } pool->stat_dentry = entry; - entry = debugfs_create_file("classes", S_IFREG | S_IRUGO, - pool->stat_dentry, pool, &zs_stats_size_fops); + entry = debugfs_create_file("classes", S_IFREG | 0444, + pool->stat_dentry, pool, + &zs_stats_size_fops); if (!entry) { pr_warn("%s: debugfs file entry <%s> creation failed\n", name, "classes"); diff -puN mm/zswap.c~mm-use-octal-not-symbolic-permissions mm/zswap.c --- a/mm/zswap.c~mm-use-octal-not-symbolic-permissions +++ a/mm/zswap.c @@ -1256,26 +1256,26 @@ static int __init zswap_debugfs_init(voi if (!zswap_debugfs_root) return -ENOMEM; - debugfs_create_u64("pool_limit_hit", S_IRUGO, - zswap_debugfs_root, &zswap_pool_limit_hit); - debugfs_create_u64("reject_reclaim_fail", S_IRUGO, - zswap_debugfs_root, &zswap_reject_reclaim_fail); - debugfs_create_u64("reject_alloc_fail", S_IRUGO, - zswap_debugfs_root, &zswap_reject_alloc_fail); - debugfs_create_u64("reject_kmemcache_fail", S_IRUGO, - zswap_debugfs_root, &zswap_reject_kmemcache_fail); - debugfs_create_u64("reject_compress_poor", S_IRUGO, - zswap_debugfs_root, &zswap_reject_compress_poor); - debugfs_create_u64("written_back_pages", S_IRUGO, - zswap_debugfs_root, &zswap_written_back_pages); - debugfs_create_u64("duplicate_entry", S_IRUGO, - zswap_debugfs_root, &zswap_duplicate_entry); - debugfs_create_u64("pool_total_size", S_IRUGO, - zswap_debugfs_root, &zswap_pool_total_size); - debugfs_create_atomic_t("stored_pages", S_IRUGO, - zswap_debugfs_root, &zswap_stored_pages); + debugfs_create_u64("pool_limit_hit", 0444, + zswap_debugfs_root, &zswap_pool_limit_hit); + debugfs_create_u64("reject_reclaim_fail", 0444, + zswap_debugfs_root, &zswap_reject_reclaim_fail); + debugfs_create_u64("reject_alloc_fail", 0444, + zswap_debugfs_root, &zswap_reject_alloc_fail); + debugfs_create_u64("reject_kmemcache_fail", 0444, + zswap_debugfs_root, &zswap_reject_kmemcache_fail); + debugfs_create_u64("reject_compress_poor", 0444, + zswap_debugfs_root, &zswap_reject_compress_poor); + debugfs_create_u64("written_back_pages", 0444, + zswap_debugfs_root, &zswap_written_back_pages); + debugfs_create_u64("duplicate_entry", 0444, + zswap_debugfs_root, &zswap_duplicate_entry); + debugfs_create_u64("pool_total_size", 0444, + zswap_debugfs_root, &zswap_pool_total_size); + debugfs_create_atomic_t("stored_pages", 0444, + zswap_debugfs_root, &zswap_stored_pages); debugfs_create_atomic_t("same_filled_pages", 0444, - zswap_debugfs_root, &zswap_same_filled_pages); + zswap_debugfs_root, &zswap_same_filled_pages); return 0; } _ Patches currently in -mm which might be from joe@xxxxxxxxxxx are checkpatch-add-a-strict-test-for-structs-with-bool-member-definitions.patch mm-use-octal-not-symbolic-permissions.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html