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

zfs allow log destroy parameter NULL #4891

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion module/zfs/zfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3345,6 +3345,8 @@ zfs_ioc_log_history(const char *unused, nvlist_t *innvl, nvlist_t *outnvl)
* we clear the TSD here.
*/
poolname = tsd_get(zfs_allow_log_key);
if (poolname == NULL)
return (SET_ERROR(EINVAL));
(void) tsd_set(zfs_allow_log_key, NULL);
error = spa_open(poolname, &spa, FTAG);
strfree(poolname);
Expand Down Expand Up @@ -6297,7 +6299,8 @@ static void
zfs_allow_log_destroy(void *arg)
{
char *poolname = arg;
strfree(poolname);
if (poolname != NULL)
strfree(poolname);
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for proposing the patch. The thing is strfree(NULL) should be safe except for very old versions of ZoL. It calls kfree() which is handled properly even by 2.6.32 era kernels. Are you able to reproduce this issue reliably?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is to be,
I have add a log to zfs_allow_log_destroy function and zfs_ioc_log_history function.
void
zfs_allow_log_destroy(void *arg)
{
char *poolname = arg;
if(NULL != poolname)
{
printk("heary-cao zfs_allow_log_destroy----------> poolname is %s\n",poolname);
strfree(poolname);
}
else
{
printk("heary-cao zfs_allow_log_destroy----------> poolname is NULL\n");
}
}
zfs_ioc_log_history:
poolname = tsd_get(zfs_allow_log_key);
if(poolname == NULL)
{
printk("heary-cao zfs_ioc_log_history ------>tsd_get error\n");
return (SET_ERROR(EINVAL));
}
else
{
printk("heary-cao zfs_ioc_log_history--->poolname:%s\n",poolname);
}

run zfs test suite:
[/opt/ztest/zfs-tests/tests/functional/cli_root/zdb]
tests = ['zdb_001_neg']
[/opt/ztest/zfs-tests/tests/functional/cli_root/zfs]
tests = ['zfs_001_neg', 'zfs_003_neg']
[/opt/ztest/zfs-tests/tests/functional/cli_root/zfs_create]
tests = ['zfs_create_001_pos', 'zfs_create_002_pos', 'zfs_create_003_pos',
'zfs_create_006_pos', 'zfs_create_007_pos', 'zfs_create_013_pos']

the log is:
[ 2085.673959] heary-cao zfs_ioc_log_history--->poolname:vd-F0703B79-EBB9-5B12-6C74-BAE161A49000
[ 2085.683826] heary-cao zfs_allow_log_destroy----------> poolname is NULL

}

#ifdef DEBUG
Expand Down