From patchwork Fri Apr 25 20:54:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 884435 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4162008wrs; Fri, 25 Apr 2025 14:05:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWGAtu5WdPMdE1ANiBDwG2wvX3rryM4d6pNF8PotbnvJNocoB0w8sBTlvTuIt9r98TpcSBKuw==@linaro.org X-Google-Smtp-Source: AGHT+IElLWOJccxhU77N/ZcXzviZEnQS8gKUvv5MSptsvWxf5l3Ol3s0wTgnsbP6+kvLI2BVuVaR X-Received: by 2002:a05:620a:44d6:b0:7c5:6140:734f with SMTP id af79cd13be357-7c96686b884mr186586685a.18.1745615143389; Fri, 25 Apr 2025 14:05:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1745615143; cv=pass; d=google.com; s=arc-20240605; b=gVTZhc24XfomFElyvACf36CVmf1hwYUWdJJbrpL582kgqkEa4jn87I7+zrGYXTlAf+ rptcRZpz2X9UEiyjDKVHyzdqTdFvftRm3DnMeFzOH/aMF6jxf7BobVpR7VyVyVldVGly bEKlT/56Fluc0c0OAPSTo7IcASGxl9buxLKgMZpw82yGzZmn93lIbZpl7ys2IJCfAMra 68u9O1N+ygCamgGpxHux78rpHqAktM5ibrF8iRJobqdIHQlbcqo2PdB2TiiBrpA0ND4g 9CfbgCUSWcXgcnZgxolTo6/2spxNxy9YvIMOCk+gbIcOA7LbCADKNdS1GnDlAO0PtnBF dYKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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:cc:to :from:dkim-signature:dkim-filter:arc-filter:dmarc-filter :delivered-to:dkim-filter; bh=JWD0gyySHFH+tchmElopPa+17tDC7IIwhe7hRrmsXd8=; fh=G1NI73xfDcVophzg1+e/pmkwSVc7WWCXN7V/bl5G28k=; b=a/39OA48el/72Rtaldk8VfEq/iSXjYmubxEFEztLKCvEBIHxVvReNlXrKi4WBCSiwL OFflWVVeuZEqLeYrsZGuxSo0hZUSHvAFKexpDBbOtxBqI2ovPe3nqYV8DazV8T9mnUBb n4kQfL5Bi2ysx91CaO/vvAuk87FtIRP3hFmy4271s/qFAW37EFBpZQ5d8IuGVFX7G5/a j/0ThJayk3pkZvMhGvboXG0YX1wpHI0GSklaS+22idPq83wPan1nMooUUEUaUHjfNtFf OZzE0o326jtZ5kXoTL7nDoCvxau71bgs5ZLIWPz9IKE2UIu8X1VErwhu+uMtQ9asLd44 28pg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bFAMUDbe; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id af79cd13be357-7c9589d141asi445102685a.0.2025.04.25.14.05.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 14:05:43 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bFAMUDbe; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 F34573858D3C for ; Fri, 25 Apr 2025 21:05:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F34573858D3C Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=bFAMUDbe X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id D67E43858C54 for ; Fri, 25 Apr 2025 20:56:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D67E43858C54 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 D67E43858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614587; cv=none; b=rWII2QP+MP5uJLmGgW5PlMlUWi4Hm92j2ACyrRtZHTB75qf4tzCChHcWDngOPM4Mvl5TvtZr6hsx3TaD2TDlf5dJQUY75oRNN2s3xSJ0ZNaMMMcYiCkhSpiq+/S4NPC5ac5QGkswscFiEXXlPxsrRb5IeFUUcMy4snx+6gFS6es= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614587; c=relaxed/simple; bh=mMbrMJDp16AxipSiq3brqyA8IeFjEms992WBdGpag0A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Tk+fj1Snp+tWSdQFqdvjuUwEjXOsUp02CEkonBr9pQYNwWiz2H53NEpmrUraTRtyVlsr/j38Sh86H5yrrmAvk1yzJDcnyfLRnRwuebExr0agCPnocSOlSnkSOnEQCwguoXcFIGOrXCFC0xvxxyd5dwTZnKDpuE2vVy0tvfTGoX0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D67E43858C54 Received: by mail-pg1-x52e.google.com with SMTP id 41be03b00d2f7-b0da25f5216so1822884a12.1 for ; Fri, 25 Apr 2025 13:56:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745614585; x=1746219385; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JWD0gyySHFH+tchmElopPa+17tDC7IIwhe7hRrmsXd8=; b=bFAMUDbeHE7gHHkF7cGoagKgaOYRqUc8SqNffiidIfFy9jgNGwTA5bMqRRTb4/clvA q1PDq0YJB6h8PaDCl4PSPxiNmDshyGLNkX4wTXha5v/jslfI34Ug1rc9a0FjODuR9h6M 06K7FIzhJ2MEReLHnaxSpmk9zTeana16gDIfWvOwQRljdTLu4cFy9mzAM17K2oLn6w33 OKQtRJadWVRVIsMu3wdHuvPhVrdf1pShDAAkeK03dm60q5OK1qJXRniOe7alF6zzGTW3 2fJ8eV4CuhJGL8VPWAhBjuZ2i3355P5Jw/1m8WrsmhXj52xnia+wYoblTgwGlJ/GOieB YE+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745614585; x=1746219385; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JWD0gyySHFH+tchmElopPa+17tDC7IIwhe7hRrmsXd8=; b=ZgX+GKPB+30tb463oe5TLXwFk4F8iLVX9vgYIoayuR6lTU0ITAcCNOj9ivcvgS6xai Uk3tqWbt4sTA85l2XEuUUBIrHtXpzt1EH1iWG3CuLJ42xoH+y9zpUwISVoiWWcILuFJ3 r3ZfVSZRAG0+/8nTQUbRcNpOUbLdfeYvNS6K0NMUe3+IMvN0wW4aOuLW/WGiW/n0fuKm r458/jRhHwkvM5KM7/ogJ+2uoguNPsuQXpr4AlcadpAmQqIZJ0M9jVV9frk5+Adjz61V xfI14DyzoTy4e+gjEt4qvgamzKYsrMYc2ylA9tVfQH0gyb+iZW6amQwYS3bZOTWr7XEY lfKA== X-Gm-Message-State: AOJu0YxhfIEFHECcpDdl0M82l4OhJ6Lse8HizEFM2EJNmljfXRSK8Y29 Qpyon8XW0hYN/JIB9kCTK00Xt+sfB0CCLjcvlPGconFadQq/ded6/CBUeZ75Io14Y6x5Tq9NlD3 V X-Gm-Gg: ASbGncuT7fqq2CE0WqU7VU+E4stDDD/bdnMmii0hQAPSRf14pFE+rTVoUvhnPFPKkeL f19/NXolqjakEM//OM/kZeZ0IX5NjQeXBaj6/A9LdKpbvaQ8FLbupjGKGo8XCvy1D0xFu64Jksn xCebZ9PUqMYUg/Hf3RkZ59B+Z4c2538AL93ryZU4zTzmWF9386POR/WR4wS17JZRKW+CxkA4Bqr o9FL7/FtbUigbj7UCTuGwZPB8YhAGeu+plUMU7ASreWqLnwWBmspguGm9MAnUgO/5AMp8uMiwuQ ++6fDXWn9uqwjRWlXqM88cr31z5ifi4FvOLgIJnvli3XAxQiTQrHSQ== X-Received: by 2002:a17:90b:574d:b0:301:a0e9:66f with SMTP id 98e67ed59e1d1-30a0130bcf5mr1568690a91.14.1745614585530; Fri, 25 Apr 2025 13:56:25 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c0:9bf1:37fb:44e3:5707:516b]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-309f782d47bsm2357188a91.37.2025.04.25.13.56.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 13:56:25 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann Subject: [PATCH 2/8] math: Fix UB on coshf Date: Fri, 25 Apr 2025 17:54:23 -0300 Message-ID: <20250425205618.360232-3-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250425205618.360232-1-adhemerval.zanella@linaro.org> References: <20250425205618.360232-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 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 The left shift overflows for 'int', use uint64_t instead. It syncs with CORE-MATH commit 4d6192d2. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. --- sysdeps/ieee754/flt-32/e_coshf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sysdeps/ieee754/flt-32/e_coshf.c b/sysdeps/ieee754/flt-32/e_coshf.c index 5f6ff8c29f..382cd55cdf 100644 --- a/sysdeps/ieee754/flt-32/e_coshf.c +++ b/sysdeps/ieee754/flt-32/e_coshf.c @@ -3,7 +3,7 @@ Copyright (c) 2022-2024 Alexei Sibidanov. The original version of this file was copied from the CORE-MATH -project (file src/binary32/cosh/coshf.c, revision 5c58ea1). +project (file src/binary32/cosh/coshf.c, revision de59ecfb). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -69,8 +69,8 @@ __ieee754_coshf (float x) double h2 = h * h; int64_t jp = asuint64 (ia + 0x1.8p52); int64_t jm = -jp; - double sp = asdouble (TB[jp & 31] + ((jp >> 5) << 52)); - double sm = asdouble (TB[jm & 31] + ((jm >> 5) << 52)); + double sp = asdouble (TB[jp & 31] + ((uint64_t)(jp >> 5) << 52)); + double sm = asdouble (TB[jm & 31] + ((uint64_t)(jm >> 5) << 52)); double te = C[0] + h2 * C[2]; double to = (C[1] + h2 * C[3]); double rp = sp * (te + h * to);