From eaa7bd5a148dd74ff93e2d8e65ce774f05405ddf Mon Sep 17 00:00:00 2001 From: Andreas Wellving Date: Wed, 22 May 2019 11:12:26 +0200 Subject: CVE-2018-13405 Fix up non-directory creation in SGID directories Reference: https://nvd.nist.gov/vuln/detail/CVE-2018-13405 https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=298243a5fb640f018e2fae22c0c895f1b27f0963 Change-Id: Ia5bb134fc9fecf9b9647197073f1a6bba7ae27eb Signed-off-by: Andreas Wellving --- ...on-directory-creation-in-SGID-directories.patch | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 patches/cve/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..d5eb1c0 --- /dev/null +++ b/patches/cve/CVE-2018-13405-Fix-up-non-directory-creation-in-SGID-directories.patch @@ -0,0 +1,53 @@ +From 298243a5fb640f018e2fae22c0c895f1b27f0963 Mon Sep 17 00:00:00 2001 +From: Linus Torvalds +Date: Tue, 3 Jul 2018 17:10:19 -0700 +Subject: [PATCH] Fix up non-directory creation in SGID directories + +commit 0fa3ecd87848c9c93c2c828ef4c3a8ca36ce46c7 upstream. + +sgid directories have special semantics, making newly created files in +the directory belong to the group of the directory, and newly created +subdirectories will also become sgid. This is historically used for +group-shared directories. + +But group directories writable by non-group members should not imply +that such non-group members can magically join the group, so make sure +to clear the sgid bit on non-directories for non-members (but remember +that sgid without group execute means "mandatory locking", just to +confuse things even more). + +CVE: CVE-2018-13405 +Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.14.y&id=298243a5fb640f018e2fae22c0c895f1b27f0963] + +Reported-by: Jann Horn +Cc: Andy Lutomirski +Cc: Al Viro +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Andreas Wellving +--- + fs/inode.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/fs/inode.c b/fs/inode.c +index e07b3e1f5970..cfc36d11bcb3 100644 +--- a/fs/inode.c ++++ b/fs/inode.c +@@ -2006,8 +2006,14 @@ void inode_init_owner(struct inode *inode, const struct inode *dir, + inode->i_uid = current_fsuid(); + if (dir && dir->i_mode & S_ISGID) { + inode->i_gid = dir->i_gid; ++ ++ /* Directories are special, and always inherit S_ISGID */ + if (S_ISDIR(mode)) + mode |= S_ISGID; ++ else if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP) && ++ !in_group_p(inode->i_gid) && ++ !capable_wrt_inode_uidgid(dir, CAP_FSETID)) ++ mode &= ~S_ISGID; + } else + inode->i_gid = current_fsgid(); + inode->i_mode = mode; +-- +2.20.1 + -- cgit v1.2.3-54-g00ecf