Re: [PATCH v2] fault-inject: support systematic fault injection

From: Andrew Morton
Date: Thu Mar 30 2017 - 19:04:16 EST


On Tue, 28 Mar 2017 15:01:28 +0200 Dmitry Vyukov <dvyukov@xxxxxxxxxx> wrote:

> +static ssize_t proc_fail_nth_write(struct file *file, const char __user *buf,
> + size_t count, loff_t *ppos)
> +{
> + struct task_struct *task;
> + int err, n;
> +
> + task = get_proc_task(file_inode(file));
> + if (!task)
> + return -ESRCH;
> + put_task_struct(task);
> + if (task != current)
> + return -EPERM;
> + err = kstrtoint_from_user(buf, count, 10, &n);
> + if (err)
> + return err;
> + if (n < 0 || n == INT_MAX)
> + return -EINVAL;
> + current->fail_nth = n + 1;
> + return len;
> +}

Well that didn't go too well.

--- a/fs/proc/base.c~fault-inject-support-systematic-fault-injection-fix
+++ a/fs/proc/base.c
@@ -1377,7 +1377,7 @@ static ssize_t proc_fail_nth_write(struc
if (n < 0 || n == INT_MAX)
return -EINVAL;
current->fail_nth = n + 1;
- return len;
+ return count;
}

static ssize_t proc_fail_nth_read(struct file *file, char __user *buf,

Are you sure I merged the correct version of this?