Skip to contentSkip to conversation

firmware: improve LSM/IMA security behaviour

PATCH In review Sven Van Asbroeck 2 participants 2 messages Jun 17, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 firmware: improve LSM/IMA security behaviour

The firmware loader queries if LSM/IMA permits it to load firmware via the sysfs fallback. Unfortunately, the code does the opposite:
it expressly permits sysfs fw loading if security_kernel_load_data( LOADING_FIRMWARE) returns -EACCES. This happens because a zero-on-success return value is cast to a bool that's true on success.

Fix the return value handling so we get the correct behaviour.

Fixes 6e852651f28e ("firmware: add call to LSM hook before firmware sysfs fallback")
Cc Stable <[email protected]>
Cc Mimi Zohar <[email protected]>
Cc Kees Cook <[email protected]>

To: Luis Chamberlain <[email protected]>

Cc Greg Kroah-Hartman <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
---
 drivers/base/firmware_loader/fallback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/firmware_loader/fallback.c +1 -1
index f962488546b6..103b5d37fa86 100644
@@ -659,7 +659,7 @@ static bool fw_run_sysfs_fallback(enum fw_opt opt_flags)
 	/* Also permit LSMs and IMA to fail firmware sysfs fallback */
 	ret = security_kernel_load_data(LOADING_FIRMWARE);
 	if (ret < 0)
-		return ret;
+		return false;
 
 	return fw_force_sysfs_fallback(opt_flags);
 }
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Sven Van Asbroeck

The firmware loader queries if LSM/IMA permits it to load firmware via the sysfs fallback. Unfortunately, the code does the opposite:
it expressly permits sysfs fw loading if security_kernel_load_data( LOADING_FIRMWARE) returns -EACCES. This happens because a zero-on-success return value is cast to a bool that's true on success.

Fix the return value handling so we get the correct behaviour.