From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B09611862A for ; Sun, 16 Nov 2025 22:31:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763332285; cv=none; b=DLoK4TFx9dIQ/1xNR3W0cYYgbq7Oq08t/S2DMFsCWLIpvbue9bIbN1pVcqV+xK7x1Niprjlu9wgjUr7/rtxr0KCL7PqIUWc+66c9mApK+dgdgTTCKeMaK+9K59AqRtyo2B43K7343bi+VyK/HaUp/H0GeBUbP07+yLra4qYL6ls= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763332285; c=relaxed/simple; bh=XCeKSIOlDuy6l383a12zf5V685Gcz3SY9BrizpDO6oc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fdG5EUEBbfhQeji2l0fGgYnx2gVL2GojrJn/nugp8GkWwe9w+E9Fzo+hNNP+NywSGCM/2nSQGoYK3NysC7Lh8Vrda1MDlywY9Dx8yrqLc2DzKfEOib3lM/+UJkMtDc1P5WQo0JWvquA+rGQ2ue8/6qrOiyhF60W3AoHnVUdtVks= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gVtijL8g; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gVtijL8g" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64DD4C19422; Sun, 16 Nov 2025 22:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1763332285; bh=XCeKSIOlDuy6l383a12zf5V685Gcz3SY9BrizpDO6oc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gVtijL8ge5dgqR3LuMAPVdB2eIdxeecNeypUInIQ5j6OyaFpnjk1L4lNhcL0vnkf7 Fl/8MV83lPCAdoxrerZa/p0SPr/3FpQ7iTgN7UOm0esTCliSS2Dlv593cZ2Laf600r oJVbd5sr1ovxODPCtjH0oEGVOcuYYCJYCXzK6rAmJ4XWDiPv3Yk46V6svxcOk5paHw dY7JBbXyXmYvEDcp79R2injyCpsjGjn0JJ3hoxpEulhWtgvHLYACz43jsdulgMY/S9 bFbcM3SR7FQFM3p6/hkfqBu244dFjKGI/4FbyCo3qayuuTGCe+rsGPQEhX1C8xKaG8 NdQRJVTxZ3UKQ== From: Miguel Ojeda To: zhengyejian@huaweicloud.com Cc: ardb@kernel.org, arnd@arndb.de, boqun.feng@gmail.com, gary@garyguo.net, gregkh@linuxfoundation.org, jannh@google.com, kees@kernel.org, linux-kernel@vger.kernel.org, masahiroy@kernel.org, mcgrof@kernel.org, ndesaulniers@google.com, song@kernel.org, wedsonaf@google.com, willy@infradead.org, yeweihua4@huawei.com Subject: Re: [PATCH v2] kallsyms: Fix wrong "big" kernel symbol type read from procfs Date: Sun, 16 Nov 2025 23:30:55 +0100 Message-ID: <20251116223055.684054-1-ojeda@kernel.org> In-Reply-To: <20241011143853.3022643-1-zhengyejian@huaweicloud.com> References: <20241011143853.3022643-1-zhengyejian@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Fri, 11 Oct 2024 22:38:53 +0800 Zheng Yejian wrote: > > Currently when the length of a symbol is longer than 0x7f characters, > its type shown in /proc/kallsyms can be incorrect. > > I found this issue when reading the code, but it can be reproduced by > following steps: > > 1. Define a function which symbol length is 130 characters: > > #define X13(x) x##x##x##x##x##x##x##x##x##x##x##x##x > static noinline void X13(x123456789)(void) > { > printk("hello world\n"); > } > > 2. The type in vmlinux is 't': > > $ nm vmlinux | grep x123456 > ffffffff816290f0 t x123456789x123456789x123456789x12[...] > > 3. Then boot the kernel, the type shown in /proc/kallsyms becomes 'g' > instead of the expected 't': > > # cat /proc/kallsyms | grep x123456 > ffffffff816290f0 g x123456789x123456789x123456789x12[...] > > The root cause is that, after commit 73bbb94466fd ("kallsyms: support > "big" kernel symbols"), ULEB128 was used to encode symbol name length. > That is, for "big" kernel symbols of which name length is longer than > 0x7f characters, the length info is encoded into 2 bytes. > > kallsyms_get_symbol_type() expects to read the first char of the > symbol name which indicates the symbol type. However, due to the > "big" symbol case not being handled, the symbol type read from > /proc/kallsyms may be wrong, so handle it properly. > > Cc: stable@vger.kernel.org > Fixes: 73bbb94466fd ("kallsyms: support "big" kernel symbols") > Signed-off-by: Zheng Yejian Applied to `rust-fixes` -- thanks everyone! Let's get some linux-next testing. If someone is against this or wants to pick it up, please shout! Cheers, Miguel