Re: [PATCH] comedi: adv_pci1710: prevent NULL deref in command test
From: Ian Abbott
Date: Wed Nov 25 2026 - 06:07:30 EST
On 25/11/2026 03:12, 김지훈 wrote:
|The COMEDI_CMDTEST ioctl permits a NULL channel list: do_cmdtest_ioctl() only loads and validates the channel list when the user-supplied pointer is non-NULL, otherwise it calls the subdevice's - >do_cmdtest() handler with cmd->chanlist == NULL (and cmd->chanlist_len still bounded only by len_chanlist). pci1710_ai_cmdtest() calls pci1710_ai_check_chanlist() unconditionally in step 5, and that helper dereferences cmd->chanlist[0] on its first lines (CR_CHAN()/CR_AREF()). A user issuing COMEDI_CMDTEST with a NULL chanlist pointer therefore triggers a NULL pointer dereference. Every other comedi driver guards the step 5 check with "if (cmd->chanlist && cmd->chanlist_len > 0)"; adv_pci1710 was missed. Add the same guard. Signed-off-by: Jeehoon Kim <Wlgns2756@xxxxxxxxx <mailto:Wlgns2756@xxxxxxxxx>> --- drivers/comedi/ drivers/adv_pci1710.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/comedi/drivers/adv_pci1710.c b/ drivers/comedi/drivers/adv_pci1710.c index fc749241d..aa0e56df4 100644 --- a/drivers/comedi/drivers/adv_pci1710.c +++ b/drivers/comedi/drivers/ adv_pci1710.c @@ -621,9 +621,9 @@ static int pci1710_ai_cmdtest(struct comedi_device *dev, if (err) return 4; - /* Step 5: check channel list */ - - err |= pci1710_ai_check_chanlist(dev, s, cmd); + /* Step 5: check channel list if it exists */ + if (cmd->chanlist && cmd->chanlist_len > 0) + err |= pci1710_ai_check_chanlist(dev, s, cmd); if (err) return 5; -- 2.43.0|
Thanks for the patch. All the emails you sent were incompatible with `git am`, so I have resent it with my "Reviewed-by:" line, and have added a "Fixes:" line, a "Cc: <stable@xxxxxxxxxxxxxxx>" line, and my own "Signed-off-by:" line.
--
-=( Ian Abbott <abbotti@xxxxxxxxx> || MEV Ltd. is a company )=-
-=( registered in England & Wales. Regd. number: 02862268. )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-