* [PATCH driver-core] kernfs: fix regression in kernfs_fop_write caused by wrong type
@ 2018-01-19 8:18 Ivan Vecera
2018-01-19 17:16 ` Tejun Heo
0 siblings, 1 reply; 3+ messages in thread
From: Ivan Vecera @ 2018-01-19 8:18 UTC (permalink / raw)
To: linux-kernel; +Cc: gregkh, tj, viro
Commit b7ce40cff0b9 ("kernfs: cache atomic_write_len in
kernfs_open_file") changes type of local variable 'len' from ssize_t
to size_t. This change caused that the *ppos value is updated also
when the previous write callback failed.
Mentioned snippet:
...
len = ops->write(...); <- return value can be negative
...
if (len > 0) <- true here in this case
*ppos += len;
...
Fixes: b7ce40cff0b9 ("kernfs: cache atomic_write_len in kernfs_open_file")
Signed-off-by: Ivan Vecera <ivecera@redhat.com>
---
fs/kernfs/file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/kernfs/file.c b/fs/kernfs/file.c
index 9698e51656b1..d8f49c412f50 100644
--- a/fs/kernfs/file.c
+++ b/fs/kernfs/file.c
@@ -275,7 +275,7 @@ static ssize_t kernfs_fop_write(struct file *file, const char __user *user_buf,
{
struct kernfs_open_file *of = kernfs_of(file);
const struct kernfs_ops *ops;
- size_t len;
+ ssize_t len;
char *buf;
if (of->atomic_write_len) {
--
2.13.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH driver-core] kernfs: fix regression in kernfs_fop_write caused by wrong type
2018-01-19 8:18 [PATCH driver-core] kernfs: fix regression in kernfs_fop_write caused by wrong type Ivan Vecera
@ 2018-01-19 17:16 ` Tejun Heo
2018-01-19 17:18 ` Al Viro
0 siblings, 1 reply; 3+ messages in thread
From: Tejun Heo @ 2018-01-19 17:16 UTC (permalink / raw)
To: Ivan Vecera; +Cc: linux-kernel, gregkh, viro
On Fri, Jan 19, 2018 at 09:18:54AM +0100, Ivan Vecera wrote:
> Commit b7ce40cff0b9 ("kernfs: cache atomic_write_len in
> kernfs_open_file") changes type of local variable 'len' from ssize_t
> to size_t. This change caused that the *ppos value is updated also
> when the previous write callback failed.
>
> Mentioned snippet:
> ...
> len = ops->write(...); <- return value can be negative
> ...
> if (len > 0) <- true here in this case
> *ppos += len;
> ...
>
> Fixes: b7ce40cff0b9 ("kernfs: cache atomic_write_len in kernfs_open_file")
> Signed-off-by: Ivan Vecera <ivecera@redhat.com>
Oops.
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH driver-core] kernfs: fix regression in kernfs_fop_write caused by wrong type
2018-01-19 17:16 ` Tejun Heo
@ 2018-01-19 17:18 ` Al Viro
0 siblings, 0 replies; 3+ messages in thread
From: Al Viro @ 2018-01-19 17:18 UTC (permalink / raw)
To: Tejun Heo; +Cc: Ivan Vecera, linux-kernel, gregkh
On Fri, Jan 19, 2018 at 09:16:36AM -0800, Tejun Heo wrote:
> On Fri, Jan 19, 2018 at 09:18:54AM +0100, Ivan Vecera wrote:
> > Commit b7ce40cff0b9 ("kernfs: cache atomic_write_len in
> > kernfs_open_file") changes type of local variable 'len' from ssize_t
> > to size_t. This change caused that the *ppos value is updated also
> > when the previous write callback failed.
> >
> > Mentioned snippet:
> > ...
> > len = ops->write(...); <- return value can be negative
> > ...
> > if (len > 0) <- true here in this case
> > *ppos += len;
> > ...
> >
> > Fixes: b7ce40cff0b9 ("kernfs: cache atomic_write_len in kernfs_open_file")
> > Signed-off-by: Ivan Vecera <ivecera@redhat.com>
>
> Oops.
>
> Acked-by: Tejun Heo <tj@kernel.org>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-19 17:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-19 8:18 [PATCH driver-core] kernfs: fix regression in kernfs_fop_write caused by wrong type Ivan Vecera
2018-01-19 17:16 ` Tejun Heo
2018-01-19 17:18 ` Al Viro
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).