Re: [PATCH] net: tun: set tun->dev->addr_len during TUNSETLINK processing

From: Phillip Potter
Date: Tue Apr 06 2021 - 06:19:18 EST


On Mon, Apr 05, 2021 at 02:59:21PM -0700, David Miller wrote:
> From: Phillip Potter <phil@xxxxxxxxxxxxxxxx>
> Date: Mon, 5 Apr 2021 12:35:55 +0100
>
> > 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@xxxxxxxxxxxxxxxxxxxxxxxxx
> > Signed-off-by: Phillip Potter <phil@xxxxxxxxxxxxxxxx>
> > ---
> > drivers/net/tun.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 48 insertions(+)
> >
> > diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> > index 978ac0981d16..56c26339ee3b 100644
> > --- a/drivers/net/tun.c
> > +++ b/drivers/net/tun.c
> > @@ -69,6 +69,14 @@
> > #include <linux/bpf.h>
> > #include <linux/bpf_trace.h>
> > #include <linux/mutex.h>
> > +#include <linux/ieee802154.h>
> > +#include <linux/if_ltalk.h>
> > +#include <uapi/linux/if_fddi.h>
> > +#include <uapi/linux/if_hippi.h>
> > +#include <uapi/linux/if_fc.h>
> > +#include <net/ax25.h>
> > +#include <net/rose.h>
> > +#include <net/6lowpan.h>
> >
> > #include <linux/uaccess.h>
> > #include <linux/proc_fs.h>
> > @@ -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. */
> > +static inline unsigned char tun_get_addr_len(unsigned short type)
> > +{
>
> 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