From: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>
To: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
Steven Rostedt <rostedt@goodmis.org>
Cc: Alexandre Ferrieux <alexandre.ferrieux@gmail.com>,
linux-trace-users@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
linux-mm@kvack.org
Subject: Re: Bug: broken /proc/kcore in 6.13
Date: Fri, 17 Jan 2025 16:19:19 +0100 [thread overview]
Message-ID: <789848f7-680c-41a0-8edd-64e8af1f2f4b@orange.com> (raw)
In-Reply-To: <4fd7e1a3-f7ff-4b9d-9a53-fb73795b5b3d@lucifer.local>
On 17/01/2025 15:44, Lorenzo Stoakes wrote:
>
>> Alexandre Ferrieux <alexandre.ferrieux@gmail.com> wrote:
>>
>> > Hi,
>> >
>> > Somewhere in the 6.13 branch (not bisected yet, sorry), it stopped being
>> > possible to disassemble the running kernel from gdb through /proc/kcore.
>
> Thanks for the report! Much appreciated.
>
> I may try to bisect here also unless you're close to finding the commit that
> broke this?
I'm currently homing in on copy_page_to_iter_nofault(), will report shortly :)
> Yikes, this is my fault. Sorry about that!
Wow. I'm so happy we connected, no problem :)
> There was some discussion at the time about the infinite loop, obviously with
> the understanding that vread_iter() should never return 0 in this scenario
> (where we had identified the _category_ of kernel memory being accessed), which
> is obviously now rendered false.
>
> The fact that it can is (obviously) rather problematic... obviously we need to
> patch this, if this were possible in real scenarios in the past we would
> probably also want to backport a fix.
>
> In any case I think we need an explicit check here no matter the cause so we can
> never loop like this. This was just an oversight at the time given this is a
> documented behaviour.
>
> My instinct is to error out if this returns 0, because that would indicate that
> the address is not part of the vmalloc area.
Yes, I did the naive patch below; it does the job, breaking out of the loop, but
does not cure the access problem, so gdb just sees zeroes :(
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index e376f48c4b8b..8c5f29240542 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -531,7 +531,13 @@ static ssize_t read_kcore_iter(struct kiocb *iocb, struct
iov_iter *iter)
* again until we are done.
*/
while (true) {
- read += vread_iter(iter, src, left);
+ long res;
+ res = vread_iter(iter, src, left);
+ if (!res) {
+ ret = -EFAULT;
+ goto out;
+ }
+ read += res;
if (read == tsz)
break;
> But then it seems add_modules_range() is just adding the module range under
> category KCORE_VMALLOC despite it not being in the vmalloc range :/ which is
> really odd. This was added a long time ago so clearly not what triggered this
> but odd.
>
> In any case, let me go have a look at this...
Ok, staying eagerly tuned !
Best regards,
-Alex
next prev parent reply other threads:[~2025-01-17 15:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <05ea473e-d7e9-4ca5-ad91-ba8c00618fb4@orange.com>
2025-01-17 13:40 ` Steven Rostedt
2025-01-17 14:44 ` Lorenzo Stoakes
2025-01-17 15:19 ` Alexandre Ferrieux [this message]
2025-01-17 15:28 ` Alexandre Ferrieux
2025-01-17 16:31 ` Lorenzo Stoakes
2025-01-17 18:13 ` Lorenzo Stoakes
2025-01-17 19:27 ` Alexandre Ferrieux
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=789848f7-680c-41a0-8edd-64e8af1f2f4b@orange.com \
--to=alexandre.ferrieux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-trace-users@vger.kernel.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=rostedt@goodmis.org \
/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