open: check filename address (re-commit)

This commit is contained in:
Tomoki Shirasawa
2017-07-19 11:37:55 +09:00
parent dd9675d65e
commit 64c2e437c6
2 changed files with 22 additions and 27 deletions

View File

@@ -2834,12 +2834,26 @@ SYSCALL_DECLARE(ioctl)
SYSCALL_DECLARE(open)
{
const char *pathname = (const char *)ihk_mc_syscall_arg0(ctx);
int len;
char *xpmem_wk;
long rc;
dkprintf("open(): pathname=%s\n", pathname);
if (!strcmp(pathname, XPMEM_DEV_PATH)) {
len = strlen_user(pathname);
if (len < 0)
return len;
if (!(xpmem_wk = kmalloc(len + 1, IHK_MC_AP_NOWAIT)))
return -ENOMEM;
if (copy_from_user(xpmem_wk, pathname, len + 1)) {
kfree(xpmem_wk);
return -EFAULT;
}
dkprintf("open(): pathname=%s\n", xpmem_wk);
rc = strcmp(xpmem_wk, XPMEM_DEV_PATH);
kfree(xpmem_wk);
if (!rc) {
rc = xpmem_open(ctx);
} else {
}
else {
rc = syscall_generic_forwarding(__NR_open, ctx);
}