From nobody Sat Jul 09 20:21:22 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 39EF817FF9EE for ; Sat, 9 Jul 2022 20:21:23 +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 4LgM426c6Cz49MV for ; Sat, 9 Jul 2022 20:21:22 +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 4LgM425gkszyTS for ; Sat, 9 Jul 2022 20:21:22 +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 269KLMcd057095 for ; Sat, 9 Jul 2022 20:21:22 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 269KLMpx057094 for bugs@FreeBSD.org; Sat, 9 Jul 2022 20:21:22 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 265119] bmake ParseDependency() can read off the end of its input buffer Date: Sat, 09 Jul 2022 20:21:22 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: misc 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=1657398082; 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=Tz0OkXwbpTkNXTMtX+phceNdYYxlDsyvyIkdm3YXAd8=; b=wA1umV0SjL6L3pkcRm2B2QJ+fshfeIB2/tqcNiTm0yriVxAgdLZTaUSKXZiY+2fs3YKVQ1 0at7dj0lVHAkklx5gXXoghI5aV/mL0ixot0tFwqK449pk7xmXUKw0KMkxwtk8bKthxUjhl +jn61qBKj+4u9h2mqUPglVAzdBDTQF9Go1q+9xeXSQVqsL76GuMSTdlFJmlGA9ilR6mMFN kruT0vdkcZwwID5DF5kVcXvGwGyghRaQhVmfyF45vW881QJOv+xlzgRc9UhYOlIT1qAeDa CRI/AXJIRw/MlajzdxYm+qxNUlzKCaJqgAUeZk34a5a/95WAw7vyqQ6KYCZCbA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657398082; a=rsa-sha256; cv=none; b=jY8ONDlPiPgpLRF1iCSjrPhYVDEC1rZJtGJE4KygAqBQTMuJkw26QrL5U6akJoSdl3we1g 0UJwpzH9XJOfBbtCo0zM0zTdku1yobcilYm/ZJJYoE4hZFg2BB5I4QVU48j4VygNZzgyVD JBcwqDxgp7/nQ0BKAc4/300OwaFQBgHaC+7bIOK6Y61HldSTY4DbVf/IroVdDUpf06HEqn 7pKZjetrBR2mpdpDnfBxnCV13XJVcVBY1cSnvc74uBiCvKuUfQCZDumT6xMEijNYKI4c/u WmhIue6UAlq5Mks4r6zOTp7zI+H6Pu/OhH4EVcRQs/pLhccFveED7giZZYelag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D265119 Bug ID: 265119 Summary: bmake ParseDependency() can read off the end of its input buffer Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: misc Assignee: bugs@FreeBSD.org Reporter: rtm@lcs.mit.edu Created attachment 235154 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D235154&action= =3Dedit A makefile filled with garbage that illustrates a bug in bmake. In this code in bmake's parse.c: static GNodeType ParseDependencyOp(char **pp) { if (**pp =3D=3D '!') return (*pp)++, OP_FORCE; if ((*pp)[1] =3D=3D ':') return *pp +=3D 2, OP_DOUBLEDEP; else return (*pp)++, OP_DEPENDS; } If bmake's parser has reached the end of the input, so that **pp =3D=3D '\0', then it executes the last line, incrementing *pp and causing the parser to venture into the unknown. I'm using a recent FreeBSD-current, on amd64, and /usr/src/contrib/bmake says _MAKE_VERSION=3D20220208 You can see the problem by compiling bmake with -fsanitize=3Daddress, and running it against the attached (broken) Makefile: % ./bmake -f bmake4b.out make: "bmake4b.out" line 2: Invalid line type make: "bmake4b.out" line 4: Unclosed variable "" =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D92690=3D=3DERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000008d34 at pc 0x0000011866c5 bp 0x7fffffffe200 sp 0x7fffffffe1f8 READ of size 1 at 0x602000008d34 thread T0 #0 0x11866c4 in ParseDependencyOp contrib/bmake/parse.c:1117:6 #1 0x11858fd in ParseDependency contrib/bmake/parse.c:1480:26 #2 0x1182685 in ParseDependencyLine contrib/bmake/parse.c:2821:2 #3 0x117b780 in ParseLine contrib/bmake/parse.c:2872:2 #4 0x117aa02 in Parse_File contrib/bmake/parse.c:2897:4 #5 0x115fe72 in ReadMakefile contrib/bmake/main.c:1709:3 #6 0x115f74f in ReadAllMakefiles contrib/bmake/main.c:1300:8 #7 0x11574fd in main_ReadFiles contrib/bmake/main.c:1516:3 #8 0x1156946 in main contrib/bmake/main.c:1645:2 --=20 You are receiving this mail because: You are the assignee for the bug.=