From: Greg KH <gregkh@linuxfoundation.org>
To: Bradley Bolen <bradleybolen@gmail.com>
Cc: stable@vger.kernel.org
Subject: Re: [PATCH] UBI: block: Fix locking for idr_alloc/idr_remove
Date: Thu, 18 Jan 2018 14:55:09 +0100 [thread overview]
Message-ID: <20180118135509.GA24935@kroah.com> (raw)
In-Reply-To: <1516283261-10968-1-git-send-email-bbolen@lexmark.com>
On Thu, Jan 18, 2018 at 08:47:41AM -0500, Bradley Bolen wrote:
> From: Bradley Bolen <bradleybolen@gmail.com>
>
> This fixes a race with idr_alloc where gd->first_minor can be set to the
> same value for two simultaneous calls to ubiblock_create. Each instance
> calls device_add_disk with the same first_minor. device_add_disk calls
> bdi_register_owner which generates several warnings.
>
> WARNING: CPU: 1 PID: 179 at kernel-source/fs/sysfs/dir.c:31
> sysfs_warn_dup+0x68/0x88
> sysfs: cannot create duplicate filename '/devices/virtual/bdi/252:2'
>
> WARNING: CPU: 1 PID: 179 at kernel-source/lib/kobject.c:240
> kobject_add_internal+0x1ec/0x2f8
> kobject_add_internal failed for 252:2 with -EEXIST, don't try to
> register things with the same name in the same directory
>
> WARNING: CPU: 1 PID: 179 at kernel-source/fs/sysfs/dir.c:31
> sysfs_warn_dup+0x68/0x88
> sysfs: cannot create duplicate filename '/dev/block/252:2'
>
> However, device_add_disk does not error out when bdi_register_owner
> returns an error. Control continues until reaching blk_register_queue.
> It then BUGs.
>
> kernel BUG at kernel-source/fs/sysfs/group.c:113!
> [<c01e26cc>] (internal_create_group) from [<c01e2950>]
> (sysfs_create_group+0x20/0x24)
> [<c01e2950>] (sysfs_create_group) from [<c00e3d38>]
> (blk_trace_init_sysfs+0x18/0x20)
> [<c00e3d38>] (blk_trace_init_sysfs) from [<c02bdfbc>]
> (blk_register_queue+0xd8/0x154)
> [<c02bdfbc>] (blk_register_queue) from [<c02cec84>]
> (device_add_disk+0x194/0x44c)
> [<c02cec84>] (device_add_disk) from [<c0436ec8>]
> (ubiblock_create+0x284/0x2e0)
> [<c0436ec8>] (ubiblock_create) from [<c0427bb8>]
> (vol_cdev_ioctl+0x450/0x554)
> [<c0427bb8>] (vol_cdev_ioctl) from [<c0189110>] (vfs_ioctl+0x30/0x44)
> [<c0189110>] (vfs_ioctl) from [<c01892e0>] (do_vfs_ioctl+0xa0/0x790)
> [<c01892e0>] (do_vfs_ioctl) from [<c0189a14>] (SyS_ioctl+0x44/0x68)
> [<c0189a14>] (SyS_ioctl) from [<c0010640>] (ret_fast_syscall+0x0/0x34)
>
> Locking idr_alloc/idr_remove removes the race and keeps gd->first_minor
> unique.
>
> Fixes: 2bf50d42f3a4 ("UBI: block: Dynamically allocate minor numbers")
> Cc: stable@vger.kernel.org
> Signed-off-by: Bradley Bolen <bradleybolen@gmail.com>
> ---
> drivers/mtd/ubi/block.c | 42 ++++++++++++++++++++++++++----------------
> 1 file changed, 26 insertions(+), 16 deletions(-)
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
It's also not how you submit patches upstream, you have read
Documentation/SubmittingPatches, right?
thanks,
greg k-h
next prev parent reply other threads:[~2018-01-18 13:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-18 13:47 [PATCH] UBI: block: Fix locking for idr_alloc/idr_remove Bradley Bolen
2018-01-18 13:55 ` Greg KH [this message]
2018-01-18 14:20 ` Brad Bolen
-- strict thread matches above, loose matches on Subject: below --
2018-01-18 13:55 Bradley Bolen
2018-01-18 15:13 ` Boris Brezillon
2018-01-18 15:49 ` Richard Weinberger
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=20180118135509.GA24935@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=bradleybolen@gmail.com \
--cc=stable@vger.kernel.org \
/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.