Re: [PATCH 2/2] userns: don't clear the install target map on map_write() failure
From: Christian Brauner
Date: Mon Aug 31 2026 - 06:20:56 EST
On Fri, Aug 28, 2026 at 11:51:10AM +0200, Jan Kara wrote:
> On Fri 28-08-26 17:16:59, Tao Cui wrote:
> > From: Tao Cui <cuitao@xxxxxxxxxx>
> >
> > At the out: label of map_write() the destination map is also cleared
> > (map->forward = NULL; map->reverse = NULL; map->nr_extents = 0)
> > whenever the write failed and the extent arrays had to be freed.
> >
> > However, the destination map is written by the successful install
> > block above, which has no failure exit; every error path reaches
> > out: without having touched it. A second write to a mapped
> > namespace is also rejected with -EPERM before any parsing happens,
> > so the clearing can never roll back a previously installed map
> > either.
> >
> > The three assignments just zero an already-zero map. Remove them.
> >
> > Signed-off-by: Tao Cui <cuitao@xxxxxxxxxx>
>
> I agree this is a dead code but it kind of makes it easier to argue about
> the correctness of the error handling branch. I guess I'll leave it to for
> Christian to decide whether he wants to take this or not.
Nah, let's leave this as is. :)