Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+5 -4
+4 -3
fs/dlm/user.c
··· 785 785 DECLARE_WAITQUEUE(wait, current); 786 786 struct dlm_callback cb; 787 787 int rv, resid, copy_lvb = 0; 788 + int old_mode, new_mode; 788 789 789 790 if (count == sizeof(struct dlm_device_version)) { 790 791 rv = copy_version_to_user(buf, count); ··· 842 841 843 842 lkb = list_entry(proc->asts.next, struct dlm_lkb, lkb_cb_list); 844 843 844 + /* rem_lkb_callback sets a new lkb_last_cast */ 845 + old_mode = lkb->lkb_last_cast.mode; 846 + 845 847 rv = dlm_rem_lkb_callback(lkb->lkb_resource->res_ls, lkb, &cb, &resid); 846 848 if (rv < 0) { 847 849 /* this shouldn't happen; lkb should have been removed from ··· 868 864 } 869 865 870 866 if (cb.flags & DLM_CB_CAST) { 871 - int old_mode, new_mode; 872 - 873 - old_mode = lkb->lkb_last_cast.mode; 874 867 new_mode = cb.mode; 875 868 876 869 if (!cb.sb_status && lkb->lkb_lksb->sb_lvbptr &&
+1 -1
include/uapi/linux/dlm_device.h
··· 26 26 /* Version of the device interface */ 27 27 #define DLM_DEVICE_VERSION_MAJOR 6 28 28 #define DLM_DEVICE_VERSION_MINOR 0 29 - #define DLM_DEVICE_VERSION_PATCH 1 29 + #define DLM_DEVICE_VERSION_PATCH 2 30 30 31 31 /* struct passed to the lock write */ 32 32 struct dlm_lock_params {