commit 14775b049642 ("dyndbg: accept query terms like file=bar and module=foo")
added the combined keyword=value parsing poorly; revert most of it,
keeping the keyword & arg change.
Instead, fix the tokenizer for the new input, by terminating the
keyword (an unquoted word) on '=' as well as space, thus letting the
tokenizer work on the quoted argument, like it would have previously.
Also add a few debug-prints to show more parsing context, into
tokenizer and parse-query, and use "keyword, value" in others.
Fixes: 14775b049642 ("dyndbg: accept query terms like file=bar and module=foo")
---
-v3 commit message, checkpatch fixes
Signed-off-by: Jim Cromie <[email protected]>
---
lib/dynamic_debug.c | 38 +++++++++++++++++---------------------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 08e4b057514c..04f4c80b0d16 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -237,6 +237,7 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
{
int nwords = 0;
+ vpr_info("entry, buf:'%s'\n", buf);
while (*buf) {
char *end;
@@ -247,6 +248,8 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
if (*buf == '#')
break; /* token starts comment, skip rest of line */
+ vpr_info("start-of-word:%d '%s'\n", nwords, buf);
+
/* find `end' of word, whitespace separated or quoted */
if (*buf == '"' || *buf == '\'') {
int quote = *buf++;
@@ -257,7 +260,9 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
return -EINVAL; /* unclosed quote */
}
} else {
- for (end = buf; *end && !isspace(*end); end++)
+ for (end = buf;
+ *end && *end != '=' && !isspace(*end);
+ end++)
;
BUG_ON(end == buf);
}
@@ -373,30 +378,21 @@ static int ddebug_parse_query(char *words[], int nwords,
unsigned int i;
int rc = 0;
char *fline;
- char *keyword, *arg;
- if (modname)
+ if (nwords % 2 != 0) {
+ pr_err("expecting pairs of match-spec <value>\n");
+ return -EINVAL;
+ }
+ if (modname) {
/* support $modname.dyndbg=<multiple queries> */
+ vpr_info("module:%s queries:'%s'\n", modname);
query->module = modname;
+ }
+ for (i = 0; i < nwords; i += 2) {
+ char *keyword = words[i];
+ char *arg = words[i+1];
- for (i = 0; i < nwords; i++) {
- /* accept keyword=arg */
- vpr_info("%d w:%s\n", i, words[i]);
-
- keyword = words[i];
- arg = strchr(keyword, '=');
- if (arg) {
- *arg++ = '\0';
- } else {
- i++; /* next word is arg */
- if (!(i < nwords)) {
- pr_err("missing arg to keyword: %s\n", keyword);
- return -EINVAL;
- }
- arg = words[i];
- }
- vpr_info("%d key:%s arg:%s\n", i, keyword, arg);
-
+ vpr_info("keyword:'%s' value:'%s'\n", keyword, arg);
if (!strcmp(keyword, "func")) {
rc = check_set(&query->function, arg, "func");
} else if (!strcmp(keyword, "file")) {
--
2.26.2
Greeting,
FYI, we noticed the following commit (built with gcc-9):
commit: 70f06a871f5d40ca8f977eb412358ab03b6804da ("[PATCH v3 3/3] dyndbg: fix problem parsing format="foo bar"")
url: https://github.com/0day-ci/linux/commits/Jim-Cromie/dyndbg-cleanups-for-5-9/20200901-022403
base: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git f75aef392f869018f78cfedf3c320a6b3fcfda6b
in testcase: kernel-selftests
with following parameters:
group: kselftests-livepatch
test-description: The kernel contains a set of "self tests" under the tools/testing/selftests/ directory. These are intended to be small unit tests to exercise individual code paths in the kernel.
test-url: https://www.kernel.org/doc/Documentation/kselftest.txt
on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 8G
caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):
+------------------------------------------+------------+------------+
| | 12aeaa9439 | 70f06a871f |
+------------------------------------------+------------+------------+
| boot_successes | 6 | 2 |
| boot_failures | 0 | 4 |
| kernel_BUG_at_lib/dynamic_debug.c | 0 | 4 |
| invalid_opcode:#[##] | 0 | 4 |
| RIP:ddebug_exec_query | 0 | 4 |
| Kernel_panic-not_syncing:Fatal_exception | 0 | 4 |
+------------------------------------------+------------+------------+
If you fix the issue, kindly add following tag
Reported-by: kernel test robot <[email protected]>
[ 78.796907] kernel BUG at lib/dynamic_debug.c:267!
[ 78.799930] invalid opcode: 0000 [#1] PREEMPT SMP PTI
[ 78.801632] CPU: 1 PID: 1068 Comm: test-livepatch. Tainted: G K 5.9.0-rc3-00003-g70f06a871f5d4 #1
[ 78.803877] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
[ 78.805929] RIP: 0010:ddebug_exec_query+0x684/0x760
[ 78.807642] Code: 0f 85 c0 08 00 00 4c 89 7c 24 28 e9 2d fc ff ff 4c 89 fe 48 8d 7c 24 10 e8 a9 f8 ff ff 85 c0 0f 84 18 fc ff ff e9 c1 07 00 00 <0f> 0b 8b 15 ac 37 e2 02 85 d2 0f 85 c1 00 00 00 45 31 e4 48 c7 c6
[ 78.812169] RSP: 0018:ffffb325411c7d78 EFLAGS: 00010246
[ 78.815411] RAX: 000000000000003d RBX: ffff9f4dab69286c RCX: 0000000000000000
[ 78.821166] RDX: 000000000000003d RSI: ffff9f4dab692868 RDI: ffff9f4dab69286c
[ 78.823160] RBP: 0000000000000004 R08: ffff9f4dab69286e R09: 0000000000000001
[ 78.825172] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000004
[ 78.827212] R13: 0000000000000004 R14: 0000000000000000 R15: 0000000000000000
[ 78.829228] FS: 00007f024c29c740(0000) GS:ffff9f4e77d00000(0000) knlGS:0000000000000000
[ 78.831343] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 78.833243] CR2: 00007f024c45c8a0 CR3: 0000000168360000 CR4: 00000000000406e0
[ 78.835312] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 78.837371] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 78.839398] Call Trace:
[ 78.840935] ? __might_fault+0x36/0x80
[ 78.842574] ddebug_exec_queries+0x6a/0x100
[ 78.844322] ddebug_proc_write+0x4e/0x80
[ 78.845985] full_proxy_write+0x56/0x80
[ 78.847621] vfs_write+0xec/0x240
[ 78.849189] ksys_write+0x68/0xe0
[ 78.850738] do_syscall_64+0x33/0x40
[ 78.852347] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 78.854106] RIP: 0033:0x7f024c389504
[ 78.855634] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b3 0f 1f 80 00 00 00 00 48 8d 05 f9 61 0d 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 49 89 d4 55 48 89 f5 53
[ 78.860364] RSP: 002b:00007fff5962d2b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[ 78.864609] RAX: ffffffffffffffda RBX: 00000000000000bc RCX: 00007f024c389504
[ 78.866696] RDX: 00000000000000bc RSI: 00005582ce63dcd0 RDI: 0000000000000001
[ 78.868751] RBP: 00005582ce63dcd0 R08: fffffffffffffff0 R09: 00007f024c419e80
[ 78.870832] R10: 00005582ce63dd8c R11: 0000000000000246 R12: 00007f024c45b760
[ 78.872933] R13: 00000000000000bc R14: 00007f024c456760 R15: 00000000000000bc
[ 78.875077] Modules linked in: intel_rapl_msr intel_rapl_common snd_pcm sr_mod cdrom sg crct10dif_pclmul ppdev crc32_pclmul snd_timer bochs_drm crc32c_intel ata_generic ghash_clmulni_intel snd pata_acpi drm_vram_helper aesni_intel drm_ttm_helper crypto_simd ttm cryptd ata_piix glue_helper soundcore joydev pcspkr serio_raw parport_pc libata parport ipmi_devintf ipmi_msghandler floppy i2c_piix4 ip_tables [last unloaded: test_klp_atomic_replace]
[ 78.889926] ---[ end trace aae1acea69a78e4f ]---
To reproduce:
# build kernel
cd linux
cp config-5.9.0-rc3-00003-g70f06a871f5d4 .config
make HOSTCC=gcc-9 CC=gcc-9 ARCH=x86_64 olddefconfig prepare modules_prepare bzImage
git clone https://github.com/intel/lkp-tests.git
cd lkp-tests
bin/lkp qemu -k <bzImage> job-script # job-script is attached in this email
Thanks,
lkp
Got it.
will investigate asap
On Wed, Sep 2, 2020 at 3:42 AM kernel test robot <[email protected]> wrote:
>
> Greeting,
>
> FYI, we noticed the following commit (built with gcc-9):
>
> commit: 70f06a871f5d40ca8f977eb412358ab03b6804da ("[PATCH v3 3/3] dyndbg: fix problem parsing format="foo bar"")
> url: https://github.com/0day-ci/linux/commits/Jim-Cromie/dyndbg-cleanups-for-5-9/20200901-022403
> base: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git f75aef392f869018f78cfedf3c320a6b3fcfda6b
>
> in testcase: kernel-selftests
> with following parameters:
>
> group: kselftests-livepatch
>
> test-description: The kernel contains a set of "self tests" under the tools/testing/selftests/ directory. These are intended to be small unit tests to exercise individual code paths in the kernel.
> test-url: https://www.kernel.org/doc/Documentation/kselftest.txt
>
>
> on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 8G
>
> caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace):
>
>
> +------------------------------------------+------------+------------+
> | | 12aeaa9439 | 70f06a871f |
> +------------------------------------------+------------+------------+
> | boot_successes | 6 | 2 |
> | boot_failures | 0 | 4 |
> | kernel_BUG_at_lib/dynamic_debug.c | 0 | 4 |
> | invalid_opcode:#[##] | 0 | 4 |
> | RIP:ddebug_exec_query | 0 | 4 |
> | Kernel_panic-not_syncing:Fatal_exception | 0 | 4 |
> +------------------------------------------+------------+------------+
>
>
> If you fix the issue, kindly add following tag
> Reported-by: kernel test robot <[email protected]>
>
>
> [ 78.796907] kernel BUG at lib/dynamic_debug.c:267!
> [ 78.799930] invalid opcode: 0000 [#1] PREEMPT SMP PTI
> [ 78.801632] CPU: 1 PID: 1068 Comm: test-livepatch. Tainted: G K 5.9.0-rc3-00003-g70f06a871f5d4 #1
> [ 78.803877] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
> [ 78.805929] RIP: 0010:ddebug_exec_query+0x684/0x760
> [ 78.807642] Code: 0f 85 c0 08 00 00 4c 89 7c 24 28 e9 2d fc ff ff 4c 89 fe 48 8d 7c 24 10 e8 a9 f8 ff ff 85 c0 0f 84 18 fc ff ff e9 c1 07 00 00 <0f> 0b 8b 15 ac 37 e2 02 85 d2 0f 85 c1 00 00 00 45 31 e4 48 c7 c6
> [ 78.812169] RSP: 0018:ffffb325411c7d78 EFLAGS: 00010246
> [ 78.815411] RAX: 000000000000003d RBX: ffff9f4dab69286c RCX: 0000000000000000
> [ 78.821166] RDX: 000000000000003d RSI: ffff9f4dab692868 RDI: ffff9f4dab69286c
> [ 78.823160] RBP: 0000000000000004 R08: ffff9f4dab69286e R09: 0000000000000001
> [ 78.825172] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000004
> [ 78.827212] R13: 0000000000000004 R14: 0000000000000000 R15: 0000000000000000
> [ 78.829228] FS: 00007f024c29c740(0000) GS:ffff9f4e77d00000(0000) knlGS:0000000000000000
> [ 78.831343] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 78.833243] CR2: 00007f024c45c8a0 CR3: 0000000168360000 CR4: 00000000000406e0
> [ 78.835312] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> [ 78.837371] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> [ 78.839398] Call Trace:
> [ 78.840935] ? __might_fault+0x36/0x80
> [ 78.842574] ddebug_exec_queries+0x6a/0x100
> [ 78.844322] ddebug_proc_write+0x4e/0x80
> [ 78.845985] full_proxy_write+0x56/0x80
> [ 78.847621] vfs_write+0xec/0x240
> [ 78.849189] ksys_write+0x68/0xe0
> [ 78.850738] do_syscall_64+0x33/0x40
> [ 78.852347] entry_SYSCALL_64_after_hwframe+0x44/0xa9
> [ 78.854106] RIP: 0033:0x7f024c389504
> [ 78.855634] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b3 0f 1f 80 00 00 00 00 48 8d 05 f9 61 0d 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 49 89 d4 55 48 89 f5 53
> [ 78.860364] RSP: 002b:00007fff5962d2b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
> [ 78.864609] RAX: ffffffffffffffda RBX: 00000000000000bc RCX: 00007f024c389504
> [ 78.866696] RDX: 00000000000000bc RSI: 00005582ce63dcd0 RDI: 0000000000000001
> [ 78.868751] RBP: 00005582ce63dcd0 R08: fffffffffffffff0 R09: 00007f024c419e80
> [ 78.870832] R10: 00005582ce63dd8c R11: 0000000000000246 R12: 00007f024c45b760
> [ 78.872933] R13: 00000000000000bc R14: 00007f024c456760 R15: 00000000000000bc
> [ 78.875077] Modules linked in: intel_rapl_msr intel_rapl_common snd_pcm sr_mod cdrom sg crct10dif_pclmul ppdev crc32_pclmul snd_timer bochs_drm crc32c_intel ata_generic ghash_clmulni_intel snd pata_acpi drm_vram_helper aesni_intel drm_ttm_helper crypto_simd ttm cryptd ata_piix glue_helper soundcore joydev pcspkr serio_raw parport_pc libata parport ipmi_devintf ipmi_msghandler floppy i2c_piix4 ip_tables [last unloaded: test_klp_atomic_replace]
> [ 78.889926] ---[ end trace aae1acea69a78e4f ]---
>
>
> To reproduce:
>
> # build kernel
> cd linux
> cp config-5.9.0-rc3-00003-g70f06a871f5d4 .config
> make HOSTCC=gcc-9 CC=gcc-9 ARCH=x86_64 olddefconfig prepare modules_prepare bzImage
>
> git clone https://github.com/intel/lkp-tests.git
> cd lkp-tests
> bin/lkp qemu -k <bzImage> job-script # job-script is attached in this email
>
>
>
> Thanks,
> lkp
>