From nobody Sat Jan 04 20:13:16 2025 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 4YQWph5pWcz5jlGg for ; Sat, 04 Jan 2025 20:13:16 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YQWph02nsz4Gny for ; Sat, 4 Jan 2025 20:13:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1736021596; 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=0PJpB6a1KwAinai6sRLLSjUG4yq5DMGDr/qSZ6O4mts=; b=vRaPjVyquYRaa9h49T8YLv3aePPEqHywMLhj3/8F1EYecWB5y8qMzVbp1xnS1IZmDu6lg3 6s8TNfWyPfTshcOBjFV7b6MKNHYTQ7uqcGYGxIJ0wKO6fkXvr7Zbr0qg4BxeZmWsH8hdsr qeaxo8V/xJ43HiAkqwgBEg1jAcGjV6BF7GGAGfLgocmP8J8KDPOYF9o1ZaShKr/GbHe0nq q1sSEbFpbogkpB9EQ41BUiYD2r/GZbUKLTKEYuk5XUXQBUPtgSiy2GESBJqPM9tysnfXD5 pIOzfjPgdiGM9Crdf0dnxvTNApxQxxcudzbUX2ZY+xYTMEqnuTRfuss9q4CnSA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736021596; a=rsa-sha256; cv=none; b=kC5yJ05xrGOwUgwpZZEmMM9+bdxLdkrBbcM8wpwxtXlnuqqsQ5ZXrnTTQsx+ddAJh+hsgc /kJiGRo7Sr18xBOHGIhSTdQmUIHVIiBCDCTdznM65xOyOaB8XYPcSWW4NXJNg3+Juzsp/p EBUgxpuWK3s2K5RHrhRUqsQRWYS+4IzoI9mM57676ART2JM7FiHUJlhMhF9CeUQvN8p8N1 XKNuJqX3TVVjDmbMpSDNVW8dtnjvh3F1ybpyM4ugRnxIWfZAFD74b9nCKFF/39JBfAF7nL flReAAOzVs6vfm0od3wvxy/8kPJqnOEonc6bmKoBonFZmB2HE5r1lUhjbE5rww== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YQWpg6hNBz16xX for ; Sat, 04 Jan 2025 20:13:15 +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 504KDFnv008245 for ; Sat, 4 Jan 2025 20:13:15 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 504KDFfL008244 for bugs@FreeBSD.org; Sat, 4 Jan 2025 20:13:15 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 283848] rtnl_handle_newroute() incomplete check of attrs.rta_table Date: Sat, 04 Jan 2025 20:13:16 +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.mimetype 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=3D283848 Bug ID: 283848 Summary: rtnl_handle_newroute() incomplete check of attrs.rta_table 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 Attachment #256427 text/plain mime type: Created attachment 256427 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D256427&action= =3Dedit pass a too-large rtm_table to RTM_NEWROUTE The attached program passes an rtm_table that's too large to netlink RTM_NEWROUTE. With INVARIANTS, this fails in rt_tables_get_rnh_ptr(): KASSERT(table < V_rt_numfibs, ("%s: table out of bounds (%d < %d)", __func__, table, V_rt_numfibs)); Without INVARIANTS, the function returns junk from beyond the end of V_rt_tables rather than a proper pointer. Perhaps a contributing factor is that rtnl_handle_newroute() only checks rta_table in one arm of the "if": if (attrs.rtm_table > 0 && attrs.rta_table =3D=3D 0) { /* pre-2.6.19 Linux API compatibility */ attrs.rta_table =3D attrs.rtm_table; } else if (attrs.rta_table >=3D V_rt_numfibs) { NLMSG_REPORT_ERR_MSG(npt, "invalid fib"); return (EINVAL); } I think also rtm_family ought to be checked against AF_MAX to avoid tripping over the relevant KASSERT in rt_tables_get_rnh_ptr(). # uname -a FreeBSD 15.0-CURRENT FreeBSD 15.0-CURRENT #345 main-n250995-3750873316a1-dirty: Sat Jan 4 13:51:03 EST 2025=20=20=20=20 rtm@zika:/usr/obj/usr/rtm/symbsd/src/riscv.riscv64/sys/RTM riscv # cc netlink12b.c # ./a.out panic: rt_tables_get_rnh_ptr: table out of bounds (1 < 1) cpuid =3D 0 time =3D 1735920333 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+0x16e panic() at panic+0x26 rt_tables_get_rnh() at rt_tables_get_rnh+0x9a nhop_get_nhop() at nhop_get_nhop+0x1e finalize_nhop() at finalize_nhop+0xd4 rtnl_handle_newroute() at rtnl_handle_newroute+0x4a2 rtnl_handle_message() at rtnl_handle_message+0x12a nl_taskqueue_handler() at nl_taskqueue_handler+0x49a taskqueue_run_locked() at taskqueue_run_locked+0x158 taskqueue_thread_loop() at taskqueue_thread_loop+0xd4 fork_exit() at fork_exit+0x68 fork_trampoline() at fork_trampoline+0xa KDB: enter: panic --=20 You are receiving this mail because: You are the assignee for the bug.=