Skip to contentSkip to conversation

setuid/setuid04.c: Fix a double cleanup() error

PATCH In review MaShimiao 2 participants 2 messages Sep 26, 2013

lore
Share & tools
lore

MaShimiao

author
#0 lore raw

PATCH v2 1/1 setuid/setuid04.c: Fix a double cleanup() error

The cleanup() may be called twice by both the parent and child process in this testcase leading to a failure.

This patch makes sure cleanup() is called only once by parent process.

---
  testcases/kernel/syscalls/setuid/setuid04.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/testcases/kernel/syscalls/setuid/setuid04.c
index d8e991e..365859b 100644

testcases/kernel/syscalls/setuid/setuid04.c +1 -1
@@ -88,7 +88,7 @@ static void do_master_child(void)
  	int pid;
  	int status;
 
-	if (SETUID(cleanup, ltpuser->pw_uid) == -1) {
+	if (SETUID(NULL, ltpuser->pw_uid) == -1) {
  		tst_brkm(TBROK, NULL,
  			 "setuid failed to set the effective uid to %d",
  			 ltpuser->pw_uid);

-- 1.7.1

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance. Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#1 lore raw

Hi!

Quoted 17 lines

The cleanup() may be called twice by both the parent and child process in this testcase leading to a failure.

This patch makes sure cleanup() is called only once by parent process.

---
  testcases/kernel/syscalls/setuid/setuid04.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
testcases/kernel/syscalls/setuid/setuid04.c +0 -0
index d8e991e..365859b 100644

testcases/kernel/syscalls/setuid/setuid04.c static void do_master_child(void) · line 94

Quoted 8 lines
testcases/kernel/syscalls/setuid/setuid04.c +1 -1
@@ -88,7 +88,7 @@ static void do_master_child(void)
  	int pid;
  	int status;
 
-	if (SETUID(cleanup, ltpuser->pw_uid) == -1) {
+	if (SETUID(NULL, ltpuser->pw_uid) == -1) {
  		tst_brkm(TBROK, NULL,
  			 "setuid failed to set the effective uid to %d",
  			 ltpuser->pw_uid);

This one is much better. Applied, thanks.

(The patch failed to apply and needed to be redone by hand.)

BTW: It would be better to remove all the tst_* interface from the
function that runs in the child and use printf() + exit() instead. (In order to avoid bugs like this one)

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list