[-mm] proc: fixup test for read
diff mbox series

Message ID 20180316232147.GA20146@avx2
State New, archived
Headers show
Series
  • [-mm] proc: fixup test for read
Related show

Commit Message

Alexey Dobriyan March 16, 2018, 11:21 p.m. UTC
/proc/kmsg can and will block if read under root.

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---

 tools/testing/selftests/proc/read.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andrew Morton March 16, 2018, 11:28 p.m. UTC | #1
On Sat, 17 Mar 2018 02:21:47 +0300 Alexey Dobriyan <adobriyan@gmail.com> wrote:

> /proc/kmsg can and will block if read under root.
> 

This fixes
proc-shotgun-test-read-readdir-readlink-a-little-write.patch.  It helps
to point that out, so that reviewers won't be scrambling around
asking wtf.

Patch
diff mbox series

--- a/tools/testing/selftests/proc/read.c
+++ b/tools/testing/selftests/proc/read.c
@@ -54,7 +54,8 @@  static void f_reg(DIR *d, const char *filename)
 	int fd;
 	ssize_t rv;
 
-	fd = openat(dirfd(d), filename, O_RDONLY);
+	/* read from /proc/kmsg can block */
+	fd = openat(dirfd(d), filename, O_RDONLY|O_NONBLOCK);
 	if (fd == -1)
 		return;
 	rv = read(fd, buf, sizeof(buf));