Skip to content

Commit 957adb6

Browse files
Alexander Aringteigland
authored andcommitted
fs: dlm: invalid buffer access in lookup error
This patch will evaluate the message length if a dlm opts header can fit in before accessing it if a node lookup fails. The invalid sequence error means that the version detection failed and an unexpected message arrived. For debugging such situation the type of arrived message is important to know. Signed-off-by: Alexander Aring <[email protected]> Signed-off-by: David Teigland <[email protected]>
1 parent f5fe8d5 commit 957adb6

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

fs/dlm/midcomms.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,23 @@ dlm_midcomms_recv_node_lookup(int nodeid, const union dlm_packet *p,
621621

622622
node = nodeid2node(nodeid, allocation);
623623
if (!node) {
624-
log_print_ratelimited("received dlm message cmd %d nextcmd %d from node %d in an invalid sequence",
625-
p->header.h_cmd, p->opts.o_nextcmd, nodeid);
624+
switch (p->header.h_cmd) {
625+
case DLM_OPTS:
626+
if (msglen < sizeof(struct dlm_opts)) {
627+
log_print("opts msg too small: %u, will skip this message from node %d",
628+
msglen, nodeid);
629+
return NULL;
630+
}
631+
632+
log_print_ratelimited("received dlm opts message nextcmd %d from node %d in an invalid sequence",
633+
p->opts.o_nextcmd, nodeid);
634+
break;
635+
default:
636+
log_print_ratelimited("received dlm message cmd %d from node %d in an invalid sequence",
637+
p->header.h_cmd, nodeid);
638+
break;
639+
}
640+
626641
return NULL;
627642
}
628643

0 commit comments

Comments
 (0)