lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <ead5c1d1-97c8-4fc6-932f-787584c29b4c@broadcom.com>
Date: Tue, 16 Apr 2024 11:03:53 +0200
From: Arend van Spriel <arend.vanspriel@...adcom.com>
To: linux-arm-kernel@...ts.infradead.org
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: arm: global variables in kernel module not loaded correctly in gdb

This issue should probably be reported to GDB bugzilla, but wanted to 
put it out here as well. Maybe someone else stumbled upon this or simply 
knows what is going on. Google searches did not provide much clues nor 
searching GDB bugzilla.

So what is my issue? When I load a .ko file into GDB using 
add-symbol-file the (static) global variables do not have the correct 
memory address. When I use the .o file iso the .ko file things work as 
expected.

I created a dummy kernel module and compiled it against 6.9-rc4. I did 
have my suspicion about PLTS which is enabled in my kernel config. When 
CONFIG_ARM_MODULE_PLTS is disabled the symbol address is correct. From 
my limited understanding this involves an additional link table. AFAICT 
the BFD library which is used by GDB supports this, but can not rule out 
there is a bug in there. I rebuild GDB and added some debug print and 
also changed a debug variable which makes symbol loading a bit more verbose.

Attached are the two kernel config files and the dummy module source 
file. Any help would be appreciated.

Regards,
Arend

with CONFIG_ARM_MODULE_PLTS
---------------------------
Reading symbols from vmlinux...
(gdb) add-symbol-file dummy.ko -s .text 0xbf607000  -s .bss 0xbf6091c0
add symbol table from file "dummy.ko" at
	.text_addr = 0xbf607000
	.bss_addr = 0xbf6091c0
(y or n) y
Reading symbols from dummy.ko...
using ABFD: name=.text idx=2 addr=0 lower=0
addrs[0]: name=.text idx=2 addr=bf607000
using ABFD: name=.bss idx=19 addr=0 lower=bf607000
addrs[1]: name=.bss idx=19 addr=bf6091c0
Reading minimal symbols of objfile 
/home/av935118/sandbox/mod_dummy/dummy.ko ...
Recording minsym:  mst_file_data                        0x45    12 
__UNIQUE_ID_depends126
Recording minsym:  mst_file_data                        0x4e    12 
__UNIQUE_ID_name125
Recording minsym:  mst_file_data                        0x59    12 
__UNIQUE_ID_vermagic124
Recording minsym:  mst_file_data                         0x0     1  _note_15
Recording minsym:  mst_file_data                        0x18     1  _note_14
Recording minsym:  mst_file_data                         0x0     5  .LC0
Recording minsym:  mst_file_text                         0x0     3 
dummy_exit
Recording minsym:  mst_file_data                         0xc     5  .LC1
Recording minsym:  mst_file_data                        0x20     5  .LC2
Recording minsym:  mst_file_text                         0x0     4 
dummy_init
Recording minsym:  mst_file_bss                          0x0    19 
LANCHOR0
Recording minsym:  mst_file_bss                         *0x0*   19 
dummy_value
Recording minsym:  mst_file_data                         0x0    15 
__UNIQUE_ID___addressable_cleanup_module125
Recording minsym:  mst_file_data                         0x0    16 
__UNIQUE_ID___addressable_init_module124
Recording minsym:  mst_file_data                         0x0    12 
__UNIQUE_ID_license127
Recording minsym:  mst_file_data                         0xe    12 
__UNIQUE_ID_author126
Recording minsym:  mst_data                              0x0    17 
__this_module
Recording minsym:  mst_text                              0x0     3 
cleanup_module
Recording minsym:  mst_text                              0x0     4 
init_module
Recording minsym:  mst_text                              0x0     2 
dummy_set_value
Recording minsym:  mst_text                             0x10     2 
dummy_get_value

(gdb) add-symbol-file dummy.o -s .text 0xbf607000  -s .bss 0xbf6091c0
add symbol table from file "dummy.o" at
	.text_addr = 0xbf607000
	.bss_addr = 0xbf6091c0
