Skip to content

Commit 02ed16b

Browse files
Al Viroteigland
authored andcommitted
dlm: missing length check in check_config()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David Teigland <teigland@redhat.com>
1 parent 4007685 commit 02ed16b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎fs/dlm/rcom.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static void make_config(struct dlm_ls *ls, struct rcom_config *rf)
8585
static int check_config(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid)
8686
{
8787
struct rcom_config *rf = (struct rcom_config *) rc->rc_buf;
88+
size_t conf_size = sizeof(struct dlm_rcom) + sizeof(struct rcom_config);
8889

8990
if ((rc->rc_header.h_version & 0xFFFF0000) != DLM_HEADER_MAJOR) {
9091
log_error(ls, "version mismatch: %x nodeid %d: %x",
@@ -93,6 +94,12 @@ static int check_config(struct dlm_ls *ls, struct dlm_rcom *rc, int nodeid)
9394
return -EPROTO;
9495
}
9596

97+
if (rc->rc_header.h_length < conf_size) {
98+
log_error(ls, "config too short: %d nodeid %d",
99+
rc->rc_header.h_length, nodeid);
100+
return -EPROTO;
101+
}
102+
96103
if (le32_to_cpu(rf->rf_lvblen) != ls->ls_lvblen ||
97104
le32_to_cpu(rf->rf_lsflags) != ls->ls_exflags) {
98105
log_error(ls, "config mismatch: %d,%x nodeid %d: %d,%x",

0 commit comments

Comments
 (0)