From: Ingo Molnar <mingo@kernel.org> To: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org>, Thomas Gleixner <tglx@linutronix.de>, LKML <linux-kernel@vger.kernel.org>, Dave Hansen <dave.hansen@linux.intel.com>, Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>, Brian Gerst <brgerst@gmail.com>, Denys Vlasenko <dvlasenk@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>, Josh Poimboeuf <jpoimboe@redhat.com>, Rik van Riel <riel@redhat.com>, Daniel Gruss <daniel.gruss@iaik.tugraz.at>, Hugh Dickins <hughd@google.com>, Kees Cook <keescook@google.com>, linux-mm <linux-mm@kvack.org>, michael.schwarz@iaik.tugraz.at, moritz.lipp@iaik.tugraz.at, richard.fellner@student.tugraz.at Subject: Re: [PATCH] vfs: Add PERM_* symbolic helpers for common file mode/permissions Date: Tue, 28 Nov 2017 12:12:14 +0100 [thread overview] Message-ID: <20171128111214.42esi4igzgnldsx5@gmail.com> (raw) In-Reply-To: <CA+55aFyLC9+S=MZueRXMmwwnx47bhovXr1YhRg+FAPFfQZXoYA@mail.gmail.com> * Linus Torvalds <torvalds@linux-foundation.org> wrote: > On Mon, Nov 27, 2017 at 2:06 AM, Ingo Molnar <mingo@kernel.org> wrote: > > > > > > +/* > > + * Human readable symbolic definitions for common > > + * file permissions: > > + */ > > +#define PERM_r________ 0400 > > +#define PERM_r__r_____ 0440 > > +#define PERM_r__r__r__ 0444 > > I'm not a fan. Particularly as you have a very random set of > permissions (rx and wx? Not very common), So I originally created those defines based on a grep of patterns used in the kernel, and added the 'wx' variants for completeness. We would only need a small subset. Here's a git grep based histogram of octal file permission masks used in the kernel source: # mode 21 0200 8 0220 14 0222 33 0400 11 0440 219 0444 91 0555 39 0600 906 0644 12 0660 12 0664 18 0666 14 0755 31 0777 So there's literally only 14 variants used, and 0644 and 0444 make up 95% of the cases. We get the patch below if we extend these existing patterns using their natural (looking) generators to a complete group - 19 patterns that should cover all the sensible combinations. > but also because it's just not that legible. Fair enough. Thanks, Ingo --- include/linux/stat.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) Index: tip/include/linux/stat.h =================================================================== --- tip.orig/include/linux/stat.h +++ tip/include/linux/stat.h @@ -6,6 +6,34 @@ #include <asm/stat.h> #include <uapi/linux/stat.h> +/* + * Human readable symbolic definitions for common + * file permissions: + */ +#define PERM_r________ 0400 +#define PERM_r__r_____ 0440 +#define PERM_r__r__r__ 0444 + +#define PERM_rw_______ 0600 +#define PERM_rw_r_____ 0640 +#define PERM_rw_r__r__ 0644 +#define PERM_rw_rw_r__ 0664 +#define PERM_rw_rw_rw_ 0666 + +#define PERM__w_______ 0200 +#define PERM__w__w____ 0220 +#define PERM__w__w__w_ 0222 + +#define PERM_r_x______ 0500 +#define PERM_r_xr_x___ 0550 +#define PERM_r_xr_xr_x 0555 + +#define PERM_rwx______ 0700 +#define PERM_rwxr_x___ 0750 +#define PERM_rwxr_xr_x 0755 +#define PERM_rwxrwxr_x 0775 +#define PERM_rwxrwxrwx 0777 + #define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) #define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) #define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH)
WARNING: multiple messages have this Message-ID (diff)
From: Ingo Molnar <mingo@kernel.org> To: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org>, Thomas Gleixner <tglx@linutronix.de>, LKML <linux-kernel@vger.kernel.org>, Dave Hansen <dave.hansen@linux.intel.com>, Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>, Brian Gerst <brgerst@gmail.com>, Denys Vlasenko <dvlasenk@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>, Josh Poimboeuf <jpoimboe@redhat.com>, Rik van Riel <riel@redhat.com>, Daniel Gruss <daniel.gruss@iaik.tugraz.at>, Hugh Dickins <hughd@google.com>, Kees Cook <keescook@google.com>, linux-mm <linux-mm@kvack.org>, michael.schwarz@iaik.tugraz.at, moritz.lipp@iaik.tugraz.at, richard.fellner@student.tugraz.at Subject: Re: [PATCH] vfs: Add PERM_* symbolic helpers for common file mode/permissions Date: Tue, 28 Nov 2017 12:12:14 +0100 [thread overview] Message-ID: <20171128111214.42esi4igzgnldsx5@gmail.com> (raw) In-Reply-To: <CA+55aFyLC9+S=MZueRXMmwwnx47bhovXr1YhRg+FAPFfQZXoYA@mail.gmail.com> * Linus Torvalds <torvalds@linux-foundation.org> wrote: > On Mon, Nov 27, 2017 at 2:06 AM, Ingo Molnar <mingo@kernel.org> wrote: > > > > > > +/* > > + * Human readable symbolic definitions for common > > + * file permissions: > > + */ > > +#define PERM_r________ 0400 > > +#define PERM_r__r_____ 0440 > > +#define PERM_r__r__r__ 0444 > > I'm not a fan. Particularly as you have a very random set of > permissions (rx and wx? Not very common), So I originally created those defines based on a grep of patterns used in the kernel, and added the 'wx' variants for completeness. We would only need a small subset. Here's a git grep based histogram of octal file permission masks used in the kernel source: # mode 21 0200 8 0220 14 0222 33 0400 11 0440 219 0444 91 0555 39 0600 906 0644 12 0660 12 0664 18 0666 14 0755 31 0777 So there's literally only 14 variants used, and 0644 and 0444 make up 95% of the cases. We get the patch below if we extend these existing patterns using their natural (looking) generators to a complete group - 19 patterns that should cover all the sensible combinations. > but also because it's just not that legible. Fair enough. Thanks, Ingo --- include/linux/stat.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) Index: tip/include/linux/stat.h =================================================================== --- tip.orig/include/linux/stat.h +++ tip/include/linux/stat.h @@ -6,6 +6,34 @@ #include <asm/stat.h> #include <uapi/linux/stat.h> +/* + * Human readable symbolic definitions for common + * file permissions: + */ +#define PERM_r________ 0400 +#define PERM_r__r_____ 0440 +#define PERM_r__r__r__ 0444 + +#define PERM_rw_______ 0600 +#define PERM_rw_r_____ 0640 +#define PERM_rw_r__r__ 0644 +#define PERM_rw_rw_r__ 0664 +#define PERM_rw_rw_rw_ 0666 + +#define PERM__w_______ 0200 +#define PERM__w__w____ 0220 +#define PERM__w__w__w_ 0222 + +#define PERM_r_x______ 0500 +#define PERM_r_xr_x___ 0550 +#define PERM_r_xr_xr_x 0555 + +#define PERM_rwx______ 0700 +#define PERM_rwxr_x___ 0750 +#define PERM_rwxr_xr_x 0755 +#define PERM_rwxrwxr_x 0775 +#define PERM_rwxrwxrwx 0777 + #define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) #define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) #define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH) -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2017-11-28 11:12 UTC|newest] Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-11-26 23:14 [patch V2 0/5] x86/kaiser: Boot time disabling and debug support Thomas Gleixner 2017-11-26 23:14 ` Thomas Gleixner 2017-11-26 23:14 ` [patch V2 1/5] x86/kaiser: Respect disabled CPU features Thomas Gleixner 2017-11-26 23:14 ` Thomas Gleixner 2017-11-27 9:57 ` Peter Zijlstra 2017-11-27 9:57 ` Peter Zijlstra 2017-11-27 11:47 ` Thomas Gleixner 2017-11-27 11:47 ` Thomas Gleixner 2017-11-27 12:31 ` Brian Gerst 2017-11-27 12:31 ` Brian Gerst 2017-11-27 13:18 ` Thomas Gleixner 2017-11-27 13:18 ` Thomas Gleixner 2017-11-27 18:11 ` Dave Hansen 2017-11-27 18:11 ` Dave Hansen 2017-11-27 18:37 ` Kees Cook 2017-11-27 18:37 ` Kees Cook 2017-11-26 23:14 ` [patch V2 2/5] x86/kaiser: Simplify disabling of global pages Thomas Gleixner 2017-11-26 23:14 ` Thomas Gleixner 2017-11-27 11:49 ` Thomas Gleixner 2017-11-27 11:49 ` Thomas Gleixner 2017-11-27 18:15 ` Dave Hansen 2017-11-27 18:15 ` Dave Hansen 2017-11-27 20:28 ` Thomas Gleixner 2017-11-27 20:28 ` Thomas Gleixner 2017-11-26 23:14 ` [patch V2 3/5] x86/dump_pagetables: Check KAISER shadow page table for WX pages Thomas Gleixner 2017-11-26 23:14 ` Thomas Gleixner 2017-11-27 18:17 ` Dave Hansen 2017-11-27 18:17 ` Dave Hansen 2017-11-26 23:14 ` [patch V2 4/5] x86/mm/debug_pagetables: Allow dumping current pagetables Thomas Gleixner 2017-11-26 23:14 ` Thomas Gleixner 2017-11-27 9:41 ` Peter Zijlstra 2017-11-27 9:41 ` Peter Zijlstra 2017-11-27 10:06 ` [PATCH] vfs: Add PERM_* symbolic helpers for common file mode/permissions Ingo Molnar 2017-11-27 10:06 ` Ingo Molnar 2017-11-27 19:21 ` Linus Torvalds 2017-11-27 19:21 ` Linus Torvalds 2017-11-28 10:54 ` Ingo Molnar 2017-11-28 10:54 ` Ingo Molnar 2017-11-28 11:12 ` Ingo Molnar [this message] 2017-11-28 11:12 ` Ingo Molnar 2017-11-29 8:52 ` Michael Ellerman 2017-11-29 8:52 ` Michael Ellerman 2017-11-27 18:18 ` [patch V2 4/5] x86/mm/debug_pagetables: Allow dumping current pagetables Dave Hansen 2017-11-27 18:18 ` Dave Hansen 2017-11-26 23:14 ` [patch V2 5/5] x86/kaiser: Add boottime disable switch Thomas Gleixner 2017-11-26 23:14 ` Thomas Gleixner 2017-11-27 9:48 ` Peter Zijlstra 2017-11-27 9:48 ` Peter Zijlstra 2017-11-27 10:22 ` Peter Zijlstra 2017-11-27 10:22 ` Peter Zijlstra 2017-11-27 11:50 ` Thomas Gleixner 2017-11-27 11:50 ` Thomas Gleixner 2017-11-27 12:49 ` Peter Zijlstra 2017-11-27 12:49 ` Peter Zijlstra 2017-11-27 21:43 ` Peter Zijlstra 2017-11-27 21:43 ` Peter Zijlstra 2017-11-27 18:22 ` Dave Hansen 2017-11-27 18:22 ` Dave Hansen 2017-11-27 19:00 ` Thomas Gleixner 2017-11-27 19:00 ` Thomas Gleixner 2017-11-27 19:18 ` Josh Poimboeuf 2017-11-27 19:18 ` Josh Poimboeuf 2017-11-27 20:47 ` Thomas Gleixner 2017-11-27 20:47 ` Thomas Gleixner
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20171128111214.42esi4igzgnldsx5@gmail.com \ --to=mingo@kernel.org \ --cc=bp@alien8.de \ --cc=brgerst@gmail.com \ --cc=daniel.gruss@iaik.tugraz.at \ --cc=dave.hansen@linux.intel.com \ --cc=dvlasenk@redhat.com \ --cc=hpa@zytor.com \ --cc=hughd@google.com \ --cc=jpoimboe@redhat.com \ --cc=keescook@google.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=luto@kernel.org \ --cc=michael.schwarz@iaik.tugraz.at \ --cc=moritz.lipp@iaik.tugraz.at \ --cc=peterz@infradead.org \ --cc=richard.fellner@student.tugraz.at \ --cc=riel@redhat.com \ --cc=tglx@linutronix.de \ --cc=torvalds@linux-foundation.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.