[PATCH 6.1 v2 0/3] aic79xx: Add some non-NULL checks

Boris Belyavtsev posted 3 patches 7 months, 3 weeks ago
drivers/scsi/aic7xxx/aic79xx_core.c | 11 +++++++++--
drivers/scsi/aic7xxx/aic79xx_osm.c  |  3 ++-
2 files changed, 11 insertions(+), 3 deletions(-)
[PATCH 6.1 v2 0/3] aic79xx: Add some non-NULL checks
Posted by Boris Belyavtsev 7 months, 3 weeks ago
Add non-NULL checks for ahd_lookup_scb return value.

scb could be NULL if faulty hardware return certain incorrect values to the
driver.

Changes in v2:
1. Reform cover letter text.
2. Fix the mess with style in v1.

Boris Belyavtsev (1):
  scsi: aic79xx: check for non-NULL scb in ahd_handle_seqint

Boris Belyavtsev (2):
  scsi: aic79xx: check for non-NULL scb in ahd_handle_pkt_busfree
  scsi: aic79xx: check for non-NULL scb in ahd_linux_queue_abort_cmd

 drivers/scsi/aic7xxx/aic79xx_core.c | 11 +++++++++--
 drivers/scsi/aic7xxx/aic79xx_osm.c  |  3 ++-
 2 files changed, 11 insertions(+), 3 deletions(-)

-- 
2.43.0
Re: [PATCH 6.1 v2 0/3] aic79xx: Add some non-NULL checks
Posted by James Bottomley 7 months, 3 weeks ago
On Mon, 2025-04-21 at 15:16 +0700, Boris Belyavtsev wrote:
> Add non-NULL checks for ahd_lookup_scb return value.
> 
> scb could be NULL if faulty hardware return certain incorrect values
> to the driver.

It's a general principle that we trust values coming from the card ...
you are, after all, trusting it with your data.  If there's a fault in
the way the card is operating, we can work around that, so if you have
a card which is producing these NULLs, can you provide details so we
can investigate?

Regards,

James
Re: [PATCH 6.1 v2 0/3] aic79xx: Add some non-NULL checks
Posted by Boris Belyavtsev 7 months, 2 weeks ago
On Mon Apr 21, 2025 at 7:12 PM +07, James Bottomley wrote:
> On Mon, 2025-04-21 at 15:16 +0700, Boris Belyavtsev wrote:
> > Add non-NULL checks for ahd_lookup_scb return value.
> >
> > scb could be NULL if faulty hardware return certain incorrect values
> > to the driver.
>
> It's a general principle that we trust values coming from the card ...
> you are, after all, trusting it with your data.  If there's a fault in
> the way the card is operating, we can work around that, so if you have
> a card which is producing these NULLs, can you provide details so we
> can investigate?
>
> Regards,
>
> James

Well, to be honest, I do not have such a device/card which would
represent the problem. These checks are more about defensive programming
(in case of an accident fault in a card for example).

I agree this checks could be excessive, especially in ahd_linux_queue_abort_cmd()
at aic_79xx_osm.c NULL value is unexpected.

What do you think about that?

Anyways it is up to maintainer if this checks could be valuable here or
not.
Re: [PATCH 6.1 v2 0/3] aic79xx: Add some non-NULL checks
Posted by James Bottomley 7 months, 2 weeks ago
On Mon, 2025-04-28 at 11:32 +0700, Boris Belyavtsev wrote:
> On Mon Apr 21, 2025 at 7:12 PM +07, James Bottomley wrote:
> > On Mon, 2025-04-21 at 15:16 +0700, Boris Belyavtsev wrote:
> > > Add non-NULL checks for ahd_lookup_scb return value.
> > > 
> > > scb could be NULL if faulty hardware return certain incorrect
> > > values to the driver.
> > 
> > It's a general principle that we trust values coming from the card
> > ... you are, after all, trusting it with your data.  If there's a
> > fault in the way the card is operating, we can work around that, so
> > if you have a card which is producing these NULLs, can you provide
> > details so we can investigate?
> > 
> > Regards,
> > 
> > James
> 
> Well, to be honest, I do not have such a device/card which would
> represent the problem. These checks are more about defensive
> programming (in case of an accident fault in a card for example).

We don't program defensively against adapters: they're part of our
trust domain.  We only program defensively against input from untrusted
domains (like user space).  The problem with defensively programming
drivers was nicely demonstrated by the driver hardening project:

https://lore.kernel.org/all/20230119170633.40944-1-alexander.shishkin@linux.intel.com/

In that there are so many ways that drivers could be used to attack the
OS, defending against all of them would dramatically impact the fast
path.  Which is also the reason we don't imagine card faults and then
program for them without first finding the problem in the field.

Regards,

James