]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r307684, r307747
authorken <ken@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Mon, 12 Dec 2016 21:54:49 +0000 (21:54 +0000)
committerken <ken@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Mon, 12 Dec 2016 21:54:49 +0000 (21:54 +0000)
commit615df5b7e30e00a9eef245a9acf33c728c9a074d
tree8caa158594a1fc28089289278ac04ee07d0ff153
parent3661ab982f8c51d4c7935cc8677966da69234753
MFC r307684, r307747
  ------------------------------------------------------------------------
  r307684 | ken | 2016-10-20 13:42:26 -0600 (Thu, 20 Oct 2016) | 13 lines

  For CCBs allocated on the stack, we need to clear the entire CCB, not just
  the header.  Otherwise stack garbage can lead to random flags getting set.

  This showed up as 'camcontrol rescan all' failing with EINVAL because the
  address type wasn't CAM_DATA_VADDR.

  sbin/camcontrol/camcontrol.c:
   In rescan_or_reset_bus(), bzero the stack-allocated CCBs before
   use instead of clearing the body.

  Sponsored by: Spectra Logic

  ------------------------------------------------------------------------
  r307747 | ken | 2016-10-21 12:54:56 -0600 (Fri, 21 Oct 2016) | 27 lines

  Fix a problem in camcontrol(8) that cropped up with r307684.

  In r307684, I changed rescan_or_reset_bus() to bzero stack-allocated CCBs
  before sending them to the kernel because there was stack garbage in there
  that wound up meaning that bogus CCB flags were set.

  While this fixed the 'camcontrol rescan all' case (XPT_DEV_MATCH CCBs were
  failing previously), it broke the 'camcontrol rescan 0' (or any other
  number) case when INVARIANTS are turned on.  Rescanning a single bus
  reliably produced an assert in cam_periph_runccb():

  panic: cam_periph_runccb: ccb=0xfffff80044ffe000, func_code=0x708, flags=0xffffdde0

  The flags values don't make sense from the code.  Changing the CCBs in
  rescan_or_reset_bus() from stack to heap allocated avoids the problem.

  It would be better to understand why userland stack allocated CCBs don't
  work properly, since there may be other code that breaks if stack allocated
  CCBs don't work.

  sbin/camcontrol/camcontrol.c:
   In rescan_or_reset_bus(), allocate the CCBs using malloc(3) instead
   of on the stack to avoid an assertion in cam_periph_runccb().

  Sponsored by: Spectra Logic

  ------------------------------------------------------------------------

Sponsored by: Spectra Logic

git-svn-id: svn://svn.freebsd.org/base/stable/10@309956 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sbin/camcontrol/camcontrol.c