From: Lyude <lyude@redhat.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [PATCH i-g-t 2/3] lib/aux: Call setgroups() in igt_drop_root() before setgid()
Date: Wed, 8 May 2019 16:15:11 -0400 [thread overview]
Message-ID: <20190508201512.14263-3-lyude@redhat.com> (raw)
In-Reply-To: <20190508201512.14263-1-lyude@redhat.com>
From: Lyude Paul <lyude@redhat.com>
While igt isn't really security sensitive, forgetting to call
setgroups() before calling setgid() causes rpmlint on Fedora to
complain:
igt-gpu-tools.x86_64: E: missing-call-to-setgroups-before-setuid
/usr/lib64/libigt.so.0
...
missing-call-to-setgroups-before-setuid:
This executable is calling setuid and setgid without setgroups or
initgroups. There is a high probability this means it didn't relinquish
all groups, and this would be a potential security issue to be fixed.
Seek POS36-C on the web for details about the problem.
Since it's likely other package maintainers for other distros will have
to deal with similar issues eventually, and I can't see any harm in it,
let's do the right thing and call setgroups() first.
Signed-off-by: Lyude Paul <lyude@redhat.com>
---
lib/igt_aux.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index caed1fed..578f8579 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -49,6 +49,7 @@
#include <sys/utsname.h>
#include <termios.h>
#include <assert.h>
+#include <grp.h>
#include <proc/readproc.h>
#include <libudev.h>
@@ -959,9 +960,11 @@ void igt_drop_root(void)
{
igt_assert_eq(getuid(), 0);
+ igt_assert_eq(setgroups(0, NULL), 0);
igt_assert_eq(setgid(2), 0);
igt_assert_eq(setuid(2), 0);
+ igt_assert_eq(getgroups(0, NULL), 0);
igt_assert_eq(getgid(), 2);
igt_assert_eq(getuid(), 2);
}
--
2.20.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2019-05-08 20:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-08 20:15 [igt-dev] [PATCH i-g-t 0/3] More fixes from Fedora packaging Lyude
2019-05-08 20:15 ` [igt-dev] [PATCH i-g-t 1/3] lib/aux: Use igt_assert_eq() in igt_drop_root() Lyude
2019-05-08 20:15 ` Lyude [this message]
2019-05-09 8:19 ` [igt-dev] [PATCH i-g-t 2/3] lib/aux: Call setgroups() in igt_drop_root() before setgid() Daniel Vetter
2019-05-08 20:15 ` [igt-dev] [PATCH i-g-t 3/3] Update Fedora dockerfile to F30 Lyude
2019-05-08 21:44 ` [igt-dev] ✓ Fi.CI.BAT: success for More fixes from Fedora packaging Patchwork
2019-05-09 3:35 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
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=20190508201512.14263-3-lyude@redhat.com \
--to=lyude@redhat.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=petri.latvala@intel.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox