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

From: Arnd Bergmann
Date: Fri Mar 04 2011 - 04:55:44 EST


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/