From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id D7CB23858D1E; Thu, 27 Jan 2022 05:11:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D7CB23858D1E Received: by mail-pf1-x435.google.com with SMTP id 128so1608440pfe.12; Wed, 26 Jan 2022 21:11:02 -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=mImD5RIjGIVCnNg4T0O1vDHDVViW2FrpPKhG8p1OMWA=; b=JaKIwG7+2IfKFsSmbWGGozSkysKaGU6YZ7pr7tqymI5dC0jIiSklIUvVwjSFrYrmGJ /DimiixcL9gODuhi/VQ4V8sZOgw7pI+GcDHamefZRcHI3IULMUeR23h1UeMZD+fhNBcV GhEJYh9Lw/K0cj8ORnupQaDGuWfhS+x4Ag1AvC02Wg7TOnJasMtnmpEDhTwbIw7uP2Lq q97nK9/AC0bqbLeYcXupYYP8UVKAcfpe3Kxlwgt9SIg4zqDIn0+k+3h73tUE2yRqLQDc TIgfs22haR+eN5uqUDKIQcXG9FRFJPNye51w8N/G/nUZ8VFqcmAZWoHs3baEcDd/SgsA zKtQ== X-Gm-Message-State: AOAM532irbOjWYmA7i8Vs/G7vP0B7U2HiJfjdM4/3kOQ9Jtv1ksSnHgG xOw1cBdS+YzU4HQ+HUuEBYqIEbt5i7BTBnMZ6QYH5uY4 X-Google-Smtp-Source: ABdhPJw3gTpdtnFeEbKTQuc8zqHM0WTu3VOSB/D1HdLtxlLudeQzqw6hQgEFVyxKWDDa9IGWumNTvbFM0pIuMOJk5XU= X-Received: by 2002:a65:414a:: with SMTP id x10mr1575836pgp.125.1643260261953; Wed, 26 Jan 2022 21:11:01 -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: "H.J. Lu" Date: Wed, 26 Jan 2022 21:10:25 -0800 Message-ID: Subject: Re: [PATCH v3 1/7] x86: Fix __wcsncmp_avx2 in strcmp-avx2.S [BZ# 28755] To: Noah Goldstein Cc: GNU C Library , Libc-stable Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3027.3 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:11:04 -0000 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. -- H.J.