elf: handle AT_SECURE

This commit is contained in:
Matheus
2025-11-04 18:46:49 -03:00
parent 5d79c7840d
commit 3308a2a39b
3 changed files with 25 additions and 16 deletions
+20 -15
View File
@@ -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(&current_thread()->proc->cred, suid, sgid);
error: