summaryrefslogtreecommitdiffstats
path: root/xlators/features/locks/src/posix.c
diff options
context:
space:
mode:
authorKinglong Mee <kinglongmee@gmail.com>2019-07-18 11:43:01 +0800
committerAmar Tumballi <amarts@gmail.com>2019-08-20 09:36:17 +0000
commitfaaf22bbe899b0f64b0237398a0d8e3c082f9392 (patch)
tree54bb7bcac96d5825c136aeb00dbf1983a4451625 /xlators/features/locks/src/posix.c
parentbb01111f50f2585429028c408932416d31c6d316 (diff)
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/posix.c')
-rw-r--r--xlators/features/locks/src/posix.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 007086df08e..47822b88bde 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -2459,6 +2459,7 @@ pl_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
uint32_t lk_flags = 0;
posix_locks_private_t *priv = this->private;
pl_local_t *local = NULL;
+ short lock_type = 0;
int ret = dict_get_uint32(xdata, GF_LOCK_MODE, &lk_flags);
if (ret == 0) {
@@ -2603,6 +2604,7 @@ pl_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
case F_SETLK:
reqlock->frame = frame;
reqlock->this = this;
+ lock_type = flock->l_type;
pthread_mutex_lock(&pl_inode->mutex);
{
@@ -2640,8 +2642,7 @@ pl_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
ret = pl_setlk(this, pl_inode, reqlock, can_block);
if (ret == -1) {
- if ((can_block) && (F_UNLCK != flock->l_type)) {
- pl_trace_block(this, frame, fd, NULL, cmd, flock, NULL);
+ if ((can_block) && (F_UNLCK != lock_type)) {
goto out;
}
gf_log(this->name, GF_LOG_DEBUG, "returning EAGAIN");