(y or n) y
Reading symbols from dummy.o...
using ABFD: name=.text idx=0 addr=0 lower=0
addrs[0]: name=.text idx=0 addr=bf607000
using ABFD: name=.bss idx=2 addr=0 lower=bf607000
addrs[1]: name=.bss idx=2 addr=bf6091c0
Reading minimal symbols of objfile 
/home/av935118/sandbox/mod_dummy/dummy.o ...
Recording minsym:  mst_file_data                         0x0     3  .LC0
Recording minsym:  mst_file_text                        0x38     4 
dummy_exit
Recording minsym:  mst_file_data                         0xc     3  .LC1
Recording minsym:  mst_file_data                        0x20     3  .LC2
Recording minsym:  mst_file_text                        0x4c     7 
dummy_init
Recording minsym:  mst_file_bss                   0xbf6091c0     2 
LANCHOR0
Recording minsym:  mst_file_bss                  *0xbf6091c0*    2 
dummy_value
Recording minsym:  mst_file_data                        0xa8    12 
__UNIQUE_ID___addressable_cleanup_module125
Recording minsym:  mst_file_data                        0xac    13 
__UNIQUE_ID___addressable_init_module124
Recording minsym:  mst_file_data                        0xb0    14 
__UNIQUE_ID_license127
Recording minsym:  mst_file_data                        0xbe    14 
__UNIQUE_ID_author126
Recording minsym:  mst_text                             0x38     4 
cleanup_module
Recording minsym:  mst_text                             0x4c     7 
init_module
Recording minsym:  mst_text                       0xbf607000     0 
dummy_set_value
Recording minsym:  mst_text                       0xbf607010     0 
dummy_get_value

without CONFIG_ARM_MODULE_PLTS
------------------------------
Reading symbols from vmlinux...
(gdb) add-symbol-file ~/sandbox/mod_dummy/dummy.ko -s .text 0xbf607000 
-s .bss 0xbf6091c0
add symbol table from file "/home/av935118/sandbox/mod_dummy/dummy.ko" at
	.text_addr = 0xbf607000
	.bss_addr = 0xbf6091c0
(y or n) y
Reading symbols from /home/av935118/sandbox/mod_dummy/dummy.ko...
using ABFD: name=.text idx=2 addr=0 lower=0
addrs[0]: name=.text idx=2 addr=bf607000
using ABFD: name=.bss idx=17 addr=0 lower=bf607000
addrs[1]: name=.bss idx=17 addr=bf6091c0
Reading minimal symbols of objfile 
/home/av935118/sandbox/mod_dummy/dummy.ko ...
Recording minsym:  mst_file_data                       0x141    12 
__UNIQUE_ID_depends126
Recording minsym:  mst_file_data                       0x14a    12 
__UNIQUE_ID_name125
Recording minsym:  mst_file_data                       0x155    12 
__UNIQUE_ID_vermagic124
Recording minsym:  mst_file_data                        0x24     1  _note_15
Recording minsym:  mst_file_data                        0x3c     1  _note_14
Recording minsym:  mst_file_data                        0xa4     5  .LC0
Recording minsym:  mst_file_text                        0x54     3 
dummy_exit
Recording minsym:  mst_file_data                        0xb0     5  .LC1
Recording minsym:  mst_file_data                        0xc4     5  .LC2
Recording minsym:  mst_file_text                        0x60     4 
dummy_init
Recording minsym:  mst_file_bss                   0xbf6091c0    17 
LANCHOR0
Recording minsym:  mst_file_bss                  *0xbf6091c0*   17 
dummy_value
Recording minsym:  mst_file_data                       0x184    14 
__UNIQUE_ID___addressable_cleanup_module125
Recording minsym:  mst_file_data                       0x188    15 
__UNIQUE_ID___addressable_init_module124
Recording minsym:  mst_file_data                        0xfc    12 
__UNIQUE_ID_license127
Recording minsym:  mst_file_data                       0x10a    12 
__UNIQUE_ID_author126
Recording minsym:  mst_data                            0x1c0    16 
__this_module
Recording minsym:  mst_text                             0x54     3 
cleanup_module
Recording minsym:  mst_text                             0x60     4 
init_module
Recording minsym:  mst_text                       0xbf607000     2 
dummy_set_value
Recording minsym:  mst_text                       0xbf607010     2 
dummy_get_value
View attachment "dummy.c" of type "text/plain" (538 bytes)

View attachment "arm-kernel-config" of type "text/plain" (91691 bytes)

View attachment "arm-kernel-config-plts" of type "text/plain" (91680 bytes)

Download attachment "smime.p7s" of type "application/pkcs7-signature" (4219 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