Re: unveil: incomplete unveil_flagmatch semantic

2018-08-05 Thread Sebastien Marie
On Sat, Aug 04, 2018 at 01:16:44PM -0600, Bob Beck wrote: > > > if ((error = namei()) != 0) > > > return (error); > > > fvp = fromnd.ni_vp; > > > @@ -2945,6 +2973,7 @@ sys_revoke(struct proc *p, void *v, regi > > > > > > NDINIT(, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path),

Re: unveil: incomplete unveil_flagmatch semantic

2018-08-04 Thread Bob Beck
> Some examples that will need consideration for unveil(2): > - mount(2) > - unmount(2) > - quotactl(2) > - chroot(2) > - getfh(2) > - acct(2) > - coredump() > - loadfirmware() - I think ifconfig(1) could make the kernel loading a > firmware for some network card > > so having ni_unveil

Re: unveil: incomplete unveil_flagmatch semantic

2018-08-04 Thread Bob Beck
> On Sat, Aug 04, 2018 at 10:40:11AM -0600, Bob Beck wrote: > > On Fri, Aug 03, 2018 at 06:31:00AM +0200, Sebastien Marie wrote: > > > On Thu, Aug 02, 2018 at 03:42:03PM +0200, Sebastien Marie wrote: > > > > On Mon, Jul 30, 2018 at 07:55:35AM -0600, Bob Beck wrote: > > > > > yeah the latter

Re: unveil: incomplete unveil_flagmatch semantic

2018-08-04 Thread Bob Beck
> > + nd.ni_unveil = 0; /* XXX No flags == allow it */ > > see my comment about ni_unveil != 0. > > as you still have check on (ni_pledge & PLEDGE_STAT), it should be still > ok. > It doesn't actually do this yt.. this comment was a reminder for me and should have had allow it? for my

Re: unveil: incomplete unveil_flagmatch semantic

2018-08-04 Thread Sebastien Marie
On Sat, Aug 04, 2018 at 10:40:11AM -0600, Bob Beck wrote: > On Fri, Aug 03, 2018 at 06:31:00AM +0200, Sebastien Marie wrote: > > On Thu, Aug 02, 2018 at 03:42:03PM +0200, Sebastien Marie wrote: > > > On Mon, Jul 30, 2018 at 07:55:35AM -0600, Bob Beck wrote: > > > > yeah the latter will be the way

Re: unveil: incomplete unveil_flagmatch semantic

2018-08-04 Thread Bob Beck
On Fri, Aug 03, 2018 at 06:31:00AM +0200, Sebastien Marie wrote: > On Thu, Aug 02, 2018 at 03:42:03PM +0200, Sebastien Marie wrote: > > On Mon, Jul 30, 2018 at 07:55:35AM -0600, Bob Beck wrote: > > > yeah the latter will be the way to go > > > > > > > new diff with direct lookup using an

Re: unveil: incomplete unveil_flagmatch semantic

2018-08-02 Thread Sebastien Marie
On Mon, Jul 30, 2018 at 07:55:35AM -0600, Bob Beck wrote: > yeah the latter will be the way to go > new diff with direct lookup using an indirection table. first reorders PLEDGE flags to have: - PLEDGE promises that could occurs in ni_pledge and are used for unveil(2) - PLEDGE promises

Re: unveil: incomplete unveil_flagmatch semantic

2018-07-31 Thread Sebastien Marie
On Mon, Jul 30, 2018 at 12:00:59PM -0600, Theo de Raadt wrote: > + for (i=0; flags[i].pledge != 0; i++) > + if (ISSET(pledge_flags, flags[i].pledge)) { > + SET(permissions, flags[i].unveil); > + CLR(pledge_flags, flags[i].pledge); > +

Re: unveil: incomplete unveil_flagmatch semantic

2018-07-30 Thread Theo de Raadt
+ for (i=0; flags[i].pledge != 0; i++) + if (ISSET(pledge_flags, flags[i].pledge)) { + SET(permissions, flags[i].unveil); + CLR(pledge_flags, flags[i].pledge); + } Rather than iterating, can this be done as a direct

Re: unveil: incomplete unveil_flagmatch semantic

2018-07-30 Thread Sebastien Marie
On Mon, Jul 30, 2018 at 07:55:35AM -0600, Bob Beck wrote: > yeah the latter will be the way to go > here it is. Some notes: - I changed flags definition from uint64_t to int - I defined `static inline' the function that do the conversion from pledge to unveil: having a function is more

Re: unveil: incomplete unveil_flagmatch semantic

2018-07-30 Thread Bob Beck
yeah the latter will be the way to go On Mon, Jul 30, 2018 at 06:02 Sebastien Marie wrote: > Hi, > > I think unveil_flagmatch() isn't complete and/or has not the right > semantic. > > A bit of internals for starting (I will speak about ni_pledge, people > that know what it is and how it works

unveil: incomplete unveil_flagmatch semantic

2018-07-30 Thread Sebastien Marie
Hi, I think unveil_flagmatch() isn't complete and/or has not the right semantic. A bit of internals for starting (I will speak about ni_pledge, people that know what it is and how it works with pledge/unveil could go to "what is the problem" part). unveil(2) works with the syscall annotation