LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 10-31-2010, 06:57 PM   #1
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 637

Rep: Reputation: 32
Question Passing variables to /proc


I am trying to pass a variable to /proc with the following command:

yoyoyo@M5-N177:$ sudo echo "1" > /proc/sys/kernel/modules_disabled
bash: /proc/sys/kernel/modules_disabled: Permission denied

Not working as you can tell... what do I need to do? This is on ubuntu 10.10 - thx
 
Old 10-31-2010, 07:24 PM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
You could try starting a shell in root using either sudo -s or sudo su. Then when you have an interactive session as root you could try the command again. I don't want to test this myself. Seems like a bad idea to put 1 in that "file".

Last edited by stress_junkie; 10-31-2010 at 07:25 PM.
 
Old 10-31-2010, 07:29 PM   #3
impert
Member
 
Registered: Feb 2009
Posts: 282

Rep: Reputation: 54
If I tell you how to do it, will you tell me how to undo it? Seriously!
Ubuntu, by default, doesn't use a root password. You can, however, give it one, using sudo passwd root. You can then become root as you would in other distributions.
Code:
cam@cwpc:~$ su
Password: 
root@cwpc:/home/cam# echo "1" > /proc/sys/kernel/modules_disabled
root@cwpc:/home/cam# cat /proc/sys/kernel/modules_disabled
1
root@cwpc:/home/cam# echo "" > /proc/sys/kernel/modules_disabled
bash: echo: write error: Invalid argument
root@cwpc:/home/cam# echo " " > /proc/sys/kernel/modules_disabled
bash: echo: write error: Invalid argument
and trying to nano it gives
Code:
Error writing /proc/sys/kernel/modules_disabled: Invalid argument
when saving.

Why do you want to do this?
 
Old 10-31-2010, 07:41 PM   #4
impert
Member
 
Registered: Feb 2009
Posts: 282

Rep: Reputation: 54
It's not obvious to get rid of it:
Code:
root@cwpc:/home/cam# cat /dev/null > /proc/sys/kernel/modules_disabled
root@cwpc:/home/cam# cat /proc/sys/kernel/modules_disabled
1
Maybe a reboot will fix it.
 
Old 10-31-2010, 07:43 PM   #5
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 637

Original Poster
Rep: Reputation: 32
Just saw this was a new security option and wanted to see what happened with it enabled and I load a module. I put the this line in /etc/sysctl.conf

modules_disabled = 1

Still it does not come back with 1 in proc when I do a cat.
 
Old 10-31-2010, 07:44 PM   #6
impert
Member
 
Registered: Feb 2009
Posts: 282

Rep: Reputation: 54
Quote:
Seems like a bad idea to put 1 in that "file".
You're probably right.
 
Old 10-31-2010, 07:49 PM   #7
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
It is designed not be be undo-able. Once set, that's it (deliberately) till reboot.
 
Old 10-31-2010, 07:53 PM   #8
impert
Member
 
Registered: Feb 2009
Posts: 282

Rep: Reputation: 54
Quote:
Seems like a bad idea to put 1 in that "file".
You're probably right.
After a reboot I've now got 0 in there. Is 0 better than nothing, I wonder? Anyhow, the sky hasn't fallen in. Yet.
Edit:
@syg00 Do you know what it does?

Last edited by impert; 10-31-2010 at 07:55 PM. Reason: Ask question
 
Old 10-31-2010, 08:02 PM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Read this
 
1 members found this post helpful.
Old 10-31-2010, 08:35 PM   #10
Thaidog
Member
 
Registered: Sep 2002
Location: Hilton Head, SC
Distribution: Gentoo
Posts: 637

Original Poster
Rep: Reputation: 32
Here is where I saw it:
https://wiki.ubuntu.com/Security/Fea...dule%20loading
 
1 members found this post helpful.
Old 11-01-2010, 06:21 AM   #11
impert
Member
 
Registered: Feb 2009
Posts: 282

Rep: Reputation: 54
@syg00

thanks for the info:
Quote:
modules_disabled:
258
259A toggle value indicating if modules are allowed to be loaded
260in an otherwise modular kernel. This toggle defaults to off
261(0), but can be set true (1). Once true, modules can be
262neither loaded nor unloaded, and the toggle cannot be set back
263to false.
Quote:
Since some of the files _can_ be used to screw up your
15system, it is advisable to read both documentation and source
16before actually making adjustments.

Sounds grim. However, on rebooting it set itself to read 0, so I imagine no damage was done. I didn't try echoing "0" to it as I wasn't sure that this was a toggle. I wouldn't be surprised though if it is possible to echo "say hullo to mum" or anything you like to it - but only as root using su, not sudo
 
Old 11-01-2010, 06:27 AM   #12
impert
Member
 
Registered: Feb 2009
Posts: 282

Rep: Reputation: 54
@Thaidog: thanks to you, too, for the link. I've got some reading to do!
 
Old 11-01-2010, 06:30 AM   #13
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
That's just a general statement about sysctls. If you're root you can generally royally screw up your system.
With modules_disabled the kernel devs may have been trying to protect you (or your system) from yourself ...
 
Old 03-29-2012, 06:44 PM   #14
tracyreed
LQ Newbie
 
Registered: Aug 2011
Posts: 4

Rep: Reputation: Disabled
kernel.modules_disabled

I was googling for kernel.modules_disabled to see what others were saying and found this thread. I know this is an old thread and this was a new feature when the thread was started but I have been playing with this and want to add some commentary which nobody has so far hit upon...

This is a GREAT feature if you want to harden your system. Right now I'm looking at a Linux box with a kernel module based rootkit on it. Had this option been set this guy would not have been owned in this way. For servers, which generally get all of their modules loaded at boot time and then never need any more, this is a great option to employ to help protect the system.
 
  


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
PHP not passing variables beebopbogo Programming 4 08-26-2009 04:37 PM
Passing variables to an include? Red Squirrel Linux - Software 4 09-23-2005 09:18 PM
PHP passing variables from url to ... latino Programming 3 08-31-2005 06:35 PM
passing variables to sed jjfate Programming 8 07-31-2003 04:15 AM
Passing variables in PHP???? vous Programming 3 03-20-2003 06:03 AM

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

All times are GMT -5. The time now is 09:46 PM.

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