From nobody Sun Jan 05 14:01:26 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 4YQzWC6gPVz5jk9p for ; Sun, 05 Jan 2025 14:01:27 +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 4YQzWC2jhzz4r4c for ; Sun, 5 Jan 2025 14:01:27 +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=1736085687; 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=RfimAKqJiRO1wl9zELfU2ygQmzly0LsO8KWRTlmU9Tg=; b=oYVrgaZiGvIxc2V1pF2O4Lt49RF2NDSwdo8McUNobxaWW+zJokPMCsAmuKT5g0GvNc3VLu yHQvXbCqqMFGI+QV9zQsXsQQvcuCwg7tF7hb6ICug0LFyWwrWdyWT+lju61Mw0HJBmKvL6 XVJTnrLGhfs4tr+mYtYFsp7UO23XwUbSteBz4S8TTUWRqClom4OF88W9C/v0BBtdq1A7mq doXNnLeYW4Ft0AUqAA3P2HJ7oHwkQMFzMI0OTs+vV0nDiT+SsAfQoeeS2szZDssqgUITCt zA9/Paaa9qUcvc072JhpOFb+v1jiNmscgSeWAA8qUpHhBKnB3LPirgaU58vkxw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1736085687; a=rsa-sha256; cv=none; b=XlZEJ6TaqV9D8MwJXuDfhx65la9LCSk88JF+B3Sm4aSvVh47i1YSlWwh2RPM5PkrDhMALt MC+HNdyk1BH5+tvUS6hn8o+cApqyhS6ED/9G9W+uM7pY7V+CrcInQXmxiXaNiYlhmMNz0Q MQ6WXmwvYnRDVDgZ+/HllyaBK7aSNSUf1G83JXEHzOMr4AcqKgKw0cmhx2eY/vssG8J2FC GCetRYm3lr3CmJ3TOrhHIoQXDE5+55W4Zaus6KRUEzBc/T/YH4NgjTlrmvIYDa6qeVkVdo AMv5mX6aolbu+3/34g7+U3ggKe++kEI2KNMAG0tig1Avp2ZxrX7BzXuCYpjFdQ== 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 4YQzWC2DTrzjBR for ; Sun, 05 Jan 2025 14:01:27 +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 505E1RoG015724 for ; Sun, 5 Jan 2025 14:01:27 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 505E1RIc015723 for bugs@FreeBSD.org; Sun, 5 Jan 2025 14:01:27 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 283860] nlattr_get_multipath() loop executes too many times if rtnh_len is zero Date: Sun, 05 Jan 2025 14:01:26 +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=3D283860 Bug ID: 283860 Summary: nlattr_get_multipath() loop executes too many times if rtnh_len is zero 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 #256438 text/plain mime type: Created attachment 256438 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D256438&action= =3Dedit cause nlattr_get_multipath() to execute loop indefinitely If a program calls netlink() NETLINK_ROUTE RTM_NEWROUTE with an RTA_MULTIPATH TLV whose first rtnexthop has rtnh_len of zero, the "for" loop in nlattr_get_multipath() will execute too many times, since the "data_len -=3D len" won't actually decrease data_len. Each iteration increments mp->num_hops, so that there's the possibility of nl_parser_header() writing off the end of the space allocated for mp. A similar scenario results if rtnh_len is 65533, so that this line yields len =3D 0 (since rtnh_len is unsigned short): int len =3D NL_ITEM_ALIGN(rtnh->rtnh_len); I've attached a demo. On one of my machines it does write off the end of allocated space and causes a redzone panic. But even without that one can see the problem by turning on netlink debugging output. # uname -a FreeBSD xxx 15.0-CURRENT FreeBSD 15.0-CURRENT #25 main-n274459-9ba7351fcfd7: Sun Dec 29 16:47:27 AST 2024=20=20=20=20 root@xxx:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 # cc netlink14b.c # sysctl -w net.netlink.debug.nl_parser_debug_level=3D100 # sysctl -w net.netlink.debug.nl_route_debug_level=3D100 # ./a.out [nl_parser] nl_parse_attrs_raw: parse 0xfffff800432b7038 remaining_len 100 [nl_parser] nl_parse_attrs_raw: >> parsing 0xfffff800432b7038 attr_type 1 l= en 8 (rem 100) [nl_parser] nl_parse_attrs_raw: >> parsing 0xfffff800432b7040 attr_type 9 l= en 12 (rem 92) [nl_parser] nl_parse_attrs_raw: parse 0xfffff800432b7104 remaining_len 0 [nl_parser] nl_parse_attrs_raw: end parse: 0 remaining_len 0 [nl_parser] nl_parse_attrs_raw: parse 0xfffff800432b7114 remaining_len 0 [nl_parser] nl_parse_attrs_raw: end parse: 0 remaining_len 0 [nl_parser] nl_parse_attrs_raw: parse 0xfffff800432b7124 remaining_len 0 [nl_parser] nl_parse_attrs_raw: end parse: 0 remaining_len 0 ... many more ... [nl_parser] nl_parse_attrs_raw: parse 0xfffff800432b7504 remaining_len 0 [nl_parser] nl_parse_attrs_raw: end parse: 0 remaining_len 0 [nl_parser] nl_parse_attrs_raw: parse 0xfffff800432b7514 remaining_len 0 [nl_parser] nl_parse_attrs_raw: end parse: 0 remaining_len 0 [nl_route] PID 9005 nlattr_get_multipath: RTA_MULTIPATH: nexhop 66: parse failed [nl_parser] nl_parse_attrs_raw: parse failed at offset 36 --=20 You are receiving this mail because: You are the assignee for the bug.=