Skip to content
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

Fixing ICP memleak introduced in #4760 #5265

Merged
merged 1 commit into from
Oct 12, 2016

Conversation

tcaputi
Copy link
Contributor

@tcaputi tcaputi commented Oct 11, 2016

The ICP requires destructors to for each crypto module that is added.
These do not necessarily exist in Illumos because they assume that
these modules can never be unloaded from the kernel. Some of this
cleanup code was missed when #4760 was merged, resulting in leaks.
This patch simply fixes that.

The ICP requires destructors to for each crypto module that is added.
These do not necessarily exist in Illumos because they assume that
these modules can never be unloaded from the kernel. Some of this
cleanup code was missed when openzfs#4760 was merged, resulting in leaks.
This patch simply fixes that.
@mention-bot
Copy link

@tcaputi, thanks for your PR! By analyzing the history of the files in this pull request, we identified @tonyhutter to be a potential reviewer.

@tonyhutter
Copy link
Contributor

Good catch. LGTM

@@ -231,6 +231,19 @@ skein_mod_init(void)

int
skein_mod_fini(void) {
int ret;
Copy link
Contributor

@behlendorf behlendorf Oct 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[style] by convention the existing code prefers to name this kind of variable error rather than ret.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below


if (skein_prov_handle != 0) {
if ((ret = crypto_unregister_provider(skein_prov_handle)) !=
CRYPTO_SUCCESS) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[style] This one's situation dependent but often it's clearer to pull the assignment out of the conditional in cases like this where the line wraps.

        error = crypto_unregister_provider(skein_prov_handle);
        if (error != CRYPTO_SUCCESS) {
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I styled the code like this in order to match the existing code of Illumos's KCF (and therefore the rest of the ICP). For instance, here is the _init() code from Illumos's sha2_mod.c. Would you still like me to change it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh I see, that explains it. Well given that I'm OK with either styling. Either we're not going to be consistent with the other _mod_fini() styling, or with the styling in the rest of the skein_mod.c file. Objection withdrawn. LGTM.

cmn_err(CE_WARN,
"skein _fini: crypto_unregister_provider() "
"failed (0x%x)", ret);
return (EBUSY);
Copy link
Contributor

@behlendorf behlendorf Oct 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for future reference in the core zfs.ko code most places where a const errno is returned the SET_ERROR() macro is used to log it. return (SET_ERROR(EBUSY));. That said, none of the existing icp code does this so let's avoid doing that here. No change needed.

@behlendorf behlendorf merged commit ef78750 into openzfs:master Oct 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants