valevalorin
Posts: 7
Joined: Thu Oct 09, 2014 4:06 pm

/proc/cpuinfo

Thu Oct 09, 2014 4:12 pm

I have a few questions about this file.

1. When does this file get generated?

2. Is this file accessible if I move the SD card from the RPI to another machine?

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6229
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: /proc/cpuinfo

Thu Oct 09, 2014 4:22 pm

The file never physically exist on the card at all and is generated when it's read.

http://www.tldp.org/LDP/Linux-Filesyste ... /proc.html

valevalorin
Posts: 7
Joined: Thu Oct 09, 2014 4:06 pm

Re: /proc/cpuinfo

Thu Oct 09, 2014 4:25 pm

So if I were to try and read this on a different machine, the file wouldn't exist?

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6229
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: /proc/cpuinfo

Thu Oct 09, 2014 4:27 pm

If you mount the on /media/sd and try reading /media/sd/proc/cpuinfo, you will find that there's nothing there. If you read /proc/cpuinfo, you will get the cpuinfo for the host machine.

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: /proc/cpuinfo

Thu Oct 09, 2014 4:47 pm

valevalorin wrote:1. When does this file get generated?
It's a virtual filesystem generated by the Linux kernel when it boots.
The code that writes the data to /proc/cpuinfo is ../linux/arch/arm/kernel/setup.c
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

valevalorin
Posts: 7
Joined: Thu Oct 09, 2014 4:06 pm

Re: /proc/cpuinfo

Thu Oct 09, 2014 5:33 pm

Alright then, thanks a lot guys!

valevalorin
Posts: 7
Joined: Thu Oct 09, 2014 4:06 pm

Re: /proc/cpuinfo

Thu Oct 09, 2014 5:44 pm

I actually have another question: can I use chmod on cpuinfo?

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: /proc/cpuinfo

Thu Oct 09, 2014 5:50 pm

No.

You can do awful things

Code: Select all

#!/bin/sh
cat /proc/cpuinfo | sed -e 's/Serial.*/Serial\t\t: 00000000deadbeef/g'  > /tmp/cpuinfo_fake
mount -o bind /tmp/cpuinfo_fake /proc/cpuinfo
mount -o remount,ro,bind /proc/cpuinfo
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

valevalorin
Posts: 7
Joined: Thu Oct 09, 2014 4:06 pm

Re: /proc/cpuinfo

Thu Oct 09, 2014 6:11 pm

Is there some other way I can make cpuinfo only accessible by root? Is it only accessible by root by default?

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6229
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: /proc/cpuinfo

Thu Oct 09, 2014 6:13 pm

What are you doing and why?

User avatar
DougieLawson
Posts: 39121
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: /proc/cpuinfo

Thu Oct 09, 2014 6:50 pm

valevalorin wrote:Is there some other way I can make cpuinfo only accessible by root? Is it only accessible by root by default?
Rewrite the kernel modules and build your own kernel. But, you WILL break lots of things that expect cpuinfo to be world readable.

There's nothing in cpuinfo that can be used for any sensible security or encryption purposes. If you're thinking about hiding the CPUID, you've failed at the first fence. The bottom six digits are used for the MAC address for the eth0 interface. I can also get it with dmesg | grep serial.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: /proc/cpuinfo

Thu Oct 09, 2014 6:53 pm

Change the password on 'pi' (and any other 'user' accounts you may have created).

That will keep those pesky users from accessing /proc/cpuinfo (or anything else).
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

User avatar
jojopi
Posts: 3268
Joined: Tue Oct 11, 2011 8:38 pm

Re: /proc/cpuinfo

Thu Oct 09, 2014 7:30 pm

valevalorin wrote:I actually have another question: can I use chmod on cpuinfo?
Yes, you can use chmod to restrict read access (but not to make the file meaningfully writeable). You will have to repeat it every boot, because the permissions are not stored on disk.

(Of course, I doubt it helps you.)

Return to “General discussion”