Re: [patch 28/28] posix clocks: Introduce dynamic clocks

From: torbenh
Date: Thu Mar 03 2011 - 09:50:25 EST


On Tue, Feb 01, 2011 at 01:52:35PM -0000, Thomas Gleixner wrote:
> From: Richard Cochran <richardcochran@xxxxxxxxx>
>
> This patch adds support for adding and removing posix clocks. The
> clock lifetime cycle is patterned after usb devices. Each clock is
> represented by a standard character device. In addition, the driver
> may optionally implement custom character device operations.
>
> The posix clock and timer system calls listed below now work with
> dynamic posix clocks, as well as the traditional static clocks.
> The following system calls are affected:
>
> - clock_adjtime (brand new syscall)
> - clock_gettime
> - clock_getres
> - clock_settime
> - timer_create
> - timer_delete
> - timer_gettime
> - timer_settime
>
> [ tglx: Adapted to the posix-timer cleanup. Moved clock_posix_dynamic
> to posix-clock.c and made all referenced functions static ]
>
> Signed-off-by: Richard Cochran <richard.cochran@xxxxxxxxxx>
> Cc: John Stultz <john.stultz@xxxxxxxxxx>
> LKML-Reference: <21258f45fcc5e08a595f411c7760f3ccc18964bb.1296124770.git.richard.cochran@xxxxxxxxxx>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> ---
> include/linux/posix-clock.h | 150 ++++++++++++++
> include/linux/posix-timers.h | 6
> kernel/posix-timers.c | 4
> kernel/time/Makefile | 3
> kernel/time/posix-clock.c | 441 +++++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 601 insertions(+), 3 deletions(-)
> create mode 100644 include/linux/posix-clock.h
> create mode 100644 kernel/time/posix-clock-syscalls.h
> create mode 100644 kernel/time/posix-clock.c



>
> +
> +static int pc_clock_adjtime(clockid_t id, struct timex *tx)
> +{
> + struct posix_clock_desc cd;
> + int err;
> +
> + err = get_clock_desc(id, &cd);
> + if (err)
> + return err;

there is no permission check here.
if i get the clock fd in READ mode, i can still adjtime.
same for settime.

> +
> + if (cd.clk->ops.clock_adjtime)
> + err = cd.clk->ops.clock_adjtime(cd.clk, tx);
> + else
> + err = -EOPNOTSUPP;
> +
> + put_clock_desc(&cd);
> +
> + return err;
> +}




--
torben Hohn
--
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/