#define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #define NSIO 0xb7 #define NS_GET_USERNS _IO(NSIO, 0x1) #define pr_err(fmt, ...) \ ({ \ fprintf(stderr, "%s:%d:" fmt ": %m\n", \ __func__, __LINE__, ##__VA_ARGS__); \ 1; \ }) int main(int argc, char *argvp[]) { int pfd[2], ns, uns, init_uns; struct stat st1, st2; char path[128]; pid_t pid; char c; if (pipe(pfd)) return 1; pid = fork(); if (pid < 0) return pr_err("fork"); if (pid == 0) { prctl(PR_SET_PDEATHSIG, SIGKILL); if (unshare(CLONE_NEWUTS | CLONE_NEWUSER)) return pr_err("unshare"); close(pfd[0]); close(pfd[1]); while (1) sleep(1); return 0; } close(pfd[1]); if (read(pfd[0], &c, 1) != 0) return pr_err("Unable to read from pipe"); close(pfd[0]); snprintf(path, sizeof(path), "/proc/%d/ns/uts", pid); ns = open(path, O_RDONLY); if (ns < 0) return pr_err("Unable to open %s", path); uns = ioctl(ns, NS_GET_USERNS); if (uns < 0) return pr_err("Unable to get an owning user namespace"); if (fstat(uns, &st1)) return pr_err("fstat"); snprintf(path, sizeof(path), "/proc/%d/ns/user", pid); if (stat(path, &st2)) return pr_err("stat"); if (st1.st_ino != st2.st_ino) return pr_err("NS_GET_USERNS returned a wrong namespace"); init_uns = ioctl(uns, NS_GET_USERNS); if (uns < 0) return pr_err("Unable to get an owning user namespace"); if (ioctl(init_uns, NS_GET_USERNS) >= 0 || errno != EPERM) return pr_err("Don't get EPERM"); if (unshare(CLONE_NEWUSER)) return pr_err("unshare"); if (ioctl(ns, NS_GET_USERNS) >= 0 || errno != EPERM) return pr_err("Don't get EPERM"); if (ioctl(init_uns, NS_GET_USERNS) >= 0 || errno != EPERM) return pr_err("Don't get EPERM"); kill(pid, SIGKILL); wait(NULL); return 0; } reecommitdiff
diff options
context:
space:
mode:
authorGiovanni Cabiddu <giovanni.cabiddu@intel.com>2016-12-22 15:00:12 +0000
committerHerbert Xu <herbert@gondor.apana.org.au>2017-02-02 21:54:52 +0800
commit3484ecbe0e9deb94afb0b9b6172d77e98eb72b94 (patch)
tree4d4be0d20d4946c51ef47a882d78c9934a219c0e /include/math-emu/op-2.h
parent11e3b725cfc282efe9d4a354153e99d86a16af08 (diff)
crypto: qat - fix bar discovery for c62x
Some accelerators of the c62x series have only two bars. This patch skips BAR0 if the accelerator does not have it. Cc: <stable@vger.kernel.org> Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include/math-emu/op-2.h')