* [PATCH] nfsd: fix bad offset use
@ 2013-03-22 18:18 Kent Overstreet
2013-03-22 19:14 ` Zach Brown
2013-03-22 20:53 ` J. Bruce Fields
0 siblings, 2 replies; 5+ messages in thread
From: Kent Overstreet @ 2013-03-22 18:18 UTC (permalink / raw)
To: linux-kernel, linux-nfs
Cc: Kent Overstreet, J. Bruce Fields, Al Viro, Eric W. Biederman, Zach Brown
vfs_writev() updates the offset argument - but the code then passes the
offset to vfs_fsync_range(). Since offset now points to the offset after
what was just written, this is probably not what was intended
Signed-off-by: Kent Overstreet <koverstreet@google.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Zach Brown <zab@redhat.com>
---
fs/nfsd/vfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 2a7eb53..2b2e239 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1013,6 +1013,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
int host_err;
int stable = *stablep;
int use_wgather;
+ loff_t pos = offset;
dentry = file->f_path.dentry;
inode = dentry->d_inode;
@@ -1025,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
/* Write the data. */
oldfs = get_fs(); set_fs(KERNEL_DS);
- host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
+ host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
set_fs(oldfs);
if (host_err < 0)
goto out_nfserr;
--
1.8.1.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nfsd: fix bad offset use
2013-03-22 18:18 [PATCH] nfsd: fix bad offset use Kent Overstreet
@ 2013-03-22 19:14 ` Zach Brown
2013-03-22 20:53 ` J. Bruce Fields
1 sibling, 0 replies; 5+ messages in thread
From: Zach Brown @ 2013-03-22 19:14 UTC (permalink / raw)
To: Kent Overstreet
Cc: linux-kernel, linux-nfs, J. Bruce Fields, Al Viro, Eric W. Biederman
On Fri, Mar 22, 2013 at 11:18:24AM -0700, Kent Overstreet wrote:
> vfs_writev() updates the offset argument - but the code then passes the
> offset to vfs_fsync_range(). Since offset now points to the offset after
> what was just written, this is probably not what was intended
Agreed, the original code does look fishy and this fix right to me.
Reviewed-by: Zach Brown <zab@redhat.com>
- z
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nfsd: fix bad offset use
2013-03-22 18:18 [PATCH] nfsd: fix bad offset use Kent Overstreet
2013-03-22 19:14 ` Zach Brown
@ 2013-03-22 20:53 ` J. Bruce Fields
2013-03-22 20:54 ` J. Bruce Fields
1 sibling, 1 reply; 5+ messages in thread
From: J. Bruce Fields @ 2013-03-22 20:53 UTC (permalink / raw)
To: Kent Overstreet
Cc: linux-kernel, linux-nfs, Al Viro, Eric W. Biederman, Zach Brown
On Fri, Mar 22, 2013 at 11:18:24AM -0700, Kent Overstreet wrote:
> vfs_writev() updates the offset argument - but the code then passes the
> offset to vfs_fsync_range(). Since offset now points to the offset after
> what was just written, this is probably not what was intended
Whoops--thanks! Looks like this was introduced by my
face15025ffdf664de95e86ae831544154d26c9c "nfsd: use vfs_fsync_range(),
not O_SYNC, for stable writes", in 3.8.
I'll queue up for 3.9 and stable.
--b.
>
> Signed-off-by: Kent Overstreet <koverstreet@google.com>
> Cc: "J. Bruce Fields" <bfields@fieldses.org>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
> Cc: Zach Brown <zab@redhat.com>
> ---
> fs/nfsd/vfs.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index 2a7eb53..2b2e239 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -1013,6 +1013,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
> int host_err;
> int stable = *stablep;
> int use_wgather;
> + loff_t pos = offset;
>
> dentry = file->f_path.dentry;
> inode = dentry->d_inode;
> @@ -1025,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
>
> /* Write the data. */
> oldfs = get_fs(); set_fs(KERNEL_DS);
> - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
> + host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
> set_fs(oldfs);
> if (host_err < 0)
> goto out_nfserr;
> --
> 1.8.1.3
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nfsd: fix bad offset use
2013-03-22 20:53 ` J. Bruce Fields
@ 2013-03-22 20:54 ` J. Bruce Fields
2013-03-22 21:21 ` Kent Overstreet
0 siblings, 1 reply; 5+ messages in thread
From: J. Bruce Fields @ 2013-03-22 20:54 UTC (permalink / raw)
To: Kent Overstreet
Cc: linux-kernel, linux-nfs, Al Viro, Eric W. Biederman, Zach Brown
On Fri, Mar 22, 2013 at 04:53:53PM -0400, J. Bruce Fields wrote:
> On Fri, Mar 22, 2013 at 11:18:24AM -0700, Kent Overstreet wrote:
> > vfs_writev() updates the offset argument - but the code then passes the
> > offset to vfs_fsync_range(). Since offset now points to the offset after
> > what was just written, this is probably not what was intended
>
> Whoops--thanks! Looks like this was introduced by my
> face15025ffdf664de95e86ae831544154d26c9c "nfsd: use vfs_fsync_range(),
> not O_SYNC, for stable writes", in 3.8.
>
> I'll queue up for 3.9 and stable.
(By the way, out of curiosity: how did you stumble across this?)
--b.
>
> --b.
>
> >
> > Signed-off-by: Kent Overstreet <koverstreet@google.com>
> > Cc: "J. Bruce Fields" <bfields@fieldses.org>
> > Cc: Al Viro <viro@zeniv.linux.org.uk>
> > Cc: "Eric W. Biederman" <ebiederm@xmission.com>
> > Cc: Zach Brown <zab@redhat.com>
> > ---
> > fs/nfsd/vfs.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> > index 2a7eb53..2b2e239 100644
> > --- a/fs/nfsd/vfs.c
> > +++ b/fs/nfsd/vfs.c
> > @@ -1013,6 +1013,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
> > int host_err;
> > int stable = *stablep;
> > int use_wgather;
> > + loff_t pos = offset;
> >
> > dentry = file->f_path.dentry;
> > inode = dentry->d_inode;
> > @@ -1025,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
> >
> > /* Write the data. */
> > oldfs = get_fs(); set_fs(KERNEL_DS);
> > - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
> > + host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
> > set_fs(oldfs);
> > if (host_err < 0)
> > goto out_nfserr;
> > --
> > 1.8.1.3
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nfsd: fix bad offset use
2013-03-22 20:54 ` J. Bruce Fields
@ 2013-03-22 21:21 ` Kent Overstreet
0 siblings, 0 replies; 5+ messages in thread
From: Kent Overstreet @ 2013-03-22 21:21 UTC (permalink / raw)
To: J. Bruce Fields
Cc: linux-kernel, linux-nfs, Al Viro, Eric W. Biederman, Zach Brown
On Fri, Mar 22, 2013 at 04:54:34PM -0400, J. Bruce Fields wrote:
> On Fri, Mar 22, 2013 at 04:53:53PM -0400, J. Bruce Fields wrote:
> > On Fri, Mar 22, 2013 at 11:18:24AM -0700, Kent Overstreet wrote:
> > > vfs_writev() updates the offset argument - but the code then passes the
> > > offset to vfs_fsync_range(). Since offset now points to the offset after
> > > what was just written, this is probably not what was intended
> >
> > Whoops--thanks! Looks like this was introduced by my
> > face15025ffdf664de95e86ae831544154d26c9c "nfsd: use vfs_fsync_range(),
> > not O_SYNC, for stable writes", in 3.8.
> >
> > I'll queue up for 3.9 and stable.
>
> (By the way, out of curiosity: how did you stumble across this?)
Just reading code - I've been trying to figure out how to improve the
way *pos pointers are passed around everywhere and I was looking at all
the users of various vfs code.
> --b.
>
> >
> > --b.
> >
> > >
> > > Signed-off-by: Kent Overstreet <koverstreet@google.com>
> > > Cc: "J. Bruce Fields" <bfields@fieldses.org>
> > > Cc: Al Viro <viro@zeniv.linux.org.uk>
> > > Cc: "Eric W. Biederman" <ebiederm@xmission.com>
> > > Cc: Zach Brown <zab@redhat.com>
> > > ---
> > > fs/nfsd/vfs.c | 3 ++-
> > > 1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> > > index 2a7eb53..2b2e239 100644
> > > --- a/fs/nfsd/vfs.c
> > > +++ b/fs/nfsd/vfs.c
> > > @@ -1013,6 +1013,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
> > > int host_err;
> > > int stable = *stablep;
> > > int use_wgather;
> > > + loff_t pos = offset;
> > >
> > > dentry = file->f_path.dentry;
> > > inode = dentry->d_inode;
> > > @@ -1025,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
> > >
> > > /* Write the data. */
> > > oldfs = get_fs(); set_fs(KERNEL_DS);
> > > - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &offset);
> > > + host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
> > > set_fs(oldfs);
> > > if (host_err < 0)
> > > goto out_nfserr;
> > > --
> > > 1.8.1.3
> > >
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-03-22 21:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-22 18:18 [PATCH] nfsd: fix bad offset use Kent Overstreet
2013-03-22 19:14 ` Zach Brown
2013-03-22 20:53 ` J. Bruce Fields
2013-03-22 20:54 ` J. Bruce Fields
2013-03-22 21:21 ` Kent Overstreet
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.