Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | From 3c87ef2961dedb10d1f674c6a530e00dbab8ec1b Mon Sep 17 00:00:00 2001 |
| 2 | From: Jan Stancek <jstancek@redhat.com> |
| 3 | Date: Tue, 17 Jul 2018 10:26:39 +0200 |
| 4 | Subject: [PATCH] open|creat: skip S_ISGID check on files created by non-group |
| 5 | members |
| 6 | |
| 7 | 0fa3ecd87848 ("Fix up non-directory creation in SGID directories") |
| 8 | fixes problem described in CVE-2018-13405. This commit is getting |
| 9 | backported to older streams as well. |
| 10 | |
| 11 | This patch removes S_ISGID check for files created by non-group members |
| 12 | in LTP tests creat08 and open10. |
| 13 | |
| 14 | Once 0fa3ecd87848 will be in non-rc kernel, we could add a new test |
| 15 | for this CVE that would be limited to 4.18+ kernels. |
| 16 | |
| 17 | Signed-off-by: Jan Stancek <jstancek@redhat.com> |
| 18 | Acked-by: Cyril Hrubis <chrubis@suse.cz> |
| 19 | Reviewed-by: Naresh Kamboju <naresh.kamboju@linaro.org> |
| 20 | |
| 21 | Upstream-Status: Backport |
| 22 | [ git://github.com/linux-test-project/ltp.git |
| 23 | 3c87ef2961dedb10d1f674c6a530e00dbab8ec1b |
| 24 | "open|creat: skip S_ISGID check on files created by non-group members" ] |
| 25 | |
| 26 | Signed-off-by: He Zhe <zhe.he@windriver.com> |
| 27 | --- |
| 28 | testcases/kernel/syscalls/creat/creat08.c | 13 ++++++------- |
| 29 | testcases/kernel/syscalls/open/open10.c | 12 +++++------- |
| 30 | 2 files changed, 11 insertions(+), 14 deletions(-) |
| 31 | |
| 32 | diff --git a/testcases/kernel/syscalls/creat/creat08.c b/testcases/kernel/syscalls/creat/creat08.c |
| 33 | index 50f2b3993..d22558ac3 100644 |
| 34 | --- a/testcases/kernel/syscalls/creat/creat08.c |
| 35 | +++ b/testcases/kernel/syscalls/creat/creat08.c |
| 36 | @@ -361,13 +361,12 @@ int main(int ac, char **av) |
| 37 | local_flag = FAILED; |
| 38 | } |
| 39 | |
| 40 | - /* Verify modes */ |
| 41 | - if (!(buf.st_mode & S_ISGID)) { |
| 42 | - tst_resm(TFAIL, |
| 43 | - "%s: Incorrect modes, setgid bit should be set", |
| 44 | - setgid_B); |
| 45 | - local_flag = FAILED; |
| 46 | - } |
| 47 | + /* |
| 48 | + * Skip S_ISGID check |
| 49 | + * 0fa3ecd87848 ("Fix up non-directory creation in SGID directories") |
| 50 | + * clears S_ISGID for files created by non-group members |
| 51 | + */ |
| 52 | + |
| 53 | close(fd); |
| 54 | |
| 55 | if (local_flag == PASSED) { |
| 56 | diff --git a/testcases/kernel/syscalls/open/open10.c b/testcases/kernel/syscalls/open/open10.c |
| 57 | index 613f2288f..14feec9e1 100644 |
| 58 | --- a/testcases/kernel/syscalls/open/open10.c |
| 59 | +++ b/testcases/kernel/syscalls/open/open10.c |
| 60 | @@ -345,13 +345,11 @@ int main(int ac, char *av[]) |
| 61 | local_flag = FAILED; |
| 62 | } |
| 63 | |
| 64 | - /* Verify modes */ |
| 65 | - if (!(buf.st_mode & S_ISGID)) { |
| 66 | - tst_resm(TFAIL, |
| 67 | - "%s: Incorrect modes, setgid bit not set", |
| 68 | - setgid_B); |
| 69 | - local_flag = FAILED; |
| 70 | - } |
| 71 | + /* |
| 72 | + * Skip S_ISGID check |
| 73 | + * 0fa3ecd87848 ("Fix up non-directory creation in SGID directories") |
| 74 | + * clears S_ISGID for files created by non-group members |
| 75 | + */ |
| 76 | |
| 77 | if (local_flag == PASSED) { |
| 78 | tst_resm(TPASS, "Test passed in block2."); |
| 79 | -- |
| 80 | 2.11.0 |
| 81 | |