All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Alexander Bendezu <alexanderbendezu10@gmail.com>
Cc: Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
	Felipe Balbi <balbi@ti.com>,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzkaller-bugs@googlegroups.com,
	syzbot+3a0d6aa450317f25e501@syzkaller.appspotmail.com
Subject: Re: [PATCH] usb: gadget: f_phonet: fix out-of-bounds read in ifname_show
Date: Sat, 22 Aug 2026 11:25:46 +0200	[thread overview]
Message-ID: <2026082242-celery-circle-dee9@gregkh> (raw)
In-Reply-To: <20260822075230.70609-1-alexanderbendezu10@gmail.com>

On Sat, Aug 22, 2026 at 07:52:30AM +0000, Alexander Bendezu wrote:
> The f_phonet_ifname_show() function incorrectly used gether_get_ifname(),
> which casts the net_device private data to 'struct eth_dev'. Since the
> Phonet gadget only allocates a small 'struct phonet_port' for its private
> data, this resulted in a KASAN slab-out-of-bounds read when accessing
> dev->ifname_set.
> 
> Fix this by safely reading the network device name directly using
> netdev_name() and dropping the u_ether.h include, completely avoiding
> the invalid struct cast.
> 
> Fixes: 0736390bea65 ("usb-gadget/f_phonet: use per-attribute show and store methods")
> Reported-by: syzbot+3a0d6aa450317f25e501@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=3a0d6aa450317f25e501
> Signed-off-by: Alexander Bendezu <alexanderbendezu10@gmail.com>
> ---
>  drivers/usb/gadget/function/f_phonet.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/function/f_phonet.c b/drivers/usb/gadget/function/f_phonet.c
> index b1ee9a7c2e94..a17e74bcc07c 100644
> --- a/drivers/usb/gadget/function/f_phonet.c
> +++ b/drivers/usb/gadget/function/f_phonet.c
> @@ -13,6 +13,7 @@
>  #include <linux/module.h>
>  #include <linux/device.h>
>  
> +#include <linux/rtnetlink.h>
>  #include <linux/netdevice.h>
>  #include <linux/if_ether.h>
>  #include <linux/if_phonet.h>
> @@ -600,7 +601,13 @@ static const struct configfs_item_operations phonet_item_ops = {
>  
>  static ssize_t f_phonet_ifname_show(struct config_item *item, char *page)
>  {
> -	return gether_get_ifname(to_f_phonet_opts(item)->net, page, PAGE_SIZE);

So this has never worked at all?  How has no one noticed this in the
past decade?

> +	struct net_device *net = to_f_phonet_opts(item)->net;
> +	int ret;
> +
> +	rtnl_lock();
> +	ret = scnprintf(page, PAGE_SIZE, "%s\n", netdev_name(net));

sysfs_emit() please.

And what is the lock really doing here?  Why would this configfs file be
here if there was not a netdev present?

thanks,

greg k-h

  reply	other threads:[~2026-08-22  9:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-22  7:52 [PATCH] usb: gadget: f_phonet: fix out-of-bounds read in ifname_show Alexander Bendezu
2026-08-22  9:25 ` Greg Kroah-Hartman [this message]
2026-09-13  0:05   ` [PATCH v2] usb: gadget: f_phonet: don't call gether_get_ifname() on a non-u_ether netdev Alexander Bendezu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2026082242-celery-circle-dee9@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=alexanderbendezu10@gmail.com \
    --cc=andrzej.p@samsung.com \
    --cc=balbi@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=syzbot+3a0d6aa450317f25e501@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.