2022-04-22 17:39:29

by Alexey Gladkov

[permalink] [raw]
Subject: [PATCH v1 2/4] ipc: Use proper ipc namespace

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

Signed-off-by: Eric W. Biederman <[email protected]>
Signed-off-by: Alexey Gladkov <[email protected]>
---
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;
--
2.33.2


2022-05-03 01:04:12

by Eric W. Biederman

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

Alexey Gladkov <[email protected]> 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 <[email protected]>
> Signed-off-by: Alexey Gladkov <[email protected]>
> ---
> 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;

2022-05-04 20:30:22

by Alexey Gladkov

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

On Mon, May 02, 2022 at 11:09:22AM -0500, Eric W. Biederman wrote:
> Alexey Gladkov <[email protected]> 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.

It was preparation for the "ipc: Check permissions for checkpoint_restart
sysctls at open time". I wanted to split the commit and make it more readable,
but it looks like I just confused everyone. This change should be part of the
next commit.

Here is a new version of the patchset where I moved the bugfix to a separate
commit as you requested in the next email.

Does that look better?

--

Alexey Gladkov (4):
ipc: Use the same namespace to modify and validate
ipc: Remove extra1 field abuse to pass ipc namespace
ipc: Check permissions for checkpoint_restart sysctls at open time
ipc: Remove extra braces

ipc/ipc_sysctl.c | 108 +++++++++++++++++++++--------------------------
1 file changed, 49 insertions(+), 59 deletions(-)

--
2.33.3