Skip to content

Commit 60606ec

Browse files
author
Al Viro
committed
ocfs2_inode_lock_update(): make sure we don't change the type bits of i_mode
... even if another node has gone insane. Fail with -ESTALE if it detects an attempt to change the type bits. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent e89f00d commit 60606ec

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

fs/ocfs2/dlmglue.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,7 +2204,7 @@ static void ocfs2_unpack_timespec(struct timespec64 *spec,
22042204
spec->tv_nsec = packed_time & OCFS2_NSEC_MASK;
22052205
}
22062206

2207-
static void ocfs2_refresh_inode_from_lvb(struct inode *inode)
2207+
static int ocfs2_refresh_inode_from_lvb(struct inode *inode)
22082208
{
22092209
struct ocfs2_inode_info *oi = OCFS2_I(inode);
22102210
struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
@@ -2213,6 +2213,8 @@ static void ocfs2_refresh_inode_from_lvb(struct inode *inode)
22132213
mlog_meta_lvb(0, lockres);
22142214

22152215
lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
2216+
if (inode_wrong_type(inode, be16_to_cpu(lvb->lvb_imode)))
2217+
return -ESTALE;
22162218

22172219
/* We're safe here without the lockres lock... */
22182220
spin_lock(&oi->ip_lock);
@@ -2240,6 +2242,7 @@ static void ocfs2_refresh_inode_from_lvb(struct inode *inode)
22402242
ocfs2_unpack_timespec(&inode->i_ctime,
22412243
be64_to_cpu(lvb->lvb_ictime_packed));
22422244
spin_unlock(&oi->ip_lock);
2245+
return 0;
22432246
}
22442247

22452248
static inline int ocfs2_meta_lvb_is_trustable(struct inode *inode,
@@ -2342,7 +2345,8 @@ static int ocfs2_inode_lock_update(struct inode *inode,
23422345
if (ocfs2_meta_lvb_is_trustable(inode, lockres)) {
23432346
mlog(0, "Trusting LVB on inode %llu\n",
23442347
(unsigned long long)oi->ip_blkno);
2345-
ocfs2_refresh_inode_from_lvb(inode);
2348+
status = ocfs2_refresh_inode_from_lvb(inode);
2349+
goto bail_refresh;
23462350
} else {
23472351
/* Boo, we have to go to disk. */
23482352
/* read bh, cast, ocfs2_refresh_inode */
@@ -2352,6 +2356,10 @@ static int ocfs2_inode_lock_update(struct inode *inode,
23522356
goto bail_refresh;
23532357
}
23542358
fe = (struct ocfs2_dinode *) (*bh)->b_data;
2359+
if (inode_wrong_type(inode, le16_to_cpu(fe->i_mode))) {
2360+
status = -ESTALE;
2361+
goto bail_refresh;
2362+
}
23552363

23562364
/* This is a good chance to make sure we're not
23572365
* locking an invalid object. ocfs2_read_inode_block()

0 commit comments

Comments
 (0)