Re: [PATCH 1/1] hurd: add validations in msync

Etienne Brateau <[email protected]>
Newsgroups gmane.os.hurd.bugs
Message-ID <CAMHDLKKLiuioxqkufxjk+FKYEoS-8eB_cP==E9U0JYbwZUgS9w@mail.gmail.com>
Yes, you are right, we want to do this. I see that linux keep the error for
later, process anyway the request and finally return the error. Do you
think I should return directly or do the same (memorize there was an error,
continue and at the end return the error)?

Le lun. 25 mai 2026 à 22:40, Samuel Thibault <[email protected]> a
écrit :

> Hello,
>
> Etienne Brateau, le lun. 25 mai 2026 22:07:13 +0200, a ecrit:
> > POSIX specs specify that invalid flags shall return EINVAL and that
> > ENOMEM shall be returned in case of address outside of address space or
> > when one or more pages are not mapped.
> > ---
> >  sysdeps/mach/hurd/msync.c | 11 ++++++++++-
> >  1 file changed, 10 insertions(+), 1 deletion(-)
> >
> > diff --git a/sysdeps/mach/hurd/msync.c b/sysdeps/mach/hurd/msync.c
> > index 46eabd1ee7..7e0ffff8db 100644
> > --- a/sysdeps/mach/hurd/msync.c
> > +++ b/sysdeps/mach/hurd/msync.c
> > @@ -36,6 +36,15 @@ msync (void *addr, size_t length, int flags)
> >    vm_address_t cur = (vm_address_t) addr;
> >    vm_address_t target = cur + length;
> >
> > +  if (flags & ~(MS_ASYNC | MS_INVALIDATE | MS_SYNC))
> > +    return __hurd_fail (EINVAL);
> > +
> > +  if (flags & MS_ASYNC && flags & MS_SYNC)
> > +    return __hurd_fail (EINVAL);
> > +
> > +  if (target < cur)
> > +    return __hurd_fail (ENOMEM);
> > +
> >    vm_size_t len;
> >    vm_prot_t prot;
> >    vm_prot_t max_prot;
> > @@ -65,7 +74,7 @@ msync (void *addr, size_t length, int flags)
> >
> >        if (cur >= target)
> >       /* We were given an ending address within a hole. */
> > -     break;
> > +     return __hurd_fail (ENOMEM);
>
> Don't we also want to return ENOMEM when begin > cur?
>
> Samuel
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.