Re: [PATCH v1 2/4] ipc: Use proper ipc namespace

From: Eric W. Biederman
Date: Mon May 02 2022 - 12:09:35 EST


Alexey Gladkov <legion@xxxxxxxxxx> writes:

> As Eric Biederman pointed out, changing the namespace broke checkpoint
> restore. I have reverted my previous changes.

Can you remind me the bug that is being fixed here?

I am probably just going to fast to see it, but it would be good to have
it described in the commit comment.

Thanks,
Eric

>
> Signed-off-by: Eric W. Biederman <ebiederm@xxxxxxxxxxxx>
> Signed-off-by: Alexey Gladkov <legion@xxxxxxxxxx>
> ---
> ipc/ipc_sysctl.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
> index eb7ba8e0a355..ff99d0305a5b 100644
> --- a/ipc/ipc_sysctl.c
> +++ b/ipc/ipc_sysctl.c
> @@ -72,7 +72,7 @@ static int proc_ipc_sem_dointvec(struct ctl_table *table, int write,
> static int proc_ipc_dointvec_minmax_checkpoint_restore(struct ctl_table *table,
> int write, void *buffer, size_t *lenp, loff_t *ppos)
> {
> - struct ipc_namespace *ns = table->extra1;
> + struct ipc_namespace *ns = current->nsproxy->ipc_ns;
> struct ctl_table ipc_table;
>
> if (write && !checkpoint_restore_ns_capable(ns->user_ns))
> @@ -244,15 +244,12 @@ bool setup_ipc_sysctls(struct ipc_namespace *ns)
> #ifdef CONFIG_CHECKPOINT_RESTORE
> } else if (tbl[i].data == &init_ipc_ns.ids[IPC_SEM_IDS].next_id) {
> tbl[i].data = &ns->ids[IPC_SEM_IDS].next_id;
> - tbl[i].extra1 = ns;
>
> } else if (tbl[i].data == &init_ipc_ns.ids[IPC_MSG_IDS].next_id) {
> tbl[i].data = &ns->ids[IPC_MSG_IDS].next_id;
> - tbl[i].extra1 = ns;
>
> } else if (tbl[i].data == &init_ipc_ns.ids[IPC_SHM_IDS].next_id) {
> tbl[i].data = &ns->ids[IPC_SHM_IDS].next_id;
> - tbl[i].extra1 = ns;
> #endif
> } else {
> tbl[i].data = NULL;