Bug 270093 - sesutil fault all ... fails with EINVAL on inaccessible elements
Summary: sesutil fault all ... fails with EINVAL on inaccessible elements
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.1-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Alan Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-10 17:44 UTC by Alan Somers
Modified: 2023-09-06 20:55 UTC (History)
0 users

See Also:
asomers: mfc-stable13+
asomers: mfc-stable12-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Somers freebsd_committer freebsd_triage 2023-03-10 17:44:48 UTC
Some SAS JBODs support zoning.  This feature allows individual SAS targets to be accessible by only some initiator ports.  One application would be connecting two servers to the same JBOD, but they wouldn't be able to see each other's disks.

A zoned JBOD should also prohibit initiators from accessing SES elements corresponding to inaccessible SAS targets.  It reports that by setting the element's status code to 0x8 (No Access Allowed).

The bug is that when doing "sesutil (fault|locate) all ...", sesutil will attempt a ENCIOC_SETELMSTAT ioctl for every single element, even the inaccessible ones.  The enclosure will reject the command, the kernel will return EINVAL, and sesutil will exit.
Comment 1 commit-hook freebsd_committer freebsd_triage 2023-03-27 19:45:05 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=57dc6f5e200b10d34ccb97ccc18d06b3f0b9b933

commit 57dc6f5e200b10d34ccb97ccc18d06b3f0b9b933
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2023-03-10 17:47:08 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2023-03-27 19:43:35 +0000

    sesutil: fix "fault all" with zoned jbods

    Some SAS JBODs support zoning.  This feature allows individual SAS
    targets to be accessible by only some initiator ports.  One application
    would be connecting two servers to the same JBOD, but they wouldn't be
    able to see each other's disks.

    A zoned JBOD should also prohibit initiators from accessing SES elements
    corresponding to inaccessible SAS targets.  It reports that by setting
    the element's status code to 0x8 (No Access Allowed).

    The bug is that when doing "sesutil (fault|locate) all ...", sesutil
    will attempt a ENCIOC_SETELMSTAT ioctl for every single element, even
    the inaccessible ones.  The enclosure will reject the command, the
    kernel will return EINVAL, and sesutil will exit.

    The solution is to check the element's status, and skip trying to set it
    if the status is 0x8.  But if the user actually supplied a ses ID, then
    assume that he knows what he's doing and try to set it anyway.

    PR:             270093
    MFC after:      1 week
    Sponsored by:   Axcient
    Reviewed by:    mav, trasz
    Differential Revision: https://reviews.freebsd.org/D39017

 usr.sbin/sesutil/sesutil.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-09-06 20:41:01 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=a6506dda739c04186e7fe966687200cc74d36091

commit a6506dda739c04186e7fe966687200cc74d36091
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2023-03-10 17:47:08 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2023-09-06 20:39:35 +0000

    sesutil: fix "fault all" with zoned jbods

    Some SAS JBODs support zoning.  This feature allows individual SAS
    targets to be accessible by only some initiator ports.  One application
    would be connecting two servers to the same JBOD, but they wouldn't be
    able to see each other's disks.

    A zoned JBOD should also prohibit initiators from accessing SES elements
    corresponding to inaccessible SAS targets.  It reports that by setting
    the element's status code to 0x8 (No Access Allowed).

    The bug is that when doing "sesutil (fault|locate) all ...", sesutil
    will attempt a ENCIOC_SETELMSTAT ioctl for every single element, even
    the inaccessible ones.  The enclosure will reject the command, the
    kernel will return EINVAL, and sesutil will exit.

    The solution is to check the element's status, and skip trying to set it
    if the status is 0x8.  But if the user actually supplied a ses ID, then
    assume that he knows what he's doing and try to set it anyway.

    PR:             270093
    Sponsored by:   Axcient
    Reviewed by:    mav, trasz
    Differential Revision: https://reviews.freebsd.org/D39017

    (cherry picked from commit 57dc6f5e200b10d34ccb97ccc18d06b3f0b9b933)

 usr.sbin/sesutil/sesutil.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
Comment 3 Alan Somers freebsd_committer freebsd_triage 2023-09-06 20:55:52 UTC
Not bothering to MFC to stable/12.  Reopen if there's a need.