Commit 96c9a780 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull vfs fixes from Al Viro:
 "Two old bugs..."

* 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  propagate_one(): mnt_set_mountpoint() needs mount_lock
  dlmfs_file_write(): fix the bogosity in handling non-zero *ppos
parents dd7bc815 b0d3869c
...@@ -275,7 +275,6 @@ static ssize_t dlmfs_file_write(struct file *filp, ...@@ -275,7 +275,6 @@ static ssize_t dlmfs_file_write(struct file *filp,
loff_t *ppos) loff_t *ppos)
{ {
int bytes_left; int bytes_left;
ssize_t writelen;
char *lvb_buf; char *lvb_buf;
struct inode *inode = file_inode(filp); struct inode *inode = file_inode(filp);
...@@ -285,32 +284,30 @@ static ssize_t dlmfs_file_write(struct file *filp, ...@@ -285,32 +284,30 @@ static ssize_t dlmfs_file_write(struct file *filp,
if (*ppos >= i_size_read(inode)) if (*ppos >= i_size_read(inode))
return -ENOSPC; return -ENOSPC;
/* don't write past the lvb */
if (count > i_size_read(inode) - *ppos)
count = i_size_read(inode) - *ppos;
if (!count) if (!count)
return 0; return 0;
if (!access_ok(buf, count)) if (!access_ok(buf, count))
return -EFAULT; return -EFAULT;
/* don't write past the lvb */ lvb_buf = kmalloc(count, GFP_NOFS);
if ((count + *ppos) > i_size_read(inode))
writelen = i_size_read(inode) - *ppos;
else
writelen = count - *ppos;
lvb_buf = kmalloc(writelen, GFP_NOFS);
if (!lvb_buf) if (!lvb_buf)
return -ENOMEM; return -ENOMEM;
bytes_left = copy_from_user(lvb_buf, buf, writelen); bytes_left = copy_from_user(lvb_buf, buf, count);
writelen -= bytes_left; count -= bytes_left;
if (writelen) if (count)
user_dlm_write_lvb(inode, lvb_buf, writelen); user_dlm_write_lvb(inode, lvb_buf, count);
kfree(lvb_buf); kfree(lvb_buf);
*ppos = *ppos + writelen; *ppos = *ppos + count;
mlog(0, "wrote %zd bytes\n", writelen); mlog(0, "wrote %zu bytes\n", count);
return writelen; return count;
} }
static void dlmfs_init_once(void *foo) static void dlmfs_init_once(void *foo)
......
...@@ -261,14 +261,13 @@ static int propagate_one(struct mount *m) ...@@ -261,14 +261,13 @@ static int propagate_one(struct mount *m)
child = copy_tree(last_source, last_source->mnt.mnt_root, type); child = copy_tree(last_source, last_source->mnt.mnt_root, type);
if (IS_ERR(child)) if (IS_ERR(child))
return PTR_ERR(child); return PTR_ERR(child);
read_seqlock_excl(&mount_lock);
mnt_set_mountpoint(m, mp, child); mnt_set_mountpoint(m, mp, child);
if (m->mnt_master != dest_master)
SET_MNT_MARK(m->mnt_master);
read_sequnlock_excl(&mount_lock);
last_dest = m; last_dest = m;
last_source = child; last_source = child;
if (m->mnt_master != dest_master) {
read_seqlock_excl(&mount_lock);
SET_MNT_MARK(m->mnt_master);
read_sequnlock_excl(&mount_lock);
}
hlist_add_head(&child->mnt_hash, list); hlist_add_head(&child->mnt_hash, list);
return count_mounts(m->mnt_ns, child); return count_mounts(m->mnt_ns, child);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment