2

I'm creating my own syscalls and I'm using functions from this link How to read/write files within a Linux kernel module? to reading and writing to files

the problem is that these functions are not working when non-root user calls my new syscall.

the options are: set root permissions before calling to these functions or create a file with permission 777 before calling to these functions maybe there are more options

but I don't know how to do this.

Cœur
  • 37,241
  • 25
  • 195
  • 267
tigger
  • 41
  • 1
  • 5

1 Answers1

0

You need to somehow emulate the setfsuid call (without permission checks), perform the open and restore the fsuid of the current process. Changing the FS UID will then allow you to actually call the open syscall, use the file descriptor for yourself (warning: user code will also be capable of using that file descriptor!), then restoring the FS UID reduces the security hole to the file descriptor you are using. It's recommended you also close the file before returning to user space.

Paul Stelian
  • 1,381
  • 9
  • 27
  • how? how? how? how? – tigger Jul 03 '16 at 17:21
  • Well, for emulating the setfsuid call it's actually something I'm messing with myself; I'd take inspiration from the real setfsuid call and simply remove the stuff that conditionally returns -EACCES, then make it set the FS UID to 0. – Paul Stelian Jul 03 '16 at 18:00
  • I can create fucntion similar to setfsuid, and I have to call my new created fucntion before a call flip_open? – tigger Jul 08 '16 at 21:20
  • You call that function, then do the file open (sys_open), then restore the old fsuid. – Paul Stelian Jul 09 '16 at 10:00