Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/teigland/dlm

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/dlm:
  dlm: add __init and __exit marks to init and exit functions
  dlm: eliminate astparam type casting
  dlm: proper types for asts and basts
  dlm: dlm/user.c input validation fixes
  dlm: fix dlm_dir_lookup() handling of too long names
  dlm: fix overflows when copying from ->m_extra to lvb
  dlm: make find_rsb() fail gracefully when namelen is too large
  dlm: receive_rcom_lock_args() overflow check
  dlm: verify that places expecting rcom_lock have packet long enough
  dlm: validate data in dlm_recover_directory()
  dlm: missing length check in check_config()
  dlm: use proper type for ->ls_recover_buf
  dlm: do not byteswap rcom_config
  dlm: do not byteswap rcom_lock
  dlm: dlm_process_incoming_buffer() fixes
  dlm: use proper C for dlm/requestqueue stuff (and fix alignment bug)
  • Loading branch information
Linus Torvalds committed Feb 8, 2008
2 parents dde0013 + 3072717 commit b5eb951
Show file tree
Hide file tree
Showing 17 changed files with 235 additions and 225 deletions.
9 changes: 4 additions & 5 deletions fs/dlm/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ void dlm_add_ast(struct dlm_lkb *lkb, int type)
dlm_user_add_ast(lkb, type);
return;
}
DLM_ASSERT(lkb->lkb_astaddr != DLM_FAKE_USER_AST, dlm_print_lkb(lkb););

