From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by sourceware.org (Postfix) with ESMTPS id 2FD5A3858D1E; Thu, 27 Jan 2022 05:52:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2FD5A3858D1E Received: by mail-pj1-x1034.google.com with SMTP id r59so1839987pjg.4; Wed, 26 Jan 2022 21:52:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yVBo5rxDjka/KMywW2+H1nhn6skhQzSBoI4nCSzMdbY=; b=oO6WOxcLPEmYpJM28F8KL4M1I/3WJ43Q1Y6PXTY7w6A9UeGQr6J8FVc3QcGGCAVjzT NtBfBo+6M9/YHesJ1uCuAjxCFJEw8l7ISDjXxM6bhBqgLOlSpl6/KVY6BmHfFz97Pukn C+pr3mmQtgbj3GLuGPs0QZUUuezEsXD7UD8+FPC/MoZWucSGAcvZ1nYqJdBicuCvoTnQ AQdSKzvWqfURyjtRcdAFUvk3yG/kXvJRtOReDFheTFqhyLRnpEZU91Efmb0qaQZgVlnv eKf2r5nGFIYrMsruyUARtdFm4wU9tC5IdTEfhOgSrR93+Va1EL0CmqwgnQcezI0MLuaf 2aYw== X-Gm-Message-State: AOAM533etpIvHQLMxBdVH6M59hTq0OJCzVhCIqPEY3nK7AbsvBnYlDq/ n1SplK7PrVy7UEtuDlWLqRxEgC2j5BTvfJdmAyQ= X-Google-Smtp-Source: ABdhPJxoRdjh1JaPdWLaswoPYnSWwgcmb/qau/+WDEL7++g1mqBbRoA/oLd1W4oAZ0f5kJ3rqbjjaLpp+dh7/2LBmwk= X-Received: by 2002:a17:903:124e:: with SMTP id u14mr2444443plh.57.1643262772303; Wed, 26 Jan 2022 21:52:52 -0800 (PST) MIME-Version: 1.0 References: <20220109122946.2754917-1-goldstein.w.n@gmail.com> <20220110213540.1258344-1-goldstein.w.n@gmail.com> In-Reply-To: From: Noah Goldstein Date: Wed, 26 Jan 2022 23:52:41 -0600 Message-ID: Subject: Re: [PATCH v3 1/7] x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] To: "H.J. Lu" Cc: GNU C Library , Libc-stable Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-stable@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-stable mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Jan 2022 05:52:54 -0000 On Wed, Jan 26, 2022 at 11:11 PM H.J. Lu wrote: > > On Wed, Jan 26, 2022 at 8:29 PM H.J. Lu wrote: > > > > On Wed, Jan 26, 2022 at 2:05 PM H.J. Lu wrote: > > > > > > On Mon, Jan 10, 2022 at 6:15 PM H.J. Lu wrote: > > > > > > > > On Mon, Jan 10, 2022 at 1:36 PM Noah Goldstein via Libc-alpha > > > > wrote: > > > > > > > > > > Fixes [BZ# 28755] for wcsncmp by redirecting length >= 2^56 to > > > > > __wcscmp_avx2. For x86_64 this covers the entire address range so any > > > > > length larger could not possibly be used to bound `s1` or `s2`. > > > > > > > > > > test-strcmp, test-strncmp, test-wcscmp, and test-wcsncmp all pass. > > > > > > > > > > Signed-off-by: Noah Goldstein > > > > > --- > > > > > sysdeps/x86_64/multiarch/strcmp-avx2.S | 10 ++++++++++ > > > > > 1 file changed, 10 insertions(+) > > > > > > > > > > diff --git a/sysdeps/x86_64/multiarch/strcmp-avx2.S b/sysdeps/x86_64/multiarch/strcmp-avx2.S > > > > > index a45f9d2749..9c73b5899d 100644 > > > > > --- a/sysdeps/x86_64/multiarch/strcmp-avx2.S > > > > > +++ b/sysdeps/x86_64/multiarch/strcmp-avx2.S > > > > > @@ -87,6 +87,16 @@ ENTRY (STRCMP) > > > > > je L(char0) > > > > > jb L(zero) > > > > > # ifdef USE_AS_WCSCMP > > > > > +# ifndef __ILP32__ > > > > > + movq %rdx, %rcx > > > > > + /* Check if length could overflow when multiplied by > > > > > + sizeof(wchar_t). Checking top 8 bits will cover all potential > > > > > + overflow cases as well as redirect cases where its impossible to > > > > > + length to bound a valid memory region. In these cases just use > > > > > + 'wcscmp'. */ > > > > > + shrq $56, %rcx > > > > > + jnz __wcscmp_avx2 > > > > > +# endif > > > > > /* Convert units: from wide to byte char. */ > > > > > shl $2, %RDX_LP > > > > > # endif > > > > > -- > > > > > 2.25.1 > > > > > > > > > > > > > LGTM. > > > > > > > > Reviewed-by: H.J. Lu > > > > > > > > Thanks. > > > > > > > > -- > > > > H.J. > > > > > > I am backporting this to 2.34 branch. > > > > > > > I am backporting this to 2.33 branch. > > > > I am backporting this to all affected release branches. Should we also backport the stuff for [BZ #27974]? It was essentially the same bug. The two commits that fixed the issues where: commit a775a7a3eb1e85b54af0b4ee5ff4dcf66772a1fb Author: Noah Goldstein Date: Wed Jun 23 01:56:29 2021 -0400 x86: Fix overflow bug in wcsnlen-sse4_1 and wcsnlen-avx2 [BZ #27974] and commit 645a158978f9520e74074e8c14047503be4db0f0 Author: Noah Goldstein Date: Wed Jun 9 16:25:32 2021 -0400 x86: Fix overflow bug with wmemchr-sse2 and wmemchr-avx2 [BZ #27974] The only thing is the avx2 fixes are based onsome other changes to the file. > > -- > H.J.