From nobody Wed Sep 28 21:41:59 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 4Md91h2fKqz4V7XN for ; Wed, 28 Sep 2022 21:42: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 4Md91h0gTgz3L4w for ; Wed, 28 Sep 2022 21:42: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 4Md91g6sQCzcGh for ; Wed, 28 Sep 2022 21:41:59 +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 28SLfxu3067429 for ; Wed, 28 Sep 2022 21:41:59 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 28SLfxk6067428 for bugs@FreeBSD.org; Wed, 28 Sep 2022 21:41:59 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 266693] llvm_textconf_decode() can LIST_REMOVE without previous LIST_INSERT_HEAD during taste Date: Wed, 28 Sep 2022 21:41:59 +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=1664401320; 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=36MYL1AFJn7/XERafD1XmLhXE7boOGPUDCSrSet9kvo=; b=Xj6DSGDRVY/QUd1QqAcEEBb9VP2spQvBWuYKG4iiWbr1dDPC1z61BI39ozRYugrX3KLtU1 toVUzw51hy/UgVbb9jbu/X9SGekyKOMmMUDC5MD6dcR27zHph71edT1iAKaj3DfU9Dn48d TQth3M7BNJOoQpMczRh8mZiyg5oLuVbCaNIzwzmFu8hybAphdVJO6DtCmtxK4toUEvojPL qRx8sqGoWn6IkmzsbZl0lHzP4E0xmiv7yE+s5vnvKjoRi8aJGws6zFst+Bn1pLOJIZKOhT 0P1KWmP7gGS/lkQrEYhZRB3rTSJGI2cefwJWbdWAXm+jJrP3HTuKaXWajQvDVg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664401320; a=rsa-sha256; cv=none; b=neSp0FokmTbKNZzDJqg7yYBKBOyFFUcORwvLvpTjBCdQj5o7QPpEu4NpvBRnZ2cF6O4fZt YdMkU1ENaK2mjTjho+1qkwBmoGPW9jNow36T1ZkAs0QHo5JS4TuJXoEGSWMvHxEZxSm1jJ ujyZr98N9baOGv1OtMwl8Oi2Gx7TW1DhC/OY328onuyMqoVUOnIgZ0o2YKIY1ls1gi8XqD SCPMFehDQmNzOlADIRS53wqkyFiMi6vEXplsviIiWX+ZsZBk23jH65Ky4DAyVN1YjOvTaE ZLVIwz9yp/w1LT6Yqwb6ANzbDusr1lCqV+owbR20PvhmNrHjYm3dJtT4NiEDuQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D266693 Bug ID: 266693 Summary: llvm_textconf_decode() can LIST_REMOVE without previous LIST_INSERT_HEAD during taste 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 236928 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D236928&action= =3Dedit malicious disk image that causes a page fault in g_llvm_free_vg() during ta= ste In llvm_textconf_decode(): /* basic checking */ if (vg->vg_extentsize =3D=3D 0) goto bad; md->md_vg =3D vg; LIST_INSERT_HEAD(&vg_list, vg, vg_next); G_LLVM_DEBUG(3, "vg: name=3D%s uuid=3D%s", vg->vg_name, vg->vg_uuid= ); return(0); bad: g_llvm_free_vg(vg); return (-1); This means g_llvm_free_vg(vg) can be called without vg having been inserted into the list. But the latter calls LIST_REMOVE(vg, vg_next) unconditionally. I've attached a demo: # kldload geom_linux_lvm # mdconfig -f taste62b.img panic: Fatal page fault at 0xffffffc08b604da6: 0000000000000000 panic() at panic+0x2a page_fault_handler() at page_fault_handler+0x1d6 do_trap_supervisor() at do_trap_supervisor+0x76 cpu_exception_handler_supervisor() at cpu_exception_handler_supervisor+0x70 --- exception 13, tval =3D 0 g_llvm_free_vg() at g_llvm_free_vg+0xc4 llvm_textconf_decode() at llvm_textconf_decode+0x4f4 g_llvm_read_md() at g_llvm_read_md+0x214 g_llvm_taste() at g_llvm_taste+0xd0 g_new_provider_event() at g_new_provider_event+0xb8 one_event() at one_event+0x102 g_run_events() at g_run_events+0x8a g_event_procbody() at g_event_procbody+0x56 fork_exit() at fork_exit+0x80 fork_trampoline() at fork_trampoline+0xa FreeBSD 14.0-CURRENT FreeBSD 14.0-CURRENT #197 main-n250931-18f03443a230-dirty: Wed Sep 28 17:36:45 EDT 2022=20=20=20=20 rtm@xxx:/usr/obj/usr/rtm/symbsd/src/riscv.riscv64/sys/RTM riscv --=20 You are receiving this mail because: You are the assignee for the bug.=