* [PATCH 1/3] kernel/nsproxy: remove unnecessary guard in validate_nsset()
2025-05-30 20:03 [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification Joel Savitz
@ 2025-05-30 20:03 ` Joel Savitz
2025-05-30 20:03 ` [PATCH 2/3] kernel/nsproxy: fix put_*() call ordering " Joel Savitz
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Joel Savitz @ 2025-05-30 20:03 UTC (permalink / raw)
To: linux-kernel; +Cc: Joel Savitz, Christian Brauner, Al Viro
By the same logic as commit 5caa2d89b7f1 ("kernel/nsproxy: remove
unnecessary guards"), remove the guard around put_pid_ns() in
validate_nsset() as put_pid_ns() already performs the NULL check.
Signed-off-by: Joel Savitz <jsavitz@redhat.com>
---
kernel/nsproxy.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index 5f31fdff8a38..be89e006e6aa 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -481,8 +481,7 @@ static int validate_nsset(struct nsset *nsset, struct pid *pid)
#endif
out:
- if (pid_ns)
- put_pid_ns(pid_ns);
+ put_pid_ns(pid_ns);
if (nsp)
put_nsproxy(nsp);
put_user_ns(user_ns);
--
2.45.2
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 2/3] kernel/nsproxy: fix put_*() call ordering in validate_nsset()
2025-05-30 20:03 [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification Joel Savitz
2025-05-30 20:03 ` [PATCH 1/3] kernel/nsproxy: remove unnecessary guard in validate_nsset() Joel Savitz
@ 2025-05-30 20:03 ` Joel Savitz
2025-05-30 20:03 ` [PATCH 3/3] kernel/nsproxy: utilize cleanup helper for nsproxy references Joel Savitz
` (2 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Joel Savitz @ 2025-05-30 20:03 UTC (permalink / raw)
To: linux-kernel; +Cc: Joel Savitz, Christian Brauner, Al Viro
The calls to get_nsproxy(), get_pid_ns(), and get_user_ns() happen in
that order, so call their respective put_*() functions in the reverse
order.
Signed-off-by: Joel Savitz <jsavitz@redhat.com>
---
kernel/nsproxy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index be89e006e6aa..20b07120dbfd 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -481,10 +481,10 @@ static int validate_nsset(struct nsset *nsset, struct pid *pid)
#endif
out:
+ put_user_ns(user_ns);
put_pid_ns(pid_ns);
if (nsp)
put_nsproxy(nsp);
- put_user_ns(user_ns);
return ret;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 3/3] kernel/nsproxy: utilize cleanup helper for nsproxy references
2025-05-30 20:03 [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification Joel Savitz
2025-05-30 20:03 ` [PATCH 1/3] kernel/nsproxy: remove unnecessary guard in validate_nsset() Joel Savitz
2025-05-30 20:03 ` [PATCH 2/3] kernel/nsproxy: fix put_*() call ordering " Joel Savitz
@ 2025-05-30 20:03 ` Joel Savitz
2025-06-09 14:23 ` [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification Joel Savitz
2025-07-14 12:22 ` Christian Brauner
4 siblings, 0 replies; 9+ messages in thread
From: Joel Savitz @ 2025-05-30 20:03 UTC (permalink / raw)
To: linux-kernel; +Cc: Joel Savitz, Christian Brauner, Al Viro
A cleanup helper for nsproxy references was added by commit d057c108155a
("nsproxy: add a cleanup helper for nsproxy") however it is only used in
commit 5b08bd408534 ("pidfs: allow retrieval of namespace file
descriptors").
Simplify nsproxy code by using this cleanup helper.
Signed-off-by: Joel Savitz <jsavitz@redhat.com>
---
kernel/nsproxy.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index 20b07120dbfd..c623e9ce3c2a 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -228,7 +228,7 @@ int unshare_nsproxy_namespaces(unsigned long unshare_flags,
void switch_task_namespaces(struct task_struct *p, struct nsproxy *new)
{
- struct nsproxy *ns;
+ struct nsproxy *ns __free(put_nsproxy) = NULL;
might_sleep();
@@ -236,9 +236,6 @@ void switch_task_namespaces(struct task_struct *p, struct nsproxy *new)
ns = p->nsproxy;
p->nsproxy = new;
task_unlock(p);
-
- if (ns)
- put_nsproxy(ns);
}
void exit_task_namespaces(struct task_struct *p)
@@ -368,7 +365,7 @@ static int validate_nsset(struct nsset *nsset, struct pid *pid)
unsigned flags = nsset->flags;
struct user_namespace *user_ns = NULL;
struct pid_namespace *pid_ns = NULL;
- struct nsproxy *nsp;
+ struct nsproxy *nsp __free(put_nsproxy) = NULL;
struct task_struct *tsk;
/* Take a "snapshot" of the target task's namespaces. */
@@ -483,8 +480,6 @@ static int validate_nsset(struct nsset *nsset, struct pid *pid)
out:
put_user_ns(user_ns);
put_pid_ns(pid_ns);
- if (nsp)
- put_nsproxy(nsp);
return ret;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification
2025-05-30 20:03 [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification Joel Savitz
` (2 preceding siblings ...)
2025-05-30 20:03 ` [PATCH 3/3] kernel/nsproxy: utilize cleanup helper for nsproxy references Joel Savitz
@ 2025-06-09 14:23 ` Joel Savitz
2025-06-18 19:49 ` Joel Savitz
2025-07-14 12:22 ` Christian Brauner
4 siblings, 1 reply; 9+ messages in thread
From: Joel Savitz @ 2025-06-09 14:23 UTC (permalink / raw)
To: linux-kernel; +Cc: Christian Brauner, Al Viro
On Fri, May 30, 2025 at 4:03 PM Joel Savitz <jsavitz@redhat.com> wrote:
>
> The first patch removes an unnecessary guard by the same logic as
> commit 5caa2d89b7f1 ("kernel/nsproxy: remove unnecessary guards").
>
> The second patch fixes the total ordering of resource acquisition
> in validate_nsset().
>
> The third patch implements usage of the cleanup helper added by commit
> d057c108155a ("nsproxy: add a cleanup helper for nsproxy").
>
> Joel Savitz (3):
> kernel/nsproxy: remove unnecessary guard in validate_nsset()
> kernel/nsproxy: fix put_*() call ordering in validate_nsset()
> kernel/nsproxy: utilize cleanup helper for nsproxy references
>
> kernel/nsproxy.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> --
> 2.45.2
>
ping
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification
2025-06-09 14:23 ` [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification Joel Savitz
@ 2025-06-18 19:49 ` Joel Savitz
2025-07-01 16:41 ` Joel Savitz
0 siblings, 1 reply; 9+ messages in thread
From: Joel Savitz @ 2025-06-18 19:49 UTC (permalink / raw)
To: linux-kernel; +Cc: Christian Brauner, Al Viro
On Mon, Jun 9, 2025 at 10:23 AM Joel Savitz <jsavitz@redhat.com> wrote:
>
> On Fri, May 30, 2025 at 4:03 PM Joel Savitz <jsavitz@redhat.com> wrote:
> >
> > The first patch removes an unnecessary guard by the same logic as
> > commit 5caa2d89b7f1 ("kernel/nsproxy: remove unnecessary guards").
> >
> > The second patch fixes the total ordering of resource acquisition
> > in validate_nsset().
> >
> > The third patch implements usage of the cleanup helper added by commit
> > d057c108155a ("nsproxy: add a cleanup helper for nsproxy").
> >
> > Joel Savitz (3):
> > kernel/nsproxy: remove unnecessary guard in validate_nsset()
> > kernel/nsproxy: fix put_*() call ordering in validate_nsset()
> > kernel/nsproxy: utilize cleanup helper for nsproxy references
> >
> > kernel/nsproxy.c | 12 +++---------
> > 1 file changed, 3 insertions(+), 9 deletions(-)
> >
> > --
> > 2.45.2
> >
>
> ping
ping 2
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification
2025-06-18 19:49 ` Joel Savitz
@ 2025-07-01 16:41 ` Joel Savitz
2025-07-07 14:37 ` Joel Savitz
0 siblings, 1 reply; 9+ messages in thread
From: Joel Savitz @ 2025-07-01 16:41 UTC (permalink / raw)
To: linux-kernel; +Cc: Christian Brauner, Al Viro
On Wed, Jun 18, 2025 at 3:49 PM Joel Savitz <jsavitz@redhat.com> wrote:
>
> On Mon, Jun 9, 2025 at 10:23 AM Joel Savitz <jsavitz@redhat.com> wrote:
> >
> > On Fri, May 30, 2025 at 4:03 PM Joel Savitz <jsavitz@redhat.com> wrote:
> > >
> > > The first patch removes an unnecessary guard by the same logic as
> > > commit 5caa2d89b7f1 ("kernel/nsproxy: remove unnecessary guards").
> > >
> > > The second patch fixes the total ordering of resource acquisition
> > > in validate_nsset().
> > >
> > > The third patch implements usage of the cleanup helper added by commit
> > > d057c108155a ("nsproxy: add a cleanup helper for nsproxy").
> > >
> > > Joel Savitz (3):
> > > kernel/nsproxy: remove unnecessary guard in validate_nsset()
> > > kernel/nsproxy: fix put_*() call ordering in validate_nsset()
> > > kernel/nsproxy: utilize cleanup helper for nsproxy references
> > >
> > > kernel/nsproxy.c | 12 +++---------
> > > 1 file changed, 3 insertions(+), 9 deletions(-)
> > >
> > > --
> > > 2.45.2
> > >
> >
> > ping
>
> ping 2
ping 3
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification
2025-07-01 16:41 ` Joel Savitz
@ 2025-07-07 14:37 ` Joel Savitz
0 siblings, 0 replies; 9+ messages in thread
From: Joel Savitz @ 2025-07-07 14:37 UTC (permalink / raw)
To: linux-kernel; +Cc: Christian Brauner, Al Viro
On Tue, Jul 1, 2025 at 12:41 PM Joel Savitz <jsavitz@redhat.com> wrote:
>
> On Wed, Jun 18, 2025 at 3:49 PM Joel Savitz <jsavitz@redhat.com> wrote:
> >
> > On Mon, Jun 9, 2025 at 10:23 AM Joel Savitz <jsavitz@redhat.com> wrote:
> > >
> > > On Fri, May 30, 2025 at 4:03 PM Joel Savitz <jsavitz@redhat.com> wrote:
> > > >
> > > > The first patch removes an unnecessary guard by the same logic as
> > > > commit 5caa2d89b7f1 ("kernel/nsproxy: remove unnecessary guards").
> > > >
> > > > The second patch fixes the total ordering of resource acquisition
> > > > in validate_nsset().
> > > >
> > > > The third patch implements usage of the cleanup helper added by commit
> > > > d057c108155a ("nsproxy: add a cleanup helper for nsproxy").
> > > >
> > > > Joel Savitz (3):
> > > > kernel/nsproxy: remove unnecessary guard in validate_nsset()
> > > > kernel/nsproxy: fix put_*() call ordering in validate_nsset()
> > > > kernel/nsproxy: utilize cleanup helper for nsproxy references
> > > >
> > > > kernel/nsproxy.c | 12 +++---------
> > > > 1 file changed, 3 insertions(+), 9 deletions(-)
> > > >
> > > > --
> > > > 2.45.2
> > > >
> > >
> > > ping
> >
> > ping 2
>
> ping 3
ping 4
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification
2025-05-30 20:03 [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification Joel Savitz
` (3 preceding siblings ...)
2025-06-09 14:23 ` [PATCH 0/3] kernel/nsproxy: Minor nsproxy code simplification Joel Savitz
@ 2025-07-14 12:22 ` Christian Brauner
4 siblings, 0 replies; 9+ messages in thread
From: Christian Brauner @ 2025-07-14 12:22 UTC (permalink / raw)
To: linux-kernel, Joel Savitz; +Cc: Christian Brauner, Al Viro
On Fri, 30 May 2025 16:03:03 -0400, Joel Savitz wrote:
> The first patch removes an unnecessary guard by the same logic as
> commit 5caa2d89b7f1 ("kernel/nsproxy: remove unnecessary guards").
>
> The second patch fixes the total ordering of resource acquisition
> in validate_nsset().
>
> The third patch implements usage of the cleanup helper added by commit
> d057c108155a ("nsproxy: add a cleanup helper for nsproxy").
>
> [...]
Applied to the kernel-6.17.nsproxy branch of the vfs/vfs.git tree.
Patches in the kernel-6.17.nsproxy branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: kernel-6.17.nsproxy
[1/3] kernel/nsproxy: remove unnecessary guard in validate_nsset()
https://git.kernel.org/vfs/vfs/c/e07195e0a5c3
[2/3] kernel/nsproxy: fix put_*() call ordering in validate_nsset()
https://git.kernel.org/vfs/vfs/c/17e48a8cfd75
[3/3] kernel/nsproxy: utilize cleanup helper for nsproxy references
https://git.kernel.org/vfs/vfs/c/04555045c014
^ permalink raw reply [flat|nested] 9+ messages in thread