Re: [PATCH 2/4] posix-timers: limit the number of posix timers perprocess

From: Thomas Gleixner
Date: Fri Sep 02 2011 - 05:30:53 EST


On Mon, 29 Aug 2011, Andi Kleen wrote:

> From: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> Now this is the main reason I wrote the whole patchkit: previously
> there was no limit on the maximum number of POSIX timers a process
> could allocate. This limits the amount of unswappable kernel memory
> a process can pin down this way.
>
> With the POSIX timer ids being per process we can do this limit
> per process now without allowing one process DoSing another.
>
> I implemented it as a sysctl, not a rlimit for now, because
> there was no clear use case for rlimit.

rlimit please.

> /*
> * we assume that the new SIGEV_THREAD_ID shares no bits with the other
> * SIGEV values. Here we put out an error if this assumption fails.
> @@ -572,6 +574,12 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
>
> it_id_set = IT_ID_SET;
> new_timer->it_id = (timer_t) new_timer_id;
> +
> + if (new_timer_id >= sysctl_max_posix_timers) {
> + error = -EMFILE; /* better error? */

EPERM might work as well

Thanks,

tglx
--
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/