Is there a way to set kptr_restrict to 0?

jab picture jab · Dec 5, 2013 · Viewed 15.8k times · Source

I am currently having trouble running linux perf, mostly because /proc/sys/kernel/kptr_restrict is currently set to 1.

However, if I try to /proc/sys/kernel/kptr_restrict by echoing 0 to it as follows...

echo 0 > /proc/sys/kernel/kptr_restrict

I get a permission denied error. I don't think I can change permissions on it either.

Is there a way to set this directly somehow? I am super user. I don't think perf will function acceptably without this being set.

Answer

Jun Ge picture Jun Ge · Dec 5, 2013

In your example, echo is running as root, but your shell is running as you.

So please try this command:

sudo sh -c " echo 0 > /proc/sys/kernel/kptr_restrict"