mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-29 05:38:21 +00:00
elf: handle AT_SECURE
This commit is contained in:
@@ -258,12 +258,6 @@ static syscallret_t execve(context_t *context, char *upath, char *uargv[], char
|
||||
VOP_RELEASE(interpnode);
|
||||
}
|
||||
|
||||
stack = elf_preparestack(STACK_TOP, &auxv64, argv, envp, path);
|
||||
if (stack == NULL) {
|
||||
ret.errno = ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
|
||||
vattr_t vattr;
|
||||
VOP_LOCK(node);
|
||||
ret.errno = VOP_GETATTR(node, &vattr, NULL);
|
||||
@@ -271,6 +265,26 @@ static syscallret_t execve(context_t *context, char *upath, char *uargv[], char
|
||||
if (ret.errno)
|
||||
goto error;
|
||||
|
||||
int suid = -1;
|
||||
int sgid = -1;
|
||||
|
||||
if (vattr.mode & V_ATTR_MODE_SUID) {
|
||||
suid = vattr.uid;
|
||||
auxv64.secure.val = 1;
|
||||
}
|
||||
|
||||
if (vattr.mode & V_ATTR_MODE_SGID) {
|
||||
sgid = vattr.gid;
|
||||
auxv64.secure.val = 1;
|
||||
}
|
||||
|
||||
stack = elf_preparestack(STACK_TOP, &auxv64, argv, envp, path);
|
||||
if (stack == NULL) {
|
||||
ret.errno = ENOMEM;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
ret.ret = 0;
|
||||
|
||||
proc_stop_other_threads();
|
||||
@@ -297,15 +311,6 @@ static syscallret_t execve(context_t *context, char *upath, char *uargv[], char
|
||||
CTX_SP(context) = (uint64_t)stack;
|
||||
CTX_IP(context) = (uint64_t)entry;
|
||||
|
||||
int suid = -1;
|
||||
int sgid = -1;
|
||||
|
||||
if (vattr.mode & V_ATTR_MODE_SUID)
|
||||
suid = vattr.uid;
|
||||
|
||||
if (vattr.mode & V_ATTR_MODE_SGID)
|
||||
sgid = vattr.gid;
|
||||
|
||||
cred_doexec(¤t_thread()->proc->cred, suid, sgid);
|
||||
|
||||
error:
|
||||
|
||||
Reference in New Issue
Block a user