Re: git: b7fd86118fb5 - main - syscalls: sprinkle in const values

From: Brooks Davis <brooks_at_freebsd.org>
Date: Thu, 18 Nov 2021 19:02:33 UTC
On Thu, Nov 18, 2021 at 12:04:42AM +0200, Konstantin Belousov wrote:
> On Wed, Nov 17, 2021 at 08:22:03PM +0000, Brooks Davis wrote:
> > The branch main has been updated by brooks:
> > 
> > URL: https://cgit.FreeBSD.org/src/commit/?id=b7fd86118fb5d41f61fdfa003d11e9367770ff0a
> > 
> > commit b7fd86118fb5d41f61fdfa003d11e9367770ff0a
> > Author:     Brooks Davis <brooks@FreeBSD.org>
> > AuthorDate: 2021-11-17 20:12:21 +0000
> > Commit:     Brooks Davis <brooks@FreeBSD.org>
> > CommitDate: 2021-11-17 20:12:21 +0000
> > 
> >     syscalls: sprinkle in const values
> >     
> >     Add missing const qualifiers to a number of syscall arguments.
> >     
> >     Obtained from:  CheriBSD
> >     
> >     Reviewed by:    kevans
> > ---
> >  sys/kern/syscalls.master | 32 ++++++++++++------------
> >  sys/kern/systrace_args.c | 64 ++++++++++++++++++++++++------------------------
> >  sys/kern/vfs_syscalls.c  | 10 ++++----
> >  sys/sys/syscallsubr.h    | 13 +++++-----
> >  sys/sys/sysproto.h       | 32 ++++++++++++------------
> :(
> 
> > @@ -501,7 +501,7 @@
> >  	}
> >  74	AUE_MPROTECT	STD|CAPENABLED {
> >  		int mprotect(
> > -		    _In_ void *addr,
> > +		    _In_ const void *addr,
> >  		    size_t len,
> >  		    int prot
> >  		);
> You did not marked addr for munmap(2) as const, but did this for mprotect(2).
> I believe that this is the right interpretation for munmap, but not for
> mprotect due to PROT_NONE.
> 
> Or at least it should be consistent WRT allowed side effects on access.
> 

Thanks for pointing this out.  It's definitly an error as the signature
of mprotect() does include const.  I'm not sure why I made this change
several years ago.  I'll revert it.

-- Brooks