Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3105728imu; Mon, 17 Dec 2018 13:26:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/V8JE0QSXDC4S0j8+ZkoEEEErPgb6N2C4GP4GLSPU6lWVXo/PFlhyFMxg/R6FF8quQn2tKM X-Received: by 2002:a17:902:28c1:: with SMTP id f59mr14040168plb.37.1545081983875; Mon, 17 Dec 2018 13:26:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545081983; cv=none; d=google.com; s=arc-20160816; b=B0+DCKGjuRE4tfz0665sGkxgK70CZnS7qOJwmk81kTkOR7UtABnuPlIDaMcA4MBF/h x+FTzxVgPvNAEFzY3PWNsbcRK5sWe6mGzRqPg3tR2mu4ma1amfc4nlvfhVKAMuJ6ALH0 EOKntgDhK0LYhtTN/QjxVGiq13qGdwaYGwDPIchtBsClMruoO36zGxeqJ7uxJQF4JWpi etOiN5hWbHOeysJIyk5oZSNNsl+f5pbAR0sJGGYGVtbDOe89SRoFIKzQ7bseWzfpN+A+ Kusmy40qlTso9W49MEMs5DDsDnQY8IIc1nFiTtEoYzN4FTrBhqVoOdoYWAaxEwtwXSCx Qb6g== 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:from:references:cc:to:subject:dkim-signature; bh=xv9R1Asq4kEgfFCTtrXG0S4Xh7eOlzNzos1JZWNF1H8=; b=Mu4HnwUb2DMe17IHkyNMgIDWPBTmaEN/75jGiuJRsckuO4/1BeCJmW1FdgCdxykhWv c5RqKSYFVe8bGkdUN1NiLudGhvovNbjrD1O5x3O9U7iuF3s8B3I0heJpZL0ULYxsRrIH agERgTYee/P52mZcohSTWdEjM0gyQPUQekmvwRj4+lZBgYXS8ejbwvv5dZnLY8mrFqsF /9FrlYv4K6rTqaeaJ1+GrgW6I5+68Vm2qiUmukld/XDIV/DbhTOG3RrEIvO2OJ4hjInr ITWiZbYSsLNDOXDHLLFihe8yFpw50urkhArSzt/VL6BbxrZNa/vQFilAdexhLID2NP+N fUXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=I0FyCN4e; 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 a1si11498804pgk.495.2018.12.17.13.26.09; Mon, 17 Dec 2018 13:26:23 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=I0FyCN4e; 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 S1728529AbeLQVOj (ORCPT + 99 others); Mon, 17 Dec 2018 16:14:39 -0500 Received: from merlin.infradead.org ([205.233.59.134]:58372 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727676AbeLQVOi (ORCPT ); Mon, 17 Dec 2018 16:14:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xv9R1Asq4kEgfFCTtrXG0S4Xh7eOlzNzos1JZWNF1H8=; b=I0FyCN4eVCfx2zW9cAgqtLF7AY 5R13wuEY3TxpTT1OYPMt/2iWjzARcGhZnElO8i9Onvm5RLye7ECxNDP3CJuGgak4KEu4ukYDFBjCI yC8QPtQpgIh6UqeKGIOe+4CgxCRkxWoD8yjpzlQfAAQOvhmSdQF1Lgpc7lM0nMuitH59NNMumjqwc FE7HGJkrpX/Myk4cSC+4OZr+fUfaS69jyxv5PGCW97h4A0ijMSWvZt4pxhYgJ07xGn4kM4Gk5lDTT uwK6lkE2bThI7BPae09KHbjvRMhUQVfKAlDk0DGWaqQRXP4rRo0c9aHT9VU1HflNJdOgEnLmMtKY7 NmEGU0nA==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gZ0DZ-0003yF-R8; Mon, 17 Dec 2018 21:14:26 +0000 Subject: Re: [PATCH 1/1] docs: Revamp tainted-kernels.rst to make it more comprehensible To: Thorsten Leemhuis , Jonathan Corbet , linux-doc@vger.kernel.org Cc: Linux Kernel Mailing List References: <20181217152043.9989-1-linux@leemhuis.info> <20181217152043.9989-2-linux@leemhuis.info> From: Randy Dunlap Message-ID: Date: Mon, 17 Dec 2018 13:14:23 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181217152043.9989-2-linux@leemhuis.info> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/17/18 7:20 AM, Thorsten Leemhuis wrote: > > Signed-off-by: Thorsten Leemhuis > --- > Documentation/admin-guide/tainted-kernels.rst | 105 ++++++++++++++++-- > 1 file changed, 96 insertions(+), 9 deletions(-) > > diff --git a/Documentation/admin-guide/tainted-kernels.rst b/Documentation/admin-guide/tainted-kernels.rst > index 28a869c509a0..aabd307a178a 100644 > --- a/Documentation/admin-guide/tainted-kernels.rst > +++ b/Documentation/admin-guide/tainted-kernels.rst > @@ -1,10 +1,102 @@ > Tainted kernels > --------------- > > -Some oops reports contain the string **'Tainted: '** after the program > -counter. This indicates that the kernel has been tainted by some > -mechanism. The string is followed by a series of position-sensitive > -characters, each representing a particular tainted value. > +The kernel will mark itself as 'tainted' when something occurs that > +might be relevant later when investigating problems. Don't worry > +yourself too much about this, most of the time it's not a problem to run > +a tainted kernel; the information is mainly of interest once someone > +wants to investigate some problem, as its real cause might be the event > +that got the kernel tainted. That's why the kernel will remain tainted > +even after you undo what caused the taint (i.e. unload a proprietary > +kernel module), to indicate the kernel remains not trustworthy. That's > +also why the kernel will print the tainted state when it noticed notices > +ainternal problem (a 'kernel bug'), a recoverable error ('kernel oops') an internal > +or a nonrecoverable error ('kernel panic') and writes debug information > +about this to the logs ``dmesg`` outputs. It's also possible to check > +the tainted state at runtime through a file in ``/proc/``. > + > + > +Tainted flag in bugs, oops or panics messages > +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > + > +You find the tainted state near the top after the list of loaded > +modules. The state is part of the line that begins with mentioning CPU > +('CPU:'), Process ID ('PID:'), and a shorted name of the executed shortened > +command ('Comm:') that triggered the event. When followed by **'Not > +tainted: '** the kernel was not tainted at the time of the event; if it > +was, then it will print **'Tainted: '** and characters either letters or > +blanks. The meaning of those characters is explained in below table. The in the table below. The > +output for example might state '``Tainted: P WO``' when the kernel got > +tainted earlier because a proprietary Module (``P``) was loaded, a > +warning occurred (``W``), and an externally-built module was loaded > +(``O``). To decode other letters use below table. use the table below. > + > + > +Decoding tainted state at runtime > +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > + > +At runtime, you can query the tainted state by reading > +``/proc/sys/kernel/tainted``. If that returns ``0``, the kernel is not > +tainted; any other number indicates the reasons why it is. You might > +find that number in below table if there was only one reason that got in the table below for the > +the kernel tainted. If there were multiple reasons you need to decode kernel to be tainted. reasons, > +the number, as it is a bitfield, where each bit indicates the absence or > +presence of a particular type of taint. You can use the following python > +command to decode:: > + > + $ python3 -c 'from pprint import pprint; from itertools import zip_longest; pprint(list(zip_longest(range(1,17), reversed(bin(int(open("/proc/sys/kernel/tainted").read()))[2:]),fillvalue="0")))' > + [(1, '1'), > + (2, '0'), > + (3, '0'), > + (4, '0'), > + (5, '0'), > + (6, '0'), > + (7, '0'), > + (8, '0'), > + (9, '0'), > + (10, '1'), > + (11, '0'), > + (12, '0'), > + (13, '1'), > + (14, '0'), > + (15, '0'), > + (16, '0')] > + > +In this case ``/proc/sys/kernel/tainted`` contained ``4609``, as the > +kernel got tainted because a proprietary Module (Bit 1) got loaded, a > +warning occurred (Bit 10), and an externally-built module got loaded > +(Bit 13). To decode other bits use below table. use the table below. > + > + > +Table for decoding tainted state > +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > + > +=== === ====== ======================================================== > +Bit Log Int Reason that got the kernel tainted > +=== === ====== ======================================================== > + 1) G/P 0 proprietary module got loaded > + 2) _/F 2 module was force loaded > + 3) _/S 4 SMP kernel oops on a officially SMP incapable processor > + 4) _/R 8 module was force unloaded > + 5) _/M 16 processor reported a Machine Check Exception (MCE) > + 6) _/B 32 bad page referenced or some unexpected page flags > + 7) _/U 64 taint requested by userspace application > + 8) _/D 128 kernel died recently, i.e. there was an OOPS or BUG > + 9) _/A 256 ACPI table overridden by user > +10) _/W 512 kernel issued warning > +11) _/C 1024 staging driver got loaded > +12) _/I 2048 workaround for bug in platform firmware in use > +13) _/O 4096 externally-built ("out-of-tree") module got loaded > +14) _/E 8192 unsigned module was loaded > +15) _/L 16384 soft lockup occurred > +16) _/K 32768 Kernel live patched > +=== === ====== ======================================================== > + > +Note: To make reading easier ``_`` is representing a blank in this > +table. > + > +More detailed explanation for tainting > +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > 1) ``G`` if all modules loaded have a GPL or compatible license, ``P`` if > any proprietary module has been loaded. Modules without a > @@ -52,8 +144,3 @@ characters, each representing a particular tainted value. > > 16) ``K`` if the kernel has been live patched. > > -The primary reason for the **'Tainted: '** string is to tell kernel > -debuggers if this is a clean kernel or if anything unusual has > -occurred. Tainting is permanent: even if an offending module is > -unloaded, the tainted value remains to indicate that the kernel is not > -trustworthy. > thanks for the update. -- ~Randy