From patchwork Mon Aug 8 13:09:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 12938793 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 682BAC00140 for ; Mon, 8 Aug 2022 13:16: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=QWXJGsATlHEDlFr+Eh1AMbbmP3tHnfX3E0+F85zScMA=; b=DVg+EphWLXe104 +JTqyXMdzCFHD/KDjiyTD69mUMMBuARUJ6IW14M2WneIZUoQkqJyYf6RlIr/4uL1kqaIPjN/SDfmh pL9yIxfiuxb/EQnRTji0/9Of1Z3/2q71aLGF4dF9BYho1RubivNMBWDbPxQPCl0ZSR3g6XBU1khkn 2u8HnB8sqRz+Uz7aLrN3/KpxWvueDFHyHzXrUXoyeC8/eg0JmLdVkKE+anVGyFIHKWGRjYXsqgRZS k8BzBvnOVajm2OazpcAda3xqtFZoSyY/w3gEmLFdl1BD2/fZhKHVrNgxgnFPYK86bNB3qq3UqXiUU LhNvOruQ6OrJly57p7nw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oL2bK-00E0sx-Vh; Mon, 08 Aug 2022 13:15:23 +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 1oL2bH-00E0rD-VE for linux-arm-kernel@lists.infradead.org; Mon, 08 Aug 2022 13:15:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1659964518; bh=aM64I3xT+nrAAK/BCGOu7rEdx/4nHtHx5JVVg4BjZUA=; h=X-UI-Sender-Class:From:To:Subject:Date; b=AegFBCpWy7h0VTIuUZvk2kg5bKbofdedndo508V+iVj9xOVSE6lWrkS/US3jZ320U 2kPokoqH25nuKfrnQc+cpruXbMXFkyWj/ywppIswOO+/yhO3LgrmF+TYbHBszHrs0Z R+q3G/T2y1Aqj/Oz3rJDGVsFaqu71SyOKR9uB//A= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.169.184]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N3KTo-1nMENI0sCY-010Q4h; Mon, 08 Aug 2022 15:09:18 +0200 From: Helge Deller To: linux-s390@vger.kernel.org, Josh Triplett , x86@kernel.org, linux-snps-arc@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 0/4] Dump command line of faulting process to syslog Date: Mon, 8 Aug 2022 15:09:13 +0200 Message-Id: <20220808130917.30760-1-deller@gmx.de> X-Mailer: git-send-email 2.37.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:84TWQbnNKsaSON1sxgzA8VMcCW1N9C9kjxeNROJetaoTlrwHyEJ 4kLAo2nY0nBKJzTbYKeIFs0wsAhsUj400kCXTzFd1LBKOgRGmPhIDqCoKMQfbK1f02UFheV T5pSHxSbW+FPInvGlRKQqW+uW/on0h1xD6YnsEiYHniWkmRAmTI8WGJknLpw6yJ+ky2f7sR gQHsOTDFqQcj4xa5P6+Vg== X-UI-Out-Filterresults: notjunk:1;V03:K0:aIInvfyohz4=:1bfonjJ3V6pggEfBaj5cPB wnN18YSlRmxF9ahgJ+sypP+V3taHhhxFqd2hzWYO9GnkDGNXSlWuZFANvNEbK4DPxxPv66Vgo kiDVlfSCWczdCpEdoiooob8+vWOarWxn9wE8/znw40pFIZs3TP+D0ruA/0InACh/0+Hk/P9UN S9kwJ5e6xJaqakO+5/dupq1YTk4bz62sypE01GcND/H0P6G1A/rEawRhcQ89O35yHSY7ZGQxI VwXDEWHkV0bk/ZTa8PddeyoxbpMbFLzL/NKx0juZr4mpuiCTK3zbINXXZkUyao0A9vsOk5ddU VhBxYcooji4Ar2RzZFYXH2hnBB0Z3Y2DdaTBufGAEC2JvhVEJkMOCAu4rpJ1SO3jlMCZKpm55 AcLQl/d1iGFU0XOKjAh0JgM8Mex1Io4qLT1hJhj3mWbnUMo3CPFgDiF0ng1COQV+Jxj8+8xBE xusYt4SRpXg7gjMaj4qTIJNzTzJ3li6dYIo6/CU+X2UDkf5Cz6IK3oT2y4/kMibS8KFKCPIWT 6e7WHbJJxrPYtsAott9c2ulzdNp6iF3MubUtQtDxBvIFh6ldJlma7qG7mqfiXDb48Q249HBrp Gm4oZHUVgwoGdsy3RfZCf7Lxa/gy5U5QH75ururjnklcAK3CaCXJVYhTiKvyCceLTu+HUp2Qw zFbAX/oTJLfaTCzx7wE5flCBnuH1omkdduKwX2tM1rRfjU9hnrBiNER4VSoqW6TNr7ynRGX7q 8TLJlX4//E3Fd+mMXRD5vjcO4YWscPEO3054Icpv4eE+O+b6qNYFhehiIVbbBHFlt5bHqiCqA FhfAtTjXaXj7AiVO8h0egpvZlxodAalTjCOeivmkz2+31wPfuVq4EOgD5316AKRBietTFwqg0 X6Vqe/oQijaLIU677orQ== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220808_061520_310498_D563FF05 X-CRM114-Status: GOOD ( 16.04 ) 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 dumps the command line (including the program parameters) of a faulting process to the syslog. 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. For example, a dump on parisc shows: do_page_fault() command='cc1' type=15 address=0x00000000 in libc-2.33.so[f6abb000+184000] -> We see the "cc1" compiler crashed, but it would be useful to know which file was compiled. With this patch you will see that cc1 crashed while compiling some haskell code: 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 Another example are the glibc testcases which always segfault in "ld.so.1" with no other info: do_page_fault() command='ld.so.1' type=15 address=0x565921d8 in libc.so[f7339000+1bb000] -> With the patch you can see it was the "tst-safe-linking-malloc-hugetlb1" testcase: 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 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 ... -> with this patch you now see the whole command line: crash[2326] cmdline: ./crash test_write_to_page_0 The patches are relatively small, and reuse functions which are used to create the output for the /proc//cmdline files. The relevant changes are in patches #1 and #2. Patch #3 adds the cmdline dump on x86. Patch #4 drops code from arc which now becomes unnecessary as this is done by generic code. Helge --- Changes in v3: - require task to be locked by caller, noticed by kernel test robot - add parameter names in header files, noticed by kernel test robot Changes in v2: - 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 (4): 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 arc: Use generic dump_stack_print_cmdline() implementation arch/arc/kernel/troubleshoot.c | 24 ----------- arch/x86/mm/fault.c | 2 + fs/proc/base.c | 74 +++++++++++++++++++++++----------- include/linux/printk.h | 5 +++ include/linux/proc_fs.h | 5 +++ lib/dump_stack.c | 34 ++++++++++++++++ 6 files changed, 97 insertions(+), 47 deletions(-) -- 2.37.1