dimanche 28 juin 2015

Read only debugfs file is being written to. Why is that?

I have created a file using debugfs API inside /sys/kernel/debug/test/testFile. I have created the file with mode set to 444, so it is now read only.

Now I have essentially followed this tutorial in creating this debugfs file. And for this file both read and write are define. Moreover, concretely, I create file using this:

debugfs_create_file("testFile", 444, pDebugfs, NULL, &debugfs_fops)

File is successfully created and I can easily read from it by cat ... but why I can write to it too even though I can explicitly created as read only. I am logged in as root. Why is that? Should not it not allow me to write to it?

Finally, ls -l results:

-r--r--r-- 1 root root 0 جون 28 15:27 /sys/kernel/debug/test/testFile

Now, you may argue that since I am root, I can write to any file. Well, then if you search let's access blob file on the page, the OP cannot write to blob file, even though as root, because it is read only. Why is that?

Aucun commentaire:

Enregistrer un commentaire