summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Wellving <andreas.wellving@enea.com>2018-10-12 16:09:38 +0200
committerAdrian Dudau <Adrian.Dudau@enea.com>2018-10-16 17:40:08 +0200
commit9b0ad321114721e8a23b800587ab3b76b02c8b90 (patch)
treefefb69439faf9c136120247cb652282a57d2eed6
parent7d11a35246278eab7f0b00496407efb1c16d5fb9 (diff)
downloadenea-kernel-cache-9b0ad321114721e8a23b800587ab3b76b02c8b90.tar.gz
CVE-2018-13405
Fix up non-directory creation in SGID directories References: https://github.com/torvalds/linux/commit/0fa3ecd87848c9c93c2c828ef4c3a8ca36ce46c7 Signed-off-by: Andreas Wellving <andreas.wellving@enea.com> Change-Id: Ia7dac6a7721e48900f93ff492f4d3c54114a0d08
-rw-r--r--patches/cve/4.9.x.scc2
-rw-r--r--patches/cve/CVE-2018-13405-Fix-up-non-directory-creation-in-SGID-directories.patch50
2 files changed, 52 insertions, 0 deletions
diff --git a/patches/cve/4.9.x.scc b/patches/cve/4.9.x.scc
index 0121888..6de2c9b 100644
--- a/patches/cve/4.9.x.scc
+++ b/patches/cve/4.9.x.scc
@@ -35,3 +35,5 @@ patch CVE-2018-10881-ext4-clear-i_data-in-ext4_inode_info-when-removing-i.patch
35patch CVE-2018-10882-ext4-add-more-inode-number-paranoia-checks.patch 35patch CVE-2018-10882-ext4-add-more-inode-number-paranoia-checks.patch
36patch CVE-2018-9516-HID-debug-check-length-before-copy_to_user.patch 36patch CVE-2018-9516-HID-debug-check-length-before-copy_to_user.patch
37 37
38#CVEs fixed in 4.9.113:
39patch CVE-2018-13405-Fix-up-non-directory-creation-in-SGID-directories.patch
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..58022b3
--- /dev/null
+++ b/patches/cve/CVE-2018-13405-Fix-up-non-directory-creation-in-SGID-directories.patch
@@ -0,0 +1,50 @@
1From 0fa3ecd87848c9c93c2c828ef4c3a8ca36ce46c7 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
6sgid directories have special semantics, making newly created files in
7the directory belong to the group of the directory, and newly created
8subdirectories will also become sgid. This is historically used for
9group-shared directories.
10
11But group directories writable by non-group members should not imply
12that such non-group members can magically join the group, so make sure
13to clear the sgid bit on non-directories for non-members (but remember
14that sgid without group execute means "mandatory locking", just to
15confuse things even more).
16
17CVE: CVE-2018-11237
18Upstream-Status: Backport
19
20Reported-by: Jann Horn <jannh@google.com>
21Cc: Andy Lutomirski <luto@kernel.org>
22Cc: Al Viro <viro@zeniv.linux.org.uk>
23Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
24Signed-off-by: Andreas Wellving <andreas.wellving@enea.com>
25---
26 fs/inode.c | 6 ++++++
27 1 file changed, 6 insertions(+)
28
29diff --git a/fs/inode.c b/fs/inode.c
30index 2c300e9..8c86c80 100644
31--- a/fs/inode.c
32+++ b/fs/inode.c
33@@ -1999,8 +1999,14 @@ void inode_init_owner(struct inode *inode, const struct inode *dir,
34 inode->i_uid = current_fsuid();
35 if (dir && dir->i_mode & S_ISGID) {
36 inode->i_gid = dir->i_gid;
37+
38+ /* Directories are special, and always inherit S_ISGID */
39 if (S_ISDIR(mode))
40 mode |= S_ISGID;
41+ else if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP) &&
42+ !in_group_p(inode->i_gid) &&
43+ !capable_wrt_inode_uidgid(dir, CAP_FSETID))
44+ mode &= ~S_ISGID;
45 } else
46 inode->i_gid = current_fsgid();
47 inode->i_mode = mode;
48--
49
50