From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Newsgroups: gmane.emacs.bugs Subject: bug#56108: 29.0.50; ASAN use-after-free in re_match_2_internal Date: Fri, 24 Jun 2022 11:35:18 +0200 Message-ID: References: <83mte7kv7c.fsf@gnu.org> <32e548cc-ffd3-4669-ad9a-317c130b0c93@Spark> <83a6a4kec0.fsf@gnu.org> <6e56407a-b564-4aa9-b74c-78883727ef09@Spark> <831qvgkc8d.fsf@gnu.org> <83sfnwisbb.fsf@gnu.org> <3146c990-63d9-4aa5-ab78-7bae2b7d6cd5@Spark> <835ykrg93i.fsf@gnu.org> <831qvfg876.fsf@gnu.org> <83tu8ad2qd.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="62b5855b_1a54d7bc_588f" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30143"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 56108@debbugs.gnu.org To: Stefan Monnier , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 24 11:36:13 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o4fjZ-0007fS-6a for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jun 2022 11:36:13 +0200 Original-Received: from localhost ([::1]:50832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4fjX-0003dm-M4 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jun 2022 05:36:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4fjO-0003cD-CW for bug-gnu-emacs@gnu.org; Fri, 24 Jun 2022 05:36:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46992) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o4fjN-0007qQ-US for bug-gnu-emacs@gnu.org; Fri, 24 Jun 2022 05:36:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o4fjN-0007Iq-Qq for bug-gnu-emacs@gnu.org; Fri, 24 Jun 2022 05:36:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Gerd =?UTF-8?Q?M=C3=B6llmann?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 Jun 2022 09:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56108 X-GNU-PR-Package: emacs Original-Received: via spool by 56108-submit@debbugs.gnu.org id=B56108.165606333428037 (code B ref 56108); Fri, 24 Jun 2022 09:36:01 +0000 Original-Received: (at 56108) by debbugs.gnu.org; 24 Jun 2022 09:35:34 +0000 Original-Received: from localhost ([127.0.0.1]:40889 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4fiv-0007I8-RS for submit@debbugs.gnu.org; Fri, 24 Jun 2022 05:35:34 -0400 Original-Received: from mail-ej1-f54.google.com ([209.85.218.54]:38907) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4fit-0007Hv-TE for 56108@debbugs.gnu.org; Fri, 24 Jun 2022 05:35:32 -0400 Original-Received: by mail-ej1-f54.google.com with SMTP id g26so3523657ejb.5 for <56108@debbugs.gnu.org>; Fri, 24 Jun 2022 02:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version; bh=GpO0Dw9bQo8316P/PdEMEwlsLQdoJloRIkOMF7zUEPg=; b=A+cGMEodMe455zAWKSWoXr0Oc1oX7SIBMHl3lz75SzvsMqdhmrYatjY6UxQ4lnx3OQ mu51M6ZoKvC6jEH9kWz9FqqtswgQgh62zC3I6fAOz4DXq3umBJSRTjK5S0nab4vdKtFo 7Mm2UAxabr7L64wOBJTejkQRFotgrTAqAcKrRT9d0dziUQ2EB+BODJ4MW4hp5Ax/xesr 67y24tvhxSnCmxxSvnfzy2mA4nqBXvF8hRkDfPti8+Ak0ydSs/VaraYn0RlUKhVzQp4a RivnxhaOIen5IBYTq5dFfS2ydNIAskV59WhlS0zaPwu2IN3pAzSysM4O9BavS3HOKDtO LJpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to :references:subject:mime-version; bh=GpO0Dw9bQo8316P/PdEMEwlsLQdoJloRIkOMF7zUEPg=; b=uQHuBsl/QX2YE2Xt3kUGBMORXdhZXeYDkJvnl+lydIaxgeQuCkqhNXUPFruq4NFLrr NwjLcJcyGR0cTyXigPEDv1iBYQqSmn4lpTGp4gx6cKdSR4hAENff4bSooJ1bj6NxnIrO zAsnfFCqxdACUi0vzHxATdOegp4PCGwmIZyr9EUI9WKkKkPURNCJuOwrVSWGJgEA1wtk ZTrgoiywt3MQ6PPCO5S3GT0QRd6iFL1UICzyuvUESUgPz0mfgdTI2tlnqEyoLkIBPQhg +Duujl5+RON6NPDGFBPZKEbrAWrVOkSj44sm9PFIie5ow1+vRKjmIWPy1qiJKZln6hp/ 5JUA== X-Gm-Message-State: AJIora+uW8h/Z8GbPvjEFDoBnsugs7MDg4i+zp9Whl10UMC9bmF5RDJv 1WVrBYdyggAGzdr2QW8PxAs= X-Google-Smtp-Source: AGRyM1uq7IK/JpZEiLloUZ3eqJsrVXqauWZVHHyxSDtsWEhaKJYvB1zc5PFJektP6i16GdJHBKlFnA== X-Received: by 2002:a17:907:6d14:b0:726:34db:89fc with SMTP id sa20-20020a1709076d1400b0072634db89fcmr1122700ejc.406.1656063325890; Fri, 24 Jun 2022 02:35:25 -0700 (PDT) Original-Received: from [192.168.178.21] (pd9e36742.dip0.t-ipconnect.de. [217.227.103.66]) by smtp.gmail.com with ESMTPSA id u3-20020aa7db83000000b0043580ac5888sm1535360edt.82.2022.06.24.02.35.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Jun 2022 02:35:24 -0700 (PDT) In-Reply-To: X-Readdle-Message-ID: d832b6b9-06fa-4276-bcf1-1acebf6524d9@Spark X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:235163 Archived-At: --62b5855b_1a54d7bc_588f Content-Type: multipart/alternative; boundary="62b5855b_2c7c62c2_588f" --62b5855b_2c7c62c2_588f Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Please find patch attached. Some notes about the patch: =E2=80=A2 TRT, I think, would be to change the whole cacheing to use Lisp= objects etc.=C2=A0=C2=A0I couldn't persuade myself to do that. =E2=80=A2 A less right thing, but better than the patch, would be to prot= ect the cache entry in re=5Fmatch=5F2=5Finternal.=C2=A0=C2=A0But that req= uires interface changes because re=5Fmatch=5F2=5Finternal currently doesn= 't know about cash entries.=C2=A0=C2=A0I couldn't bring myself to do that= either. Another note:=C2=A0=C2=A0Should some document mention that trailing white= space are not allowed in the git repo=3F=C2=A0=C2=A0I couldn't find that = anywhere. --62b5855b_2c7c62c2_588f Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Please find patch attached.

