[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250819003908.GF222315@ZenIV>
Date: Tue, 19 Aug 2025 01:39:08 +0100
From: Al Viro <viro@...iv.linux.org.uk>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: David Laight <david.laight.linux@...il.com>,
Thomas Gleixner <tglx@...utronix.de>,
LKML <linux-kernel@...r.kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Peter Zijlstra <peterz@...radead.org>,
Darren Hart <dvhart@...radead.org>,
Davidlohr Bueso <dave@...olabs.net>,
André Almeida <andrealmeid@...lia.com>,
x86@...nel.org, Christian Brauner <brauner@...nel.org>,
Jan Kara <jack@...e.cz>, linux-fsdevel@...r.kernel.org
Subject: Re: [patch 0/4] uaccess: Provide and use helpers for user masked
access
On Mon, Aug 18, 2025 at 04:00:44PM -0700, Linus Torvalds wrote:
> Now, I don't advocate 'goto' as a general programming model, but for
> exception handling it's superior to any alternative I know of.
>
> Exceptions simply DO NOT NEST, and 'try-catch-finally' is an insane
> model for exceptions that has only made things worse both for
> compilers and for programmers.
>
> So I do think using labels (without any crazy attempt nesting syntax)
> is objectively the superior model.
>
> And the 'finally' mess is much better handled by compilers dealing
> with cleanup - again without any pointless artificial nesting
> structures. I think most of our <linux/cleanup.h> models have been
> quite successful.
I'm still rather cautious about the uses related to locks - it's
very easy to overextend the area where lock is held (witness the
fs/namespace.c bugs of the "oops, that should've been scoped_guard(),
not guard()" variety - we had several this year) and "grab lock,
except it might fail" stuff appears to be all awful - when macro
is supposed to be used like
scoped_cond_guard(lock_timer, return -EINVAL, _id)
(hidden in the bowels of another macro, no less)...
I'm still trying to come up with something edible for lock_mount() -
the best approximation I've got so far is
CLASS(lock_mount, mp)(path);
if (IS_ERR(mp.mp))
bugger off
...
with things like do_add_mount() avoiding the IS_ERR(...) part by
starting with if (IS_ERR(mp)) return PTR_ERR(mp);
With that we get e.g.
CLASS(lock_mount, mp)(mountpoint);
error = do_add_mount(real_mount(mnt), mp.mp, mountpoint, mnt_flags);
if (!error) // mnt is consumed by successful do_add_mount()
retain_and_null_ptr(mnt);
return error;
but it takes some massage to get there...
Powered by blists - more mailing lists