From owner-svn-src-stable@freebsd.org Tue Sep 3 16:20:05 2019 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7A637E169E; Tue, 3 Sep 2019 16:20:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46NBxd2SZvz3K5F; Tue, 3 Sep 2019 16:20:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 342A15819; Tue, 3 Sep 2019 16:20:05 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x83GK5ii035207; Tue, 3 Sep 2019 16:20:05 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x83GK4pJ035202; Tue, 3 Sep 2019 16:20:04 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201909031620.x83GK4pJ035202@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 3 Sep 2019 16:20:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r351752 - in stable/12/sys/cam: ata mmc nvme scsi X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12/sys/cam: ata mmc nvme scsi X-SVN-Commit-Revision: 351752 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Sep 2019 16:20:05 -0000 Author: mav Date: Tue Sep 3 16:20:04 2019 New Revision: 351752 URL: https://svnweb.freebsd.org/changeset/base/351752 Log: MFC r351606: Take proper lock in ses_setphyspath_callback(). XPT_DEV_ADVINFO call should be protected by the lock of the specific device it is addressed to, not the lock of SES device. In some weird case, probably with hardware violating standards, it sometimes caused NULL dereference due to race. To protect from it further, add lock assertion to *_dev_advinfo(). Modified: stable/12/sys/cam/ata/ata_xpt.c stable/12/sys/cam/mmc/mmc_xpt.c stable/12/sys/cam/nvme/nvme_xpt.c stable/12/sys/cam/scsi/scsi_enc_ses.c stable/12/sys/cam/scsi/scsi_xpt.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cam/ata/ata_xpt.c ============================================================================== --- stable/12/sys/cam/ata/ata_xpt.c Tue Sep 3 16:18:07 2019 (r351751) +++ stable/12/sys/cam/ata/ata_xpt.c Tue Sep 3 16:20:04 2019 (r351752) @@ -1726,8 +1726,9 @@ ata_dev_advinfo(union ccb *start_ccb) { struct cam_ed *device; struct ccb_dev_advinfo *cdai; - off_t amt; + off_t amt; + xpt_path_assert(start_ccb->ccb_h.path, MA_OWNED); start_ccb->ccb_h.status = CAM_REQ_INVALID; device = start_ccb->ccb_h.path->device; cdai = &start_ccb->cdai; Modified: stable/12/sys/cam/mmc/mmc_xpt.c ============================================================================== --- stable/12/sys/cam/mmc/mmc_xpt.c Tue Sep 3 16:18:07 2019 (r351751) +++ stable/12/sys/cam/mmc/mmc_xpt.c Tue Sep 3 16:20:04 2019 (r351752) @@ -341,6 +341,7 @@ mmc_dev_advinfo(union ccb *start_ccb) struct ccb_dev_advinfo *cdai; off_t amt; + xpt_path_assert(start_ccb->ccb_h.path, MA_OWNED); start_ccb->ccb_h.status = CAM_REQ_INVALID; device = start_ccb->ccb_h.path->device; cdai = &start_ccb->cdai; Modified: stable/12/sys/cam/nvme/nvme_xpt.c ============================================================================== --- stable/12/sys/cam/nvme/nvme_xpt.c Tue Sep 3 16:18:07 2019 (r351751) +++ stable/12/sys/cam/nvme/nvme_xpt.c Tue Sep 3 16:20:04 2019 (r351752) @@ -588,8 +588,9 @@ nvme_dev_advinfo(union ccb *start_ccb) { struct cam_ed *device; struct ccb_dev_advinfo *cdai; - off_t amt; + off_t amt; + xpt_path_assert(start_ccb->ccb_h.path, MA_OWNED); start_ccb->ccb_h.status = CAM_REQ_INVALID; device = start_ccb->ccb_h.path->device; cdai = &start_ccb->cdai; Modified: stable/12/sys/cam/scsi/scsi_enc_ses.c ============================================================================== --- stable/12/sys/cam/scsi/scsi_enc_ses.c Tue Sep 3 16:18:07 2019 (r351751) +++ stable/12/sys/cam/scsi/scsi_enc_ses.c Tue Sep 3 16:20:04 2019 (r351752) @@ -1027,7 +1027,7 @@ ses_setphyspath_callback(enc_softc_t *enc, enc_element args = (ses_setphyspath_callback_args_t *)arg; old_physpath = malloc(MAXPATHLEN, M_SCSIENC, M_WAITOK|M_ZERO); - cam_periph_lock(enc->periph); + xpt_path_lock(path); xpt_setup_ccb(&cdai.ccb_h, path, CAM_PRIORITY_NORMAL); cdai.ccb_h.func_code = XPT_DEV_ADVINFO; cdai.buftype = CDAI_TYPE_PHYS_PATH; @@ -1052,7 +1052,7 @@ ses_setphyspath_callback(enc_softc_t *enc, enc_element if (cdai.ccb_h.status == CAM_REQ_CMP) args->num_set++; } - cam_periph_unlock(enc->periph); + xpt_path_unlock(path); free(old_physpath, M_SCSIENC); } Modified: stable/12/sys/cam/scsi/scsi_xpt.c ============================================================================== --- stable/12/sys/cam/scsi/scsi_xpt.c Tue Sep 3 16:18:07 2019 (r351751) +++ stable/12/sys/cam/scsi/scsi_xpt.c Tue Sep 3 16:20:04 2019 (r351752) @@ -2515,6 +2515,7 @@ scsi_dev_advinfo(union ccb *start_ccb) struct ccb_dev_advinfo *cdai; off_t amt; + xpt_path_assert(start_ccb->ccb_h.path, MA_OWNED); start_ccb->ccb_h.status = CAM_REQ_INVALID; device = start_ccb->ccb_h.path->device; cdai = &start_ccb->cdai;