fs: dlm: dlm lock from user space fixes
Alexander Aring
maintainercover fs: dlm: dlm lock from user space fixes
Hi,
found some issues with the user space fixes and that we don't have proper aligned dlm messages. I found these issues while having my pending patches applied which introduced a "hart" assert for this and dropping messages on such case. With this assert dlm will probably not backwards compatible anymore...
so here my question/suggestion:
We should queue these patches to stable?
- Alex
btw: these patches can be applied, I will send PATCHv3 for my pending patches, I added two other patches.
Alexander Aring (2):
fs: dlm: check for invalid namelen
fs: dlm: transparently align name buffer
fs/dlm/user.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
Signature · 1 line
2.26.2
Alexander Aring
maintainerPATCH 1/2 fs: dlm: check for invalid namelen
This patch adds an additional check inside the dlm locking from user space functionality that the namelen isn't above the maximum allowed dlm resource name length.
--- fs/dlm/user.c | 3 +++ 1 file changed, 3 insertions(+)
fs/dlm/user.c +3 -0
@@ -241,6 +241,9 @@ static int device_user_lock(struct dlm_user_proc *proc,uint32_t lkid;int error = -ENOMEM ; +if (params->namelen >DLM_RESNAME_MAXLEN ) +return -EINVAL ; + ls =dlm_find_lockspace_local (proc->lockspace);if (!ls)return -ENOENT ;
Signature · 1 line
2.26.2
Alexander Aring
maintainerPATCH 2/2 fs: dlm: transparently align name buffer
In reply to Alexander AringThis 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.
--- fs/dlm/user.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/dlm/user.c +5 -2
@@ -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;
Signature · 1 line
2.26.2