Skip to content

Commit ccb48e8

Browse files
committed
Merge branch 'net-fix-uninit-values-in-networking-stack'
Eric Dumazet says: ==================== net: fix uninit-values in networking stack It seems syzbot got new features enabled, and fired some interesting reports. Oh well. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents f12c643 + 3099a52 commit ccb48e8

File tree

10 files changed

+20
-12
lines changed

10 files changed

+20
-12
lines changed

crypto/af_alg.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,16 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
158158
void *private;
159159
int err;
160160

161-
/* If caller uses non-allowed flag, return error. */
162-
if ((sa->salg_feat & ~allowed) || (sa->salg_mask & ~allowed))
163-
return -EINVAL;
164-
165161
if (sock->state == SS_CONNECTED)
166162
return -EINVAL;
167163

168164
if (addr_len < sizeof(*sa))
169165
return -EINVAL;
170166

167+
/* If caller uses non-allowed flag, return error. */
168+
if ((sa->salg_feat & ~allowed) || (sa->salg_mask & ~allowed))
169+
return -EINVAL;
170+
171171
sa->salg_type[sizeof(sa->salg_type) - 1] = 0;
172172
sa->salg_name[sizeof(sa->salg_name) + addr_len - sizeof(*sa) - 1] = 0;
173173

include/net/inet_timewait_sock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ struct inet_timewait_sock {
4343
#define tw_family __tw_common.skc_family
4444
#define tw_state __tw_common.skc_state
4545
#define tw_reuse __tw_common.skc_reuse
46+
#define tw_reuseport __tw_common.skc_reuseport
4647
#define tw_ipv6only __tw_common.skc_ipv6only
4748
#define tw_bound_dev_if __tw_common.skc_bound_dev_if
4849
#define tw_node __tw_common.skc_nulls_node

include/net/nexthop.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
static inline int rtnh_ok(const struct rtnexthop *rtnh, int remaining)
99
{
10-
return remaining >= sizeof(*rtnh) &&
10+
return remaining >= (int)sizeof(*rtnh) &&
1111
rtnh->rtnh_len >= sizeof(*rtnh) &&
1212
rtnh->rtnh_len <= remaining;
1313
}

net/core/dev_addr_lists.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ static int __hw_addr_add_ex(struct netdev_hw_addr_list *list,
5757
return -EINVAL;
5858

5959
list_for_each_entry(ha, &list->list, list) {
60-
if (!memcmp(ha->addr, addr, addr_len) &&
61-
ha->type == addr_type) {
60+
if (ha->type == addr_type &&
61+
!memcmp(ha->addr, addr, addr_len)) {
6262
if (global) {
6363
/* check if addr is already used as global */
6464
if (ha->global_use)

net/core/skbuff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,7 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb)
857857
n->hdr_len = skb->nohdr ? skb_headroom(skb) : skb->hdr_len;
858858
n->cloned = 1;
859859
n->nohdr = 0;
860+
n->peeked = 0;
860861
n->destructor = NULL;
861862
C(tail);
862863
C(end);

net/dccp/ipv4.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@ int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
614614
ireq = inet_rsk(req);
615615
sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
616616
sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
617+
ireq->ir_mark = inet_request_mark(sk, skb);
617618
ireq->ireq_family = AF_INET;
618619
ireq->ir_iif = sk->sk_bound_dev_if;
619620

net/dccp/ipv6.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
351351
ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
352352
ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
353353
ireq->ireq_family = AF_INET6;
354+
ireq->ir_mark = inet_request_mark(sk, skb);
354355

355356
if (ipv6_opt_accepted(sk, skb, IP6CB(skb)) ||
356357
np->rxopt.bits.rxinfo || np->rxopt.bits.rxoinfo ||

net/ipv4/inet_timewait_sock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk,
178178
tw->tw_dport = inet->inet_dport;
179179
tw->tw_family = sk->sk_family;
180180
tw->tw_reuse = sk->sk_reuse;
181+
tw->tw_reuseport = sk->sk_reuseport;
181182
tw->tw_hash = sk->sk_hash;
182183
tw->tw_ipv6only = 0;
183184
tw->tw_transparent = inet->transparent;

net/ipv4/route.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,13 +2297,14 @@ struct rtable *ip_route_output_key_hash(struct net *net, struct flowi4 *fl4,
22972297
const struct sk_buff *skb)
22982298
{
22992299
__u8 tos = RT_FL_TOS(fl4);
2300-
struct fib_result res;
2300+
struct fib_result res = {
2301+
.type = RTN_UNSPEC,
2302+
.fi = NULL,
2303+
.table = NULL,
2304+
.tclassid = 0,
2305+
};
23012306
struct rtable *rth;
23022307

2303-
res.tclassid = 0;
2304-
res.fi = NULL;
2305-
res.table = NULL;
2306-
23072308
fl4->flowi4_iif = LOOPBACK_IFINDEX;
23082309
fl4->flowi4_tos = tos & IPTOS_RT_MASK;
23092310
fl4->flowi4_scope = ((tos & RTO_ONLINK) ?

net/netlink/af_netlink.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,8 @@ static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
18441844

18451845
if (msg->msg_namelen) {
18461846
err = -EINVAL;
1847+
if (msg->msg_namelen < sizeof(struct sockaddr_nl))
1848+
goto out;
18471849
if (addr->nl_family != AF_NETLINK)
18481850
goto out;
18491851
dst_portid = addr->nl_pid;

0 commit comments

Comments
 (0)