Project

General

Profile

Actions

Bug #11892

closed

ahciem doesn't properly check if enclosure services are present

Added by Robert Mustacchi over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Category:
driver - device drivers
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

Using ahci enclosure services on something without an enclosure service present can lead to a panic:

> ::status
debugging crash dump vmcore.0 (64-bit) from sun-srv-1
operating system: 5.11 illumos-cc7e66e6be (i86pc)
image uuid: ca0aa28b-b3bc-6da8-b748-d2ed8ea3c29a
panic message: BAD TRAP: type=e (#pf Page fault) rp=ffffff006ca37970 addr=38 occurred in module "genunix" due to a NULL pointer dereference
dump content: kernel pages only
> $C
ffffff006ca37ad0 taskq_dispatch+0x1b(0, fffffffff797cb30, ffffff16a71f3620, 0)
ffffff006ca37b00 ddi_taskq_dispatch+0x15(0, fffffffff797cb30, ffffff16a71f3620, 0)
ffffff006ca37b50 ahci_em_ioctl_set+0x10d(ffffff163b0ffe00, 8040800)
ffffff006ca37b90 ahci_em_ioctl+0x53(ffffff163a6e2d58, 61656d01, 8040800)
ffffff006ca37c90 sata_hba_ioctl+0x48f(b00000000, 61656d01, 8040800, 100003, ffffff16a1659568, ffffff006ca37de0)
ffffff006ca37cd0 cdev_ioctl+0x25(b00000000, 61656d01, 8040800, 100003, ffffff16a1659568, ffffff006ca37de0)
ffffff006ca37d20 spec_ioctl+0x4d(ffffff1651ca7400, 61656d01, 8040800, 100003, ffffff16a1659568, ffffff006ca37de0, 0)
ffffff006ca37db0 fop_ioctl+0x55(ffffff1651ca7400, 61656d01, 8040800, 100003, ffffff16a1659568, ffffff006ca37de0, 0)
ffffff006ca37ec0 ioctl+0x143(3, 61656d01, 8040800)
ffffff006ca37f10 sys_syscall32+0xff()

The problem is that we tried to dispatch to a non-existant taskq. While the ahci enclosure management code does check if the device is present, it does it after the taskq dispatch which is only created conditionally. The fix here is to make sure that we check that the AHCI_EM_PRESENT flag is there before doing anything else. We also should guard the suspend and resume paths.


Related issues

Related to illumos gate - Feature #9815: Want basic AHCI enclosure servicesClosedRobert Mustacchi2018-09-09

Actions
Actions #1

Updated by Robert Mustacchi over 3 years ago

  • Subject changed from ahciem doesn't properly check if enclsoure services are present to ahciem doesn't properly check if enclosure services are present
Actions #3

Updated by Robert Mustacchi over 3 years ago

  • Related to Feature #9815: Want basic AHCI enclosure services added
Actions #4

Updated by Robert Mustacchi over 3 years ago

To test this, I used a VM which previously reproduced this. Now, when I try to get or set information on this VM that doesn't support it properly fails:

$ pfexec /usr/lib/ahci/ahciem 
PORT                 ACTIVE       SUPPORTED
ahciem: failed to get AHCI enclosure information for ahci0: Operation not supported
$ pfexec /usr/lib/ahci/ahciem -s ident ahci0
ahciem: failed to get AHCI enclosure information for ahci0: Operation not supported
ahciem: failed to find ahci enclosure port "ahci0" 
$ pfexec /usr/lib/ahci/ahciem -s ident ahci0/*
ahciem: failed to get AHCI enclosure information for ahci0: Operation not supported
ahciem: failed to find ahci enclosure port "ahci0/*" 
Actions #5

Updated by Electric Monk over 3 years ago

  • Status changed from New to Closed
  • % Done changed from 90 to 100

git commit 4941d7e28c1065788adea77fa2518f4e208b4979

commit  4941d7e28c1065788adea77fa2518f4e208b4979
Author: Robert Mustacchi <rm@fingolfin.org>
Date:   2019-11-12T19:46:37.000Z

    11892 ahciem doesn't properly check if enclosure services are present
    Reviewed by: Jason King <jason.king@joyent.com>
    Reviewed by: John Levon <john.levon@joyent.com>
    Approved by: Joshua M. Clulow <josh@sysmgr.org>

Actions

Also available in: Atom PDF