From patchwork Sat Aug 6 12:23:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 12938014 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8468C25B07 for ; Sat, 6 Aug 2022 12:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=DNEhPHA/Xibi6kGnxJVrl4PzMDzQGHST4wKQMaV1cI0=; b=iOW3cKiAcTBB67 u9TRSv+m8HSiUPXxX8BJa176gyf1IPUZBenBrY5WW1varI6WgEeVXzOjnfrdtOrlrgBgR7BYbfig+ SlNHzFXc+KE90ZwShPrLH5lo+SaKRKUKWHkDSvWQ+i00mkCj4NGCyM9x3PPKL4y0wD3djwzd0LK/Z b+tnYy0uCq9fI3aFgwKuWBEZEnHcJX55cpOlTahPUBIJ03NTJWkR6lc6idE2YxAJcVc+4hoJufZqc r8SVhq3Hn0zwK8Q/Y3Xi+WmNfTLyIMLAvMIcCGK3bHgsiDuuYth2z+22HyzMONFYlKLoARiVWpzRc AYimxqI/x/WhwV9VqySQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oKIqY-00AtwG-NF; Sat, 06 Aug 2022 12:24:02 +0000 Received: from mout.gmx.net ([212.227.15.18]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oKIqV-00AtfC-Dm for linux-arm-kernel@lists.infradead.org; Sat, 06 Aug 2022 12:24:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1659788630; bh=2Q7uVoi9etUHQcg6k8CWD2qINr2lwPxkOfHfz7vCqgM=; h=X-UI-Sender-Class:From:To:Subject:Date; b=dFXsfITa8u0yUy3ATKvqfVosIu2sxDMttJpXYT3TExqQp1qxFdgnoUQjeMpqd5gQ/ QQMHQiWm6SdRlU8OgFdbjAzlUKw2mQ1dhutjmaGiPsYC8liv37JyMFe1/qpAHknbYv DYlmqzk0EIASiPY1ep0YZABrkVCvEuXaXAojiaVs= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.170.46]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M2wGs-1oGzSU1xXg-003PL9; Sat, 06 Aug 2022 14:23:50 +0200 From: Helge Deller To: linux-s390@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, Josh Triplett , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 0/3] Dump command line of faulting process to syslog Date: Sat, 6 Aug 2022 14:23:45 +0200 Message-Id: <20220806122348.82584-1-deller@gmx.de> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:SFsa6Df2ppv7VmXIO81pLmiWdYqA+5p7hjdVr9P8sJdlxgTdXyx 4V3iT2wC6bHvXC7t2xifm5y+1XtJi7CeGrvmNskRuT+NUD70O1J5kP8BJ76oKwyi2IlzJAr BeVqMiWEYJvxsEVrSmCLgUqGp4CJmeKFij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VQWEQi HfSiHrbgxVk4SM5aifHPQ4GYREukr8JSjjSscgDJaupYeFWtv6m/mkWt6qBtEyZqPmJRkN01n +9RmeFlvcC5tQ9ZRZOxyjKnn9f/LpeYVvd1XBc6k8iviKZgjzN8iIz15z+oMOCq+ykV/7gpEM 7dtXolVTvvRrkiLCJgrNc2tjARUPGdMGI/3X0z8o+CrNmWV0eVzMu7/FQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220806_052359_973178_39E81366 X-CRM114-Status: GOOD ( 16.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch series allows the arch-specific kernel fault handlers to dump the command line parameters of the faulting process. The motivation for this patch is that it's sometimes quite hard to find out and annoying to not know which program *exactly* faulted when looking at the syslog. Some examples from the syslog are: On parisc: do_page_fault() command='cc1' type=15 address=0x00000000 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/ccRkFSfY -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 -quiet -dumpdir /tmp/ghc13413_0/ -dumpbase ghc_5.hc -dumpbase-ext .hc -O -Wimplicit -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='ld.so.1' type=15 address=0x565921d8 in libc.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-path /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 error 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. In this version 2 of the patch set, all or parts of the command line isn't shown if the value of the kptr_restrict sysctl >= 1. Thanks! Helge --- Changes compared to v1 of this patchset: ---------------------------------------- - Don't dump all or parts of the commandline depending on the kptr_restrict sysctl value (suggested by Josh Triplett). - Patch sent to more arch mailing lists 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 | 34 +++++++++++++++++++++ 5 files changed, 91 insertions(+), 23 deletions(-) -- 2.37.1