mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Thomas Gleixner <tglx@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>, Ye Liu <ye.liu@linux.dev>,
	Marco Elver <elver@google.com>, Ye Liu <liuye@kylinos.cn>,
	Yi Tao <escape@linux.alibaba.com>, Tejun Heo <tj@kernel.org>,
	Bart Van Assche <bvanassche@acm.org>,
	Christian Brauner <brauner@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/8] mm: introduce for_each_process_rcu and for_each_thread_rcu
Date: Tue, 8 Sep 2026 10:38:17 +0200	[thread overview]
Message-ID: <20260908083817.GN4121339@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <8733vo6tui.ffs@fw13>

On Sat, Sep 05, 2026 at 09:27:33AM +0200, Thomas Gleixner wrote:
> On Fri, Sep 04 2026 at 19:07, Steven Rostedt wrote:
> > On Fri, 04 Sep 2026 23:17:38 +0200
> > Thomas Gleixner <tglx@kernel.org> wrote:
> >
> >> No. Scopes can be left by any valid termination mechanism. 
> >> 
> >> The only problematic case of leaving a scoped_guard() with goto is when
> >> the goto is actually implemented as an ASM goto. See the comment above
> >> arch_unsafe_get_user() in linux/uaccess.h.
> >
> > Oh OK. I was under the impression that goto's could cause undefined
> > behavior with guards. Or is that just when a goto jumps over one? Or is
> > that OK too?
> 
> Jump where ever you want. The keyword is 'scope'.
> 
> The normal visibility rules of variables in C scopes apply. So if the
> scope for which a variable is defined is left and the variable is
> defined with __attribute__((__cleanup__(cleanup_func))) then the compiler
> inserts a call to 'cleanup_func()'.
> 
> The problem with ASM GOTO is that the 'goto' is not visible to the C
> compiler because it is burried in the asm inline. Clang detects it at
> some later point and fails the build. GCC simply emits buggy code or at
> least used to. Haven't checked whether that's still the case.
> 
> So we worked around that by letting the ASM goto jump to a local label
> within the scope and use goto 'outofscope' from there. That makes it
> observe that the scope is left and the cleanup call is inserted at the
> right place. See 3eb6660f26d1 ("uaccess: Provide ASM GOTO safe wrappers
> for unsafe_*_user()")

Right, so GCC will accept and miscompile jumps into a scope. Clang will
warn/error about this, so this should never happen.

Aside from the ASM GOTO issue, there is also an issue with computed
goto, those don't work either.

  reply	other threads:[~2026-09-08  8:38 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  8:29 [PATCH 0/8] " Ye Liu
2026-09-04  8:29 ` [PATCH 1/8] " Ye Liu
2026-09-04 11:03   ` Michal Hocko
2026-09-04 16:25   ` Steven Rostedt
2026-09-04 21:17     ` Thomas Gleixner
2026-09-04 23:07       ` Steven Rostedt
2026-09-05  7:27         ` Thomas Gleixner
2026-09-08  8:38           ` Peter Zijlstra [this message]
2026-09-11 12:54             ` Steven Rostedt
2026-09-11 15:54               ` Bart Van Assche
2026-09-08 12:42           ` Steven Rostedt
2026-09-04  8:29 ` [PATCH 2/8] mm/oom_kill: convert process/thread iterators to for_each_*_rcu Ye Liu
2026-09-04 11:04   ` Michal Hocko
2026-09-05  0:32   ` SJ Park
2026-09-04  8:29 ` [PATCH 3/8] mm/ksm: convert process iterator to for_each_process_rcu Ye Liu
2026-09-04 11:04   ` Michal Hocko
2026-09-05  0:33   ` SJ Park
2026-09-04  8:29 ` [PATCH 4/8] mm/memory-failure: " Ye Liu
2026-09-04 11:05   ` Michal Hocko
2026-09-05  0:39   ` SJ Park
2026-09-07  3:05   ` Miaohe Lin
2026-09-04  8:29 ` [PATCH 5/8] kernel: convert process/thread iterators to for_each_*_rcu Ye Liu
2026-09-04 11:06   ` Michal Hocko
2026-09-04 14:14   ` Günther Noack
2026-09-04  8:29 ` [PATCH 6/8] fs: " Ye Liu
2026-09-04  9:05   ` Oleg Nesterov
2026-09-04  9:22   ` Lorenzo Stoakes (ARM)
2026-09-04 11:06   ` Michal Hocko
2026-09-08 16:45   ` Alexey Dobriyan
2026-09-08 17:10     ` Lorenzo Stoakes (ARM)
2026-09-08 17:26       ` Alexey Dobriyan
2026-09-08 17:41         ` Lorenzo Stoakes (ARM)
2026-09-08 17:12     ` Oleg Nesterov
2026-09-04  8:29 ` [PATCH 7/8] lib: convert process iterator to for_each_process_rcu Ye Liu
2026-09-04 11:09   ` Michal Hocko
2026-09-04  8:30 ` [PATCH 8/8] security/landlock: convert thread iterator to for_each_thread_rcu Ye Liu
2026-09-04 12:21   ` Justin Suess
2026-09-04 14:17   ` Günther Noack

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260908083817.GN4121339@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=brauner@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=elver@google.com \
    --cc=escape@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuye@kylinos.cn \
    --cc=rostedt@goodmis.org \
    --cc=tglx@kernel.org \
    --cc=tj@kernel.org \
    --cc=ye.liu@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®