On Thu, Aug 15, 2019 at 05:09:45PM -0700, Scott Branden wrote:
A race condition exists between _request_firmware_prepare checkingI am not buying this fix, and it seems sloppy. More below.
if firmware is assigned and firmware_fallback_sysfs creating a sysfs
entry (kernel trace below). To avoid such condition add a mutex
fw_lock_fallback to protect against such condition.
misc test_firmware: Falling back to sysfs fallback for: nope-test-firmware.binSo the fallback kicks in with the file that is not there.
sysfs: cannot create duplicate filename '/devices/virtual/misc/test_firmware/nope-test-firmware.bin'And we have a duplicate entry, for the *device* created to allow us to
create a file entry to allow us to copy the file. Your tests had a loop,
so there is actually a race between two entries being created while
one one failed.
CPU: 4 PID: 2059 Comm: test_firmware-3 Not tainted 5.3.0-rc4 #1Note: kobject_add().
Hardware name: Dell Inc. OptiPlex 7010/0KRC95, BIOS A13 03/25/2013
? _cond_resched+0x15/0x30So above it makes it even clearer, two kobjets with the same name.
kobject_add_internal failed for nope-test-firmware.bin with -EEXIST, don't try to register things with the same name in the same directory.
Signed-off-by: Scott Branden <scott.branden@xxxxxxxxxxxx>The reason I don't like this fix is that this mutex is named after ther
drivers/base/firmware_loader/main.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index bf44c79beae9..ce9896e3b782 100644
@@ -88,6 +88,7 @@ static inline struct fw_priv *to_fw_priv(struct kref *ref)
/* fw_lock could be moved to 'struct fw_sysfs' but since it is just
* guarding for corner cases a global lock should be OK */
fallback interface... but...
static struct firmware_cache fw_cache;Whoa.. What does no-cache have anything to do with the fallback interface
@@ -758,6 +759,17 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
+ * There is a race condition between _request_firmware_prepare checking
+ * if firmware is assigned and firmware_fallback_sysfs creating sysfs
+ * entries with duplicate names.
+ * Yet, with this lock the firmware_test locks up with cache enabled
+ * and no event used during firmware test.
+ * This points to some very racy code I don't know how to entirely fix.
+ if (opt_flags & FW_OPT_NOCACHE)
other than the fact we enable this feature for the fallback interface?
We don't need to penalize non-fallback users who *also* may want to
enable the no-cache feature.
So, the fix should be within the boundaries of the creation / deletion
of the kobject, not this nocache feature. Can you please re-evaluate
this code and look for a more compartamentalized solution to the
fallback code only?