From owner-svn-src-stable-11@freebsd.org Wed Sep 30 18:09:52 2020 Return-Path: Delivered-To: svn-src-stable-11@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 0DC8B42D54B; Wed, 30 Sep 2020 18:09:52 +0000 (UTC) (envelope-from jhb@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 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 4C1kmv6XPnz4bMx; Wed, 30 Sep 2020 18:09:51 +0000 (UTC) (envelope-from jhb@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 BF53823922; Wed, 30 Sep 2020 18:09:51 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 08UI9p9Z088313; Wed, 30 Sep 2020 18:09:51 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 08UI9p9r088312; Wed, 30 Sep 2020 18:09:51 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202009301809.08UI9p9r088312@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 30 Sep 2020 18:09:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r366297 - in stable: 11/sys/cam/scsi 12/sys/cam/scsi X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/sys/cam/scsi 12/sys/cam/scsi X-SVN-Commit-Revision: 366297 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-11@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Sep 2020 18:09:52 -0000 Author: jhb Date: Wed Sep 30 18:09:50 2020 New Revision: 366297 URL: https://svnweb.freebsd.org/changeset/base/366297 Log: MFC 366175: Revert most of r360179. I had failed to notice that sgsendccb() was using cam_periph_mapmem() and thus was not passing down user pointers directly to drivers. In practice this broke requests submitted from userland. PR: 249395 Modified: stable/11/sys/cam/scsi/scsi_sg.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/sys/cam/scsi/scsi_sg.c Directory Properties: stable/12/ (props changed) Modified: stable/11/sys/cam/scsi/scsi_sg.c ============================================================================== --- stable/11/sys/cam/scsi/scsi_sg.c Wed Sep 30 17:49:06 2020 (r366296) +++ stable/11/sys/cam/scsi/scsi_sg.c Wed Sep 30 18:09:50 2020 (r366297) @@ -506,7 +506,6 @@ sgioctl(struct cdev *dev, u_long cmd, caddr_t arg, int struct cam_periph *periph; struct sg_softc *softc; struct sg_io_hdr *req; - void *data_ptr; int dir, error; periph = (struct cam_periph *)dev->si_drv1; @@ -551,20 +550,12 @@ sgioctl(struct cdev *dev, u_long cmd, caddr_t arg, int break; } - if (req->dxfer_len > MAXPHYS) { - error = EINVAL; - break; - } - - data_ptr = malloc(req->dxfer_len, M_DEVBUF, M_WAITOK); - ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL); csio = &ccb->csio; error = copyin(req->cmdp, &csio->cdb_io.cdb_bytes, req->cmd_len); if (error) { - free(data_ptr, M_DEVBUF); xpt_release_ccb(ccb); break; } @@ -585,21 +576,12 @@ sgioctl(struct cdev *dev, u_long cmd, caddr_t arg, int break; } - if (dir == CAM_DIR_IN || dir == CAM_DIR_BOTH) { - error = copyin(req->dxferp, data_ptr, req->dxfer_len); - if (error) { - free(data_ptr, M_DEVBUF); - xpt_release_ccb(ccb); - break; - } - } - cam_fill_csio(csio, /*retries*/1, sgdone, dir|CAM_DEV_QFRZDIS, MSG_SIMPLE_Q_TAG, - data_ptr, + req->dxferp, req->dxfer_len, req->mx_sb_len, req->cmd_len, @@ -609,7 +591,6 @@ sgioctl(struct cdev *dev, u_long cmd, caddr_t arg, int if (error) { req->host_status = DID_ERROR; req->driver_status = DRIVER_INVALID; - free(data_ptr, M_DEVBUF); xpt_release_ccb(ccb); break; } @@ -628,10 +609,6 @@ sgioctl(struct cdev *dev, u_long cmd, caddr_t arg, int req->sb_len_wr); } - if ((dir == CAM_DIR_OUT || dir == CAM_DIR_BOTH) && error == 0) - error = copyout(data_ptr, req->dxferp, req->dxfer_len); - - free(data_ptr, M_DEVBUF); xpt_release_ccb(ccb); break;