[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALkUMdRv0tMuLpi3Syw7MndBTa9b0xRLGdb6QvM8Q69zXnmUkw@mail.gmail.com>
Date: Mon, 7 Feb 2022 18:51:50 +0530
From: Vimal Agrawal <avimalin@...il.com>
To: Luis Chamberlain <mcgrof@...nel.org>
Cc: Christoph Hellwig <hch@...radead.org>,
Masahiro Yamada <masahiroy@...nel.org>,
Michal Marek <michal.lkml@...kovi.net>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Jan Beulich <JBeulich@...e.com>, Jeff Mahoney <jeffm@...e.com>,
Sam Ravnborg <sam@...nborg.org>, linux-kbuild@...r.kernel.org,
jeyu@...nel.org, linux-kernel@...r.kernel.org,
nishit.shah@...hos.com, Vimal Agrawal <vimal.agrawal@...hos.com>,
Dirk VanDerMerwe <Dirk.VanDerMerwe@...hos.com>
Subject: Re: [PATCH v5] modules: add heuristic when stripping unneeded symbols
>
> You did not explain why you change your code to not use the below
> (!best) branch. I'd much prefer it there as that is when we know
> for sure we have no real symbol defined.
>
> Luis
Actually I had it under (!best) in my first patch. I had to change it
because it was resolving the address to symbols like __this_module for
init address at times which is not correct for text address. It was
not entering inside if (!best) as it found some match but the match
was not correct. It could be fine for some non text addresses but not
for text addresses.
So I had to move this check out of (!best) and put a check explicitly
for text address to avoid any impact on non text addresses by
following:
+ if ((is_module_text_address(addr) &&
+ (bestval < baseval || bestval > nextval))) {
+ /*
+ * return MODULE base and offset if we could not find
+ * any best match for text address
+ */
I tested it on next-20220116-1-gff24014a52c0 today and I am able to
repro at least for init address easily with test_module.ko.
it is showing like following without the patch in my latest run (
decoding it to __this_module wrongly as mentioned earlier) :
[129558.843823] CPU: 2 PID: 39541 Comm: insmod Tainted: G W E
5.16.0-next-20220116+ #6
[129558.843827] Hardware name: innotek GmbH VirtualBox/VirtualBox,
BIOS VirtualBox 12/01/2006
[129558.843829] RIP: 0010:__this_module+0x9fc4/0x9fc7 [test_module].
<<<<<<<<<<<======================
[129558.843840] Code: Unable to access opcode bytes at RIP 0xffffffffc083ffda.
[129558.843841] RSP: 0018:ffffa2cc800cbbf0 EFLAGS: 00010202
[129558.843844] RAX: 0000000000000035 RBX: 0000000000000000 RCX:
0000000000000000
[129558.843846] RDX: 0000000000000000 RSI: ffffffffb6d930f1 RDI:
0000000000000001
[129558.843848] RBP: ffffa2cc800cbbf8 R08: 0000000000000000 R09:
ffffa2cc800cb9f0
[129558.843849] R10: ffffa2cc800cb9e8 R11: ffffffffb7155108 R12:
ffffffffc0840007
[129558.843851] R13: ffff97acb458d580 R14: 0000000000000000 R15:
ffffffffc0836040
[129558.843853] FS: 00007f752eb90400(0000) GS:ffff97ad80f00000(0000)
knlGS:0000000000000000
[129558.843855] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[129558.843857] CR2: ffffffffc083ffda CR3: 0000000100786001 CR4:
00000000000706e0
[129558.843863] Call Trace:
[129558.843865] <TASK>
[129558.843866] ? init_module+0x40/0xff9 [test_module]
Not sure what has changed but it is not showing the absolute address
as I had seen earlier.
post my patch, it is showing like following:
[ 59.600299] CPU: 1 PID: 1620 Comm: insmod Tainted: G E
5.16.0-next-20220116+ #7
[ 59.600303] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS
VirtualBox 12/01/2006
[ 59.600305] RIP: 0010:[module __init]+0x4/0x7 [test_module]
<<<<<<====================
[ 59.600315] Code: Unable to access opcode bytes at RIP 0xffffffffc0827fda.
[ 59.600316] RSP: 0018:ffffbda002a8fc20 EFLAGS: 00010202
[ 59.600319] RAX: 0000000000000035 RBX: 0000000000000000 RCX: 0000000000000000
[ 59.600321] RDX: 0000000000000000 RSI: ffffffffa0f930f1 RDI: 0000000000000001
[ 59.600323] RBP: ffffbda002a8fc28 R08: 0000000000000000 R09: ffffbda002a8fa20
[ 59.600325] R10: ffffbda002a8fa18 R11: ffffffffa1355108 R12: ffffffffc0828007
[ 59.600326] R13: ffff9554c4e72220 R14: 0000000000000000 R15: ffffffffc0822040
[ 59.600328] FS: 00007f9c773d8400(0000) GS:ffff9555c0e80000(0000)
knlGS:0000000000000000
[ 59.600331] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 59.600333] CR2: ffffffffc0827fda CR3: 000000000c19c003 CR4: 00000000000706e0
[ 59.600338] Call Trace:
[ 59.600340] <TASK>
[ 59.600342] ? init_module+0x40/0xff9 [test_module]
I can update the patch explaining this in comments in between the code.
Vimal
Powered by blists - more mailing lists