Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/tests/kernel




On 06.11.2016 17:56, Robert Elz wrote:
>     Date:        Sun, 6 Nov 2016 16:24:16 +0000
>     From:        "Kamil Rytarowski" <kamil%netbsd.org@localhost>
>     Message-ID:  <20161106162416.95D77FBA6%cvs.NetBSD.org@localhost>
> 
>   | assert_pid1 asserts that non-root user cannot attach to PID 1 as it is the
>   | /dev/init process. This tests is skipped if run as root.
> 
> There's no need to skip it, just
> 
> 	child=fork(); 	/* err if -1 */
> 	if (child == 0) {
> 		(void)setuid(10);
> 		if (ptrace(.....) < 0)
> 			_exit(errno);
> 		else
> 			_exit(0);
> 	}
> 	waitpid(child, &status, 0);
> 	/* and check status */
> 
> If you're root, the setuid() works, and the child isn't root any more.
> if you happened to be uid(10), the setuid() is a no-op, if you were some
> other user the setuid() fails, but you don't care.
> 
> kre
> 

Good point.

I noted a sequence in other tests like:

        struct passwd *pw;
        pw = getpwnam("nobody");
        if (pid == 0) {
                (void)setuid(pw->pw_uid);
        }

I will make use of something similar.

I was evaluating whether it's possible to PT_ATTACH to getpid() [I will
check documentation later]. It doesn't make sense but we shouldn't hang.
I will test it and add an entry for it in the t_ptrace code.

Another idea is to test chroot(8) attach failure.

I'm inventing potential tests without the usage of wait(2)-like
functions, and without help of hacks like sleep(3) - such test would be
waste of precious time of execution of the ATF framework and the
behavior would not be practical.

My intention is to move all other tests to ptrace_wait* files.

Thank you for your suggestions!

Attachment: signature.asc
Description: OpenPGP digital signature



Home | Main Index | Thread Index | Old Index