From patchwork Fri Nov 3 12:24:16 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: 1858892 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=Doipox+/; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SMKhG5m5Qz1yQ5 for ; Fri, 3 Nov 2023 23:25:18 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B52D038618D0 for ; Fri, 3 Nov 2023 12:25:10 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by sourceware.org (Postfix) with ESMTPS id C6FF0385842E for ; Fri, 3 Nov 2023 12:24:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C6FF0385842E 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 C6FF0385842E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::731 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699014285; cv=none; b=iC9S42eAOC/NN4G7MTgat+hF7kLl24g1kDCjMI+p+dc/wFyoiWEXM3kB6azWZ/bBLzpFXkdTXdblpebhsQfAZGccDilDXV/JQtRGTx4MtoK473kaXYQfULO8bJUvWnWhgXoRsG777swbQXtDVuCoYh0duSXmyApj2Lz1mqcQfw8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699014285; c=relaxed/simple; bh=X2wiZ3laELaKsR0jgcmuy/E0a1j+Y6CXbQpJCpc45wA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=nMTia3kMHu3OuU/+96827WCwJUUKMFi/IxFJwIUifz+x0W322HmYj3XlbtXSBnwvopzQi2uLW466v03uyc/zwXc7TXK45ALDvX5/5YtdrESbgS6Rq1r9clwHWInY56uwXGflKcp0BGxeQz5b6YdUCOQzik2xf08XQ6MPgFwdgbw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qk1-x731.google.com with SMTP id af79cd13be357-77a453eb01cso115134585a.0 for ; Fri, 03 Nov 2023 05:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699014275; x=1699619075; 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=Doipox+/yoOv8wHW4S6MqWwfe62yt+cLtJZTB8BeJ381LbwaJCJOyTZeXlXgeEcOoh ij7gN6bw4+vcoD9r8NfQ9+gfTbntsfM2yMB2Jot2pXnOYYGCYsUjN33vdXyk0vit2GFd YWPLZKPm51H/04s/qF3aCZd5Jwzu89Fb6/U+QfzSbqY5yHgpJJaJTE/S9osFcSr5guRm 5H8vCU58WkZyDG7nEFW7SgxAez+LN4iKnEGYVYRCD2+cnXLCPDfSfJxj1gwRXsHD4u/U Pqzra2rL1Ih9eZsdwcxpGydaJ5Azuqpi9UeSGLZUxj/oYWp/MPlQj8q8OK691ngZ30Re Q7zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699014275; x=1699619075; 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=K69DBUqd7vUzrNasfll0qpoyFEGreqIxqnVcmMnSvdkBH/7+Ki5HPqpnCIxwh9u4oV jRGY+iBSnQDdwF6jFGOtdY+clQRAuQPiSxSUr+fQ+O146fVOJoSfUtsrW3bZacndn6c2 Hkxdumi4cqTPPoaoC0k/0JhO8upiSbJ/3Xdqo7ozXSTqv5YkaUotwk0ocUI50kzfzbKF FAm1POY7i1Ghis2oKk/0bxxS50EaDtgCpSuGOnkOH6xlmppDfdI7BuofWpslQr9a8X7Z v+aqgo1jio8OxbZmhdMNVwzb21BySMZkk/xBQQ+EWQiRIMW+KX+qeiB2ZHo8sgmYuI7e 87wQ== X-Gm-Message-State: AOJu0YwenkOoZBV/v170RgqNgqwo1Z6uEltNSkVC4SWN+bWnXksBz3mi dwfzJFWTXTKJTmmkZmKM+TxwZ4ztFt2cVKNNKPGkiA== X-Google-Smtp-Source: AGHT+IGZSgRK57EX9sAgEgqm355RHP8Tr0llG5WtZSGvIuSr4Aj5YYmTNTVIg2g+D0F09Y2UFLTXWA== X-Received: by 2002:a05:620a:2a01:b0:778:8b8a:37e with SMTP id o1-20020a05620a2a0100b007788b8a037emr25457419qkp.21.1699014275434; Fri, 03 Nov 2023 05:24:35 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:a715:dd81:f992:f726:338a]) by smtp.gmail.com with ESMTPSA id e15-20020a05620a12cf00b0076eee688a95sm693833qkl.0.2023.11.03.05.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 05:24:34 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org, Bruno Haible Subject: [PATCH 7/7] hppa: Fix undefined behaviour in feclearexcept (BZ 30983) Date: Fri, 3 Nov 2023 09:24:16 -0300 Message-Id: <20231103122416.2724355-8-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231103122416.2724355-1-adhemerval.zanella@linaro.org> References: <20231103122416.2724355-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 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+incoming=patchwork.ozlabs.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. --- 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. */