From patchwork Thu Dec 14 11:13:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 121908 Delivered-To: patch@linaro.org Received: by 10.80.152.193 with SMTP id j59csp6564593edb; Thu, 14 Dec 2017 03:13:42 -0800 (PST) X-Google-Smtp-Source: ACJfBouRqrbh/d4OkJnluPBA7TJMJtVWLjkOh31v4Oej3PjcMUN+A11iVZJ2aQ0Lr2ItPdkzpWsu X-Received: by 10.101.93.66 with SMTP id e2mr8137597pgt.50.1513250022722; Thu, 14 Dec 2017 03:13:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513250022; cv=none; d=google.com; s=arc-20160816; b=e/16oqW73GS8VfIohQnySbg0AkJipr2oWOfcobdeAC8YTJbWf+HJ9W8/DRcbxxzrD4 B1/NmxVWOcm6IkKGOR9U5CYdMFrbpFWHTITfi8ibtH8NW1qzWBXP3pT7RC9DxobWxVXG 3CT+PWHdD0afDn0LvV8rV68KNh7mFQJvMG83TzScJmlvpGCQbQ334DiYBbdicvzXQbxb B6zWggXrH3GgVMob/wFRmUYWB89xY9dZZGSYutQ+wh20FHGjWxagJYCSXDYcvSw3oRbW jt6iPEk2Vqhmc7r5AUDRcpYDdTr1wj3lyOpz1b+CpZnk+xUJLe76TMODdtbZBFJJy/5i K1kQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-subscribe:list-unsubscribe:list-id :precedence:mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=DhUgf6hxcDMqkGIeScYPMkq2tpcJxeuDafvRShNEjmY=; b=rvDbYSu92GR2vUYBQ1a612MHW5G6kMcMu0vryoX5AwxTxx/tNGP9Y5VozkEI0Jpw6s JhzG29HGepMxRlxLiWNfNUBQtoGxf0tFaDtxtJ95N0xznoFs80vJqfxF67lOT0vOnM57 qrPW0bx6dqWX9y+0gu+Vcvhic0SzqZaYH/QIRHJ4uoTr042mzixJrvXDxqn/wl6CMSCA 2smQcke/LjIximR/B9fHZoEdVK0+0hoelvGJJNrA97CMv3r+kVADSZrimpCt5V5dfFho X2wRtPJjHAgUW8TpvYen8+6Y1DSSNpvM0WXHZZ5OdmyT+VHj0yHAQ8sM0gsuy0Ld1co7 6OMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=HNgrb/KA; spf=pass (google.com: domain of libc-alpha-return-88124-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-88124-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id p5si2990650pll.156.2017.12.14.03.13.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 03:13:42 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-88124-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=HNgrb/KA; spf=pass (google.com: domain of libc-alpha-return-88124-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-88124-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=m3iaMPjOyzFnMJa2ylsTp3xruSdpGHC5H3EbyGkiMRLAqtv1JV3nD XPTm6aEp5PnSw0jrf/g5InqKpdt2ma4CpJuBEbGOZuQEWMhqwGCIn3AeCF9qusFN 7W+bC4mh+hSrsN0t2gmV3qk3+81Il0UI0yzmLhgNqY/IpiPOdrrEK0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=TVZUSkXV/v2R4JnZZ6W93lJJJdg=; b=HNgrb/KAFC0A45UOhnZ5owApK5vM Wdk+jTQMW2TGzNYD7ZjM/CIqwRPQshJnPrXvSHn+bW+sVY8EL5cCd4GevYxtnKR1 nctKzYZqwtekDduNOKYv8DQaQFpcDB7mkyCR44bt2ZOA8q/N1GHoMlZPsbrkzIE+ MqQAWSFbD/qdHbg= Received: (qmail 47805 invoked by alias); 14 Dec 2017 11:13:28 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 47758 invoked by uid 89); 14 Dec 2017 11:13:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=UD:u X-HELO: mail-qk0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=DhUgf6hxcDMqkGIeScYPMkq2tpcJxeuDafvRShNEjmY=; b=kZVCVhEYo5iR3gvANxsx1LMm2Ig7kXKDAuKZEXXOgDL3R9HutoofV/j4WtJ7FITdbR LAd8DjZ0Wzao6oxYXIG57uQY5gyY6txRdUJvyPxsQyItN4/QfM1j4JjhBM5r9Fbe0U0P dKQRFzVi1RAzuIPyIxpwMAxLpzYap/+/9RWIByeB2R0opg+IKLQkFy86FWfPeW2EvIXi cUogPeEmTmOzJ/nvhp9VbQ+KNFO8abFFTad1TYMD/ypgiUFIdihreWGlWrNHi4rPJG6T aiLd0HG8IJ3g7G4LCDdu30+HUx9ruDRBogp9emdznUyhJ7LrT/l91mpnXHFZzAVaOmeg Mvog== X-Gm-Message-State: AKGB3mJEA8cmLphcmQuZlEao6JpHRebxN5d+HUTobVBlGAwZhME6+4CU tX5NV00m7WuLB9QsHtV66gdmGjEE1+8= X-Received: by 10.55.21.140 with SMTP id 12mr12326070qkv.175.1513250005033; Thu, 14 Dec 2017 03:13:25 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] ia64: Fix memchr for large input sizes (BZ #22603) Date: Thu, 14 Dec 2017 09:13:20 -0200 Message-Id: <1513250000-30206-1-git-send-email-adhemerval.zanella@linaro.org> Current optimized ia64 memchr uses a strategy to check for last address by adding the input one with expected size. However it does not take care for possible overflow. It was triggered by 3038145ca23 where default rawmemchr now uses memchr (p, c, (size_t)-1). This patch fixes it by implement a satured addition where overflows sets the maximum pointer size to UINTPTR_MAX. Checked on ia64-linux-gnu where it fixes both stratcliff and test-rawmemchr failures. Adhemerval Zanella James Clarke [BZ #22603] * sysdeps/ia64/memchr.S (__memchr): Avoid overflow in pointer addition. --- ChangeLog | 7 +++++++ sysdeps/ia64/memchr.S | 4 ++++ 2 files changed, 11 insertions(+) -- 2.7.4 diff --git a/sysdeps/ia64/memchr.S b/sysdeps/ia64/memchr.S index d60cf7b..9a0abc6 100644 --- a/sysdeps/ia64/memchr.S +++ b/sysdeps/ia64/memchr.S @@ -67,6 +67,10 @@ ENTRY(__memchr) .body mov ret0 = str add last = str, in2 // last byte + ;; + cmp.ltu p6, p0 = last, str + ;; +(p6) mov last = -1 and tmp = 7, str // tmp = str % 8 cmp.ne p7, p0 = r0, r0 // clear p7 extr.u chr = in1, 0, 8 // chr = (unsigned char) in1