LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-22-2023, 09:17 AM   #1
tyty
LQ Newbie
 
Registered: Dec 2023
Posts: 6

Rep: Reputation: 0
How can I disable magic sysrq in linux?


I have a prodlem with disable sysrq. I had done follow actions but it didn't help.

1) # grep "SYSRQ" /boot/config-$(uname -r)
CONFIG_MAGIC_SYSRQ=y
CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x0
# CONFIG_MAGIC_SYSRQ_SERIAL is not set

2) # sysctl -a | grep sysrq
kernel.sysrq = 0

3) # cat /etc/sysctl.conf | grep sysrq
kernel.sysrq = 0

4) # cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-5.14.21-at154.148.1-default root=/dev/mapper/system-root rw systemd.show_status=1 console=ttyS0,115200 console=tty0 init_on_alloc=1 iommu=force iommu.strict=1 iommu.passthrough=0 randomize_kstack_offset=1 vsyscall=none debugfs=no-mount tsx=off splash=silent resume=/dev/system/swap preempt=full mitigations=auto quiet security=apparmor

But when I do
# echo o > /proc/sysrq-trigger
The machime immediately powers off

Have somebody faced with it and can help?
 
Old 12-22-2023, 10:32 AM   #2
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Salix
Posts: 6,145

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
You want
Code:
echo 0 > /proc/sys/kernel/sysrq
 
Old 12-25-2023, 01:03 AM   #3
tyty
LQ Newbie
 
Registered: Dec 2023
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by DavidMcCann View Post
You want
Code:
echo 0 > /proc/sys/kernel/sysrq
I tried it. It dosen't help. echo o > /proc/sysrq-trigger will be work.

# cat /proc/sys/kernel/sysrq
0

Last edited by tyty; 12-25-2023 at 01:14 AM.
 
Old 12-25-2023, 01:50 AM   #4
lvm_
Member
 
Registered: Jul 2020
Posts: 955

Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
You can't. Invocation via /proc/sysrq-trigger is always allowed, configuration options affect only the the key itself.
 
Old 12-25-2023, 01:53 AM   #5
tyty
LQ Newbie
 
Registered: Dec 2023
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by lvm_ View Post
You can't. Invocation via /proc/sysrq-trigger is always allowed, configuration options affect only the the key itself.
Are there opportunity disable sysrq-trigger, maybe it can be disabled with kernel?
I followed https://www.kernel.org/doc/html/late...ide/sysrq.html

Last edited by tyty; 12-25-2023 at 01:58 AM.
 
Old 12-25-2023, 02:16 AM   #6
lvm_
Member
 
Registered: Jul 2020
Posts: 955

Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
This very page says the same: "Note that the value of /proc/sys/kernel/sysrq influences only the invocation via a keyboard. Invocation of any operation via /proc/sysrq-trigger is always allowed (by a user with admin privileges)." Apart from patching the kernel nothing can done.
 
1 members found this post helpful.
Old 12-25-2023, 02:23 AM   #7
tyty
LQ Newbie
 
Registered: Dec 2023
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by lvm_ View Post
This very page says the same: "Note that the value of /proc/sys/kernel/sysrq influences only the invocation via a keyboard. Invocation of any operation via /proc/sysrq-trigger is always allowed (by a user with admin privileges)." Apart from patching the kernel nothing can done.
thanx.
I didn't pay attention
 
Old 12-25-2023, 04:33 AM   #8
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,837

Rep: Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507
Try
Code:
# CONFIG_MAGIC_SYSRQ is not set
But why? Only root can write to /proc/sysrq-trigger.
 
Old 12-25-2023, 05:22 AM   #9
tyty
LQ Newbie
 
Registered: Dec 2023
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Petri Kaukasoina View Post
Try
Code:
# CONFIG_MAGIC_SYSRQ is not set
But why? Only root can write to /proc/sysrq-trigger.
I tried it but when kernel builds the value changes to "y". According guide you can manage it changing CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE.
 
Old 12-25-2023, 07:42 AM   #10
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,837

Rep: Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507Reputation: 1507
Quote:
Originally Posted by tyty View Post
I tried it but when kernel builds the value changes to "y". According guide you can manage it changing CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE.
There is something wrong in your kernel building process if it changes CONFIG_MAGIC_SYSRQ to "y". It does not do it here, and the new kernel does not have /proc/sysrq-trigger or /proc/sys/kernel/sysrq.

If you compile in the Magic SysRq key support (CONFIG_MAGIC_SYSRQ=y) then you can set the default value of /proc/sys/kernel/sysrq using CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE.
 
1 members found this post helpful.
Old 12-28-2023, 05:19 AM   #11
tyty
LQ Newbie
 
Registered: Dec 2023
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Petri Kaukasoina View Post
There is something wrong in your kernel building process if it changes CONFIG_MAGIC_SYSRQ to "y". It does not do it here, and the new kernel does not have /proc/sysrq-trigger or /proc/sys/kernel/sysrq.

If you compile in the Magic SysRq key support (CONFIG_MAGIC_SYSRQ=y) then you can set the default value of /proc/sys/kernel/sysrq using CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE.
I found why it could not be set "# CONFIG_MAGIC_SYSRQ is not set" because for it you need also disable "# CONFIG_KGDB is not set" only after it you can disable CONFIG_MAGIC_SYSRQ

thank everyone

Last edited by tyty; 12-28-2023 at 05:23 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sysrq: SysRq : HELP ? glorsplitz Slackware - ARM 7 09-27-2019 09:27 PM
LXer: Understanding the SysRq Key – The Magic Key To Control Linux LXer Syndicated Linux News 0 08-01-2012 02:50 PM
LXer: Use Magic SysRq combination key to recover from a frozen system in Linux LXer Syndicated Linux News 1 10-19-2010 05:59 AM
LXer: Linux Kernel Magic SysRq keys in openSUSE for crash recovery LXer Syndicated Linux News 0 09-28-2008 11:30 PM
Magic sysrq key + Framebuffer console jspenguin Linux - Software 0 04-14-2003 08:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration