From patchwork Mon Nov 6 13:27:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 741397 Delivered-To: patch@linaro.org Received: by 2002:adf:fd90:0:b0:32d:baff:b0ca with SMTP id d16csp1083955wrr; Mon, 6 Nov 2023 05:28:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFDCC0NByMIlyc6Kiv1j5/BkwBH/SR4PE3g6OOqfz0ulI+aEN8d+rtFUwsw/A0JisKTqky X-Received: by 2002:a05:620a:191c:b0:767:ff8e:74ff with SMTP id bj28-20020a05620a191c00b00767ff8e74ffmr14533395qkb.25.1699277297870; Mon, 06 Nov 2023 05:28:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1699277297; cv=pass; d=google.com; s=arc-20160816; b=uUkSl9Gdou/eSuiFq5XXmIuBCZpiPTncsZhdE2xAhnBGZIshY6SvWBdV2CadN4aYOc wO2txBHZCz8mKAIdGIx0QaKroxP5oQD/4ag2e9G6R3gG022r3hAOXLPPowaTSFkhA5Yt 3ietJCeuQQB5PfszfQtdSLa6MqlAB2NqDJ3+Ke7xuJJ5lST3jIMn1iDNF4FcaGoISVKy 9yj/Y0Lq1cdAqM9f+xUCd2imJNuuUKvN8t7bQpDPb39ghCe+fJ9tLAgURvVn29sUdBIU bEeIDtUXi7FU/RrFueYoIyuuuCx7Qgfm8zomjP3lgaAeUFSo4TZn2QtwG6EkLjqbGOKi DO9A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=6jWpJtYgU4AupWiGBpR3CkeP70iQINh300sZdk4guoA=; fh=01HD8dtuIqmy9rV/eMJuvD8dAGq4TXBqBjIxWaMzNQI=; b=xW7RHs977BbZHam67QRSiyk4BchftpNVz5bXxRwyiO7WHaFJRByBZ6CSMjhxwMaJHk wWBJspX6d1jUg43nqsLUfXQEBKxywUttPRnaHhSexZXoOEK//bFIpC8O3g2D3hSyRhXR 5C2LmWDuVzpkcMALfkvRLa5G/APHZ8CSPATcXCjWjhot24Gt1+GvPqbbdXFMKQJgh0eH vCM5hyKbXJodLEg/0wMjJLf6i470e//PuL11TUbvGAbuN3CjYOY2H36eVOZwsK2ixHhQ htgVaUoOaIrezftFBmjn+WVsWtlNG/kBdHov4P8piLlUMvcWbTtsdP7Cxof3LvNyJC+/ 1r5w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WifGkwAM; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o4-20020a05620a2a0400b00778988d1648si5946205qkp.544.2023.11.06.05.28.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 05:28:17 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WifGkwAM; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces+patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="libc-alpha-bounces+patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7992E3861840 for ; Mon, 6 Nov 2023 13:28:16 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by sourceware.org (Postfix) with ESMTPS id 5DA6A385559B for ; Mon, 6 Nov 2023 13:27:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5DA6A385559B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5DA6A385559B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::734 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699277252; cv=none; b=lEU+nuX63DtVR18J0Bbihgr3qjb7Tmo8AEa52Kik0jaSxVCXbtf4Tew9RZMLKw8In4ZnK+sfhJ0ay0URcBzrcwNforyXreallwfV2/smhRG7t/dPhctbtBYds7jLOzZzLM1U95YCxmMU4mKpfR0uNR6f4WuxYNFewH6QkfGEkcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699277252; c=relaxed/simple; bh=X2wiZ3laELaKsR0jgcmuy/E0a1j+Y6CXbQpJCpc45wA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=RMjyHTp7jjV6bDqBb2l+uBKVItW8iBTNy+z7HBJWvOC2Tm8x9HiqFRWZQSE1whgMsLQmqz7v789jvq29Js/rsQdu7q85EElIicRuD2NSpBEHIg5vmLRnBnuAa8p0yysOcLqppI1cgSFlSPxBvZfR9D/VK4ro0e+o9P4GqBofvFg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-778a108ae49so443638985a.0 for ; Mon, 06 Nov 2023 05:27:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699277250; x=1699882050; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=6jWpJtYgU4AupWiGBpR3CkeP70iQINh300sZdk4guoA=; b=WifGkwAMX5L+/YTGt8N2SnozNgSfctejJamS8LZFA+DSlNdLEubA6XtIru+CGsUAnj f3djEtFhUI93gBu0GHTQG6hmPTfSRBUHd8+wtYAJZrl5f4s8PSdNVTd7vdOe0mIQryfw 1OyjdiTA29y3IVAPeUwRIrnRYCCiw1r1S38/w9kgPsc9mFUc+9TpOxbUdAGag8+hXVfb msL45+OyiaJ3D/VKlRYBffTjKP1DGP4Lrs1y6MAP4sXxxPSOR6hQsxwddlT38QBPJs80 PypQeTWafFRj1ZTsX3vF2blJdaICiJ+xOYupoI8jiav+mWrZGOtviVNl4ViwQvk/60O1 lgnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699277250; x=1699882050; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6jWpJtYgU4AupWiGBpR3CkeP70iQINh300sZdk4guoA=; b=pTWfVXcqoqK9ZmWCGP2jfIIOX/PRhsNpheCy4beLxzq5jSPLtChOjg+U4ejq4hgQjN OuCb+u4hp8rZ4tI5BgoNOP5+reMWpHlaCosrRG0uTosNUYZmZDYLHON5Rq+qhKJTXxOL NajuU0zypL89yO4z//wbvpJPpWRGFT7QsKpcv+kW7EM8evF8zg1Y+u6iaQMpfhTuXcBR iWEFjG7GzXgX0LrVTyWE6+KMJaG32SDWATR2gcYOzQVoh2cAY9VCZM/ndMdt5uXqu+4t UI322Ha5/p3836bti3Tp46ay3dZPr/nOaZsCneJ+/3S2XX443D4r3IYD1D/zx2pqwsDe Gk0A== X-Gm-Message-State: AOJu0Yx7aoPIWwtAGt/NFD+uLaPjuOxmjEVvcRE5dyG5Ym8BZxHtG6M4 nnLJr5XlIW8Q/NWK4cJBtBtqxLUPE60QYn+fhO0AoA== X-Received: by 2002:a05:620a:4095:b0:76c:ae1f:201e with SMTP id f21-20020a05620a409500b0076cae1f201emr15580845qko.27.1699277250303; Mon, 06 Nov 2023 05:27:30 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:a715:c1a0:7281:6384:2ee9]) by smtp.gmail.com with ESMTPSA id k3-20020a05620a142300b0076f12fcb0easm3272722qkj.2.2023.11.06.05.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 05:27:29 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Bruno Haible Subject: [PATCH v2 7/7] hppa: Fix undefined behaviour in feclearexcept (BZ 30983) Date: Mon, 6 Nov 2023 10:27:13 -0300 Message-Id: <20231106132713.953501-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106132713.953501-1-adhemerval.zanella@linaro.org> References: <20231106132713.953501-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patch=linaro.org@sourceware.org From: Bruno Haible The expression (excepts & FE_ALL_EXCEPT) << 27 produces a signed integer overflow when 'excepts' is specified as FE_INVALID (= 0x10), because - excepts is of type 'int', - FE_ALL_EXCEPT is of type 'int', - thus (excepts & FE_ALL_EXCEPT) is (int) 0x10, - 'int' is 32 bits wide. The patched code produces the same instruction sequence as previosuly. Reviewed-by: Carlos O'Donell --- sysdeps/hppa/fpu/fclrexcpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/hppa/fpu/fclrexcpt.c b/sysdeps/hppa/fpu/fclrexcpt.c index 055fb04ccc..46caf39ec1 100644 --- a/sysdeps/hppa/fpu/fclrexcpt.c +++ b/sysdeps/hppa/fpu/fclrexcpt.c @@ -26,7 +26,7 @@ feclearexcept (int excepts) /* Get the current status word. */ __asm__ ("fstd %%fr0,0(%1)" : "=m" (s.l) : "r" (&s.l) : "%r0"); /* Clear all the relevant bits. */ - s.sw[0] &= ~((excepts & FE_ALL_EXCEPT) << 27); + s.sw[0] &= ~(((unsigned int) excepts & FE_ALL_EXCEPT) << 27); __asm__ ("fldd 0(%0),%%fr0" : : "r" (&s.l), "m" (s.l) : "%r0"); /* Success. */