Skip to content

Commit b96f465

Browse files
committed
dlm: fix lvb copy for user locks
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>
1 parent 18df8a8 commit b96f465

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎fs/dlm/user.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
785785
DECLARE_WAITQUEUE(wait, current);
786786
struct dlm_callback cb;
787787
int rv, resid, copy_lvb = 0;
788+
int old_mode, new_mode;
788789

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

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

845+
/* rem_lkb_callback sets a new lkb_last_cast */
846+
old_mode = lkb->lkb_last_cast.mode;
847+
844848
rv = dlm_rem_lkb_callback(lkb->lkb_resource->res_ls, lkb, &cb, &resid);
845849
if (rv < 0) {
846850
/* this shouldn't happen; lkb should have been removed from
@@ -864,9 +868,6 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
864868
}
865869

866870
if (cb.flags & DLM_CB_CAST) {
867-
int old_mode, new_mode;
868-
869-
old_mode = lkb->lkb_last_cast.mode;
870871
new_mode = cb.mode;
871872

872873
if (!cb.sb_status && lkb->lkb_lksb->sb_lvbptr &&

‎include/uapi/linux/dlm_device.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/* Version of the device interface */
2727
#define DLM_DEVICE_VERSION_MAJOR 6
2828
#define DLM_DEVICE_VERSION_MINOR 0
29-
#define DLM_DEVICE_VERSION_PATCH 1
29+
#define DLM_DEVICE_VERSION_PATCH 2
3030

3131
/* struct passed to the lock write */
3232
struct dlm_lock_params {

0 commit comments

Comments
 (0)