Skip to content

Commit

Permalink
dlm: make find_rsb() fail gracefully when namelen is too large
Browse files Browse the repository at this point in the history
We *can* get there from receive_request() and dlm_recover_master_copy()
with namelen too large if incoming request is invalid; BUG() from
DLM_ASSERT() in allocate_rsb() is a bit excessive reaction to that
and in case of dlm_recover_master_copy() we would actually oops before
that while calculating hash of up to 64Kb worth of data - with data
actually being 64 _bytes_ in kmalloc()'ed struct.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David Teigland <teigland@redhat.com>
  • Loading branch information
Al Viro authored and David Teigland committed Feb 4, 2008
1 parent a5dd063 commit ef58bcc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/dlm/lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,15 @@ static int find_rsb(struct dlm_ls *ls, char *name, int namelen,
{
struct dlm_rsb *r, *tmp;
uint32_t hash, bucket;
int error = 0;
int error = -EINVAL;

if (namelen > DLM_RESNAME_MAXLEN)
goto out;

if (dlm_no_directory(ls))
flags |= R_CREATE;

error = 0;
hash = jhash(name, namelen, 0);
bucket = hash & (ls->ls_rsbtbl_size - 1);

Expand Down

0 comments on commit ef58bcc

Please sign in to comment.