Re: Fork Bombing Patch

From: Krzysztof Halasa
Date: Thu Aug 23 2007 - 07:52:38 EST


Hi,

"Anand Jahagirdar" <anandjigar@xxxxxxxxx> writes:

> I am forwarding one more improved patch which i have modified as
> per your suggestions. Insted of KERN_INFO i have used KERN_NOTICE and
> i have added one more if block to check hard limit. how good it is?

Not very, still lacks "#ifdef CONFIG_something" and the required
Kconfig change (or other runtime thing defaulting to "no printk").

And now, it seems, the "goto bad_fork_tree" (not only printk())
ignores the soft limit -> really bad.

> +++ root/Desktop/a1/linux-2.6.17.tar.bz2_FILES/linux-2.6.17/kernel/fork.c 2007-06-26 20:41:41.000000000 +0530
> @@ -957,12 +957,19 @@
>
> retval = -EAGAIN;
>
> -
> + /*
> + * following code does not allow Non Root User to cross its process
> + * limit and it alerts administrator about user Nearing the process limit.
> + */
> +
> if (atomic_read(&p->user->processes) >= p->signal->rlim[RLIMIT_NPROC].rlim_cur)
> + if (atomic_read(&p->user->processes) >= p->signal->rlim[RLIMIT_NPROC].rlim_max)
> if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
> - p->user != &root_user)
> + p->user != &root_user) {
> + if (printk_ratelimit())
> + printk(KERN_NOTICE "User with uid %u is Nearing the process limit\n",p->user->uid);
> +
> goto bad_fork_free;
> -
> + }
>
> atomic_inc(&p->user->__count);
> atomic_inc(&p->user->processes);

--
Krzysztof Halasa
-
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/