From nobody Tue Feb 27 18:26:00 2024 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 4TkmBw75gtz5CBYb for ; Tue, 27 Feb 2024 18:26: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 4TkmBw3VFZz4tkl for ; Tue, 27 Feb 2024 18:26:00 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709058360; a=rsa-sha256; cv=none; b=bjv1sKekryDwcxZ32gYNvcrUJkbDSROmp/bsin3HtYof63Tdl5IdCjgio+ozk7zwYPjPEb gNWpFfXkEY4EpGUmSP4SZiKqK9Fw42v7x8FR0d8EZmOEDCT/o3mJrJYY0B5l27nJ3IqU6G lT1uJRV0/9IHvumn4b/R7EOxPCgkoILfBTnKGstTH2ddzG82o6a6n3n2TsjOg0/eDfrx/E 4JzDYTxHSeRbeaJESworXN5c5iJG02nYNzcOH24V/3LharH0QoLw4cgObe2Lka55RS8NoS bSOJSX/kTd/jsBdo0pzgxGsOg8mqZYkJOoyEA9aEmtRU/R+2ji4DU+6hX5uGNQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709058360; 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=p6i5KKdAKQzbC5X7wNnCce/nXirKNJoHprMAnSOYCgI=; b=xwKFYyrMW1S/Lm0Z9Mz5852N+yh4ltF8vRQCDC0YBlnXr16YInj4pvYCxgUWukC6Ly5748 YBDgGMuXunOcBlwpH3ZeraKTv1QNHhl7sT0OROMYimnVkWGA2cY1W9piNULckFZJlgu2f2 lIbgiMQ/GGmKk2sVfLtunwH1BFggZBV7xNA+sHctNJhsicg5Ey3bZyeCreOWJuSjDQRMPN V6Ebjq3DiYr6yaUEKM3bv98eZj/9gqAOVOwistej16Y2W/U4CRwuAySCeP5HBnx4r0AMKJ I91gUBhsW8+ql7WXJuH8In3pPdS6/r7hC6DTFLr3vVYd9YWKfOWeqQhP1JIIEg== 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 4TkmBw2bGLzNm2 for ; Tue, 27 Feb 2024 18:26: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 41RIQ0SO012963 for ; Tue, 27 Feb 2024 18:26:00 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 41RIQ04b012962 for bugs@FreeBSD.org; Tue, 27 Feb 2024 18:26: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 277360] use-after-free or MPASS() failure during tarfs mount Date: Tue, 27 Feb 2024 18:26: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 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D277360 Bug ID: 277360 Summary: use-after-free or MPASS() failure during tarfs mount 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 248798 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D248798&action= =3Dedit corrupt tar image that triggers a tarfs use-after-free I've attached a tar image which, if mounted with tarfs on an INVARIANTS kernel, fails this MPASS() in tarfs_lookup_path(): MPASS(name !=3D NULL && namelen !=3D 0); On a non-INVARIANTS kernel, this image causes tarfs to use memory after freeing it. tarfs_alloc_mount() encounters an error from tarfs_alloc_one(), and calls tarfs_free_mount(). The latter frees everything on tmp->allnodes. But if the root tarfs_node is early on the list, then tarfs_free_node()'s recursive call case VDIR: ...; if (tnp->parent !=3D NULL && tnp->parent !=3D tnp) tarfs_free_node(tnp->parent); can use a tnp->parent that is the now-freed root tarfs_node. Without INVARIANTS: # uname -a FreeBSD 15.0-CURRENT FreeBSD 15.0-CURRENT #221 main-n250978-0a0623e9c824-dirty: Tue Feb 27 09:42:26 EST 2024=20=20=20=20 rtm@zika:/usr/obj/usr/rtm/symbsd/src/riscv.riscv64/sys/RTM riscv # mount -t tarfs tarfs2a.tar /mnt panic: pmap_kextract: No l2 KDB: stack backtrace: db_trace_self() at db_trace_self db_trace_self_wrapper() at db_trace_self_wrapper+0x36 kdb_backtrace() at kdb_backtrace+0x2c vpanic() at vpanic+0x120 panic() at panic+0x26 pmap_kextract() at pmap_kextract+0xfa free() at free+0x4e tarfs_free_node() at tarfs_free_node+0x8e tarfs_free_node() at tarfs_free_node+0x7a tarfs_alloc_mount() at tarfs_alloc_mount+0x100a tarfs_mount() at tarfs_mount+0x344 vfs_domount_first() at vfs_domount_first+0x20e vfs_domount() at vfs_domount+0x278 vfs_donmount() at vfs_donmount+0x89e sys_nmount() at sys_nmount+0x5a do_trap_user() at do_trap_user+0x23a cpu_exception_handler_user() at cpu_exception_handler_user+0x72 --- syscall (378, FreeBSD ELF64, nmount) With INVARIANTS: panic: Assertion name !=3D NULL && namelen !=3D 0 failed at /usr/src/sys/fs/tarfs/tarfs_vfsops.c:299 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe01255e7= 2c0 vpanic() at vpanic+0x135/frame 0xfffffe01255e73f0 panic() at panic+0x43/frame 0xfffffe01255e7450 tarfs_lookup_path() at tarfs_lookup_path+0x362/frame 0xfffffe01255e74f0 tarfs_alloc_mount() at tarfs_alloc_mount+0x19c3/frame 0xfffffe01255e78d0 tarfs_mount() at tarfs_mount+0x407/frame 0xfffffe01255e7ad0 vfs_domount_first() at vfs_domount_first+0x258/frame 0xfffffe01255e7c10 vfs_domount() at vfs_domount+0x318/frame 0xfffffe01255e7d30 vfs_donmount() at vfs_donmount+0x8dd/frame 0xfffffe01255e7dc0 sys_nmount() at sys_nmount+0x6c/frame 0xfffffe01255e7e00 amd64_syscall() at amd64_syscall+0x153/frame 0xfffffe01255e7f30 fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe01255e7f30 --- syscall (378, FreeBSD ELF64, nmount), rip =3D 0x25b598c3f23a, rsp =3D 0x25b59668f6e8, rbp =3D 0x25b59668fc50 --- --=20 You are receiving this mail because: You are the assignee for the bug.=