ret = setrlimit(RLIMIT_FSIZE, &rlim);
FAIL_IF(ret);
}
return TEST_PASS;
}
staticint child(struct shared_info *info)
{ bool disable_execute = true; int pkey1, pkey2, pkey3; int *ptr, ret;
/* Wait until parent fills out the initial register values. */
ret = wait_parent(&info->child_sync); if (ret) return ret;
ret = increase_core_file_limit();
FAIL_IF(ret);
/* Get some pkeys so that we can change their bits in the AMR. */
pkey1 = sys_pkey_alloc(0, PKEY_DISABLE_EXECUTE); if (pkey1 < 0) {
pkey1 = sys_pkey_alloc(0, PKEY_UNRESTRICTED);
FAIL_IF(pkey1 < 0);
/* * We won't use pkey3. This tests whether the kernel restores the UAMOR * permissions after a key is freed.
*/
sys_pkey_free(pkey3);
info->core_time = time(NULL);
/* Crash. */
ptr = 0;
*ptr = 1;
/* Shouldn't get here. */
FAIL_IF(true);
return TEST_FAIL;
}
/* Return file size if filename exists and pass sanity check, or zero if not. */ static off_t try_core_file(constchar *filename, struct shared_info *info,
pid_t pid)
{ struct stat buf; int ret;
ret = stat(filename, &buf); if (ret == -1) return TEST_FAIL;
/* Make sure we're not using a stale core file. */ return buf.st_mtime >= info->core_time ? buf.st_size : TEST_FAIL;
}
/* * Get the initial values for AMR, IAMR and UAMOR and communicate them * to the child.
*/
ret = ptrace_read_regs(pid, NT_PPC_PKEY, regs, 3);
PARENT_SKIP_IF_UNSUPPORTED(ret, &info->child_sync, "PKEYs not supported");
PARENT_FAIL_IF(ret, &info->child_sync);
ret = read_file(core_pattern_file, core_pattern, PATH_MAX - 1, &len); if (ret) {
perror("Error reading core_pattern file");
ret = TEST_FAIL; goto out;
}
core_pattern[len] = '\0';
/* Check whether we can predict the name of the core file. */ if (!strcmp(core_pattern, "core") || !strcmp(core_pattern, "core.%p"))
*changed_ = false; else {
ret = write_core_pattern("core-pkey.%p"); if (ret) goto out;
*changed_ = true;
}
*core_pattern_ = core_pattern;
ret = TEST_PASS;
out: if (ret)
free(core_pattern);
return ret;
}
staticint core_pkey(void)
{ char *core_pattern; bool changed_core_pattern; struct shared_info *info; int shm_id; int ret;
pid_t pid;
ret = setup_core_pattern(&core_pattern, &changed_core_pattern); if (ret) return ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.