crypto: qat - remove unused ioctl interface
Subsystems (4)
Giovanni Cabiddu
maintainerv3 cover crypto: qat - remove unused ioctl interface
The QAT driver exposes a character device (qat_adf_ctl) with IOCTLs for device configuration, start, stop, status query and enumeration. These IOCTLs are not part of any public uAPI header and have no known in-tree or out-of-tree users.
This ioctl interface increases the attack surface and is the subject of a number of bug reports. Remove it entirely.
Patch 1 removes the character device, the IOCTL definitions, the related data structures and headers. It strips adf_ctl_drv.c down to the minimal module_init/module_exit hooks. This is marked for stable.
Patch 2 renames the now-minimal adf_ctl_drv.c to adf_module.c and adjusts function names to match the new file name. This is not marked for stable as it is a pure rename.
Changes since v1:
- Addressed comments from Sashiko: cleaned up leftover dead code
https://sashiko.dev/#/patchset/20260508091912.206913-1-giovanni.cabiddu%40intel.com
Changes since v2:
- Removed additional dead code: adf_devmgr_get_dev_by_id(), adf_get_vf_real_id() and a few ADF_CFG unused macros
Giovanni Cabiddu (2):
crypto: qat - remove unused character device and IOCTLs
crypto: qat - rename adf_ctl_drv.c to adf_module.c
.../userspace-api/ioctl/ioctl-number.rst | 1 - drivers/crypto/intel/qat/qat_common/Makefile | 2 +- drivers/crypto/intel/qat/qat_common/adf_cfg.c | 10 - drivers/crypto/intel/qat/qat_common/adf_cfg.h | 1 - .../intel/qat/qat_common/adf_cfg_common.h | 32 -- .../intel/qat/qat_common/adf_cfg_user.h | 38 -- .../intel/qat/qat_common/adf_common_drv.h | 3 - .../crypto/intel/qat/qat_common/adf_ctl_drv.c | 466 ------------------ .../crypto/intel/qat/qat_common/adf_dev_mgr.c | 70 --- .../crypto/intel/qat/qat_common/adf_module.c | 64 +++ 10 files changed, 65 insertions(+), 622 deletions(-) delete mode 100644 drivers/crypto/intel/qat/qat_common/adf_cfg_user.h delete mode 100644 drivers/crypto/intel/qat/qat_common/adf_ctl_drv.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_module.c
base-commit: f7dd32c5179d7755de18e21d5674b08f9e5cb180
Signature · 1 line
2.54.0
Giovanni Cabiddu
maintainerPATCH v3 1/2 crypto: qat - remove unused character device and IOCTLs
The QAT driver exposes a character device (qat_adf_ctl) with IOCTLs for device configuration, start, stop, status query and enumeration. These IOCTLs are not part of any public uAPI header and have no known in-tree or out-of-tree users. Device lifecycle is already managed via sysfs.
The ioctl interface also increases the attack surface and is the subject of a number of bug reports.
Remove the character device, the IOCTL definitions, and the related data structures (adf_dev_status_info, adf_user_cfg_key_val, adf_user_cfg_section, adf_user_cfg_ctl_data). Drop the now-unused adf_cfg_user.h header and strip adf_ctl_drv.c down to the minimal module_init/module_exit hooks for workqueue, AER, and crypto/compression algorithm registration.
Clean up leftover dead code that was only reachable from the removed IOCTL paths: adf_cfg_del_all(), adf_devmgr_verify_id(), adf_devmgr_get_num_dev(), adf_devmgr_get_dev_by_id(), adf_get_vf_real_id() and the unused ADF_CFG macros.
Additionally, drop the entry associated to QAT IOCTLs in ioctl-number.rst.
--- .../userspace-api/ioctl/ioctl-number.rst | 1 - drivers/crypto/intel/qat/qat_common/adf_cfg.c | 10 - drivers/crypto/intel/qat/qat_common/adf_cfg.h | 1 - .../intel/qat/qat_common/adf_cfg_common.h | 32 -- .../intel/qat/qat_common/adf_cfg_user.h | 38 -- .../intel/qat/qat_common/adf_common_drv.h | 3 - .../crypto/intel/qat/qat_common/adf_ctl_drv.c | 404 +----------------- .../crypto/intel/qat/qat_common/adf_dev_mgr.c | 70 --- 8 files changed, 1 insertion(+), 558 deletions(-) delete mode 100644 drivers/crypto/intel/qat/qat_common/adf_cfg_user.h
Documentation/userspace-api/ioctl/ioctl-number.rst +0 -1
@@ -229,7 +229,6 @@ Code Seq# Include File Comments <mailto:[email protected]> 'a' all linux/atm*.h, linux/sonet.h ATM on linux <http://lrcwww.epfl.ch/> -'a' 00-0F drivers/crypto/qat/qat_common/adf_cfg_common.h conflict! qat driver 'b' 00-FF conflict! bit3 vme host bridge <mailto:[email protected]> 'b' 00-0F linux/dma-buf.h conflict!
drivers/crypto/intel/qat/qat_common/adf_cfg.c +0 -10
@@ -103,16 +103,6 @@ static void adf_cfg_section_del_all(struct list_head *head);static void adf_cfg_section_del_all_except (struct list_head *head,const char *section_name); -void adf_cfg_del_all (struct adf_accel_dev *accel_dev) -{ -struct adf_cfg_device_data *dev_cfg_data = accel_dev->cfg; - -down_write (&dev_cfg_data->lock); -adf_cfg_section_del_all (&dev_cfg_data->sec_list); -up_write (&dev_cfg_data->lock); -clear_bit (ADF_STATUS_CONFIGURED , &accel_dev->status); -} -void adf_cfg_del_all_except (struct adf_accel_dev *accel_dev,const char *section_name) {
drivers/crypto/intel/qat/qat_common/adf_cfg.h +0 -1
@@ -34,7 +34,6 @@ void adf_cfg_dev_remove(struct adf_accel_dev *accel_dev);void adf_cfg_dev_dbgfs_add (struct adf_accel_dev *accel_dev);void adf_cfg_dev_dbgfs_rm (struct adf_accel_dev *accel_dev);int adf_cfg_section_add (struct adf_accel_dev *accel_dev,const char *name); -void adf_cfg_del_all (struct adf_accel_dev *accel_dev);void adf_cfg_del_all_except (struct adf_accel_dev *accel_dev,const char *section_name); int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev,
drivers/crypto/intel/qat/qat_common/adf_cfg_common.h +0 -32
@@ -4,18 +4,11 @@#define ADF_CFG_COMMON_H_ #include <linux/types.h> -#include <linux/ioctl.h> #define ADF_CFG_MAX_STR_LEN 64#define ADF_CFG_MAX_KEY_LEN_IN_BYTES ADF_CFG_MAX_STR_LEN#define ADF_CFG_MAX_VAL_LEN_IN_BYTES ADF_CFG_MAX_STR_LEN#define ADF_CFG_MAX_SECTION_LEN_IN_BYTES ADF_CFG_MAX_STR_LEN -#define ADF_CFG_BASE_DEC 10 -#define ADF_CFG_BASE_HEX 16 -#define ADF_CFG_ALL_DEVICES 0xFE -#define ADF_CFG_NO_DEVICE 0xFF -#define ADF_CFG_AFFINITY_WHATEVER 0xFF -#define MAX_DEVICE_NAME_SIZE 32#define ADF_MAX_DEVICES (32 * 32)#define ADF_DEVS_ARRAY_SIZE BITS_TO_LONGS(ADF_MAX_DEVICES)
@@ -51,29 +44,4 @@ enum adf_device_type {DEV_420XX , DEV_6XXX, }; - -struct adf_dev_status_info { -enum adf_device_type type; -__u32 accel_id; -__u32 instance_id; -__u8 num_ae; -__u8 num_accel; -__u8 num_logical_accel; -__u8 banks_per_accel; -__u8 state; -__u8 bus; -__u8 dev; -__u8 fun; -char name[MAX_DEVICE_NAME_SIZE ]; -}; - -#define ADF_CTL_IOC_MAGIC 'a' -#define IOCTL_CONFIG_SYS_RESOURCE_PARAMETERS _IOW(ADF_CTL_IOC_MAGIC, 0, \ - struct adf_user_cfg_ctl_data) -#define IOCTL_STOP_ACCEL_DEV _IOW(ADF_CTL_IOC_MAGIC, 1, \ - struct adf_user_cfg_ctl_data) -#define IOCTL_START_ACCEL_DEV _IOW(ADF_CTL_IOC_MAGIC, 2, \ - struct adf_user_cfg_ctl_data) -#define IOCTL_STATUS_ACCEL_DEV _IOW(ADF_CTL_IOC_MAGIC, 3, __u32) -#define IOCTL_GET_NUM_DEVICES _IOW(ADF_CTL_IOC_MAGIC, 4, __s32)#endif
drivers/crypto/intel/qat/qat_common/adf_cfg_user.h deleted +0 -38
@@ -1,38 +0,0 @@ -/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0-only) */ -/* Copyright(c) 2014 - 2020 Intel Corporation */ -#ifndef ADF_CFG_USER_H_ -#define ADF_CFG_USER_H_ - -#include "adf_cfg_common.h" -#include "adf_cfg_strings.h" - -struct adf_user_cfg_key_val { -char key[ADF_CFG_MAX_KEY_LEN_IN_BYTES ]; -char val[ADF_CFG_MAX_VAL_LEN_IN_BYTES ]; -union { -struct adf_user_cfg_key_val *next; -__u64 padding3; - }; -enum adf_cfg_val_type type; -} __packed; - -struct adf_user_cfg_section { -char name[ADF_CFG_MAX_SECTION_LEN_IN_BYTES ]; -union { -struct adf_user_cfg_key_val *params; -__u64 padding1; - }; -union { -struct adf_user_cfg_section *next; -__u64 padding3; - }; -} __packed; - -struct adf_user_cfg_ctl_data { -union { -struct adf_user_cfg_section *config_section; -__u64 padding; - }; -__u8 device_id; -} __packed; -#endif
drivers/crypto/intel/qat/qat_common/adf_common_drv.h +0 -3
@@ -68,10 +68,7 @@ int adf_devmgr_add_dev(struct adf_accel_dev *accel_dev,void adf_devmgr_rm_dev (struct adf_accel_dev *accel_dev,struct adf_accel_dev *pf);struct list_head *adf_devmgr_get_head (void ); -struct adf_accel_dev *adf_devmgr_get_dev_by_id (u32 id);struct adf_accel_dev *adf_devmgr_pci_to_accel_dev (struct pci_dev *pci_dev); -int adf_devmgr_verify_id (u32 id); -void adf_devmgr_get_num_dev (u32 *num);int adf_devmgr_in_reset (struct adf_accel_dev *accel_dev);int adf_dev_started (struct adf_accel_dev *accel_dev);int adf_dev_restarting_notify (struct adf_accel_dev *accel_dev);
drivers/crypto/intel/qat/qat_common/adf_ctl_drv.c +1 -403
433 lines not on this page · raw message
drivers/crypto/intel/qat/qat_common/adf_dev_mgr.c +0 -70
82 lines not on this page · raw message
Signature · 1 line
2.54.0
Giovanni Cabiddu
maintainerPATCH v3 2/2 crypto: qat - rename adf_ctl_drv.c to adf_module.c
In reply to Giovanni CabidduNow that the character device and IOCTL interface have been removed, adf_ctl_drv.c only contains module_init/module_exit hooks. Rename it to adf_module.c to better reflect its purpose and rename the init/exit functions accordingly.
---
drivers/crypto/intel/qat/qat_common/Makefile | 2 +-
.../intel/qat/qat_common/{adf_ctl_drv.c => adf_module.c} | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
rename drivers/crypto/intel/qat/qat_common/{adf_ctl_drv.c => adf_module.c} (84%)drivers/crypto/intel/qat/qat_common/Makefile +1 -1
@@ -9,7 +9,6 @@ intel_qat-y := adf_accel_engine.o \ adf_cfg.o \ adf_cfg_services.o \ adf_clock.o \ - adf_ctl_drv.o \ adf_dc.o \ adf_dev_mgr.o \ adf_gen2_config.o \
@@ -26,6 +25,7 @@ intel_qat-y := adf_accel_engine.o \ adf_hw_arbiter.o \ adf_init.o \ adf_isr.o \ + adf_module.o \ adf_mstate_mgr.o \ adf_rl_admin.o \ adf_rl.o \
drivers/crypto/intel/qat/qat_common/adf_module.c renamed from drivers/crypto/intel/qat/qat_common/adf_ctl_drv.c +4 -4
@@ -7,7 +7,7 @@#include "adf_common_drv.h" -static int __init adf_register_ctl_device_driver (void ) +static int __init adf_register_module (void ) {if (adf_init_misc_wq ()) goto err_misc_wq;
@@ -43,7 +43,7 @@ static int __init adf_register_ctl_device_driver(void)return -EFAULT ; } -static void __exit adf_unregister_ctl_device_driver(void) +static void __exit adf_unregister_module(void) {adf_exit_misc_wq ();adf_exit_aer ();
@@ -54,8 +54,8 @@ static void __exit adf_unregister_ctl_device_driver(void)adf_clean_vf_map (false); } -module_init (adf_register_ctl_device_driver); -module_exit (adf_unregister_ctl_device_driver); +module_init (adf_register_module); +module_exit (adf_unregister_module);MODULE_LICENSE ("Dual BSD/GPL" );MODULE_AUTHOR ("Intel" );MODULE_DESCRIPTION ("Intel(R) QuickAssist Technology" );
Signature · 1 line
2.54.0
Herbert Xu
maintainerQuoted 44 lines · Giovanni Cabiddu
The QAT driver exposes a character device (
qat_adf_ctl) with IOCTLs for device configuration, start, stop, status query and enumeration. These IOCTLs are not part of any public uAPI header and have no known in-tree or out-of-tree users.This ioctl interface increases the attack surface and is the subject of a number of bug reports. Remove it entirely.
Patch 1 removes the character device, the IOCTL definitions, the related data structures and headers. It strips
adf_ctl_drv.cdown to the minimal module_init/module_exit hooks. This is marked for stable.Patch 2 renames the now-minimal
adf_ctl_drv.ctoadf_module.cand adjusts function names to match the new file name. This is not marked for stable as it is a pure rename.Changes since v1:
- Addressed comments from Sashiko: cleaned up leftover dead code
https://sashiko.dev/#/patchset/20260508091912.206913-1-giovanni.cabiddu%40intel.comChanges since v2:
- Removed additional dead code:adf_devmgr_get_dev_by_id(),adf_get_vf_real_id()and a fewADF_CFGunused macrosGiovanni Cabiddu (2):
crypto: qat - remove unused character device and IOCTLs
crypto: qat - renameadf_ctl_drv.ctoadf_module.c.../userspace-api/ioctl/ioctl-number.rst | 1 - drivers/crypto/intel/qat/qat_common/Makefile | 2 +- drivers/crypto/intel/qat/qat_common/adf_cfg.c | 10 - drivers/crypto/intel/qat/qat_common/adf_cfg.h | 1 - .../intel/qat/qat_common/adf_cfg_common.h | 32 -- .../intel/qat/qat_common/adf_cfg_user.h | 38 -- .../intel/qat/qat_common/adf_common_drv.h | 3 - .../crypto/intel/qat/qat_common/adf_ctl_drv.c | 466 ------------------ .../crypto/intel/qat/qat_common/adf_dev_mgr.c | 70 --- .../crypto/intel/qat/qat_common/adf_module.c | 64 +++ 10 files changed, 65 insertions(+), 622 deletions(-) delete mode 100644 drivers/crypto/intel/qat/qat_common/adf_cfg_user.h delete mode 100644 drivers/crypto/intel/qat/qat_common/adf_ctl_drv.c create mode 100644 drivers/crypto/intel/qat/qat_common/adf_module.c
Quoted 3 lines
base-commit:
f7dd32c5179d7755de18e21d5674b08f9e5cb180Signature · 1 line
2.54.0
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt