fs: dlm: stop unnecessarily filling zero ms_extra bytes
authorAlexander Aring <aahringo@redhat.com>
Fri, 21 Apr 2023 15:55:52 +0000 (11:55 -0400)
committerDavid Teigland <teigland@redhat.com>
Fri, 21 Apr 2023 16:46:47 +0000 (11:46 -0500)
Commit 7175e131ebba ("fs: dlm: fix invalid derefence of sb_lvbptr")
fixes an issue when the lkb->lkb_lvbptr set to an dangled pointer and an
followed memcpy() would fail. It was fixed by an additional check of
DLM_LKF_VALBLK flag. The mentioned commit forgot to add an additional check
if DLM_LKF_VALBLK is set for the additional amount of LVB data allocated
in a dlm message. This patch is changing the message allocation to check
additionally if DLM_LKF_VALBLK is set otherwise a dangled lkb->lkb_lvbptr
pointer would allocated zero LVB message data which not gets filled with
actual data.

This patch is however only a cleanup to reduce the amount of zero bytes
transmitted over network as receive_lvb() will only evaluates message LVB
data if DLM_LKF_VALBLK is set.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
fs/dlm/lock.c

index 1582c8b1404c9c37a4e68510dfe68e6c60f03747..debf8a55ad7d9b56428703f79f3b07884281b1f5 100644 (file)
@@ -3381,7 +3381,7 @@ static int create_message(struct dlm_rsb *r, struct dlm_lkb *lkb,
        case DLM_MSG_REQUEST_REPLY:
        case DLM_MSG_CONVERT_REPLY:
        case DLM_MSG_GRANT:
-               if (lkb && lkb->lkb_lvbptr)
+               if (lkb && lkb->lkb_lvbptr && (lkb->lkb_exflags & DLM_LKF_VALBLK))
                        mb_len += r->res_ls->ls_lvblen;
                break;
        }