Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4745731rwb; Mon, 8 Aug 2022 06:27:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR7IHhHjJZ+kAAO3KvDh+h1+CV3a2Kd5RRE7+EGdvhtheb6zrS/4Jcanr4yVqdFQMPHd6ZH7 X-Received: by 2002:a17:903:4d6:b0:170:bf85:8ccc with SMTP id jm22-20020a17090304d600b00170bf858cccmr3298025plb.111.1659965266875; Mon, 08 Aug 2022 06:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659965266; cv=none; d=google.com; s=arc-20160816; b=nHvQeludvoyKJSZs5W+xgZJBQMM1qmd6xafCJWhfZAgsus59Aw0UGWVJV66qQnIsXN k1PaAs6zO0yJD/vQ06igiEp/2kvWbipdTysWGf+yA9yUCDyYkoUEpVhhPMH5Fr1YIttw hvvLpIQakERJ+lD7owPQQDkAdMAnHqBKUwHlQlEJMqvBmATZhhGsIKflRnqlQ2Ikf8tG 24K69CgeUezf0sWhlw274G54Jqid2Zg+MqjwKvswPCsRxFjV0csQ/uHXAeGNyWBaVPJj mkt5hcmrjXCqBmiCD8wQhzewjvz2Bv4EkhjETmpsh4i/1LeHygV1ko1q1vfcXy6Ncnz5 +mwQ== 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=YStffvzhkR7wMkrRI3AhXFOm3UYZDWIdhSh5TRgi45I=; b=JS5SVLDN0P2u9pV1uH90W7GfibFqttPFElBFPyhaH0to+TMxqKh3DMIqkNBpfc+YiE NsnZ1HWq4nPehJq+SPMp70XaAWS4bx+gWJ+6/2Fg/YntCLuM1tNouFkV1f/Wv4kqbWHu j5cEtkXUP7+NX8L/HhHvXHYMZg39uvHIJDhbiQa9IevlNgknvE5vhvztZ/wYcL5H43w6 yKSyJy16AtoIxVCYBtmXB0GaDgI7AkIZ7SAm84DQP37qGDPt8qPRYSz8Xj8cPie3EOlJ 9JV0pUDzhdvLP34COZHuyEb7+qJh39hdzzGn4NqdpnHVh6WkJYXcJT4jWJBxP9YObl9a 4eiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=Yhhqd8gN; 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 i193-20020a6287ca000000b0052abccd715csi7410106pfe.118.2022.08.08.06.27.30; Mon, 08 Aug 2022 06:27:46 -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=Yhhqd8gN; 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 S243233AbiHHNKJ (ORCPT + 99 others); Mon, 8 Aug 2022 09:10:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243215AbiHHNJx (ORCPT ); Mon, 8 Aug 2022 09:09:53 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47A46CE0D; Mon, 8 Aug 2022 06:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1659964158; bh=aM64I3xT+nrAAK/BCGOu7rEdx/4nHtHx5JVVg4BjZUA=; h=X-UI-Sender-Class:From:To:Subject:Date; b=Yhhqd8gNlgo7WkmfXdoNiJLT5rGDDzerm7vNcQdF0WC3fY3jLTKPOnaS4Dd2/o89E uxV3tIAJBlPmf75Tt4tttgsxJrFwmeq+7am5xzYog9YODqjr2JOClwchIpus4BjujT 3Z7F1zwZOh7SPl5IFCtBNm9NNoK33vXkUQ+4Awlk= 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 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:84TWQbnNKsaSON1sxgzA8VMcCW1N9C9kjxeNROJetaoTlrwHyEJ 4kLAo2nY0nBKJzTbYKeIFs0wsAhsUj400kCXTzFd1LBKOgRGmPhIDqCoKMQfbK1f02UFheV T5pSHxSbW+FPInvGlRKQqW+uW/on0h1xD6YnsEiYHniWkmRAmTI8WGJknLpw6yJ+ky2f7sR gQHsOTDFqQcj4xa5P6+Vg== X-UI-Out-Filterresults: notjunk:1;V03:K0:qkPkvFZxlQc=:l818vHvl4KYHXR/6nteSWt Drrh+hI657zDwl8V1U3h+u1Z+pOM/EhP9IKv5hA7uLl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cqOymz8uumA== X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,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 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 ou= t and annoying to not know which program *exactly* faulted when looking at the s= yslog. For example, a dump on parisc shows: do_page_fault() command=3D'cc1' type=3D15 address=3D0x00000000 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/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 Another example are the glibc testcases which always segfault in "ld.so.1"= with no other info: do_page_fault() command=3D'ld.so.1' type=3D15 address=3D0x565921d8 in l= ibc.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-pat= h /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 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 ... -> 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 =2D-- 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(-) =2D- 2.37.1