From: Alexander Aring <aahringo@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH dlm-next 2/2] fs: dlm: transparently align name buffer
Date: Fri, 11 Dec 2020 10:47:18 -0500 [thread overview]
Message-ID: <20201211154718.99346-3-aahringo@redhat.com> (raw)
In-Reply-To: <20201211154718.99346-1-aahringo@redhat.com>
This patch adds a zeroed temporary buffer to align the given resource
name of a dlm lock user space request transparently to a 4 byte aligned
buffer. I hit the assert while running the recent pending patch which
contains a 4 byte aligned assert for the dlm header msglength field.
It's important that the allocation and msglength field is 4 byte aligned
as the dlm_header structure is natural aligned to 4 byte values. The
internal dlm allocator can return the next remaining space from a
previously allocated length. The buffer will not be aligned to 4 byte
anymore if this case occurs. At receiving side we cannot parse the next
dlm message because the next dlm header starts at a unaligned address as
well.
Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
fs/dlm/user.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/dlm/user.c b/fs/dlm/user.c
index 9f2f743eeb31..70a5116df9fe 100644
--- a/fs/dlm/user.c
+++ b/fs/dlm/user.c
@@ -236,6 +236,7 @@ void dlm_user_add_ast(struct dlm_lkb *lkb, uint32_t flags, int mode,
static int device_user_lock(struct dlm_user_proc *proc,
struct dlm_lock_params *params)
{
+ unsigned char name[DLM_RESNAME_MAXLEN] = {};
struct dlm_ls *ls;
struct dlm_user_args *ua;
uint32_t lkid;
@@ -270,17 +271,19 @@ static int device_user_lock(struct dlm_user_proc *proc,
params->lkid, params->lvb,
(unsigned long) params->timeout);
} else if (params->flags & DLM_LKF_ORPHAN) {
+ memcpy(name, params->name, params->namelen);
error = dlm_user_adopt_orphan(ls, ua,
params->mode, params->flags,
- params->name, params->namelen,
+ name, ALIGN(params->namelen, 4),
(unsigned long) params->timeout,
&lkid);
if (!error)
error = lkid;
} else {
+ memcpy(name, params->name, params->namelen);
error = dlm_user_request(ls, ua,
params->mode, params->flags,
- params->name, params->namelen,
+ name, ALIGN(params->namelen, 4),
(unsigned long) params->timeout);
if (!error)
error = ua->lksb.sb_lkid;
--
2.26.2
prev parent reply other threads:[~2020-12-11 15:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-11 15:47 [Cluster-devel] [PATCH dlm-next 0/2] fs: dlm: dlm lock from user space fixes Alexander Aring
2020-12-11 15:47 ` [Cluster-devel] [PATCH dlm-next 1/2] fs: dlm: check for invalid namelen Alexander Aring
2020-12-11 15:47 ` Alexander Aring [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201211154718.99346-3-aahringo@redhat.com \
--to=aahringo@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).