Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp872122imu; Fri, 21 Dec 2018 08:41:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ux43TIF6mSCVma92ChMlIYpF/s3rZKSdrboTRTu7FRAH/Q7VQVAhUOTxChGypR/MFnhUeW X-Received: by 2002:a62:d005:: with SMTP id p5mr3237649pfg.175.1545410500949; Fri, 21 Dec 2018 08:41:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545410500; cv=none; d=google.com; s=arc-20160816; b=K9VsF4mUqzk/X0gHNQZoS1dbYWEx5E/DRkjyuXlKjnFJBKehTkhVS0GV2l4VX+2hqw v04ppLajNwHH3VaJVKIgeJksCb2K6zYvT+upHwqca5BAoM0c3AMq1VWi+yTEdyQO0gNO 2gLfqf860FpvXm2ZNdxRYD6e7vPVfjDP145OQC4MEm7P5hJ36op1vedFVGkpiknXw26a BbxUu2+zeXJ8iDHW1pmOVsJPB3gwtpfto5H/2kktXeYcVGdc5Mgm5dEkQsvgP/BYmRUy DfloJ4cdv8x1QJpOvCWhSdAbXLx2IteDSObUuKRvQ9jW/oTGvzy8AyxNYYeTH5nzfGi0 PyEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:subject:autocrypt:openpgp:from:references:cc:to; bh=7hBKNCcLSkmcB1ExWmVp63a1euR2NjzbzZYyabt9V/Y=; b=EtqHTKdTe29VENFu/qJ33EbnEsLHlX4whBNCcaiUlmJ34e+3BeSrn3u5T1Qw5CgmZP CEyfNjp6bHDOakL3bwdfzwBLLZ+zFhow6zRT226fKJhd5YpGb+5wtLcsgtOd5FFdSbzu uYvO1Z609AmD8RQoIRJT+xIfH2MrCdaBhxxtAueDbCYq3Wwo1eSU5fl955w6xLHWmIx2 S3lcSRtGH1sUxrjeTGKkP+3c6qHOCsjV+DjBoPCRH9sIf3i0GkkwSL95Dqq5soQWvXhu ZKnHwxYf4JMal9gVYdFf9wpwAwmjoXx2BaixfzieKisVWzybMasBIwF+ri34FR5NPd9h 8m3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m75si21489263pga.432.2018.12.21.08.41.24; Fri, 21 Dec 2018 08:41:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390326AbeLUMbj (ORCPT + 99 others); Fri, 21 Dec 2018 07:31:39 -0500 Received: from wp227.webpack.hosteurope.de ([80.237.132.234]:46860 "EHLO wp227.webpack.hosteurope.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732614AbeLUMbj (ORCPT ); Fri, 21 Dec 2018 07:31:39 -0500 Received: from ip4d142c80.dynamic.kabel-deutschland.de ([77.20.44.128] helo=[192.168.66.118]); authenticated by wp227.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) id 1gaJxl-0006SL-BY; Fri, 21 Dec 2018 13:31:33 +0100 To: Randy Dunlap , Jonathan Corbet Cc: linux-doc@vger.kernel.org, Linux Kernel Mailing List References: <20181217152043.9989-1-linux@leemhuis.info> <20181217112437.5fe868eb@lwn.net> <8f67a8ca-bf64-c537-843a-b03bcfc3dace@infradead.org> <96fc8865-c54f-5c6c-f6c8-d7a5a12735e6@leemhuis.info> <20181220082819.69fc3e5c@lwn.net> <0996ba55-e5e1-49e2-f0ed-82cb1619ee03@leemhuis.info> From: Thorsten Leemhuis Openpgp: preference=signencrypt Autocrypt: addr=linux@leemhuis.info; prefer-encrypt=mutual; keydata= mQINBFJ4AQ0BEADCz16x4kl/YGBegAsYXJMjFRi3QOr2YMmcNuu1fdsi3XnM+xMRaukWby47 JcsZYLDKRHTQ/Lalw9L1HI3NRwK+9ayjg31wFdekgsuPbu4x5RGDIfyNpd378Upa8SUmvHik apCnzsxPTEE4Z2KUxBIwTvg+snEjgZ03EIQEi5cKmnlaUynNqv3xaGstx5jMCEnR2X54rH8j QPvo2l5/79Po58f6DhxV2RrOrOjQIQcPZ6kUqwLi6EQOi92NS9Uy6jbZcrMqPIRqJZ/tTKIR OLWsEjNrc3PMcve+NmORiEgLFclN8kHbPl1tLo4M5jN9xmsa0OZv3M0katqW8kC1hzR7mhz+ Rv4MgnbkPDDO086HjQBlS6Zzo49fQB2JErs5nZ0mwkqlETu6emhxneAMcc67+ZtTeUj54K2y Iu8kk6ghaUAfgMqkdIzeSfhO8eURMhvwzSpsqhUs7pIj4u0TPN8OFAvxE/3adoUwMaB+/plk sNe9RsHHPV+7LGADZ6OzOWWftk34QLTVTcz02bGyxLNIkhY+vIJpZWX9UrfGdHSiyYThHCIy /dLz95b9EG+1tbCIyNynr9TjIOmtLOk7ssB3kL3XQGgmdQ+rJ3zckJUQapLKP2YfBi+8P1iP rKkYtbWk0u/FmCbxcBA31KqXQZoR4cd1PJ1PDCe7/DxeoYMVuwARAQABtCdUaG9yc3RlbiBM ZWVtaHVpcyA8bGludXhAbGVlbWh1aXMuaW5mbz6JAj0EEwEKACcFAlJ4A3UCGwMFCQ0oaIAF CwkIBwMFFQoJCAsFFgIDAQACHgECF4AACgkQcrbm70xYPS0OOw/+OM+pakOz+MDn9vAgc5Xj dVqxjH1+cg7UWkW6UrkniT3i+THv535lGwwB93iQpG0eaLqIPcfFqWGHCJDY4ys8AdCiGA55 D8eX/A/94Dboz6hzxfu2M4Kvp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QsVYJZz6nb+bHe73m9Gs+Sxkus8lU3U27j1LuAtWW7LT27gg cEsHtxEab6ZnSMx7SCuBvYhiEd0nqNKFjs0L5BZ/JtpOh9vw3pc/SHBxHn0nubtBoyANfG2R Le0dpPAjGfOL6cljnIYMFytgzVwDs6uM8FfFuE4mIhYiFV30o9fObwqbhO49LoKdABEBAAGJ AiUEGAEKAA8FAlJ4AQ0CGwwFCQ0oaIAACgkQcrbm70xYPS2OxxAAr8OqW+bEjQV2PLLAHIh6 fmhajXtSn9bzULofgyD4PsgMsG25di74GbegGyTIwt7cS7Z5ZR5KL7ZkN1GTDFGlWyiZ+6NC VsWR62+eujnYvtHsQPaTo8A/uFV+Too4v4ikS4ZD0ondWa1FimLouem9QwOSnyn4yErxUQcU yUXHLhUtYs7MO5R4G++Ev+9eK7rRqPeUOqTjQV6Eigi5Ny4536fKMJDNp+YhlRopWBA0fVjf tF0MJTV0ShFK1YWLOADJYo9NG+KOeyUqesOvRSxtpQcdcrwPFjkJ3JcknxZstvWid4goqMY7 l/vGoG7zQDSxUDpXcG9X70yHrmVK/w0dn/PHalfUnOsQpvQYTjGhZ4UnXAVaBsouYLGFo9AL lLNERHY4eRR4MEYvk6ABZ1AEaJwiwyZuPRt/iN1EIMM7fnQQcdBYHGJzaV8a3jwHeLAPY1e/ hS1OsrR9pqGvqQsagYkiZFOCjZxx0IQhokMSIxbFvNfLHTqXXpJzlCv9QGj3s2ZG6o36u42k yc+mP1ya8uxIFEwcp6C1h4TTisVFC2DXxDi7pqUd9oTuI4Hg19/i07cdYUHDiraDXSXW5zH9 5ZDV+rSqDU3ercoRd2qjGUOIXWOytHTeJhVOWqM0vOmXDUwwYHuEb0HFn3d/tz+idSrXUSXZ 5iv6NKaV29GWHbY= Subject: Re: [PATCH 0/1] RFC: Revamp admin-guide/tainted-kernels.rst to make it more comprehensible Message-ID: Date: Fri, 21 Dec 2018 13:31:32 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-MW Content-Transfer-Encoding: 8bit X-bounce-key: webpack.hosteurope.de;linux@leemhuis.info;1545395496;fb8432d1; X-HE-SMSGID: 1gaJxl-0006SL-BY Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 20.12.18 um 21:10 schrieb Randy Dunlap: > On 12/20/18 10:21 AM, Thorsten Leemhuis wrote: >> Am 20.12.18 um 17:38 schrieb Randy Dunlap: >>> On 12/20/18 7:28 AM, Jonathan Corbet wrote: >>>> On Thu, 20 Dec 2018 16:23:38 +0100 >>>> Thorsten Leemhuis wrote: >>>>> While at it: Jonathan, you mentioned putting the script in scripts/, but >>>>> according to the Makefile in that directory it is "for various helper >>>>> programs used throughout the kernel for the build process". That's one >>>>> reason why it feels wrong to put it there. Another one: that script >>>>> targets users and thus we should try to make sure they can access it >>>>> easily. That's why I'm currently inclined to put it in tools/ somewhere. >>>> Yeah, tools/ is a better place. Maybe a tools/debugging directory or some >>>> such? >>> chktaint >> BTW, I renamed it to kernel-taintstatus, sounded more appropriate to me. >> Does anyone mind? > Not terribly, although that seems too long to me. ;) > maybe 'taintstatus'? I settled to "kernel-chktaint" for now. I'm not attached to the name, but IMHO making it obvious what this tool checks is worth the "kernel-" prefix. >> BTW, for those following this thread and my earlier quest for a simple >> cmd to decode /proc/sys/kernel/tainted: looks like @apexo on twitter >> (thx again!) found a trick to do what I want which should work on most >> systems out-of-the-box: >> $ for i in $(seq 18); do echo $i $(($(cat >> /proc/sys/kernel/tainted)>>($i-1)&1));done > I think Jon mentioned this: The output should begin with bit #0, > not bit #1, so it should show bits 0 - 17 (or whatever the max is), > not 1 - 18. No worries, replying to that is nearly next on my todo list. BTW & FYI, find below the patch I have prepared now. Ciao, Thorsten commit 2aa04b7a65a5ecceac27a0d9c0d64a4b04ae943a Author: Thorsten Leemhuis Date: Fri Dec 21 12:24:19 2018 +0100 tools: create tools/debugging/ and add a script decoding /proc/sys/kernel/tainted Add a script to the tools/ directory that shows if or why the running kernel was tainted. The script was mostly written by Randy Dunlap (thx!), who published it while discussing changes that try to make admin-guide/tainted-kernels.rst more comprehensible (https://lore.kernel.org/lkml/8f67a8ca-bf64-c537-843a-b03bcfc3dace@infradead.org/); I enhanced the script a bit and created this patch. As the script targets users I did not want to add it to scripts/, as according to its Makefile "contains sources for various helper programs used throughout the kernel for the build process". The directory tools/scripts/ also did not look like a good fit, as the stuff that's there already is used for other purposes. That's why I created a new directory for tools like this; maybe we should move scripts/decodecode there as well, but that's something for another day. Signed-off-by: Randy Dunlap Signed-off-by: Thorsten Leemhuis diff --git a/tools/Makefile b/tools/Makefile index abb358a70ad0..c0d1e59f5abb 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -12,6 +12,7 @@ help: @echo ' acpi - ACPI tools' @echo ' cgroup - cgroup tools' @echo ' cpupower - a tool for all things x86 CPU power' + @echo ' debugging - tools for debugging' @echo ' firewire - the userspace part of nosy, an IEEE-1394 traffic sniffer' @echo ' freefall - laptop accelerometer program for disk protection' @echo ' gpio - GPIO tools' @@ -60,7 +61,7 @@ acpi: FORCE cpupower: FORCE $(call descend,power/$@) -cgroup firewire hv guest spi usb virtio vm bpf iio gpio objtool leds wmi pci: FORCE +cgroup firewire hv guest spi usb virtio vm bpf iio gpio objtool leds wmi pci debugging: FORCE $(call descend,$@) liblockdep: FORCE @@ -95,7 +96,8 @@ kvm_stat: FORCE all: acpi cgroup cpupower gpio hv firewire liblockdep \ perf selftests spi turbostat usb \ virtio vm bpf x86_energy_perf_policy \ - tmon freefall iio objtool kvm_stat wmi pci + tmon freefall iio objtool kvm_stat wmi \ + pci debugging acpi_install: $(call descend,power/$(@:_install=),install) @@ -103,7 +105,7 @@ acpi_install: cpupower_install: $(call descend,power/$(@:_install=),install) -cgroup_install firewire_install gpio_install hv_install iio_install perf_install spi_install usb_install virtio_install vm_install bpf_install objtool_install wmi_install pci_install: +cgroup_install firewire_install gpio_install hv_install iio_install perf_install spi_install usb_install virtio_install vm_install bpf_install objtool_install wmi_install pci_install debugging_install: $(call descend,$(@:_install=),install) liblockdep_install: @@ -129,7 +131,7 @@ install: acpi_install cgroup_install cpupower_install gpio_install \ perf_install selftests_install turbostat_install usb_install \ virtio_install vm_install bpf_install x86_energy_perf_policy_install \ tmon_install freefall_install objtool_install kvm_stat_install \ - wmi_install pci_install + wmi_install pci_install debugging_install acpi_clean: $(call descend,power/acpi,clean) @@ -137,7 +139,7 @@ acpi_clean: cpupower_clean: $(call descend,power/cpupower,clean) -cgroup_clean hv_clean firewire_clean spi_clean usb_clean virtio_clean vm_clean wmi_clean bpf_clean iio_clean gpio_clean objtool_clean leds_clean pci_clean: +cgroup_clean hv_clean firewire_clean spi_clean usb_clean virtio_clean vm_clean wmi_clean bpf_clean iio_clean gpio_clean objtool_clean leds_clean pci_clean debugging_clean: $(call descend,$(@:_clean=),clean) liblockdep_clean: @@ -175,6 +177,6 @@ clean: acpi_clean cgroup_clean cpupower_clean hv_clean firewire_clean \ perf_clean selftests_clean turbostat_clean spi_clean usb_clean virtio_clean \ vm_clean bpf_clean iio_clean x86_energy_perf_policy_clean tmon_clean \ freefall_clean build_clean libbpf_clean libsubcmd_clean liblockdep_clean \ - gpio_clean objtool_clean leds_clean wmi_clean pci_clean + gpio_clean objtool_clean leds_clean wmi_clean pci_clean debugging_clean .PHONY: FORCE diff --git a/tools/debugging/Makefile b/tools/debugging/Makefile new file mode 100644 index 000000000000..e2b7c1a6fb8f --- /dev/null +++ b/tools/debugging/Makefile @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0 +# Makefile for debugging tools + +PREFIX ?= /usr +BINDIR ?= bin +INSTALL ?= install + +TARGET = kernel-chktaint + +all: $(TARGET) + +clean: + +install: kernel-chktaint + $(INSTALL) -D -m 755 $(TARGET) $(DESTDIR)$(PREFIX)/$(BINDIR)/$(TARGET) + diff --git a/tools/debugging/kernel-chktaint b/tools/debugging/kernel-chktaint new file mode 100644 index 000000000000..98861858b192 --- /dev/null +++ b/tools/debugging/kernel-chktaint @@ -0,0 +1,199 @@ +#! /bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# Randy Dunlap , 2018 +# Thorsten Leemhuis , 2018 + +usage() +{ + cat < + +Call without parameters to decode /proc/sys/kernel/tainted. + +Call with a positive integer as parameter to decode a value you +retrieved from /proc/sys/kernel/tainted on another system. + +EOF +} + +if [ "$1"x != "x" ]; then + if [ "$1"x == "--helpx" ] || [ "$1"x == "-hx" ] ; then + usage + exit 1 + elif [ $1 -ge 0 ] 2>/dev/null ; then + taint=$1 + else + echo "Error: Parameter '$1' not a positive interger. Aborting." >&2 + exit 1 + fi +else + TAINTFILE="/proc/sys/kernel/tainted" + if [ ! -r $TAINTFILE ]; then + echo "No file: $TAINTFILE" + exit + fi + + taint=`cat $TAINTFILE` +fi + +if [ $taint -eq 0 ]; then + echo "Kernel not Tainted" + exit +else + echo "Kernel is Tainted for following reasons:" +fi + +T=$taint +out= + +addout() { + out=$out$1 +} + +if [ `expr $T % 2` -eq 0 ]; then + addout "G" +else + addout "P" + echo " * Proprietary module was loaded." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "F" + echo " * Module was force loaded." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "S" + echo " * SMP kernel oops on an officially SMP incapable processor." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "R" + echo " * Module was force unloaded." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "M" + echo " * Processor reported a Machine Check Exception (MCE)." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "B" + echo " * Bad page referenced or some unexpected page flags." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "U" + echo " * Taint requested by userspace application." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "D" + echo " * Kernel died recently, i.e. there was an OOPS or BUG" +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "A" + echo " * ACPI table overridden by user." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "W" + echo " * Kernel issued warning." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "C" + echo " * Staging driver was loaded." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "I" + echo " * Workaround for bug in platform firmware applied." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "O" + echo " * Externally-built ('out-of-tree') module was loaded" +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "E" + echo " * Unsigned module was loaded." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "L" + echo " * Soft lockup occurred." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "K" + echo " * Kernel live patched." +fi + +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "X" + echo " * Auxiliary taint, defined for and used by distros." + +fi +T=`expr $T / 2` +if [ `expr $T % 2` -eq 0 ]; then + addout " " +else + addout "T" + echo " * Kernel was built with the struct randomization plugin." +fi + +echo "Raw taint value as int/string: $taint/'$out'" +#EOF#