Skip to content

Commit 96c9a78

Browse files
committed
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
2 parents dd7bc81 + b0d3869 commit 96c9a78

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

fs/ocfs2/dlmfs/dlmfs.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ static ssize_t dlmfs_file_write(struct file *filp,
275275
loff_t *ppos)
276276
{
277277
int bytes_left;
278-
ssize_t writelen;
279278
char *lvb_buf;
280279
struct inode *inode = file_inode(filp);
281280

@@ -285,32 +284,30 @@ static ssize_t dlmfs_file_write(struct file *filp,
285284
if (*ppos >= i_size_read(inode))
286285
return -ENOSPC;
287286

287+
/* don't write past the lvb */
288+
if (count > i_size_read(inode) - *ppos)
289+
count = i_size_read(inode) - *ppos;
290+
288291
if (!count)
289292
return 0;
290293

291294
if (!access_ok(buf, count))
292295
return -EFAULT;
293296

294-
/* don't write past the lvb */
295-
if ((count + *ppos) > i_size_read(inode))
296-
writelen = i_size_read(inode) - *ppos;
297-
else
298-
writelen = count - *ppos;
299-
300-
lvb_buf = kmalloc(writelen, GFP_NOFS);
297+
lvb_buf = kmalloc(count, GFP_NOFS);
301298
if (!lvb_buf)
302299
return -ENOMEM;
303300

304-
bytes_left = copy_from_user(lvb_buf, buf, writelen);
305-
writelen -= bytes_left;
306-
if (writelen)
307-
user_dlm_write_lvb(inode, lvb_buf, writelen);
301+
bytes_left = copy_from_user(lvb_buf, buf, count);
302+
count -= bytes_left;
303+
if (count)
304+
user_dlm_write_lvb(inode, lvb_buf, count);
308305

309306
kfree(lvb_buf);
310307

311-
*ppos = *ppos + writelen;
312-
mlog(0, "wrote %zd bytes\n", writelen);
313-
return writelen;
308+
*ppos = *ppos + count;
309+
mlog(0, "wrote %zu bytes\n", count);
310+
return count;
314311
}
315312

316313
static void dlmfs_init_once(void *foo)

fs/pnode.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,13 @@ static int propagate_one(struct mount *m)
261261
child = copy_tree(last_source, last_source->mnt.mnt_root, type);
262262
if (IS_ERR(child))
263263
return PTR_ERR(child);
264+
read_seqlock_excl(&mount_lock);
264265
mnt_set_mountpoint(m, mp, child);
266+
if (m->mnt_master != dest_master)
267+
SET_MNT_MARK(m->mnt_master);
268+
read_sequnlock_excl(&mount_lock);
265269
last_dest = m;
266270
last_source = child;
267-
if (m->mnt_master != dest_master) {
268-
read_seqlock_excl(&mount_lock);
269-
SET_MNT_MARK(m->mnt_master);
270-
read_sequnlock_excl(&mount_lock);
271-
}
272271
hlist_add_head(&child->mnt_hash, list);
273272
return count_mounts(m->mnt_ns, child);
274273
}

0 commit comments

Comments
 (0)