Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140526215412.GA507@brightrain.aerifal.cx>
Date: Mon, 26 May 2014 17:54:12 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: [UGLY PATCH v2] Support for no-legacy-syscalls archs

On Mon, May 26, 2014 at 11:13:49PM +0200, Szabolcs Nagy wrote:
> * Rich Felker <dalias@...c.org> [2014-05-26 14:40:36 -0400]:
> > +#ifdef SYS_fork
> >  	ret = syscall(SYS_fork);
> > +#else
> > +	ret = syscall(SYS_clone, SIGCHLD);
> > +#endif
> 
> clone has more args

The remaining args are only read if flags!=0 though (flags are in the
upper bits of the first argument; the lower bits are the signal to be
generated on exit). As far as I can tell, this is the correct way to
use clone to provide fork.

> >  int select(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, struct timeval *restrict tv)
> >  {
> > +#ifdef SYS_select
> >  	return syscall_cp(SYS_select, n, rfds, wfds, efds, tv);
> > +#else
> > +	long data[2] = { 0, _NSIG/8 };
> > +	struct timespec ts;
> > +	if (tv) {
> > +		ts.tv_sec = tv->tv_sec;
> > +		ts.tv_nsec = tv->tv_usec > 999999 ?
> > +			999999999 : tv->tv_usec * 1000;
> > +	}
> > +	return syscall_cp(SYS_pselect6, n, rfds, wfds, efds, tv ? &ts : 0, data);
> > +#endif
> 
> tv_usec may be negative

Then the kernel should generate the EINVAL for us.

> isnt it better to adjust tv_sec if usec is large?
> or fail with EINVAL like in futimensat:

POSIX allows implementation-defined limits on the duration, but now
that you say it, what I wrote above is not not a correct
implementation of such a limit. I'm not clear on whether we should
renormalize into timespec or just reject out-of-range usec values;
unlike in some other places where timespec is used, POSIX is missing
text on select and pselect regarding how out-of-range timespec and
timeval structs should be handled...

> >  pid_t getpgrp(void)
> >  {
> > +#ifdef SYS_getpgrp
> >  	return __syscall(SYS_getpgrp);
> > +#else
> > +	return __syscall(SYS_getpgid, 0);
> > +#endif
> 
> you said this can be just the new call

Ah yes, I forgot to change that.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.