diff options
author | Alexander Aring <aahringo@redhat.com> | 2021-11-02 22:17:20 +0300 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2021-11-02 22:39:20 +0300 |
commit | 9af5b8f0ead7cd90161b0555ed8e85ee38f79fa5 (patch) | |
tree | ea127bf5ce24641ae0cf177234319fcf25d14461 /fs/dlm/midcomms.c | |
parent | 5c16febbc19bb463bfb8e80cb5b24ec6ff1a439f (diff) | |
download | linux-9af5b8f0ead7cd90161b0555ed8e85ee38f79fa5.tar.xz |
fs: dlm: add debugfs rawmsg send functionality
This patch adds a dlm functionality to send a raw dlm message to a
specific cluster node. This raw message can be build by user space and
send out by writing the message to "rawmsg" dlm debugfs file.
There is a in progress scapy dlm module which provides a easy build of
DLM messages in user space. For example:
DLM(h_cmd=3, o_nextcmd=1, h_nodeid=1, h_lockspace=0xe4f48a18, ...)
The goal is to provide an easy reproducable state to crash DLM or to
fuzz the DLM kernel stack if there are possible ways to crash it.
Note: that if the sequence number is zero and dlm version is not set to
3.1 the kernel will automatic will set a right sequence number, otherwise
DLM stack testing is not possible.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs/dlm/midcomms.c')
-rw-r--r-- | fs/dlm/midcomms.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c index 95a5643a950e..0b9bce6f04e1 100644 --- a/fs/dlm/midcomms.c +++ b/fs/dlm/midcomms.c @@ -1427,3 +1427,51 @@ int dlm_midcomms_close(int nodeid) return ret; } + +/* debug functionality to send raw dlm msg from user space */ +struct dlm_rawmsg_data { + struct midcomms_node *node; + void *buf; +}; + +static void midcomms_new_rawmsg_cb(void *data) +{ + struct dlm_rawmsg_data *rd = data; + struct dlm_header *h = rd->buf; + + switch (h->h_version) { + case cpu_to_le32(DLM_VERSION_3_1): + break; + default: + switch (h->h_cmd) { + case DLM_OPTS: + if (!h->u.h_seq) + h->u.h_seq = rd->node->seq_send++; + break; + default: + break; + } + break; + } +} + +int dlm_midcomms_rawmsg_send(struct midcomms_node *node, void *buf, + int buflen) +{ + struct dlm_rawmsg_data rd; + struct dlm_msg *msg; + char *msgbuf; + + rd.node = node; + rd.buf = buf; + + msg = dlm_lowcomms_new_msg(node->nodeid, buflen, GFP_NOFS, + &msgbuf, midcomms_new_rawmsg_cb, &rd); + if (!msg) + return -ENOMEM; + + memcpy(msgbuf, buf, buflen); + dlm_lowcomms_commit_msg(msg); + return 0; +} + |