From owner-svn-src-stable@freebsd.org Thu Oct 22 16:29:22 2020 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 938C944CC1B; Thu, 22 Oct 2020 16:29:22 +0000 (UTC) (envelope-from brooks@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 4CHCVp3N28z4616; Thu, 22 Oct 2020 16:29:22 +0000 (UTC) (envelope-from brooks@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 3951B19879; Thu, 22 Oct 2020 16:29:22 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09MGTMhE000357; Thu, 22 Oct 2020 16:29:22 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09MGTMxY000356; Thu, 22 Oct 2020 16:29:22 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <202010221629.09MGTMxY000356@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Thu, 22 Oct 2020 16:29:22 +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: r366939 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 366939 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.33 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: Thu, 22 Oct 2020 16:29:22 -0000 Author: brooks Date: Thu Oct 22 16:29:21 2020 New Revision: 366939 URL: https://svnweb.freebsd.org/changeset/base/366939 Log: MFC r366731: physio: Don't store user addresses in bio_data Only assign the address from the iovec to bio_data if it is a kernel address. This was the single place where bio_data stored (however briefly) a userspace pointer. Reviewed by: imp, markj Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D26783 Modified: stable/11/sys/kern/kern_physio.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_physio.c ============================================================================== --- stable/11/sys/kern/kern_physio.c Thu Oct 22 16:27:24 2020 (r366938) +++ stable/11/sys/kern/kern_physio.c Thu Oct 22 16:29:21 2020 (r366939) @@ -43,7 +43,7 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) struct buf *pbuf; struct bio *bp; struct vm_page **pages; - caddr_t sa; + char *base, *sa; u_int iolen, poff; int error, i, npages, maxpages; vm_prot_t prot; @@ -136,7 +136,7 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) curthread->td_ru.ru_oublock++; } bp->bio_offset = uio->uio_offset; - bp->bio_data = uio->uio_iov[i].iov_base; + base = uio->uio_iov[i].iov_base; bp->bio_length = uio->uio_iov[i].iov_len; if (bp->bio_length > dev->si_iosize_max) bp->bio_length = dev->si_iosize_max; @@ -149,13 +149,13 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) * larger than MAXPHYS - PAGE_SIZE must be * page aligned or it will be fragmented. */ - poff = (vm_offset_t)bp->bio_data & PAGE_MASK; + poff = (vm_offset_t)base & PAGE_MASK; if (pbuf && bp->bio_length + poff > pbuf->b_kvasize) { if (dev->si_flags & SI_NOSPLIT) { uprintf("%s: request ptr %p is not " "on a page boundary; cannot split " "request\n", devtoname(dev), - bp->bio_data); + base); error = EFBIG; goto doerror; } @@ -170,7 +170,7 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) if (pages) { if ((npages = vm_fault_quick_hold_pages( &curproc->p_vmspace->vm_map, - (vm_offset_t)bp->bio_data, bp->bio_length, + (vm_offset_t)base, bp->bio_length, prot, pages, maxpages)) < 0) { error = EFAULT; goto doerror; @@ -186,7 +186,8 @@ physio(struct cdev *dev, struct uio *uio, int ioflag) bp->bio_data = unmapped_buf; bp->bio_flags |= BIO_UNMAPPED; } - } + } else + bp->bio_data = base; csw->d_strategy(bp); if (uio->uio_rw == UIO_READ)