Commit 72f6e0ea authored by Adam Guerin's avatar Adam Guerin Committed by Herbert Xu

crypto: qat - add limit to linked list parsing

adf_copy_key_value_data() copies data from userland to kernel, based on
a linked link provided by userland. If userland provides a circular
list (or just a very long one) then it would drive a long loop where
allocation occurs in every loop. This could lead to low memory conditions.
Adding a limit to stop endless loop.
Signed-off-by: default avatarAdam Guerin <adam.guerin@intel.com>
Co-developed-by: default avatarCiunas Bennett <ciunas.bennett@intel.com>
Signed-off-by: default avatarCiunas Bennett <ciunas.bennett@intel.com>
Reviewed-by: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 0cb3c9cd
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
#include "adf_cfg_common.h" #include "adf_cfg_common.h"
#include "adf_cfg_user.h" #include "adf_cfg_user.h"
#define ADF_CFG_MAX_SECTION 512
#define ADF_CFG_MAX_KEY_VAL 256
#define DEVICE_NAME "qat_adf_ctl" #define DEVICE_NAME "qat_adf_ctl"
static DEFINE_MUTEX(adf_ctl_lock); static DEFINE_MUTEX(adf_ctl_lock);
...@@ -137,10 +140,11 @@ static int adf_copy_key_value_data(struct adf_accel_dev *accel_dev, ...@@ -137,10 +140,11 @@ static int adf_copy_key_value_data(struct adf_accel_dev *accel_dev,
struct adf_user_cfg_key_val key_val; struct adf_user_cfg_key_val key_val;
struct adf_user_cfg_key_val *params_head; struct adf_user_cfg_key_val *params_head;
struct adf_user_cfg_section section, *section_head; struct adf_user_cfg_section section, *section_head;
int i, j;
section_head = ctl_data->config_section; section_head = ctl_data->config_section;
while (section_head) { for (i = 0; section_head && i < ADF_CFG_MAX_SECTION; i++) {
if (copy_from_user(&section, (void __user *)section_head, if (copy_from_user(&section, (void __user *)section_head,
sizeof(*section_head))) { sizeof(*section_head))) {
dev_err(&GET_DEV(accel_dev), dev_err(&GET_DEV(accel_dev),
...@@ -156,7 +160,7 @@ static int adf_copy_key_value_data(struct adf_accel_dev *accel_dev, ...@@ -156,7 +160,7 @@ static int adf_copy_key_value_data(struct adf_accel_dev *accel_dev,
params_head = section.params; params_head = section.params;
while (params_head) { for (j = 0; params_head && j < ADF_CFG_MAX_KEY_VAL; j++) {
if (copy_from_user(&key_val, (void __user *)params_head, if (copy_from_user(&key_val, (void __user *)params_head,
sizeof(key_val))) { sizeof(key_val))) {
dev_err(&GET_DEV(accel_dev), dev_err(&GET_DEV(accel_dev),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment