Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2037271imn; Mon, 1 Aug 2022 08:55:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR7iQDYQo6367q+z2Z1/90ssH3t/N0f27pZtGK6BvWJx958a9GCcgjE+llXc5LTCy/dJgy0b X-Received: by 2002:a17:907:1ca8:b0:730:871e:498c with SMTP id nb40-20020a1709071ca800b00730871e498cmr3877671ejc.651.1659369319503; Mon, 01 Aug 2022 08:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659369319; cv=none; d=google.com; s=arc-20160816; b=QNx+EYfiPg1P2ehAkR+FXr2DM6F7nOAwcGvyGCIrDKKFB9ONv9aiJU0zXlTI/jQ7HF 2u5pE9HLijm7cke8nKYx16zrA94VCmfFPHIBjzhP2wbWlCwLvciTSFD3SjWmEBrnd5q6 av8ABgPIZF1Z3Nnc9DNdN8prCxeIp01y7JqvUy+ro+jCqQUjkE5FjtPiKlyKm0H0boJq pvaAkup2mtToiTKGc4+aCgxt8lxAHqZr9Dier9dp7nw7FeYx5y0YbheEzSL421QoCxXP w94UYqK3fwi1VCa2CNEgk6DlaijXNX4UyFqskMhctgpWytQcuctpk4qcNGpq+loED8Sw RebQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=5++yJrRKHLhfUOToaETru8vpCJRYt8y3xYQtQAKhFM0=; b=kp+cgUHQNvvDgV9K9L5bv0/RQsgPRUoczoIZkYPsZ+tamRfILaxVteUblCs7/rMqj2 IyVMmSYk9o0hWP4/8eOHudGP6UVYfmcmQoT17k6DNE6EQIKVmEVMM4GKQSjMU95Ipdq4 /qNwDpR2kc/HUaLKiGeXH9rV3eXsmvBaCNYOlxyr0CuywVPj8MAaw4FGOCXFmDvadJtV ko7JzeQ7Um4poAXNDuBacbkLo9DKHNLUm99j/xcrTb6Q4vCypOjKUsH1HvyMvL0w8gE5 /1YPtlPd5oAHcEQnpDpD8sbu2Jjf0GwWn4x5zqEb7/L/ysV+wQH0INz4z88mx9yKz26N elSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=lE549N2g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bj26-20020a170906b05a00b0072b41b3d3c3si9003362ejb.766.2022.08.01.08.54.53; Mon, 01 Aug 2022 08:55:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=lE549N2g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233438AbiHAPU2 (ORCPT + 99 others); Mon, 1 Aug 2022 11:20:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233436AbiHAPUW (ORCPT ); Mon, 1 Aug 2022 11:20:22 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5166564C7; Mon, 1 Aug 2022 08:20:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1659367217; bh=pmPjh/lA87Z5W2nyaW7ihvFXNYv9bkrPbRGc5PPQH8A=; h=X-UI-Sender-Class:From:To:Subject:Date; b=lE549N2gSiLnnfNA1wunzQTZ+ah4tpEP5Bky62c5DTnXldiU1lPMBHJrBwe3+9Qnu J5RxSVvWxIULnM47pbVjyQ5x7+9wS4ZGdM31tFENgA3SCUZ3OFBhf4EfpqK84u9ISp RF+X9JScAdU/5u1cu9wPuwY0+39At0MaOJZFm5AI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.150.19]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1McYCl-1nk0kP3d8P-00d1GX; Mon, 01 Aug 2022 17:20:16 +0200 From: Helge Deller To: linux-arch@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 0/3] Dump command line of faulting process to syslog Date: Mon, 1 Aug 2022 17:20:13 +0200 Message-Id: <20220801152016.36498-1-deller@gmx.de> X-Mailer: git-send-email 2.37.1 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:W8hcioovE+Z+4+5r9LvNT3xnxYPDcNyVIT36mxBOBAsVYnianR1 Fk0uyBo+lIsSbJ/nZIXitqJA1/uzvLwohmND4IIR7ZWkVtOugqDY0npB7Dnkx+e/nAS0Fp8 k1Hfd6gXQglgB2oTxS83+hzgwJEHFCC+fOLLODfL84+hBXHNLAtD5moH83E/9ukNtflxtjF bphXKtzcRjuE9otnQSFWw== X-UI-Out-Filterresults: notjunk:1;V03:K0:1Oq5XVvyQtI=:QCeDmdf+soI5wZ/NjoG3tL OEWeTxDe5F0McjEZSPiLyG2dbFOr/wIeNlbJpB24bAi4kPMl1jqhnEWALm48vaYp1Q7t7NvIw nd8zS4fO7GYDTWSEbx/pligOafIk+tcGJ4Kwx5eRlkO4VwqK6OttsfzOrD7ZHpMvteGCcvaAd bdf35qmgowe0LpIPpfsVol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_LOW,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch series allows the arch-specific kernel fault handlers to dump in addition to the typical info (IP address, fault type, backtrace and so = on) the command line of the faulting process. The motivation for this patch is that it's sometimes quite hard to find ou= t and annoying to not know which program *exactly* faulted when looking at the s= yslog. Some examples from the syslog are: On parisc: do_page_fault() command=3D'cc1' type=3D15 address=3D0x00000000 in libc-= 2.33.so[f6abb000+184000] CPU: 1 PID: 13472 Comm: cc1 Tainted: G E 5.10.133+ #45 Hardware name: 9000/785/C8000 -> We see the "cc1" compiler crashed, but it would be useful to know which= file was compiled. With this patch series, the kernel now prints in addition: cc1[13472] cmdline: /usr/lib/gcc/hppa-linux-gnu/12/cc1 -quiet @/tmp/ccR= kFSfY -imultilib . -imultiarch hppa-linux-gnu -D USE_MINIINTERPRETER -D NO= _REGS -D _HPUX_SOURCE -D NOSMP -D THREADED_RTS -include /build/ghc/ghc-9.0= .2/includes/dist-install/build/ghcversion.h -iquote compiler/GHC/Iface -qu= iet -dumpdir /tmp/ghc13413_0/ -dumpbase ghc_5.hc -dumpbase-ext .hc -O -Wim= plicit -fno-PIC -fwrapv -fno-builtin -fno-strict-aliasing -o /tmp/ghc13413= _0/ghc_5.s -> now we know that cc1 crashed while compiling some haskell code. Another parisc example: do_page_fault() command=3D'ld.so.1' type=3D15 address=3D0x565921d8 in l= ibc.so[f7339000+1bb000] CPU: 1 PID: 1151 Comm: cc1 Tainted: G E 5.10.133+ #45 Hardware name: 9000/785/C8000 -> apparently here a program from the glibc testsuite segfaulted. With this patch we now additionally get: ld.so.1[1151] cmdline: /home/gnu/glibc/objdir/elf/ld.so.1 --library-pat= h /home/gnu/glibc/objdir:/home/gnu/glibc/objdir/math:/home/gnu/ /home/gnu/glibc/objdir/malloc/tst-safe-linking-malloc-hugetlb1 -> it was the tst-safe-linking-malloc-hugetlb1 testcase which faulted. An example of a typical x86 fault shows up as: crash[2326]: segfault at 0 ip 0000561a7969c12e sp 00007ffe97a05630 erro= r 6 in crash[561a7969c000+1000] Code: 68 ff ff ff c6 05 19 2f 00 00 01 5d c3 0f 1f 80 00 00 00 00 c3 0f= 1f 80 00 00 00 00 e9 7b ff ff ff 55 48 89 e5 b8 00 00 00 00 00 01 00= 00 00 b8 00 00 00 00 5d c3 0f 1f 44 00 00 41 57 4c 8d -> with this patch we now will see the whole command line: crash[2326] cmdline: ./crash test_write_to_page_0 The patches are relatively small, and reuses functions which are used to create the output for the /proc//cmdline files. This is the version 1 of the patch series. I'm interested if people find this useful too, and if so, I'm happy for any feedback on those patches. Thanks! Helge Helge Deller (3): proc: Add get_task_cmdline_kernel() function lib/dump_stack: Add dump_stack_print_cmdline() and wire up in dump_stack_print_info() x86/fault: Dump command line of faulting process to syslog arch/x86/mm/fault.c | 2 ++ fs/proc/base.c | 68 +++++++++++++++++++++++++++-------------- include/linux/printk.h | 5 +++ include/linux/proc_fs.h | 5 +++ lib/dump_stack.c | 17 +++++++++++ 5 files changed, 74 insertions(+), 23 deletions(-) =2D- 2.37.1