diff options
author | Kinglong Mee <kinglongmee@gmail.com> | 2019-07-18 11:43:01 +0800 |
---|---|---|
committer | Amar Tumballi <amarts@gmail.com> | 2019-08-20 09:36:17 +0000 |
commit | faaf22bbe899b0f64b0237398a0d8e3c082f9392 (patch) | |
tree | 54bb7bcac96d5825c136aeb00dbf1983a4451625 /xlators/features/locks/src/inodelk.c | |
parent | bb01111f50f2585429028c408932416d31c6d316 (diff) | |
download | glusterfs-faaf22bbe899b0f64b0237398a0d8e3c082f9392.tar.gz glusterfs-faaf22bbe899b0f64b0237398a0d8e3c082f9392.tar.xz glusterfs-faaf22bbe899b0f64b0237398a0d8e3c082f9392.zip |
features/locks: avoid use after freed of frame for blocked lock
The fop contains blocked lock may use freed frame info when other
unlock fop has unwind the blocked lock.
Because the blocked lock is added to block list in inode lock(or
other lock), after that, when out of the inode lock, the fop
contains the blocked lock should not use it.
Change-Id: Icb309a1cc78380dc982b26d50c18d67e4f2c8915
fixes: bz#1737291
Signed-off-by: Kinglong Mee <mijinlong@horiscale.com>
Diffstat (limited to 'xlators/features/locks/src/inodelk.c')
-rw-r--r-- | xlators/features/locks/src/inodelk.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/xlators/features/locks/src/inodelk.c b/xlators/features/locks/src/inodelk.c index cf556ea12a..6022e5a6d9 100644 --- a/xlators/features/locks/src/inodelk.c +++ b/xlators/features/locks/src/inodelk.c @@ -418,6 +418,8 @@ __lock_blocked_add(xlator_t *this, pl_dom_list_t *dom, pl_inode_lock_t *lock, lkowner_utoa(&lock->owner), lock->user_flock.l_start, lock->user_flock.l_len); + pl_trace_block(this, lock->frame, NULL, NULL, F_SETLKW, &lock->user_flock, + lock->volume); out: return -EAGAIN; } @@ -960,6 +962,7 @@ pl_common_inodelk(call_frame_t *frame, xlator_t *this, const char *volume, int ret = -1; GF_UNUSED int dict_ret = -1; int can_block = 0; + short lock_type = 0; pl_inode_t *pinode = NULL; pl_inode_lock_t *reqlock = NULL; pl_dom_list_t *dom = NULL; @@ -1024,13 +1027,13 @@ pl_common_inodelk(call_frame_t *frame, xlator_t *this, const char *volume, /* fall through */ case F_SETLK: + lock_type = flock->l_type; memcpy(&reqlock->user_flock, flock, sizeof(struct gf_flock)); ret = pl_inode_setlk(this, ctx, pinode, reqlock, can_block, dom, inode); if (ret < 0) { - if ((can_block) && (F_UNLCK != flock->l_type)) { - pl_trace_block(this, frame, fd, loc, cmd, flock, volume); + if ((can_block) && (F_UNLCK != lock_type)) { goto out; } gf_log(this->name, GF_LOG_TRACE, "returning EAGAIN"); |