提交 bcb1dc73 编写于 作者: W Willem de Bruijn 提交者: Xie XiuQi

net: always initialize pagedlen

mainline inclusion
from mainline-4.20
commit aba36930a35e
category: bugfix
bugzilla: 6118
CVE: NA

-------------------------------------------------

In ip packet generation, pagedlen is initialized for each skb at the
start of the loop in __ip(6)_append_data, before label alloc_new_skb.

Depending on compiler options, code can be generated that jumps to
this label, triggering use of an an uninitialized variable.

In practice, at -O2, the generated code moves the initialization below
the label. But the code should not rely on that for correctness.

Fixes: 15e36f5b ("udp: paged allocation with gso")
Signed-off-by: NWillem de Bruijn <willemb@google.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NKeefe LIU <liuqifa@huawei.com>
Reviewed-by: NWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 014610d0
...@@ -939,7 +939,7 @@ static int __ip_append_data(struct sock *sk, ...@@ -939,7 +939,7 @@ static int __ip_append_data(struct sock *sk,
unsigned int fraglen; unsigned int fraglen;
unsigned int fraggap; unsigned int fraggap;
unsigned int alloclen; unsigned int alloclen;
unsigned int pagedlen = 0; unsigned int pagedlen;
struct sk_buff *skb_prev; struct sk_buff *skb_prev;
alloc_new_skb: alloc_new_skb:
skb_prev = skb; skb_prev = skb;
...@@ -956,6 +956,7 @@ static int __ip_append_data(struct sock *sk, ...@@ -956,6 +956,7 @@ static int __ip_append_data(struct sock *sk,
if (datalen > mtu - fragheaderlen) if (datalen > mtu - fragheaderlen)
datalen = maxfraglen - fragheaderlen; datalen = maxfraglen - fragheaderlen;
fraglen = datalen + fragheaderlen; fraglen = datalen + fragheaderlen;
pagedlen = 0;
if ((flags & MSG_MORE) && if ((flags & MSG_MORE) &&
!(rt->dst.dev->features&NETIF_F_SG)) !(rt->dst.dev->features&NETIF_F_SG))
......
...@@ -1355,7 +1355,7 @@ static int __ip6_append_data(struct sock *sk, ...@@ -1355,7 +1355,7 @@ static int __ip6_append_data(struct sock *sk,
unsigned int fraglen; unsigned int fraglen;
unsigned int fraggap; unsigned int fraggap;
unsigned int alloclen; unsigned int alloclen;
unsigned int pagedlen = 0; unsigned int pagedlen;
alloc_new_skb: alloc_new_skb:
/* There's no room in the current skb */ /* There's no room in the current skb */
if (skb) if (skb)
...@@ -1379,6 +1379,7 @@ static int __ip6_append_data(struct sock *sk, ...@@ -1379,6 +1379,7 @@ static int __ip6_append_data(struct sock *sk,
if (datalen > (cork->length <= mtu && !(cork->flags & IPCORK_ALLFRAG) ? mtu : maxfraglen) - fragheaderlen) if (datalen > (cork->length <= mtu && !(cork->flags & IPCORK_ALLFRAG) ? mtu : maxfraglen) - fragheaderlen)
datalen = maxfraglen - fragheaderlen - rt->dst.trailer_len; datalen = maxfraglen - fragheaderlen - rt->dst.trailer_len;
fraglen = datalen + fragheaderlen; fraglen = datalen + fragheaderlen;
pagedlen = 0;
if ((flags & MSG_MORE) && if ((flags & MSG_MORE) &&
!(rt->dst.dev->features&NETIF_F_SG)) !(rt->dst.dev->features&NETIF_F_SG))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册