kernel: validnamedup() the name argument for segattach()

this moves the name validation out of segattach() to syssegattach()
to make sure the segment name cannot be changed by the user while
segattach looks at it.
This commit is contained in:
cinap_lenrek 2015-08-06 11:48:51 +02:00
parent d275add1a8
commit b09cd67860
2 changed files with 10 additions and 4 deletions

View file

@ -604,9 +604,6 @@ segattach(Proc *p, ulong attr, char *name, uintptr va, uintptr len)
if(va != 0 && va >= USTKTOP)
error(Ebadarg);
validaddr((uintptr)name, 1, 0);
vmemchr(name, 0, ~0);
for(sno = 0; sno < NSEG; sno++)
if(p->seg[sno] == nil && sno != ESEG)
break;

View file

@ -775,7 +775,16 @@ syssegattach(va_list list)
name = va_arg(list, char*);
va = va_arg(list, uintptr);
len = va_arg(list, ulong);
return segattach(up, attr, name, va, len);
validaddr((uintptr)name, 1, 0);
name = validnamedup(name, 1);
if(waserror()){
free(name);
nexterror();
}
va = segattach(up, attr, name, va, len);
free(name);
poperror();
return va;
}
uintptr