summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/fault-injection/fault-injection.txt7
-rw-r--r--fs/proc/base.c9
-rw-r--r--include/linux/sched.h2
3 files changed, 8 insertions, 10 deletions
diff --git a/Documentation/fault-injection/fault-injection.txt b/Documentation/fault-injection/fault-injection.txt
index 192d8cbcc5f9..a32190508751 100644
--- a/Documentation/fault-injection/fault-injection.txt
+++ b/Documentation/fault-injection/fault-injection.txt
@@ -138,8 +138,8 @@ o proc entries
- /proc/self/task/<current-tid>/fail-nth:
- Write to this file of integer N makes N-th call in the current task fail
- (N is 0-based). Read from this file returns a single char 'Y' or 'N'
+ Write to this file of integer N makes N-th call in the task fail.
+ Read from this file returns a single char 'Y' or 'N'
that says if the fault setup with a previous write to this file was
injected or not, and disables the fault if it wasn't yet injected.
Note that this file enables all types of faults (slab, futex, etc).
@@ -320,7 +320,7 @@ int main()
system("echo N > /sys/kernel/debug/failslab/ignore-gfp-wait");
sprintf(buf, "/proc/self/task/%ld/fail-nth", syscall(SYS_gettid));
fail_nth = open(buf, O_RDWR);
- for (i = 0;; i++) {
+ for (i = 1;; i++) {
sprintf(buf, "%d", i);
write(fail_nth, buf, strlen(buf));
res = socketpair(AF_LOCAL, SOCK_STREAM, 0, fds);
@@ -339,7 +339,6 @@ int main()
An example output:
-0-th fault Y: res=-1/23
1-th fault Y: res=-1/23
2-th fault Y: res=-1/23
3-th fault Y: res=-1/12
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 5d93512beea1..c1fdaecb8d23 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1360,7 +1360,8 @@ 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;
+ int err;
+ unsigned int n;
task = get_proc_task(file_inode(file));
if (!task)
@@ -1368,12 +1369,10 @@ static ssize_t proc_fail_nth_write(struct file *file, const char __user *buf,
put_task_struct(task);
if (task != current)
return -EPERM;
- err = kstrtoint_from_user(buf, count, 0, &n);
+ err = kstrtouint_from_user(buf, count, 0, &n);
if (err)
return err;
- if (n < 0 || n == INT_MAX)
- return -EINVAL;
- current->fail_nth = n + 1;
+ current->fail_nth = n;
return count;
}
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 3822d749fc9e..2ba9ec93423f 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -974,7 +974,7 @@ struct task_struct {
#ifdef CONFIG_FAULT_INJECTION
int make_it_fail;
- int fail_nth;
+ unsigned int fail_nth;
#endif
/*
* When (nr_dirtied >= nr_dirtied_pause), it's time to call