Re: [PATCH] pid: restore the old behaviour of the ns_last_pid sysctl
From: Oleg Nesterov
Date: Mon Nov 06 2017 - 09:47:40 EST
On 11/03, Andrei Vagin wrote:
>
> @@ -297,8 +298,18 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
> * it should synchronize its usage with external means.
> */
>
> - tmp.data = &pid_ns->idr.idr_next;
> - return proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
> + next = idr_get_cursor(&pid_ns->idr) - 1;
> +
> + tmp.data = &next;
> + ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
> + if (ret < 0)
> + return ret;
> +
> + if (!write)
> + return 0;
> +
> + idr_set_cursor(&pid_ns->idr, next + 1);
> + return 0;
Ah yes, we should also take "write" into account, I forgot it is readable.
Can't resist, to me
err = proc_dointvec_minmax(...);
if (!err && write)
idr_set_cursor(...);
return err;
looks a bit more readable, but this is matter of taste of course.
Acked-by: Oleg Nesterov <oleg@xxxxxxxxxx>