crypto: Fix stack frame size exceeded error in fuzzing build

Enabling KASAN is causing stack frame size exceeded error in crypto
driver, Fix this by allocating struct get_ivc_db dynamically while
enabling KASAN for fuzzing build.

Bug 4615347

Change-Id: Ie1959b3c79c8ca2f31f79ea76aeb55490bd9917b
Signed-off-by: Yash Bhatt <ybhatt@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3196965
Reviewed-by: Pritesh Raithatha <praithatha@nvidia.com>
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Yash Bhatt
2024-08-20 13:23:53 +00:00
committed by Jon Hunter
parent 66e40e599c
commit 4a1b0df1df

View File

@@ -1837,7 +1837,7 @@ static long tnvvse_crypto_dev_ioctl(struct file *filp,
struct tegra_nvvse_aes_drng_ctl *aes_drng_ctl; struct tegra_nvvse_aes_drng_ctl *aes_drng_ctl;
struct tegra_nvvse_aes_gmac_init_ctl *aes_gmac_init_ctl; struct tegra_nvvse_aes_gmac_init_ctl *aes_gmac_init_ctl;
struct tegra_nvvse_aes_gmac_sign_verify_ctl *aes_gmac_sign_verify_ctl; struct tegra_nvvse_aes_gmac_sign_verify_ctl *aes_gmac_sign_verify_ctl;
struct tegra_nvvse_get_ivc_db get_ivc_db; struct tegra_nvvse_get_ivc_db *get_ivc_db;
struct tegra_nvvse_tsec_get_keyload_status *tsec_keyload_status; struct tegra_nvvse_tsec_get_keyload_status *tsec_keyload_status;
int ret = 0; int ret = 0;
@@ -2106,18 +2106,27 @@ static long tnvvse_crypto_dev_ioctl(struct file *filp,
break; break;
case NVVSE_IOCTL_CMDID_GET_IVC_DB: case NVVSE_IOCTL_CMDID_GET_IVC_DB:
ret = tnvvse_crypto_get_ivc_db(&get_ivc_db); get_ivc_db = kzalloc(sizeof(*get_ivc_db), GFP_KERNEL);
if (!get_ivc_db) {
pr_err("%s(): failed to allocate memory\n", __func__);
return -ENOMEM;
}
ret = tnvvse_crypto_get_ivc_db(get_ivc_db);
if (ret) { if (ret) {
pr_err("%s(): Failed to get ivc database get_ivc_db:%d\n", __func__, ret); pr_err("%s(): Failed to get ivc database get_ivc_db:%d\n", __func__, ret);
kfree(get_ivc_db);
goto out; goto out;
} }
ret = copy_to_user((void __user *)arg, &ivc_database, sizeof(ivc_database)); ret = copy_to_user((void __user *)arg, &ivc_database, sizeof(ivc_database));
if (ret) { if (ret) {
pr_err("%s(): Failed to copy_to_user ivc_database:%d\n", __func__, ret); pr_err("%s(): Failed to copy_to_user ivc_database:%d\n", __func__, ret);
kfree(get_ivc_db);
goto out; goto out;
} }
kfree(get_ivc_db);
break; break;
case NVVSE_IOCTL_CMDID_TSEC_SIGN_VERIFY: case NVVSE_IOCTL_CMDID_TSEC_SIGN_VERIFY: