lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260130170416.49994-34-abbotti@mev.co.uk>
Date: Fri, 30 Jan 2026 16:47:58 +0000
From: Ian Abbott <abbotti@....co.uk>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Ian Abbott <abbotti@....co.uk>,
	H Hartley Sweeten <hsweeten@...ionengravers.com>
Subject: [PATCH 33/46] comedi: pcl724: Add sanity checks for I/O base address

The "pcl724" driver uses an admin-supplied configuration option
(`it->options[0]`) to configure the I/O port base address of various
8255 chip-based digital I/O ISA boards from Advantech, ADLINK,
WinSystems, and Diamond Systems.  It currently allows any base address
to be configured but the hardware only supports base addresses
(configured by on-board DIP switches or jumpers) in various ranges, and
on various alignment boundaries, depending on the model.

Store the minimum and maximum supported I/O address ranges in the static
board information array elements (the required alignment is already
stored in the `io_range` member), and add a sanity check to ensure the
device is not configured at an unsupported base address.

Signed-off-by: Ian Abbott <abbotti@....co.uk>
---
 drivers/comedi/drivers/pcl724.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/comedi/drivers/pcl724.c b/drivers/comedi/drivers/pcl724.c
index 00474710b81f..9707d0c89304 100644
--- a/drivers/comedi/drivers/pcl724.c
+++ b/drivers/comedi/drivers/pcl724.c
@@ -31,6 +31,8 @@
 struct pcl724_board {
 	const char *name;
 	unsigned int io_range;
+	unsigned int min_io_start;
+	unsigned int max_io_end;
 	unsigned int can_have96:1;
 	unsigned int is_pet48:1;
 	int numofports;
@@ -40,37 +42,53 @@ static const struct pcl724_board boardtypes[] = {
 	{
 		.name		= "pcl724",
 		.io_range	= 0x04,
+		.min_io_start	= 0x200,
+		.max_io_end	= 0x3ff,
 		.numofports	= 1,	/* 24 DIO channels */
 	}, {
 		.name		= "pcl722",
 		.io_range	= 0x20,
+		.min_io_start	= 0x200,
+		.max_io_end	= 0x3ff,
 		.can_have96	= 1,
 		.numofports	= 6,	/* 144 (or 96) DIO channels */
 	}, {
 		.name		= "pcl731",
 		.io_range	= 0x08,
+		.min_io_start	= 0,
+		.max_io_end	= 0x3ff,
 		.numofports	= 2,	/* 48 DIO channels */
 	}, {
 		.name		= "acl7122",
 		.io_range	= 0x20,
+		.min_io_start	= 0x200,
+		.max_io_end	= 0x3ff,
 		.can_have96	= 1,
 		.numofports	= 6,	/* 144 (or 96) DIO channels */
 	}, {
 		.name		= "acl7124",
 		.io_range	= 0x04,
+		.min_io_start	= 0x200,
+		.max_io_end	= 0x3ff,
 		.numofports	= 1,	/* 24 DIO channels */
 	}, {
 		.name		= "pet48dio",
 		.io_range	= 0x02,
+		.min_io_start	= 0,
+		.max_io_end	= 0x3ff,
 		.is_pet48	= 1,
 		.numofports	= 2,	/* 48 DIO channels */
 	}, {
 		.name		= "pcmio48",
 		.io_range	= 0x08,
+		.min_io_start	= 0x100,
+		.max_io_end	= 0x17f,
 		.numofports	= 2,	/* 48 DIO channels */
 	}, {
 		.name		= "onyx-mm-dio",
 		.io_range	= 0x10,
+		.min_io_start	= 0,
+		.max_io_end	= 0x3ff,
 		.numofports	= 2,	/* 48 DIO channels */
 	},
 };
@@ -112,7 +130,9 @@ static int pcl724_attach(struct comedi_device *dev,
 		n_subdevices = 4;
 	}
 
-	ret = comedi_request_region(dev, it->options[0], iorange);
+	ret = comedi_check_request_region(dev, it->options[0], iorange,
+					  board->min_io_start,
+					  board->max_io_end, iorange);
 	if (ret)
 		return ret;
 
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