linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 4.6-rc2 regression with commit 104daa71b396: check VPD access offset against length
@ 2016-04-08 22:24 Casey Leedom
       [not found] ` <BY2PR12MB0648F0C35D907AA640D7E56CC8940@BY2PR12MB0648.namprd12.prod.outlook.com>
  0 siblings, 1 reply; 12+ messages in thread
From: Casey Leedom @ 2016-04-08 22:24 UTC (permalink / raw)
  To: linux-pci@vger.kernel.org; +Cc: Bjorn Helgaas, Hannes Reinecke, Hariprasad S

[[ I apologize if this is a duplicate message.  I've been struggling all
    afternoon to get a message successfully delivered to the linux-pci
    list.
    -- Casey ]]

  kernel.org commit 104daa71b396 added a check to make sure that efforts to
read/write the VPD wouldn't extend past the computed length of the VPD.
Later, kernel.org commit 408641e93aa5 folded the pci_vpd_pci22 into
struct pci_vpd so things moved around a bit after that and an error return
got changed into a silent failure instead of -EINVAL.

  The problem is that the previous pci_vpd_pci22_read() didn't check for a read with
a VPD Offset > VPD Length and the new pci_vpd_read() is checking that.  Worse
yet, when a VPD Offset is greater than the recorded VPD Length, it simply
returns 0 rather than -EINVAL.

  The problem is stemming from the fact that the Chelsio adapters actually have
two VPD structures stored in the VPD.  An abbreviated on at Offset 0x0 and the
complete VPD at Offset 0x400.  The abbreviated one only contains the PN, SN and
EC Keywords, while the complete VPD contains those plus various adapter
constants contained in V0, V1, etc.  And it also contains the Base Ethernet MAC
Address in the "NA" Keyword which the cxgb4 driver needs when it can't contact
the adapter firmware.  (We don't have the "NA" Keywork in the VPD Structure at
Offset 0x0 because that's not an allowed VPD Keyword in the PCI-E 3.0
specification.)

  With the new code, the computed size of the VPD is 0x200 and so our efforts
to read the VPD at Offset 0x400 silently fails.  We check the result of the
read looking for a signature 0x82 byte but we're checking against random stack
garbage.

  The end result is that the cxgb4 driver now fails the PCI-E Probe.

  Again,  apologies if I'm not communicating this to the Linux Development
Community properly -- I'm usually not allowed out of my cage.

Casey

^ permalink raw reply	[flat|nested] 12+ messages in thread
* 4.6-rc2 regression with commit 104daa71b396: check VPD access offset against length
@ 2016-04-08 21:58 Casey Leedom
  0 siblings, 0 replies; 12+ messages in thread
From: Casey Leedom @ 2016-04-08 21:58 UTC (permalink / raw)
  To: linux-pci@vger.kernel.org; +Cc: Bjorn Helgaas, Hannes Reinecke, Hariprasad S

[[ I apologize if this is a duplicate message.  I've been struggling all
    afternoon to get a message successfully delivered to the linux-pci
    list.
    -- Casey ]]

  kernel.org commit 104daa71b396 added a check to make sure that efforts to
read/write the VPD wouldn't extend past the computed length of the VPD.
Later, kernel.org commit 408641e93aa5 folded the pci_vpd_pci22 into
struct pci_vpd so things moved around a bit after that and an error return
got changed into a silent failure instead of -EINVAL.

  The problem is that the previous pci_vpd_pci22_read() didn't check for a read with
a VPD Offset > VPD Length and the new pci_vpd_read() is checking that.  Worse
yet, when a VPD Offset is greater than the recorded VPD Length, it simply
returns 0 rather than -EINVAL.

  The problem is stemming from the fact that the Chelsio adapters actually have
two VPD structures stored in the VPD.  An abbreviated on at Offset 0x0 and the
complete VPD at Offset 0x400.  The abbreviated one only contains the PN, SN and
EC Keywords, while the complete VPD contains those plus various adapter
constants contained in V0, V1, etc.  And it also contains the Base Ethernet MAC
Address in the "NA" Keyword which the cxgb4 driver needs when it can't contact
the adapter firmware.  (We don't have the "NA" Keywork in the VPD Structure at
Offset 0x0 because that's not an allowed VPD Keyword in the PCI-E 3.0
specification.)

  With the new code, the computed size of the VPD is 0x200 and so our efforts
to read the VPD at Offset 0x400 silently fails.  We check the result of the
read looking for a signature 0x82 byte but we're checking against random stack
garbage.

  The end result is that the cxgb4 driver now fails the PCI-E Probe.

  Again,  apologies if I'm not communicating this to the Linux Development
Community properly -- I'm usually not allowed out of my cage.

Casey

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-04-13 17:06 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-08 22:24 4.6-rc2 regression with commit 104daa71b396: check VPD access offset against length Casey Leedom
     [not found] ` <BY2PR12MB0648F0C35D907AA640D7E56CC8940@BY2PR12MB0648.namprd12.prod.outlook.com>
2016-04-11 18:16   ` Steve Wise
2016-04-12  5:37     ` Bjorn Helgaas
2016-04-12  6:20       ` Hannes Reinecke
2016-04-12  8:23         ` Hariprasad Shenai
2016-04-12  8:46           ` Hannes Reinecke
2016-04-12 17:35             ` Casey Leedom
2016-04-12 20:17               ` Casey Leedom
2016-04-12 21:52               ` Steve Wise
2016-04-13  6:00               ` Hannes Reinecke
2016-04-13 16:52                 ` Casey Leedom
  -- strict thread matches above, loose matches on Subject: below --
2016-04-08 21:58 Casey Leedom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).