From: Phillip Potter <phil@philpotter.co.uk> Date: 2021-04-05 11:36:02
When changing type with TUNSETLINK ioctl command, set tun->dev->addr_len
to match the appropriate type, using new tun_get_addr_len utility function
which returns appropriate address length for given type. Fixes a
KMSAN-found uninit-value bug reported by syzbot at:
https://syzkaller.appspot.com/bug?id=0766d38c656abeace60621896d705743aeefed51
Reported-by: syzbot+001516d86dbe88862cec@syzkaller.appspotmail.com
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
drivers/net/tun.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
@@ -2925,6 +2933,45 @@ static int tun_set_ebpf(struct tun_struct *tun, struct tun_prog __rcu **prog_p,return__tun_set_ebpf(tun,prog_p,prog);}+/* Return correct value for tun->dev->addr_len based on tun->dev->type. */+staticinlineunsignedchartun_get_addr_len(unsignedshorttype)+{+switch(type){+caseARPHRD_IP6GRE:+caseARPHRD_TUNNEL6:+returnsizeof(structin6_addr);+caseARPHRD_IPGRE:+caseARPHRD_TUNNEL:+caseARPHRD_SIT:+return4;+caseARPHRD_ETHER:+returnETH_ALEN;+caseARPHRD_IEEE802154:+caseARPHRD_IEEE802154_MONITOR:+returnIEEE802154_EXTENDED_ADDR_LEN;+caseARPHRD_PHONET_PIPE:+caseARPHRD_PPP:+caseARPHRD_NONE:+return0;+caseARPHRD_6LOWPAN:+returnEUI64_ADDR_LEN;+caseARPHRD_FDDI:+returnFDDI_K_ALEN;+caseARPHRD_HIPPI:+returnHIPPI_ALEN;+caseARPHRD_IEEE802:+returnFC_ALEN;+caseARPHRD_ROSE:+returnROSE_ADDR_LEN;+caseARPHRD_NETROM:+returnAX25_ADDR_LEN;+caseARPHRD_LOCALTLK:+returnLTALK_ALEN;+default:+return0;+}+}+staticlong__tun_chr_ioctl(structfile*file,unsignedintcmd,unsignedlongarg,intifreq_len){
@@ -3088,6 +3135,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,break;}tun->dev->type=(int)arg;+tun->dev->addr_len=tun_get_addr_len(tun->dev->type);netif_info(tun,drv,tun->dev,"linktype set to %d\n",tun->dev->type);call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE,
When changing type with TUNSETLINK ioctl command, set tun->dev->addr_len
to match the appropriate type, using new tun_get_addr_len utility function
which returns appropriate address length for given type. Fixes a
KMSAN-found uninit-value bug reported by syzbot at:
https://syzkaller.appspot.com/bug?id=0766d38c656abeace60621896d705743aeefed51
Reported-by: syzbot+001516d86dbe88862cec@syzkaller.appspotmail.com
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
drivers/net/tun.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
@@ -2925,6 +2933,45 @@ static int tun_set_ebpf(struct tun_struct *tun, struct tun_prog __rcu **prog_p,return__tun_set_ebpf(tun,prog_p,prog);}+/* Return correct value for tun->dev->addr_len based on tun->dev->type. */+staticinlineunsignedchartun_get_addr_len(unsignedshorttype)+{
Please do not use inline in foo.c files, let the compiler decide.
Thanks.
When changing type with TUNSETLINK ioctl command, set tun->dev->addr_len
to match the appropriate type, using new tun_get_addr_len utility function
which returns appropriate address length for given type. Fixes a
KMSAN-found uninit-value bug reported by syzbot at:
https://syzkaller.appspot.com/bug?id=0766d38c656abeace60621896d705743aeefed51
Reported-by: syzbot+001516d86dbe88862cec@syzkaller.appspotmail.com
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
drivers/net/tun.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
@@ -2925,6 +2933,45 @@ static int tun_set_ebpf(struct tun_struct *tun, struct tun_prog __rcu **prog_p,return__tun_set_ebpf(tun,prog_p,prog);}+/* Return correct value for tun->dev->addr_len based on tun->dev->type. */+staticinlineunsignedchartun_get_addr_len(unsignedshorttype)+{
Please do not use inline in foo.c files, let the compiler decide.
Thanks.
Dear David,
Thank you for the feedback, I will resend.
Regards,
Phil
From: Eric Dumazet <hidden> Date: 2021-04-06 17:26:35
On 4/5/21 1:35 PM, Phillip Potter wrote:
When changing type with TUNSETLINK ioctl command, set tun->dev->addr_len
to match the appropriate type, using new tun_get_addr_len utility function
which returns appropriate address length for given type. Fixes a
KMSAN-found uninit-value bug reported by syzbot at:
https://syzkaller.appspot.com/bug?id=0766d38c656abeace60621896d705743aeefed51
Reported-by: syzbot+001516d86dbe88862cec@syzkaller.appspotmail.com
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
Please give credits to people who helped.
You could have :
Suggested-by: Eric Dumazet <edumazet@google.com>
Or
Diagnosed-by: Eric Dumazet [off-list ref]
Or at least CCed me :/
From: Phillip Potter <phil@philpotter.co.uk> Date: 2021-04-06 17:39:04
On Tue, Apr 06, 2021 at 07:26:29PM +0200, Eric Dumazet wrote:
On 4/5/21 1:35 PM, Phillip Potter wrote:
quoted
When changing type with TUNSETLINK ioctl command, set tun->dev->addr_len
to match the appropriate type, using new tun_get_addr_len utility function
which returns appropriate address length for given type. Fixes a
KMSAN-found uninit-value bug reported by syzbot at:
https://syzkaller.appspot.com/bug?id=0766d38c656abeace60621896d705743aeefed51
Reported-by: syzbot+001516d86dbe88862cec@syzkaller.appspotmail.com
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
Please give credits to people who helped.
You could have :
Suggested-by: Eric Dumazet <edumazet@google.com>
Or
Diagnosed-by: Eric Dumazet [off-list ref]
Or at least CCed me :/
Dear Eric,
Please accept my apology for this oversight. It certainly wasn't
intentional on my part, and entirely down to inexperience. I will send
the patch again with Diagnosed-by.
Regards,
Phil