[{"id":1762439,"web_url":"http://patchwork.ozlabs.org/comment/1762439/","msgid":"<f72dea64-8a2d-da98-78c6-12d947f4a2b6@redhat.com>","list_archive_url":null,"date":"2017-09-04T06:08:43","subject":"Re: [PATCH] Disable type demotion for sanitizer (PR sanitizer/82072)","submitter":{"id":4400,"url":"http://patchwork.ozlabs.org/api/people/4400/","name":"Jeff Law","email":"law@redhat.com"},"content":"On 09/01/2017 11:47 AM, Marek Polacek wrote:\n> Here, do_narrow and convert_to_integer_1 is demoting signed types to unsigned,\n> e.g. for\n>   i = i - lmin\n> where i is int and lmin is long int, so what we should produce is\n>   i = (int) ((long int) i - lmin)\n> but instead it produces\n>   i = (int) ((unsigned int) i - (unsigned int) lmin);\n> which hides the overflow.  Similarly for NEGATE_EXPR.  This patch prevents\n> such demoting when the sanitizer is on.\n> \n> There still might be a similar issue with division or shifting, but I couldn't\n> trigger that.\n> \n> Bootstrapped/regtested on x86_64-linux, ok for trunk?\n> \n> 2017-09-01  Marek Polacek  <polacek@redhat.com>\n> \n> \tPR sanitizer/82072\n> \t* convert.c (do_narrow): When sanitizing signed integer overflows,\n> \tbail out for signed types.\n> \t(convert_to_integer_1) <case NEGATE_EXPR>: Likewise.\n> \n> \t* c-c++-common/ubsan/pr82072.c: New test.\nOK.  There's probably other places that may need similar treatment.  You\nmight want to peek at shorten_binary_op and shorten_compare to see if\nthey suffer from similar problems.  We really want them to go away, but\nwe haven't gotten back to that project since Kai left.\n\nJeff","headers":{"Return-Path":"<gcc-patches-return-461380-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461380-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"wo8WPzIT\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=law@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xlzv11QxJz9s7c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon,  4 Sep 2017 16:08:58 +1000 (AEST)","(qmail 78602 invoked by alias); 4 Sep 2017 06:08:51 -0000","(qmail 78593 invoked by uid 89); 4 Sep 2017 06:08:51 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tMon, 04 Sep 2017 06:08:50 +0000","from smtp.corp.redhat.com\n\t(int-mx06.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.16])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id C2CDB83F3F\tfor\n\t<gcc-patches@gcc.gnu.org>; Mon,  4 Sep 2017 06:08:48 +0000 (UTC)","from localhost.localdomain (ovpn-112-3.rdu2.redhat.com\n\t[10.10.112.3])\tby smtp.corp.redhat.com (Postfix) with ESMTP\n\tid 5D5C55C550; Mon,  4 Sep 2017 06:08:45 +0000 (UTC)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:subject:to:references:from:message-id:date:mime-version\n\t:in-reply-to:content-type:content-transfer-encoding; q=dns; s=\n\tdefault; b=A0BwhyL6E9n375PB3MoA65Yky7b0l2KcqOvDq32vFQ65A1keh2zyd\n\tRWI0tHUeZXuHbjDVEMiuURj1eMiA8M92mWG+zX+fzbGBkB1Qz9EYb2tjKoLmVG6I\n\t18A2lC28yauPkZtTsGzj7M7e+dwi2/Sn5Q9kgr8G/9W9lmRUyOXUhc=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:subject:to:references:from:message-id:date:mime-version\n\t:in-reply-to:content-type:content-transfer-encoding; s=default;\n\tbh=iDXfwdKK3MnAT14WO6wkNR/hhDM=; b=wo8WPzITnXW/rcDjcnJfe08h9f9Z\n\tjGo38d084cjumUDdWrgh0ycQ+YsUVQ3mkQDyVW11+X7hDa0W/NWUNxfwL8zl+Hmb\n\tEyEPMW6BXtnmG1RkH998jUQHp1g9MJNtlPrNZylt+Pya7fnE7YApIJcbZVqG4Tz+\n\t5nhaiCLoZRzvzOY=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-0.9 required=5.0 tests=BAYES_00,\n\tKAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=no version=3.3.2 spammy=kai, peek,\n\ttreatment","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com C2CDB83F3F","Subject":"Re: [PATCH] Disable type demotion for sanitizer (PR sanitizer/82072)","To":"Marek Polacek <polacek@redhat.com>, GCC Patches <gcc-patches@gcc.gnu.org>,\n\tJakub Jelinek <jakub@redhat.com>","References":"<20170901174714.GB20631@redhat.com>","From":"Jeff Law <law@redhat.com>","Message-ID":"<f72dea64-8a2d-da98-78c6-12d947f4a2b6@redhat.com>","Date":"Mon, 4 Sep 2017 00:08:43 -0600","User-Agent":"Mozilla/5.0 (X11; Linux x86_64;\n\trv:52.0) Gecko/20100101 Thunderbird/52.2.1","MIME-Version":"1.0","In-Reply-To":"<20170901174714.GB20631@redhat.com>","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"7bit","X-IsSubscribed":"yes"}}]