Some notes about the patch:
  • TRT, I think, would be to change the whole cacheing to use Lisp objec= ts etc.&=23160;&=23160;I couldn't persuade myself to do that.
  • A less right thing, but better than the patch, would be to protect th= e cache entry in re=5Fmatch=5F2=5Finternal.&=23160;&=23160;But that requi= res interface changes because re=5Fmatch=5F2=5Finternal currently doesn't= know about cash entries.&=23160;&=23160;I couldn't bring myself to do th= at either.
Another note:&=23160;&=23160;Should some = document mention that trailing whitespace are not allowed in the git repo= =3F&=23160;&=23160;I couldn't find that anywhere.





--62b5855b_2c7c62c2_588f-- --62b5855b_1a54d7bc_588f Content-Type: application/octet-stream Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="0001-Prevent-reexp-cache-entry-GC-in-more-cases.patch" RnJvbSA2OWEzMWM5OTc2MzE2YjNhMDU0MjUwM2Y4YzM0YWRiMTc4MmE5NTRmIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiA9P1VURi04P3E/R2VyZD0yME09QzM9QjZsbG1hbm4/PSA8Z2Vy ZEBnbnUub3JnPgpEYXRlOiBGcmksIDI0IEp1biAyMDIyIDEwOjQ0OjE3ICswMjAwClN1YmplY3Q6 IFtQQVRDSF0gUHJldmVudCByZWV4cCBjYWNoZSBlbnRyeSBHQyBpbiBtb3JlIGNhc2VzCgoqIHNy Yy9zZWFyY2guYyAoc3RyaW5nX21hdGNoXzEsIGZhc3Rfc3RyaW5nX21hdGNoX2ludGVybmFsKQoo ZmFzdF9jX3N0cmluZ19tYXRjaF9pZ25vcmVfY2FzZSk6IFVzZSBmcmVlemVfcGF0dGVybi4KLS0t CiBzcmMvc2VhcmNoLmMgfCA0OSArKysrKysrKysrKysrKysrKysrKysrKysrKy0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tCiAxIGZpbGUgY2hhbmdlZCwgM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