From nobody Sat Jun 15 09:39:35 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 4W1WMD2T7Tz5NT7L for ; Sat, 15 Jun 2024 09:39:36 +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 4W1WMD0kT7z4qmD for ; Sat, 15 Jun 2024 09:39:36 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718444376; a=rsa-sha256; cv=none; b=ctbHSqbxfs0PYTGzvLknKcQAvUP6JHldPpJT83jUBCz8bqOt7744pm6jbUalK11RqiILWc wEJ8iRJgY5bk4UKizRv1iP4PZMFnCV03yb9mLjrjnsjvX1dQfHxyoiSCcU99EW/9Q/6UYi HrF8wqndqHHSzraj3W8ebwzsuwH0cjxyRcXZbLd1KVqs+LbCeq25NrxNiXrlqWC/qTdAnt iNNsuxzRA8SDMyGbj5WC+lzTiMfEu9g6G8wPC2MI/XP62mQ98v33oXBDOcyr3p0/mTJgBI 87a9GkLyGW+W7FDmWuQ+C9K2lCJWG4urxswjF6m25JXvKKMTuxtK/OiP+pQZwQ== 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=1718444376; 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=lxK9n7VfEoFeAiUOwxnJWR900+hW8hGhHHyKgMjhtRc=; b=brpxMYeIifyev5iYFiioYk8nhVb/AWP9hpHZCDvNpuUbMTYEtWzXKGyGIF0qPEs1C15sVW ans9zzZPIBd6Tt3bI7KcaPvghNC6Ho+PMCWmebGMBIIcXS5SL7/DUWcBVt9qFN7OupCF3S 6uTBLt+15vynKseBgnOBnkGW3733ZzmHPLdfuCdmYFsCBBkbW2OFF4jnuiuVdC+qPt0npp N1HLD3kEaz6YVl7Xaj3MCxzC17JFczX8jRO8nLonGOu228D8xGUoPjm8g279e+Jambxx/1 wW6QR8HWRKHeYT5TJx2dhMaw+N6JLln+y26WVpzs4+P6QnyJETvZi1u2zaT4RA== 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 4W1WMC6rzjzyQF for ; Sat, 15 Jun 2024 09:39:35 +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 45F9dZOB062351 for ; Sat, 15 Jun 2024 09:39:35 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 45F9dZjj062350 for bugs@FreeBSD.org; Sat, 15 Jun 2024 09:39:35 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 279762] libedit's cv_prev_word() can read before start of buffer Date: Sat, 15 Jun 2024 09:39:35 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me 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 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=3D279762 Bug ID: 279762 Summary: libedit's cv_prev_word() can read before start of buffer Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: rtm@lcs.mit.edu This code in contrib/libedit/chared.c cv_prev_word(): while (n--) { ...; test =3D (*wtest)(*p); while ((p >=3D low) && (*wtest)(*p) =3D=3D test) p--; The ">=3D" can cause p to be decremented even when it is equal to low, so that the next iteration of the outer loop dereferences an illegal p. If I run valgrind /bin/sh and type $ set -o vi then: ESC option-shift-s option-shift-3 2 b valgrind says: Invalid read of size 4 at 0x4873DA1: cv_prev_word (rtm/freebsd/contrib/libedit/chared.c:319) by 0x489C6D0: vi_prev_word (rtm/freebsd/contrib/libedit/vi.c:189) by 0x4889747: el_wgets (rtm/freebsd/contrib/libedit/read.c:540) by 0x4879B3C: el_gets (rtm/freebsd/contrib/libedit/eln.c:75) by 0x123D6E: preadfd (rtm/freebsd/bin/sh/input.c:138) by 0x12387A: preadbuffer (rtm/freebsd/bin/sh/input.c:210) by 0x1326C5: xxreadtoken (rtm/freebsd/bin/sh/parser.c:910) by 0x12E4FC: readtoken (rtm/freebsd/bin/sh/parser.c:827) by 0x12E379: parsecmd (rtm/freebsd/bin/sh/parser.c:222) by 0x129786: cmdloop (rtm/freebsd/bin/sh/main.c:206) by 0x1295D2: main (rtm/freebsd/bin/sh/main.c:167) Address 0x552186c is 4 bytes before a block of size 4,096 alloc'd at 0x4851735: calloc (vg_replace_malloc.c:1599) by 0x48740AA: ch_init (rtm/freebsd/contrib/libedit/chared.c:399) by 0x4877714: el_init_internal (rtm/freebsd/contrib/libedit/el.c:107) by 0x48775B0: el_init_fd (rtm/freebsd/contrib/libedit/el.c:124) by 0x487754A: el_init (rtm/freebsd/contrib/libedit/el.c:66) by 0x1215BC: histedit (rtm/freebsd/bin/sh/histedit.c:183) by 0x12C1ED: optschanged (rtm/freebsd/bin/sh/options.c:130) by 0x12BEA1: procargs (rtm/freebsd/bin/sh/options.c:121) by 0x1293EC: main (rtm/freebsd/bin/sh/main.c:131) FreeBSD stock14 15.0-CURRENT FreeBSD 15.0-CURRENT #22 main-n270479-ecd1d1f1dac4-dirty: Thu May 30 18:42:11 AST 2024=20=20=20=20 root@stock14:/usr/obj/usr/src/amd64.amd64/sys/GENERIC amd64 --=20 You are receiving this mail because: You are the assignee for the bug.=