From owner-freebsd-bugs@freebsd.org Thu Sep 20 13:44:53 2018 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D24E1109D51F for ; Thu, 20 Sep 2018 13:44:52 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 5B8EE8DC6C for ; Thu, 20 Sep 2018 13:44:52 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id 20706109D51A; Thu, 20 Sep 2018 13:44:52 +0000 (UTC) Delivered-To: bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F2858109D519 for ; Thu, 20 Sep 2018 13:44:51 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 94F188DC64 for ; Thu, 20 Sep 2018 13:44:51 +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 mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id CA4F3153B4 for ; Thu, 20 Sep 2018 13:44:50 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id w8KDiobE004668 for ; Thu, 20 Sep 2018 13:44:50 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id w8KDio0o004667 for bugs@FreeBSD.org; Thu, 20 Sep 2018 13:44:50 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 231515] Potential out-of-bounds access in function pmap_bootstrap (sys/riscv/riscv/pmap.c) Date: Thu, 20 Sep 2018 13:44:50 +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: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: yangx92@hotmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: 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 attachments.created 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.27 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Sep 2018 13:44:53 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D231515 Bug ID: 231515 Summary: Potential out-of-bounds access in function pmap_bootstrap (sys/riscv/riscv/pmap.c) Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: yangx92@hotmail.com Created attachment 197279 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D197279&action= =3Dedit Patch_for_RISCV_OUT-OF-BOUNDS-ACCESS There is a potential out-of-bounds access in function pmap_bootstrap (sys/riscv/riscv/pmap.c). 563 void 564 pmap_bootstrap(vm_offset_t l1pt, vm_paddr_t kernstart, vm_size_t kernl= en) 565 { 566 u_int l1_slot, l2_slot, avail_slot, map_slot, used_map_slot; 567 uint64_t kern_delta; 568 pt_entry_t *l2; 569 vm_offset_t va, freemempos; 570 vm_offset_t dpcpu, msgbufpv; 571 vm_paddr_t pa, min_pa, max_pa; 572 int i; ... 621 map_slot =3D avail_slot =3D 0; 622 for (; map_slot < (physmap_idx * 2); map_slot +=3D 2) { 623 if (physmap[map_slot] =3D=3D physmap[map_slot + 1]) 624 continue; 625=20 626 if (physmap[map_slot] <=3D pa && 627 physmap[map_slot + 1] > pa) 628 break; 629=20 630 phys_avail[avail_slot] =3D physmap[map_slot]; 631 phys_avail[avail_slot + 1] =3D physmap[map_slot + 1]; 632 physmem +=3D (phys_avail[avail_slot + 1] - 633 phys_avail[avail_slot]) >> PAGE_SHIFT; 634 avail_slot +=3D 2; 635 } 636=20 637 /* Add the memory before the kernel */ 638 if (physmap[avail_slot] < pa) { 639 phys_avail[avail_slot] =3D physmap[map_slot]; 640 phys_avail[avail_slot + 1] =3D pa; 641 physmem +=3D (phys_avail[avail_slot + 1] - 642 phys_avail[avail_slot]) >> PAGE_SHIFT; 643 avail_slot +=3D 2; 644 } ... 737 } avail_slot may bigger or equal than PHYS_AVAIL_SIZE - 2 in loop (line 634). Then, there would be out-of-bounds access for phys_avail array in line 630, 631, 639, 640 and so on. The attachment is the proposal patch for this vulnerability. --=20 You are receiving this mail because: You are the assignee for the bug.=