From nobody Thu Sep 22 15:11:00 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MYJdJ4vpkz4cZ41 for ; Thu, 22 Sep 2022 15:11:00 +0000 (UTC) (envelope-from bugzilla-noreply@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MYJdJ2rjdz3GkV for ; Thu, 22 Sep 2022 15:11:00 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MYJdJ1whRzRlF for ; Thu, 22 Sep 2022 15:11:00 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 28MFB0F2029446 for ; Thu, 22 Sep 2022 15:11:00 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 28MFB0J8029429 for bugs@FreeBSD.org; Thu, 22 Sep 2022 15:11:00 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 266548] malicious gpt can cause kernel page fault during tasting Date: Thu, 22 Sep 2022 15:11:00 +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 Some People X-Bugzilla-Who: rtm@lcs.mit.edu 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 List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663859460; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=L7UYPSDxI9GvtX4btDcS0SBPz9iL/5dRQAq7vwo00k4=; b=VJKlDbi7KE6N/UYOZgfoKRTC7sC/1eAU/MuajVRxLisBD4v9/dWTqbMPUh059dyqH7QHgn SIdM7O+dRR13IcErW/BEX4GMFs4CmRk7tB18thSKIaj/+P5+LS8Mj9jxKddhEsD1R3lu6V 5nxwqNv1xGo6XpqZMLg3MCwCAKXCb6319l8TpZvyL3exeOyuL+LRsWuQVyxOpYwkqrxLM4 +syBx23WkAIHVWNk9VWBCzLnH/9u+zrvaMfDuLJhhDzjNtUrhIZdtmwiIK5aqP25Snp4md Jlcdqx73S7vJ4HOGFw5JSdN2sNnaJUdL2lHSU2a6Bplx2oUD0n/1SiXSpFFI2g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663859460; a=rsa-sha256; cv=none; b=iCdTUK6aAeGCaUydN1YEqCRLFR2IUv+E1j5RSkn2nwvUUvfqKpndYyojJGnMyUz32qZonJ X00HDjGXx+gNdGlf1dbk/ZudSOFQEVhFX/kGyTYhU20/utJLzC20I/VFfhwahZBflUnWw5 Sf12XM/qcah54nQ645UMRI/2rqUKrP+x8flJ08+l+1WPYbgywudyNOVp/8/GZRAN0Mrg+g MeVBtKl/zMIYNCnTRvzPfFNWp+oCpKtH2sZok8ENSUZRvJ3Kx0k2vMHGN4PXL+MdFssJnD jknRdrrsL6uZgoXKQOx7EulMUjW8YIXE9lBIBWT95EUudiSVjTak5SJkcvGnGw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D266548 Bug ID: 266548 Summary: malicious gpt can cause kernel page fault during tasting Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: rtm@lcs.mit.edu Created attachment 236747 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D236747&action= =3Dedit a disk image that causes a crash in the GPT taste code I've attached a disk image that, if it's on a USB thumb drive and inserted (but not mounted), will cause a kernel page fault (or assertion failure for an INVARIANTS kernel). This code in gpt_read_tbl(): tbl =3D g_malloc(hdr->hdr_entries * sizeof(struct gpt_ent), M_WAITOK | M_ZERO); The disk image contains the crazy value hdr_entries=3D4294967295; g_malloc()'s size argument is a 32-bit signed int, and the result is to call g_malloc(-128). Here's a backtrace from a CURRENT amd64 machine with INVARIANTS: # uname -a FreeBSD stock14 14.0-CURRENT FreeBSD 14.0-CURRENT #3 main-n258027-c9baa9747= 17a: Thu Sep 15 20:02:51 AST 2022=20=20=20=20 root@stock14:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 # mdconfig -f taste18a.img panic: Assertion size > 0 failed at /usr/src/sys/kern/subr_vmem.c:1332 cpuid =3D 0 time =3D 1663856658 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe0063aa0= c00 vpanic() at vpanic+0x151/frame 0xfffffe0063aa0c50 panic() at panic+0x43/frame 0xfffffe0063aa0cb0 vmem_alloc() at vmem_alloc+0xf1/frame 0xfffffe0063aa0ce0 kmem_malloc_domainset() at kmem_malloc_domainset+0x92/frame 0xfffffe0063aa0= d50 malloc_large() at malloc_large+0x2f/frame 0xfffffe0063aa0d80 gpt_read_tbl() at gpt_read_tbl+0x25f/frame 0xfffffe0063aa0e00 g_part_gpt_read() at g_part_gpt_read+0xfb/frame 0xfffffe0063aa0e60 g_part_taste() at g_part_taste+0x172/frame 0xfffffe0063aa0ea0 g_new_provider_event() at g_new_provider_event+0x9a/frame 0xfffffe0063aa0ec0 g_run_events() at g_run_events+0x104/frame 0xfffffe0063aa0ef0 fork_exit() at fork_exit+0x80/frame 0xfffffe0063aa0f30 fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe0063aa0f30 Without INVARIANTS, the kernel gets a bit farther before a page fault. --=20 You are receiving this mail because: You are the assignee for the bug.=