mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Yafang Shao <laoar.shao@gmail.com>,
	mingo@redhat.com, arnd@arndb.de, gregkh@linuxfoundation.org
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] /dev/mem: Add a new parameter strict_devmem to bypass strict devmem
Date: Thu, 21 Nov 2024 09:51:47 +0100	[thread overview]
Message-ID: <0aa9f3bd-b1b6-4089-b9eb-5b72d7a1541a@redhat.com> (raw)
In-Reply-To: <20241120122858.22190-1-laoar.shao@gmail.com>

On 20.11.24 13:28, Yafang Shao wrote:
> When CONFIG_STRICT_DEVMEM is enabled, writing to /dev/mem to override
> kernel data for debugging purposes is prohibited. This configuration is
> always enabled on our production servers. However, there are times when we
> need to use the crash utility to modify kernel data to analyze complex
> issues.
> 
> As suggested by Ingo, we can add a boot time knob of soft-enabling it.
> Therefore, a new parameter "strict_devmem=" is added. The reuslt are as
> follows,
> 
> - Before this change
>    crash> wr panic_on_oops 0
>    wr: cannot write to /proc/kcore      <<<< failed
> 
> - After this change
>    - default
>      crash> wr panic_on_oops 0
>      wr: cannot write to /proc/kcore    <<<< failed
> 
>    - strict_devmem=off
>      crash> p panic_on_oops
>      panic_on_oops = $1 = 1
>      crash> wr panic_on_oops 0
>      crash> p panic_on_oops
>      panic_on_oops = $2 = 0            <<<< succeeded
> 
>    - strict_devmem=invalid
>      [    0.230052] Invalid option string for strict_devmem: 'invalid'
>      crash> wr panic_on_oops 0
>      wr: cannot write to /proc/kcore  <<<< failed
> 
> Suggested-by: Ingo Molnar <mingo@kernel.org>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> ---
>   .../admin-guide/kernel-parameters.txt         | 16 ++++++++++++++
>   drivers/char/mem.c                            | 21 +++++++++++++++++++
>   2 files changed, 37 insertions(+)
> 
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 1518343bbe22..7fe0f66d0dfb 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -6563,6 +6563,22 @@
>   			them frequently to increase the rate of SLB faults
>   			on kernel addresses.
>   
> +	strict_devmem=
> +			[KNL] Under CONFIG_STRICT_DEVMEM, whether strict devmem
> +			is enabled for this boot. Strict devmem checking is used
> +			to protect the userspace (root) access to all of memory,
> +			including kernel and userspace memory. Accidental access
> +			to this is obviously disastrous, but specific access can
> +			be used by people debugging the kernel. Note that with
> +			PAT support enabled, even in this case there are
> +			restrictions on /dev/mem use due to the cache aliasing
> +			requirements.
> +		on	If IO_STRICT_DEVMEM=n, the /dev/mem file only allows
> +			userspace access to PCI space and the BIOS code and data
> +			regions. This is sufficient for dosemu and X and all
> +			common users of /dev/mem. (default)
> +		off	Disable strict devmem checks.
> +
>   	sunrpc.min_resvport=
>   	sunrpc.max_resvport=
>   			[NFS,SUNRPC]

This will allow to violate EXCLUSIVE_SYSTEM_RAM, and I am afraid I don't 
enjoy seeing devmem handling+config getting more complicated.

-- 
Cheers,

David / dhildenb


  reply	other threads:[~2024-11-21  8:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-20 12:28 Yafang Shao
2024-11-21  8:51 ` David Hildenbrand [this message]
2024-11-21 14:31   ` Yafang Shao
2024-11-21 15:14     ` Greg KH
2024-11-21 15:23       ` David Hildenbrand
2024-11-22  2:14         ` Yafang Shao
2024-11-22 10:58           ` David Hildenbrand
2024-11-22 11:50             ` Yafang Shao
2024-11-22 13:21               ` David Hildenbrand
2024-11-22  2:26       ` Yafang Shao
2024-11-22 11:00         ` David Hildenbrand
2024-11-22 11:55           ` Yafang Shao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0aa9f3bd-b1b6-4089-b9eb-5b72d7a1541a@redhat.com \
    --to=david@redhat.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=laoar.shao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®