The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: pavankumaryalagada@gmail.com
Cc: michael.christie@oracle.com, nab@linux-iscsi.org, mkp@kernel.org,
	leitao@debian.org, skhan@linuxfoundation.org,
	linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+a9efa71b884a23e74153@syzkaller.appspotmail.com,
	stable@vger.kernel.org
Subject: Re: [PATCH v2] usb: gadget: f_tcm: avoid NULL dereference in usbg_make_tpg()
Date: Fri, 20 Nov 2026 11:59:11 +0100	[thread overview]
Message-ID: <2026112001-emptiness-rewrap-28ef@gregkh> (raw)
In-Reply-To: <20260915080523.15979-1-pavankumaryalagada@gmail.com>

On Tue, Sep 15, 2026 at 01:35:23PM +0530, pavankumaryalagada@gmail.com wrote:
> From: Yalagada Pavan Kumar <pavankumaryalagada@gmail.com>
> 
> usbg_make_tpg() can race with creation of USB gadget function
> instance. tcm_alloc_inst() adds the function instance to
> tpg_instances before configfs links the item to its parent group.
> 
> As a result, usbg_make_tpg() can find the instance while its
> ci_group is still NULL. Passing this item to
> configfs_depend_item_unlocked() then causes a NULL pointer
> dereference.
> 
> Verify that ci_group is set before calling configfs_depend_item_unlocked()
> and fail TPG creation if the item has not been linked yet.
> 
> keep this validation in f_tcm instead of changing the configfs API to
> accept unlinked items.
> 
> Reported-by: syzbot+a9efa71b884a23e74153@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=a9efa71b884a23e74153
> Fixes: 4bb8548df632 ("usb: gadget: f_tcm: add configfs support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yalagada Pavan Kumar <pavankumaryalagada@gmail.com>
> ---
> Changes in v2:
>  - Move the NULL check from configfs to f_tcm.
>  - Restore configfs_depend_item_unlocked() to its original behaviour
> 
> v1: https://lore.kernel.org/all/20260914094426.25595-1-pavankumaryalagada@gmail.com/T/
> ---
>  drivers/usb/gadget/function/f_tcm.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
> index 9e6d4f39900a..2c2cf1164edf 100644
> --- a/drivers/usb/gadget/function/f_tcm.c
> +++ b/drivers/usb/gadget/function/f_tcm.c
> @@ -1682,6 +1682,9 @@ static struct se_portal_group *usbg_make_tpg(struct se_wwn *wwn,
>  		if (!try_module_get(opts->dependent))
>  			goto unlock_inst;
>  	} else {
> +		if (!READ_ONCE(opts->func_inst.group.cg_item.ci_group))
> +			goto unlock_inst;

Why READ_ONCE()?


      reply	other threads:[~2026-11-20 10:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15  8:05 [PATCH v2] usb: gadget: f_tcm: avoid NULL dereference in usbg_make_tpg() pavankumaryalagada
2026-11-20 10:59 ` Greg KH [this message]

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=2026112001-emptiness-rewrap-28ef@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=michael.christie@oracle.com \
    --cc=mkp@kernel.org \
    --cc=nab@linux-iscsi.org \
    --cc=pavankumaryalagada@gmail.com \
    --cc=skhan@linuxfoundation.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+a9efa71b884a23e74153@syzkaller.appspotmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox