Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1431108

Possible unwanted behaviour in configfs

From Tal Shorer <tal.shorer@gmail.com>
Newsgroups linux.kernel
Subject Possible unwanted behaviour in configfs
Date 2016-06-25 11:50 +0200
Message-ID <rNSnT-3OC-3@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Hey,
I encountered a possible unwanted behaviour in the way configfs
handles read() on items' attributes.
The show() function is called only once (which is good) on the first
time the user attempts to read from the file. If show() returns an
error that error is returned to the user. However, if the user calls
read() again, no data is copied (good) and a value of zero is
returned.
This is especially evident when using busybox's cat utility, which
first attempts sendfile64() and if that fails falls back to read(),
giving the user the impression that reading the attribute was
successful but no data was returned.

I traced this to the function configfs_read_file in fs/configfs/file.c
and have two fixes in mind:
1. In fill_read_buffer(), If an error is returned by show(), don't set
buffer->needs_read_fill to zero, making the next read() call show()
again and either get an error or data.
2. Add an "err" field to struct configfs_buffer and keep the returned
error from show() there. Any additional read() on this file will
return this error.

Any thoughts?

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Possible unwanted behaviour in configfs Tal Shorer <tal.shorer@gmail.com> - 2016-06-25 11:50 +0200
  Re: Possible unwanted behaviour in configfs Christoph Hellwig <hch@lst.de> - 2016-06-30 11:40 +0200
    [PATCH] fs: configfs: don't set buffer_needs_fill to zero if show() returns error Tal Shorer <tal.shorer@gmail.com> - 2016-07-01 11:30 +0200

csiph-web