From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16C90C02185 for ; Fri, 17 Jan 2025 15:19:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5766D6B0082; Fri, 17 Jan 2025 10:19:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 526686B0083; Fri, 17 Jan 2025 10:19:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F0286B0085; Fri, 17 Jan 2025 10:19:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 208E46B0082 for ; Fri, 17 Jan 2025 10:19:27 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9C09980170 for ; Fri, 17 Jan 2025 15:19:26 +0000 (UTC) X-FDA: 83017302732.13.361046D Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) by imf13.hostedemail.com (Postfix) with ESMTP id 8C30120007 for ; Fri, 17 Jan 2025 15:19:24 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=P1qFIJ23; spf=pass (imf13.hostedemail.com: domain of alexandre.ferrieux@gmail.com designates 209.85.208.50 as permitted sender) smtp.mailfrom=alexandre.ferrieux@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737127164; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=b2Iyh5CkCJ/iMDR9UC1Tk3RYBAf9B7HyAwuM83UZHao=; b=3FwOfriBZrz+XVGIn032AYJJG7t2MOE0b2kDkANOywRP2JduPsxFY9D78/i89fyu8Mireg Iv5z1+oR+fMck5SetPzlV3/36iUNIDZuJKgefD4JV8OHFQozSbBU90ksEGdFjy5vjVudbA S6g/OWB7XaCWuIlxRF5NFFH2szIK6Zc= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=P1qFIJ23; spf=pass (imf13.hostedemail.com: domain of alexandre.ferrieux@gmail.com designates 209.85.208.50 as permitted sender) smtp.mailfrom=alexandre.ferrieux@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737127164; a=rsa-sha256; cv=none; b=rnPN34jAJifmxEWjC3IPIO/zylxVgC5fhd5M2WIe3uD0+0dCGuc0yPZFaqY8NUmxKB+BlT KbwmE3pk2q9Zrop+NNt3/CSb/Lw1fr1OiwrptkafAofsIfn1jnRh//mO2ZjJOtFfVWQDuv TUtvLAVGviDUNmvjnABcBgP3qiwq04k= Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-5d3cf094768so3871130a12.0 for ; Fri, 17 Jan 2025 07:19:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737127163; x=1737731963; darn=kvack.org; h=content-transfer-encoding:in-reply-to:organization:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=b2Iyh5CkCJ/iMDR9UC1Tk3RYBAf9B7HyAwuM83UZHao=; b=P1qFIJ23aGn5Z1+xXd7sJLkCEdqZ3Hy6GN54FKbkGEi19YPN59M6LPejQvXTls5Ko0 rBO3dNw6hLv0HjMRYCa6HOkoAhHd+81QQCxJ4rQYzFc6Q7gMyMyBQmJmHOD70hxIYtZg 68X0YqSs3JHTeVzr3snv2Ta3AMlQaqFU8C2J43eUVifHLiVMQMOAMYRIYuqYuASkkJDF SZ12FOblnWFcmeCDzDIqe3D/UmHYf69YSdNkVYREcb/1plCSVf/K1OkBoEPuaFUZR0s1 ma/C2ZUgfX/qAudj8Eppd8IrxVGMl6+RKwRrO5ORolSrs+Ixb00ZFDmYo4PocM29Ovvq XHOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737127163; x=1737731963; h=content-transfer-encoding:in-reply-to:organization:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=b2Iyh5CkCJ/iMDR9UC1Tk3RYBAf9B7HyAwuM83UZHao=; b=boOf1ZfjWCFy+kdkycTWCWD9utODye8kc0VHDCiS37Me8VXNPSjhEjmxFwuNzIR9Tv vg/JKyVPVFWbDbQaGaou4+FgU+SjR1l6tPk0/8QNq+svFyxV4RYYex+Ibgy56I4Tz7ex /PvZwHzzKpftQS2nRG+4sG4GGG4Va2weMNifXTcr9CCmjfixmh9fXHpw4bazZRe6Te3W j+ywg/SbYmRUtIYgpH9ZHafAKcgVlCivvRhUcTWcJegTG/Ystg6sS9eO2L2WMfVhqVdp bb5+djb6qqRAnmMTXG19/v25yN7wVRgWDSTSi9cxImsJAFH65XvhTHhM2bvw064EQYUA XnYQ== X-Forwarded-Encrypted: i=1; AJvYcCX9R0K0V1NYyLL+jabbklVWoQoWAR1upB5w8fkj6NJkt/bbPj9m2AfmbG6BQXhZm7ecMdxTBKeLLg==@kvack.org X-Gm-Message-State: AOJu0Yy8wKwJG/ZVlq6S+wbtbA7OEtPSbMIH0vkI+Viqm9evxpiL4DPV ev3wGPbvMn5jE3zucVp1fQn6virvUjXhqG+dHc1Vy3fOGPzJYFNn X-Gm-Gg: ASbGnctcuQAZCW03m/AJYfF22xxqIGkMulhBoW74aYzCzEKfX22dtNIqs+1Vy0xW0+2 9sRWAlXF2cWYHFCmoYeHUoNd4yMMhNdIhRlek8mjqSwDXsCFxJKTqa/Mqvg7cHPaztWBzteRvO2 NWHynWGFC4Ll2ZM+4WpkDWWEsCbaPrdpIOrbvrfyAvpS1CotZzOWsda5SY4Kw7miPnbs+Wx29ZM xeBLhHhOTb8zBhfK0n6nstlMa7OoFm4XKXTmSAAzsz5b7fUKUxO9ODg/SYgj8sJrdvqnZtqEy+z Zl2GXQ== X-Google-Smtp-Source: AGHT+IEp+hR1eFHuS1J921on24IXVij12VpkwyiNGDzOQet38LODlcpk+R4Y/VOPH8aWsPkOaUMCFQ== X-Received: by 2002:a05:6402:4308:b0:5d3:d917:dd90 with SMTP id 4fb4d7f45d1cf-5db7d2ec11fmr3337794a12.6.1737127162772; Fri, 17 Jan 2025 07:19:22 -0800 (PST) Received: from [127.0.0.1] ([193.252.113.11]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5db736716d6sm1631091a12.31.2025.01.17.07.19.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Jan 2025 07:19:21 -0800 (PST) From: Alexandre Ferrieux X-Google-Original-From: Alexandre Ferrieux Message-ID: <789848f7-680c-41a0-8edd-64e8af1f2f4b@orange.com> Date: Fri, 17 Jan 2025 16:19:19 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Bug: broken /proc/kcore in 6.13 To: Lorenzo Stoakes , Steven Rostedt Cc: Alexandre Ferrieux , linux-trace-users@vger.kernel.org, LKML , linux-mm@kvack.org References: <05ea473e-d7e9-4ca5-ad91-ba8c00618fb4@orange.com> <20250117084038.79f40307@gandalf.local.home> <4fd7e1a3-f7ff-4b9d-9a53-fb73795b5b3d@lucifer.local> Content-Language: fr, en-US Organization: Orange In-Reply-To: <4fd7e1a3-f7ff-4b9d-9a53-fb73795b5b3d@lucifer.local> Content-Type: text/plain; charset=UTF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QmLiQNvu2quIBCS8Kdlz+Y+vuRHVgXLm7lypwP0/pi/N+mVpo7t MuTRo2x3 ryD4ut5KmkEfiKi4FepJuuRqiRVuJQGluClLdZIWT5K1JPLPQfJKvfVt1UQkf0sZU2/iKXUEYHCu/W+7ESyrCf4LfRtM6FwZ2Q41s7vom0Gsh57w+WJ3MvK8VoG0neXR5gheb9KJAPNpQyWGLUg9QwNdjYZjJu5x6NHTTQBAtO5GkdX5euBeMp42kUbHkv3Z4dBCq7JY2qnhFdbD13wfvLRaauntpmw0QT8lXUuOmCS0HIkfVSVS3/MCej0neWhNgmw10DcCdQy/qIGII+VuQjeVBh8t8sFouJ2wJzqY5M3EteFHAJjwU0pBdGb0ijT4/Wenp5jvaHiYTbi/M4PdT39OK7TJwAXBSFM8xi96ROFRa0nWGT8tiyevOXGkUSRzXXUeIDvE4vwZywpm1OszKY2jegnV1T9fpKS03QH6v7W/uydUZah8xoAiAzSIgNFmpfKZ8SDH4DXmCtfn+euiFOfQHsWHrHfooWkxyDzr2es9qPHPppDUmDlKYIHo40LmncgLsvpS63kbZR3aaDDzBnBAkk7Ldvbippm2oKyoQ1ZEsHjNljK9rJolWoN/jkuXJ4f9a X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 17/01/2025 15:44, Lorenzo Stoakes wrote: > >> Alexandre Ferrieux 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