Skip to content

Commit

Permalink
dlm: fix lvb copy for user locks
Browse files Browse the repository at this point in the history
For a userland lock request, the previous and current
lock modes are used to decide when the lvb should be
copied back to the user.  The wrong previous value was
used, so that it always matched the current value.
This caused the lvb to be copied back to the user in
the wrong cases.

Signed-off-by: David Teigland <teigland@redhat.com>
  • Loading branch information
David Teigland committed Aug 25, 2015
1 parent 18df8a8 commit b96f465
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions fs/dlm/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
DECLARE_WAITQUEUE(wait, current);
struct dlm_callback cb;
int rv, resid, copy_lvb = 0;
int old_mode, new_mode;

if (count == sizeof(struct dlm_device_version)) {
rv = copy_version_to_user(buf, count);
Expand Down Expand Up @@ -841,6 +842,9 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,

lkb = list_entry(proc->asts.next, struct dlm_lkb, lkb_cb_list);

/* rem_lkb_callback sets a new lkb_last_cast */
old_mode = lkb->lkb_last_cast.mode;

rv = dlm_rem_lkb_callback(lkb->lkb_resource->res_ls, lkb, &cb, &resid);
if (rv < 0) {
/* this shouldn't happen; lkb should have been removed from
Expand All @@ -864,9 +868,6 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
}

if (cb.flags & DLM_CB_CAST) {
int old_mode, new_mode;

old_mode = lkb->lkb_last_cast.mode;
new_mode = cb.mode;

if (!cb.sb_status && lkb->lkb_lksb->sb_lvbptr &&
Expand Down
2 changes: 1 addition & 1 deletion include/uapi/linux/dlm_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/* Version of the device interface */
#define DLM_DEVICE_VERSION_MAJOR 6
#define DLM_DEVICE_VERSION_MINOR 0
#define DLM_DEVICE_VERSION_PATCH 1
#define DLM_DEVICE_VERSION_PATCH 2

/* struct passed to the lock write */
struct dlm_lock_params {
Expand Down

0 comments on commit b96f465

Please sign in to comment.