Skip to content

Commit

Permalink
tipc: fix message importance range check
Browse files Browse the repository at this point in the history
Commit 3b4f302 ("tipc: eliminate
redundant locking") introduced a bug by removing the sanity check
for message importance, allowing programs to assign any value to
the msg_user field. This will mess up the packet reception logic
and may cause random link resets.

Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Erik Hugne authored and David S. Miller committed Aug 17, 2014
1 parent 2100968 commit ac32c7f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion net/tipc/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,10 @@ static inline int tipc_port_importance(struct tipc_port *port)
return msg_importance(&port->phdr);
}

static inline void tipc_port_set_importance(struct tipc_port *port, int imp)
static inline int tipc_port_set_importance(struct tipc_port *port, int imp)
{
if (imp > TIPC_CRITICAL_IMPORTANCE)
return -EINVAL
msg_set_importance(&port->phdr, (u32)imp);
}

Expand Down
2 changes: 1 addition & 1 deletion net/tipc/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ static int tipc_setsockopt(struct socket *sock, int lvl, int opt,

switch (opt) {
case TIPC_IMPORTANCE:
tipc_port_set_importance(port, value);
res = tipc_port_set_importance(port, value);
break;
case TIPC_SRC_DROPPABLE:
if (sock->type != SOCK_STREAM)
Expand Down

0 comments on commit ac32c7f

Please sign in to comment.