Skip to content

Commit 70549c8

Browse files
wangyufen316gregkh
authored andcommitted
ipv6: Fix signed integer overflow in __ip6_append_data
commit f93431c upstream. Resurrect ubsan overflow checks and ubsan report this warning, fix it by change the variable [length] type to size_t. UBSAN: signed-integer-overflow in net/ipv6/ip6_output.c:1489:19 2147479552 + 8567 cannot be represented in type 'int' CPU: 0 PID: 253 Comm: err Not tainted 5.16.0+ #1 Hardware name: linux,dummy-virt (DT) Call trace: dump_backtrace+0x214/0x230 show_stack+0x30/0x78 dump_stack_lvl+0xf8/0x118 dump_stack+0x18/0x30 ubsan_epilogue+0x18/0x60 handle_overflow+0xd0/0xf0 __ubsan_handle_add_overflow+0x34/0x44 __ip6_append_data.isra.48+0x1598/0x1688 ip6_append_data+0x128/0x260 udpv6_sendmsg+0x680/0xdd0 inet6_sendmsg+0x54/0x90 sock_sendmsg+0x70/0x88 ____sys_sendmsg+0xe8/0x368 ___sys_sendmsg+0x98/0xe0 __sys_sendmmsg+0xf4/0x3b8 __arm64_sys_sendmmsg+0x34/0x48 invoke_syscall+0x64/0x160 el0_svc_common.constprop.4+0x124/0x300 do_el0_svc+0x44/0xc8 el0_svc+0x3c/0x1e8 el0t_64_sync_handler+0x88/0xb0 el0t_64_sync+0x16c/0x170 Changes since v1: -Change the variable [length] type to unsigned, as Eric Dumazet suggested. Changes since v2: -Don't change exthdrlen type in ip6_make_skb, as Paolo Abeni suggested. Changes since v3: -Don't change ulen type in udpv6_sendmsg and l2tp_ip6_sendmsg, as Jakub Kicinski suggested. Reported-by: Hulk Robot <[email protected]> Signed-off-by: Wang Yufen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]> [ Conflict due to f37a4cc ("udp6: pass flow in ip6_make_skb together with cork") not in the tree ] Signed-off-by: Abdelkareem Abdelsaamad <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 21c0225 commit 70549c8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/net/ipv6.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr);
10001000
int ip6_append_data(struct sock *sk,
10011001
int getfrag(void *from, char *to, int offset, int len,
10021002
int odd, struct sk_buff *skb),
1003-
void *from, int length, int transhdrlen,
1003+
void *from, size_t length, int transhdrlen,
10041004
struct ipcm6_cookie *ipc6, struct flowi6 *fl6,
10051005
struct rt6_info *rt, unsigned int flags);
10061006

@@ -1016,7 +1016,7 @@ struct sk_buff *__ip6_make_skb(struct sock *sk, struct sk_buff_head *queue,
10161016
struct sk_buff *ip6_make_skb(struct sock *sk,
10171017
int getfrag(void *from, char *to, int offset,
10181018
int len, int odd, struct sk_buff *skb),
1019-
void *from, int length, int transhdrlen,
1019+
void *from, size_t length, int transhdrlen,
10201020
struct ipcm6_cookie *ipc6, struct flowi6 *fl6,
10211021
struct rt6_info *rt, unsigned int flags,
10221022
struct inet_cork_full *cork);

net/ipv6/ip6_output.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,7 +1461,7 @@ static int __ip6_append_data(struct sock *sk,
14611461
struct page_frag *pfrag,
14621462
int getfrag(void *from, char *to, int offset,
14631463
int len, int odd, struct sk_buff *skb),
1464-
void *from, int length, int transhdrlen,
1464+
void *from, size_t length, int transhdrlen,
14651465
unsigned int flags, struct ipcm6_cookie *ipc6)
14661466
{
14671467
struct sk_buff *skb, *skb_prev = NULL;
@@ -1806,7 +1806,7 @@ static int __ip6_append_data(struct sock *sk,
18061806
int ip6_append_data(struct sock *sk,
18071807
int getfrag(void *from, char *to, int offset, int len,
18081808
int odd, struct sk_buff *skb),
1809-
void *from, int length, int transhdrlen,
1809+
void *from, size_t length, int transhdrlen,
18101810
struct ipcm6_cookie *ipc6, struct flowi6 *fl6,
18111811
struct rt6_info *rt, unsigned int flags)
18121812
{
@@ -2000,7 +2000,7 @@ EXPORT_SYMBOL_GPL(ip6_flush_pending_frames);
20002000
struct sk_buff *ip6_make_skb(struct sock *sk,
20012001
int getfrag(void *from, char *to, int offset,
20022002
int len, int odd, struct sk_buff *skb),
2003-
void *from, int length, int transhdrlen,
2003+
void *from, size_t length, int transhdrlen,
20042004
struct ipcm6_cookie *ipc6, struct flowi6 *fl6,
20052005
struct rt6_info *rt, unsigned int flags,
20062006
struct inet_cork_full *cork)

0 commit comments

Comments
 (0)