X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fldso%2Fdynlink.c;h=cb35759bad6de15296c09143aff8e0ef3f20a74f;hp=8ade0737f4af23301610cea363f44c524f4e50fa;hb=368ba4a0a9aa5cc9a769872adbef6da433babf54;hpb=596d60c5650488069ac1bbabb786685ebd3298c1 diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c index 8ade0737..cb35759b 100644 --- a/src/ldso/dynlink.c +++ b/src/ldso/dynlink.c @@ -48,6 +48,7 @@ struct dso }; static struct dso *head, *tail, *libc; +static int trust_env; #define AUX_CNT 15 #define DYN_CNT 34 @@ -317,6 +318,7 @@ static void reloc_all(struct dso *p) 2, p->syms, p->strings, p); do_relocs(p->base, (void *)(p->base+dyn[DT_RELA]), dyn[DT_RELASZ], 3, p->syms, p->strings, p); + p->relocated = 1; } } @@ -373,6 +375,11 @@ void *__dynlink(int argc, char **argv, size_t *got) /* At this point the standard library is fully functional */ + /* Only trust user/env if kernel says we're not suid/sgid */ + trust_env = (aux[0]&0x7800)==0x7800 + && aux[AT_UID]==aux[AT_EUID] + && aux[AT_GID]==aux[AT_EGID]; + head = tail = &app; libc = &lib; app.next = 0;