linux kernel - How to verify if the pointer is pointing to the process address table -
linux kernel - How to verify if the pointer is pointing to the process address table -
i trying write own scheme phone call under arch linux system, next format of scheme call:
long getpeuid(pid_t pid, uid_t *uid) which used euid of calling process's parent process.
i know have verify 3 things first:
check if pointer pointing user space. that can done access_ok().
check if pointer pointing calling process's address space.
check if calling process has permission write space pointer pointing to.
i found syscall copy_to_user() can re-create kernel space variable user space, but not sure if syscall checks other prerequisites first.
also, not sure how can calling process's parent process euid. know getppid() parent process id, not sure how proceed that. can give me hint on this?
thanks in advance!
edit:
a follow question, if want check if effective uid of parent process root, see if euid equals 0, right?
edit:
another question, allowed phone call getppid() , other syscalls within syscall? after googling, seems trying avoid doing this.
(i'm new linux kernel development, please right reply necessary!)
yes, copy_to_user makes needed checks see if process allowed write referenced memory space. major reason why copy_to_user used often.
once have pid of parent process, need reference task descriptor. believe can calling find_task_by_vpid(pid_number).
now have pointer parent process' task_struct. has 2 struct cred * members: cred , real_cred. (i'm not sure 1 should use.) struct cred has fellow member euid.
if euid 0, yes, parent process running root. note if scheme uses lxc containers, root inside container.
linux-kernel system-calls
Comments
Post a Comment