summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--patches/cve/CVE-2018-13405-Fix-up-non-directory-creation-in-SGID-directories.patch53
1 files changed, 53 insertions, 0 deletions
diff --git a/patches/cve/CVE-2018-13405-Fix-up-non-directory-creation-in-SGID-directories.patch b/patches/cve/CVE-2018-13405-Fix-up-non-directory-creation-in-SGID-directories.patch
new file mode 100644
index 0000000..d5eb1c0
--- /dev/null
+++ b/patches/cve/CVE-2018-13405-Fix-up-non-directory-creation-in-SGID-directories.patch
@@ -0,0 +1,53 @@
1From 298243a5fb640f018e2fae22c0c895f1b27f0963 Mon Sep 17 00:00:00 2001
2From: Linus Torvalds <torvalds@linux-foundation.org>
3Date: Tue, 3 Jul 2018 17:10:19 -0700
4Subject: [PATCH] Fix up non-directory creation in SGID directories
5
6commit 0fa3ecd87848c9c93c2c828ef4c3a8ca36ce46c7 upstream.
7
8sgid directories have special semantics, making newly created files in
9the directory belong to the group of the directory, and newly created
10subdirectories will also become sgid. This is historically used for
11group-shared directories.
12
13But group directories writable by non-group members should not imply
14that such non-group members can magically join the group, so make sure
15to clear the sgid bit on non-directories for non-members (but remember
16that sgid without group execute means "mandatory locking", just to
17confuse things even more).
18
19CVE: CVE-2018-13405
20Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=298243a5fb640f018e2fae22c0c895f1b27f0963]
21
22Reported-by: Jann Horn <jannh@google.com>
23Cc: Andy Lutomirski <luto@kernel.org>
24Cc: Al Viro <viro@zeniv.linux.org.uk>
25Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
26Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
28---
29 fs/inode.c | 6 ++++++
30 1 file changed, 6 insertions(+)
31
32diff --git a/fs/inode.c b/fs/inode.c
33index e07b3e1f5970..cfc36d11bcb3 100644
34--- a/fs/inode.c
35+++ b/fs/inode.c
36@@ -2006,8 +2006,14 @@ void inode_init_owner(struct inode *inode, const struct inode *dir,
37 inode->i_uid = current_fsuid();
38 if (dir && dir->i_mode & S_ISGID) {
39 inode->i_gid = dir->i_gid;
40+
41+ /* Directories are special, and always inherit S_ISGID */
42 if (S_ISDIR(mode))
43 mode |= S_ISGID;
44+ else if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP) &&
45+ !in_group_p(inode->i_gid) &&
46+ !capable_wrt_inode_uidgid(dir, CAP_FSETID))
47+ mode &= ~S_ISGID;
48 } else
49 inode->i_gid = current_fsgid();
50 inode->i_mode = mode;
51--
522.20.1
53