From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id 6DDF83857C4E; Wed, 26 Jan 2022 22:05:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6DDF83857C4E Received: by mail-pj1-x102d.google.com with SMTP id h12so908732pjq.3; Wed, 26 Jan 2022 14:05:01 -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=65h3Nb2T9+5QZv02rFGalW6ZZxCjoRL+9ZRGLC+JJOs=; b=yf8GDx5Zwq4ZJcPyv7gqDOBPMa2TyJaCsPjQrWmSJi2HJIEfMFFGZ22mgZWkxX7eLm ATB3W9FlG52hJ6rDBfNIzRoZO9y2pVFD53dxIwuGtqFEwPjtquSn8eSZ7phwrBktbShN W2d8pOWSTZ/GN9IWT/4c/W7s8bkelWioSDUaxKDdg5KS444sCGtii4KFXSE3tR1UXtB+ iiTSsB4Uz0CfYCzLz+r/QUuN/oPD24UVqtj2OKh9CUeT6+frc7kmqvg08H58Z1gMgfkb S5PATB4fM4mMRxEY6e27cnDGwVPBquJULHyzic0Liu7VP3xNYnLNBfEFr7NErY6xyhY/ XHzg== X-Gm-Message-State: AOAM530nTecLnAxHTMY2INpKuZS+GOoVEMAVjBkzQweSkMa4S0pVm9Ax lP8AfTaOOrsahNECpD2aOIygL3QQKPbIi0kFqb+p7Ltr X-Google-Smtp-Source: ABdhPJzQyyQmXTknqTyydmK/SHrx3f5QDoEveQ2C/QpHot4MBEdkUUjJVSjkN1j7+xTCRKlwgnCMs+cNBAqohE6HoM8= X-Received: by 2002:a17:90b:1b46:: with SMTP id nv6mr10625518pjb.143.1643234700530; Wed, 26 Jan 2022 14:05:00 -0800 (PST) MIME-Version: 1.0 References: <20220109122946.2754917-1-goldstein.w.n@gmail.com> <20220110213540.1258344-1-goldstein.w.n@gmail.com> <20220110213540.1258344-2-goldstein.w.n@gmail.com> In-Reply-To: From: "H.J. Lu" Date: Wed, 26 Jan 2022 14:04:24 -0800 Message-ID: Subject: Re: [PATCH v3 2/7] x86: Fix __wcsncmp_evex in strcmp-evex.S [BZ# 28755] To: Noah Goldstein , GNU C Library Cc: Libc-stable Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3027.6 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: Wed, 26 Jan 2022 22:05:02 -0000 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_evex. 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-evex.S | 10 ++++++++++ > > 1 file changed, 10 insertions(+) > > > > diff --git a/sysdeps/x86_64/multiarch/strcmp-evex.S b/sysdeps/x86_64/multiarch/strcmp-evex.S > > index 1d971f3889..0cd939d5af 100644 > > --- a/sysdeps/x86_64/multiarch/strcmp-evex.S > > +++ b/sysdeps/x86_64/multiarch/strcmp-evex.S > > @@ -104,6 +104,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_evex > > +# 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. -- H.J.