Re: [PATCH 3/3] Check for write permission on FD based posix-clocks

Arnd Bergmann
2011-03-04T09:55:40Z

On Friday 04 March 2011 08:22:39 Richard Cochran wrote:
> > diff --git a/kernel/time/posix-clock.c b/kernel/time/posix-clock.c
> > index 04498cb..25028dd 100644
> > --- a/kernel/time/posix-clock.c
> > +++ b/kernel/time/posix-clock.c
> > @@ -287,11 +287,16 @@ static int pc_clock_adjtime(clockid_t id, struct timex *tx)
> > if (err)
> > return err;
> >
> > + if ((cd.fp->f_mode & FMODE_WRITE) == 0) {
> > + err = -EACCES;
>
> Looks like clock_settime and adjtimex are supposed to return EPERM in
> this case.
>

I think both choices are correct:

EACCESS often refers to the file permissions of an inode or the mode
of an open file. EPERM usually means that an operation can only be
performed by the owner of an object or by root. So clock_settime and
adjtimex should return EPERM and pc_clock_adjtime should return EACCESS.

Arnd