[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <04d8c32a-06cd-d71a-43d9-47b1de6c7684@i-love.sakura.ne.jp>
Date: Tue, 10 Nov 2020 13:43:06 +0900
From: Tetsuo Handa <penguin-kernel@...ove.sakura.ne.jp>
To: Aleksandr Nogikh <aleksandrnogikh@...il.com>, jmorris@...ei.org,
serge@...lyn.com, akinobu.mita@...il.com
Cc: andreyknvl@...gle.com, dvyukov@...gle.com, elver@...gle.com,
glider@...gle.com, keescook@...gle.com, casey@...aufler-ca.com,
linux-kernel@...r.kernel.org,
linux-security-module@...r.kernel.org,
Aleksandr Nogikh <nogikh@...gle.com>
Subject: Re: [PATCH v3 1/2] security: add fault injection capability
On 2020/10/30 3:35, Aleksandr Nogikh wrote:
> +#ifdef CONFIG_FAIL_LSM_HOOKS
> +
> +static struct {
> + struct fault_attr attr;
> + int retval;
> +} fail_lsm_hooks = {
> + .attr = FAULT_ATTR_INITIALIZER,
> + .retval = -EACCES
> +};
> +
> +static int __init setup_fail_lsm_hooks(char *str)
> +{
> + return setup_fault_attr(&fail_lsm_hooks.attr, str);
> +}
> +__setup("fail_lsm_hooks=", setup_fail_lsm_hooks);
> +
> +static int lsm_hooks_inject_fail(void)
> +{
> + return should_fail(&fail_lsm_hooks.attr, 1) ? fail_lsm_hooks.retval : 0;
> +}
> +
> +#ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
> +
> +static int __init fail_lsm_hooks_debugfs(void)
> +{
> + umode_t mode = S_IFREG | 0600;
> + struct dentry *dir;
> +
> + dir = fault_create_debugfs_attr("fail_lsm_hooks", NULL,
> + &fail_lsm_hooks.attr);
> + debugfs_create_u32("retval", mode, dir, &fail_lsm_hooks.retval);
Since production kernels will use CONFIG_FAIL_LSM_HOOKS=n, we won't need to worry about userspace ABI.
Reviewed-by: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
By the way, fail_lsm_hooks.retval is "signed int" but debugfs_create_u32() handles "unsigned int".
Do we want to allow lsm_hooks_inject_fail() to inject arbitrary !IS_ERR_VALUE() values?
> + return 0;
> +}
Powered by blists - more mailing lists