-
Notifications
You must be signed in to change notification settings - Fork 284
drivers: firmware: imx: fix dependency for IMX_SEC_ENCLAVE and use-after-free #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: lf-6.12.y
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2076,11 +2076,6 @@ static void se_if_probe_cleanup(void *plat_dev) | |
| * un-set bit. | ||
| */ | ||
| of_reserved_mem_device_release(dev); | ||
|
|
||
| /* Free Kobj created for logging */ | ||
| if (se_kobj) | ||
| kobject_put(se_kobj); | ||
|
|
||
| } | ||
|
|
||
| static int get_se_fw_img_nm_idx(const struct se_fw_img_name *se_fw_img_nm) | ||
|
|
@@ -2280,6 +2275,8 @@ static int se_if_probe(struct platform_device *pdev) | |
| ret = se_sysfs_log(); | ||
| if (ret) | ||
| pr_warn("Warn: Creating sysfs entry for se_log and se_rcv_msg_timeout: %d\n", ret); | ||
| } else { | ||
| kobject_get(se_kobj); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ernestvh Just a heads-up: this isn’t really my area of expertise, so feel free to correct me if I’m off. From what I can tell There’s no success path for "already existed". Because of that, in this patch, calling
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @iuliana-prodan, thanks for taking the time to review this. Only the first probe should ever call Indeed, If either of the In short, hitting "already existed" seems impossible to me, but it does seem like we have some issues with the failure logic here, but that does not seem to be introduced by this patch. In any case, we would only hit such issues if the system is out of memory, so maybe it is not a big concern. This logic is certainly confusing and I am also not an expert on this, so please feel free to correct me as well.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I'm correct about the possible issue, a solution could be to call This way the usage is more in one place and easier to follow, and with some additional logic the creation of the files could be tried again if a probe is deferred because of out-of-memory issues.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good points @ernestvh! I like the idea of moving the Probably best to hear from the driver owner on which pattern they want. |
||
| } | ||
|
|
||
| dev_info(dev, "i.MX secure-enclave: %s%d interface to firmware, configured.\n", | ||
|
|
@@ -2296,6 +2293,10 @@ static int se_if_probe(struct platform_device *pdev) | |
| static void se_if_remove(struct platform_device *pdev) | ||
| { | ||
| se_if_probe_cleanup(pdev); | ||
|
|
||
| /* Free Kobj created for logging */ | ||
| if (se_kobj) | ||
| kobject_put(se_kobj); | ||
| } | ||
|
|
||
| static int se_suspend(struct device *dev) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -
depends onensures the enclave driver can’t be y when NVMEM_IMX_OCOTP_SCU is m, avoiding probe defers.Good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Credit to @MaxKrummenacher!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ernestvh add @MaxKrummenacher as Suggested-by or Reported-by to give credit.
Also, NVMEM_IMX_OCOTP_SCU is enabled only for SCU (System controller unit) based platforms right (like 8qxp/8qm)?
So it means that IMX_SEC_ENCLAVE is only available on this boards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current imx_v8_defconfig enables NVMEM_IMX_OCOTP_SCU, so IMX_SEC_ENCLAVE would be there for boards without an SCU.
But you are right the this seems not the proper or complete solution to forcing IMX_SEC_ENCLAVE=m when the OCOTP driver is m.
Assuming it to handle the =m vs. =y issue correctly probably the following would be better: