mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Abbott <abbotti@mev.co.uk>
To: 李天宇 <2200013188@stu.pku.edu.cn>,
	linux-kernel <linux-kernel@vger.kernel.org>
Cc: hsweeten <hsweeten@visionengravers.com>,
	xujiakai2025 <xujiakai2025@iscas.ac.cn>,
	"zhaoruilin22@mails.ucas.ac.cn" <zhaoruilin22@mails.ucas.ac.cn>
Subject: Re: [BUG] Drivers/8255: Page fault in comedi_8255.c
Date: Thu, 4 Dec 2025 17:11:38 +0000	[thread overview]
Message-ID: <2dd7ba02-6af0-4b66-9a72-d06da8b0057d@mev.co.uk> (raw)
In-Reply-To: <AMgA9QAeJpb138vn*G9h8qoW.3.1764849805322.Hmail.2200013188@stu.pku.edu.cn>

On 04/12/2025 12:03, 李天宇 wrote:
> Hi Ian,
> 
> Thank you very much for the analysis and your helpful suggestions.
> 
> Following your hint, I performed additional experiments by modifying the I/O base address passed through COMEDI_DEVCONFIG. The results are quite interesting:
> 
> 	- Using 0x100, 0x200, or 0x300 as the base address consistently triggers a kernel panic (page fault in subdev_8255_io).
> 	- Removing the value entirely from the options array avoids the crash (I/O port conflict remains).
> 	- Using 0x400 also does *not* trigger the issue.
> 
> This seems to support your point that certain I/O port ranges may be problematic, and the fault is not solely caused by the conversion from negative values to an unsigned address. Instead, it may indeed be related to specific port regions conflicting or being unmapped during device initialization.

There must be something special about those I/O port addresses on the 
test system, but nothing that the 8255 driver should care about.  It's a 
non-PnP driver and the system administrator is supposed to supply the 
correct information when using the COMEDI_DEVCONFIG ioctl (via the 
comedi_config command).

It's not unique to comedi.  For example, non-PnP serial ports can be 
configured in the same way using the TIOCSSERIAL ioctl (via the 
setserial command).


> At this point, I am not sufficiently familiar with the driver internals to confidently determine whether this behavior is expected or if it should be considered a bug. Given the reproducibility and the fact that unvalidated base addresses can lead to a direct page fault, I would like to ask:
> 
> Do you think this should be treated as a bug in the 8255 driver, possibly requiring additional validation or rejection of unsupported I/O port ranges? If so, I would be happy to continue testing or assist in any way, but further guidance from someone experienced with this driver would be greatly appreciated.

I think it does sufficient validation on the base address, but one 
improvement would be to only allow base addresses aligned to a 4-byte 
boundary, because (base & 3) != 0 does not make sense for an 8255 chip.

One thing that will affect the fuzzing tests is that the "8255" driver 
in "linux-next" now returns an error as soon as it fails to reserve any 
I/O port region, so unless the special base addresses (0x100 etc.) 
appear early in the list before the conflicting base addresses, it won't 
crash.

Best regards,
Ian

-- 
-=( Ian Abbott <abbotti@mev.co.uk> || 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 )=-

  reply	other threads:[~2025-12-04 19:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-29 13:19 李天宇
2025-12-03 13:08 ` Ian Abbott
2025-12-04 12:03   ` 李天宇
2025-12-04 17:11     ` Ian Abbott [this message]
2025-12-09 13:24       ` Tianyu Li
2025-12-10 10:06         ` Ian Abbott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2dd7ba02-6af0-4b66-9a72-d06da8b0057d@mev.co.uk \
    --to=abbotti@mev.co.uk \
    --cc=2200013188@stu.pku.edu.cn \
    --cc=hsweeten@visionengravers.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xujiakai2025@iscas.ac.cn \
    --cc=zhaoruilin22@mails.ucas.ac.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®