Re: [PATCH V8 13/44] mm/pkeys: Add initial PKS Test code

Edgecombe, Rick P
2022-01-31T19:30:24Z

On Thu, 2022-01-27 at 09:54 -0800, ira.weiny@intel.com wrote:
> +static void crash_it(void)
> +{
> + struct pks_test_ctx *ctx;
> + void *ptr;
> +
> + pr_warn(" ***** BEGIN: Unhandled fault test *****\n");
> +
> + ctx = alloc_ctx(PKS_KEY_TEST);
> + if (IS_ERR(ctx)) {
> + pr_err("Failed to allocate context???\n");
> + return;
> + }
> +
> + ptr = alloc_test_page(ctx->pkey);
> + if (!ptr) {
> + pr_err("Failed to vmalloc page???\n");
> + return;
> + }
> +
> + /* This purposely faults */
> + memcpy(ptr, ctx->data, 8);
> +
> + /* Should never get here if so the test failed */
> + last_test_pass = false;
> +
> + vfree(ptr);
> + free_ctx(ctx);

So these only gets cleaned up if the test fails? Could you clean them
up in pks_release_file() like the later test patch?

> +}

snip

> +
> +static void __exit pks_test_exit(void)
> +{
> + debugfs_remove(pks_test_dentry);
> + pr_info("test exit\n");
> +}

How does this get called?