spin_lock(&ast_queue_lock);
if (!(lkb->lkb_ast_type & (AST_COMP | AST_BAST))) {
Expand All @@ -58,8 +57,8 @@ static void process_asts(void)
struct dlm_ls *ls = NULL;
struct dlm_rsb *r = NULL;
struct dlm_lkb *lkb;
void (*cast) (long param);
void (*bast) (long param, int mode);
void (*cast) (void *astparam);
void (*bast) (void *astparam, int mode);
int type = 0, found, bmode;

for (;;) {
Expand All @@ -83,8 +82,8 @@ static void process_asts(void)
if (!found)
break;

cast = lkb->lkb_astaddr;
bast = lkb->lkb_bastaddr;
cast = lkb->lkb_astfn;
bast = lkb->lkb_bastfn;
bmode = lkb->lkb_bastmode;

if ((type & AST_COMP) && cast)
Expand Down
2 changes: 1 addition & 1 deletion fs/dlm/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ static struct clusters clusters_root = {
},
};

int dlm_config_init(void)
int __init dlm_config_init(void)
{
config_group_init(&clusters_root.subsys.su_group);
mutex_init(&clusters_root.subsys.su_mutex);
Expand Down
8 changes: 3 additions & 5 deletions fs/dlm/debug_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,12 @@ static int print_resource(struct dlm_rsb *res, struct seq_file *s)

static void print_lock(struct seq_file *s, struct dlm_lkb *lkb, struct dlm_rsb *r)
{
struct dlm_user_args *ua;
unsigned int waiting = 0;
uint64_t xid = 0;

if (lkb->lkb_flags & DLM_IFL_USER) {
ua = (struct dlm_user_args *) lkb->lkb_astparam;
if (ua)
xid = ua->xid;
if (lkb->lkb_ua)
xid = lkb->lkb_ua->xid;
}

if (lkb->lkb_timestamp)
Expand Down Expand Up @@ -543,7 +541,7 @@ void dlm_delete_debug_file(struct dlm_ls *ls)
debugfs_remove(ls->ls_debug_locks_dentry);
}

int dlm_register_debugfs(void)
int __init dlm_register_debugfs(void)
{
mutex_init(&debug_buf_lock);
dlm_root = debugfs_create_dir("dlm", NULL);
Expand Down
28 changes: 24 additions & 4 deletions fs/dlm/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ int dlm_recover_directory(struct dlm_ls *ls)
last_len = 0;

for (;;) {
int left;
error = dlm_recovery_stopped(ls);
if (error)
goto out_free;
Expand All @@ -235,12 +236,21 @@ int dlm_recover_directory(struct dlm_ls *ls)
* pick namelen/name pairs out of received buffer
*/

b = ls->ls_recover_buf + sizeof(struct dlm_rcom);
b = ls->ls_recover_buf->rc_buf;
left = ls->ls_recover_buf->rc_header.h_length;
left -= sizeof(struct dlm_rcom);

for (;;) {
memcpy(&namelen, b, sizeof(uint16_t));
namelen = be16_to_cpu(namelen);
b += sizeof(uint16_t);
__be16 v;

error = -EINVAL;
if (left < sizeof(__be16))
goto out_free;

memcpy(&v, b, sizeof(__be16));
namelen = be16_to_cpu(v);
b += sizeof(__be16);
left -= sizeof(__be16);

/* namelen of 0xFFFFF marks end of names for
this node; namelen of 0 marks end of the
Expand All @@ -251,6 +261,12 @@ int dlm_recover_directory(struct dlm_ls *ls)
if (!namelen)
break;

if (namelen > left)
goto out_free;

if (namelen > DLM_RESNAME_MAXLEN)
goto out_free;

error = -ENOMEM;
de = get_free_de(ls, namelen);
if (!de)
Expand All @@ -262,6 +278,7 @@ int dlm_recover_directory(struct dlm_ls *ls)
memcpy(de->name, b, namelen);
memcpy(last_name, b, namelen);
b += namelen;
left -= namelen;

add_entry_to_hash(ls, de);
count++;
Expand Down Expand Up @@ -302,6 +319,9 @@ static int get_entry(struct dlm_ls *ls, int nodeid, char *name,

write_unlock(&ls->ls_dirtbl[bucket].lock);

if (namelen > DLM_RESNAME_MAXLEN)
return -EINVAL;

de = kzalloc(sizeof(struct dlm_direntry) + namelen, GFP_KERNEL);
if (!de)
return -ENOMEM;
Expand Down
53 changes: 30 additions & 23 deletions fs/dlm/dlm_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ do { \
} \
}

#define DLM_FAKE_USER_AST ERR_PTR(-EINVAL)


struct dlm_direntry {
struct list_head list;
Expand Down Expand Up @@ -146,9 +144,9 @@ struct dlm_recover {

struct dlm_args {
uint32_t flags;
void *astaddr;
long astparam;
void *bastaddr;
void (*astfn) (void *astparam);
void *astparam;
void (*bastfn) (void *astparam, int mode);
int mode;
struct dlm_lksb *lksb;
unsigned long timeout;
Expand Down Expand Up @@ -253,9 +251,12 @@ struct dlm_lkb {

char *lkb_lvbptr;
struct dlm_lksb *lkb_lksb; /* caller's status block */
void *lkb_astaddr; /* caller's ast function */
void *lkb_bastaddr; /* caller's bast function */
long lkb_astparam; /* caller's ast arg */
void (*lkb_astfn) (void *astparam);
void (*lkb_bastfn) (void *astparam, int mode);
union {
void *lkb_astparam; /* caller's ast arg */
struct dlm_user_args *lkb_ua;
};
};


Expand Down Expand Up @@ -403,28 +404,34 @@ struct dlm_rcom {
char rc_buf[0];
};

union dlm_packet {
struct dlm_header header; /* common to other two */
struct dlm_message message;
struct dlm_rcom rcom;
};

struct rcom_config {
uint32_t rf_lvblen;
uint32_t rf_lsflags;
uint64_t rf_unused;
__le32 rf_lvblen;
__le32 rf_lsflags;
__le64 rf_unused;
};

struct rcom_lock {
uint32_t rl_ownpid;
uint32_t rl_lkid;
uint32_t rl_remid;
uint32_t rl_parent_lkid;
uint32_t rl_parent_remid;
uint32_t rl_exflags;
uint32_t rl_flags;
uint32_t rl_lvbseq;
int rl_result;
__le32 rl_ownpid;
__le32 rl_lkid;
__le32 rl_remid;
__le32 rl_parent_lkid;
__le32 rl_parent_remid;
__le32 rl_exflags;
__le32 rl_flags;
__le32 rl_lvbseq;
__le32 rl_result;
int8_t rl_rqmode;
int8_t rl_grmode;
int8_t rl_status;
int8_t rl_asts;
uint16_t rl_wait_type;
uint16_t rl_namelen;
__le16 rl_wait_type;
__le16 rl_namelen;
char rl_name[DLM_RESNAME_MAXLEN];
char rl_lvb[0];
};
Expand Down Expand Up @@ -494,7 +501,7 @@ struct dlm_ls {
struct rw_semaphore ls_recv_active; /* block dlm_recv */
struct list_head ls_requestqueue;/* queue remote requests */
struct mutex ls_requestqueue_mutex;
char *ls_recover_buf;
struct dlm_rcom *ls_recover_buf;
int ls_recover_nodeid; /* for debugging */
uint64_t ls_rcom_seq;
spinlock_t ls_rcom_spin;
Expand Down
Loading

0 comments on commit b5eb951

Please sign in to comment.