Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: qat - validate service in rate limiting sysfs api

The sysfs interface 'qat_rl/srv' currently allows all valid services,
even if a service is not configured for the device. This leads to a failure
when attempting to add the SLA using 'qat_rl/sla_op'.

Add a check using is_service_enabled() to ensure the requested service is
enabled. If not, return -EINVAL to prevent invalid configurations.

Signed-off-by: Suman Kumar Chakraborty <suman.kumar.chakraborty@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Suman Kumar Chakraborty and committed by
Herbert Xu
63fa7c4d f0ae287c

+10 -2
+1 -2
drivers/crypto/intel/qat/qat_common/adf_rl.c
··· 209 209 } 210 210 } 211 211 212 - static bool is_service_enabled(struct adf_accel_dev *accel_dev, 213 - enum adf_base_services rl_srv) 212 + bool is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services rl_srv) 214 213 { 215 214 enum adf_cfg_service_type arb_srv = srv_to_cfg_svc_type(rl_srv); 216 215 struct adf_hw_device_data *hw_data = GET_HW_DATA(accel_dev);
+1
drivers/crypto/intel/qat/qat_common/adf_rl.h
··· 175 175 enum adf_base_services svc_type); 176 176 u32 adf_rl_calculate_slice_tokens(struct adf_accel_dev *accel_dev, u32 sla_val, 177 177 enum adf_base_services svc_type); 178 + bool is_service_enabled(struct adf_accel_dev *accel_dev, enum adf_base_services rl_srv); 178 179 179 180 #endif /* ADF_RL_H_ */
+8
drivers/crypto/intel/qat/qat_common/adf_sysfs_rl.c
··· 291 291 static ssize_t srv_store(struct device *dev, struct device_attribute *attr, 292 292 const char *buf, size_t count) 293 293 { 294 + struct adf_accel_dev *accel_dev; 294 295 unsigned int val; 295 296 int ret; 297 + 298 + accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev)); 299 + if (!accel_dev) 300 + return -EINVAL; 296 301 297 302 ret = sysfs_match_string(rl_services, buf); 298 303 if (ret < 0) 299 304 return ret; 300 305 301 306 val = ret; 307 + if (!is_service_enabled(accel_dev, val)) 308 + return -EINVAL; 309 + 302 310 ret = set_param_u(dev, SRV, val); 303 311 if (ret) 304 312 return ret;