From: David Laight <David.Laight@ACULAB.COM>
To: 'Jann Horn' <jannh@google.com>, Kees Cook <keescook@chromium.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>,
Vito Caputo <vcaputo@pengaru.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
Qi Zheng <zhengqi.arch@bytedance.com>,
"peterz@infradead.org" <peterz@infradead.org>,
"luto@kernel.org" <luto@kernel.org>
Subject: RE: CONFIG_ORC_UNWINDER=y breaks get_wchan()?
Date: Sat, 25 Sep 2021 19:07:02 +0000 [thread overview]
Message-ID: <bbe02e79355c42139d3b7fcc15344474@AcuMS.aculab.com> (raw)
In-Reply-To: <CAG48ez2zC=+PuNgezH53HBPZ8CXU5H=vkWx7nJs60G8RXt3w0Q@mail.gmail.com>
From: Jann Horn
> Sent: 24 September 2021 01:00
...
> > Normally wchan is protected by:
> >
> > ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS)
> >
> > I might argue that this check isn't right -- it needs to be using
> > f_cred, but I'll let Jann answer more there.
> >
> > > ... since presumably proc_pid_wchan()'s use of '%ps' can result in an
> > > actual address getting printed if the unwind gets confused, thanks to
> > > __sprint_symbol()'s backup option if kallsyms_lookup_buildid() doesn't
> > > find a name.
> >
> > Ew, yeah, __sprint_symbol() falls back to exposing addresses. :(
> >
> > name = kallsyms_lookup_buildid(address, &size, &offset, &modname, &buildid,
> > buffer);
> > if (!name)
> > return sprintf(buffer, "0x%lx", address - symbol_offset);
>
> Whaaaat? That's not how wchan worked when I looked at this the last
> time a few years ago...
Hmmmm....
Historically (and I mean SYSV and probably BSD) the 'wchan'
was the 'token' passed to the kernel sleep() function and
value that needed to be passed to wakeup() to get the process
rescheduled.
It was usually the address of something associated with the
sleep - but didn't have to be.
Linux doesn't do process sleep/wakeup the same way.
The nearest thing would be 'struct wait_queue_head'.
But the address of that isn't a useful value.
Plausibly the address of the function that initialises
the wait_queue_head could be put into it and that
value saved by schedule() to that it can be returned
as the 'wchan'.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2021-09-25 19:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-21 19:32 Vito Caputo
2021-09-22 0:15 ` Josh Poimboeuf
2021-09-22 3:04 ` Kees Cook
2021-09-23 23:59 ` Jann Horn
2021-09-25 19:07 ` David Laight [this message]
2021-09-22 3:30 ` Qi Zheng
2021-10-05 0:51 ` Andy Lutomirski
2021-09-24 5:46 ` Vito Caputo
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=bbe02e79355c42139d3b7fcc15344474@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=jannh@google.com \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=vcaputo@pengaru.com \
--cc=x86@kernel.org \
--cc=zhengqi.arch@bytedance.com \
/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®