From owner-dev-commits-src-branches@freebsd.org Sat Jul 10 17:12:57 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 16087657E99; Sat, 10 Jul 2021 17:12:57 +0000 (UTC) (envelope-from git@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 4GMc6c5JFVz4VSV; Sat, 10 Jul 2021 17:12:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 281D54112; Sat, 10 Jul 2021 17:12:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 16AHCuT4088400; Sat, 10 Jul 2021 17:12:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16AHCuXP088399; Sat, 10 Jul 2021 17:12:56 GMT (envelope-from git) Date: Sat, 10 Jul 2021 17:12:56 GMT Message-Id: <202107101712.16AHCuXP088399@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: e32d04bed890 - stable/12 - awk: Fix subobject out-of-bounds access MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e32d04bed89057c54147db931fa544bb601f48ac Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Jul 2021 17:12:57 -0000 The branch stable/12 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=e32d04bed89057c54147db931fa544bb601f48ac commit e32d04bed89057c54147db931fa544bb601f48ac Author: Alex Richardson AuthorDate: 2020-09-21 19:03:07 +0000 Commit: Warner Losh CommitDate: 2021-07-10 17:11:15 +0000 awk: Fix subobject out-of-bounds access When matching a regex with ^, it would attempt to access gototab[NSTATES][NCHARS+2], and therefore access the state for the \002 character instead. This change is required to run awk under CHERI (with sub-object bounds) and when running with UBSan instrumentation. This was committed upstream as https://github.com/onetrueawk/awk/commit/cbf924342b63a095a4c6842280c3085b1b63ae45 Found by: CHERI (with subobject bounds enabled) Obtained from: CheriBSD Reviewed By: imp Differential Revision: https://reviews.freebsd.org/D26509 (cherry picked from commit ae692c42cb46a5e72772070070840b15dd5d6bd8) --- contrib/one-true-awk/awk.h | 4 +++- contrib/one-true-awk/b.c | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/one-true-awk/awk.h b/contrib/one-true-awk/awk.h index b16c2f36f828..31d070aecddc 100644 --- a/contrib/one-true-awk/awk.h +++ b/contrib/one-true-awk/awk.h @@ -218,6 +218,8 @@ extern int pairstack[], paircnt; #define NCHARS (256+3) /* 256 handles 8-bit chars; 128 does 7-bit */ /* watch out in match(), etc. */ #define NSTATES 32 +#define HAT (NCHARS+2) /* matches ^ in regular expr */ + /* NCHARS is 2**n */ typedef struct rrow { long ltype; /* long avoids pointer warnings on 64-bit */ @@ -230,7 +232,7 @@ typedef struct rrow { } rrow; typedef struct fa { - uschar gototab[NSTATES][NCHARS]; + uschar gototab[NSTATES][HAT + 1]; uschar out[NSTATES]; uschar *restr; int *posns[NSTATES]; diff --git a/contrib/one-true-awk/b.c b/contrib/one-true-awk/b.c index 4de746fa087f..0cdcf30a972e 100644 --- a/contrib/one-true-awk/b.c +++ b/contrib/one-true-awk/b.c @@ -37,8 +37,6 @@ __FBSDID("$FreeBSD$"); #include "awk.h" #include "ytab.h" -#define HAT (NCHARS+2) /* matches ^ in regular expr */ - /* NCHARS is 2**n */ #define MAXLIN 22 #define type(v) (v)->nobj /* badly overloaded here */