From patchwork Fri Apr 25 20:54:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 884432 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4160197wrs; Fri, 25 Apr 2025 14:02:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV915ZfHS+w+bLRgfRK1bOcITEi44pFY29v/kG76izXA+yNOHqLfPKwO5r3MRrSstm3gqA35Q==@linaro.org X-Google-Smtp-Source: AGHT+IGjvyN1khQVmRI4t05CgdETay+z48k+DebeThs8qm/mWlB+sv+A3dZVk+L3hoOuXqd/558j X-Received: by 2002:a05:6808:4493:b0:3f6:a9ea:eab0 with SMTP id 5614622812f47-401fd6ec530mr538964b6e.6.1745614937836; Fri, 25 Apr 2025 14:02:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1745614937; cv=pass; d=google.com; s=arc-20240605; b=c4637PUBfqV9eN10QifKKGyBMCe7OD98/vpKMXwbYj1iLU+nmZzyMc+NwHb3ufaavT N66ZvtvwcXxNM5Rojhwgv+LUASqukLTVIltl9qHQPxtuk5NubRdJ+lZLIj31qToRe5lE seNR4aw8jmOPPrQR5zyEWJtsglN9+THn5FyjfqrFnKTHZIqlA4w5G/Ii33yKn91qN+Br sDIard2aReu6vn7RTur2q5mx+HMe05l/oW/Leez0RpAkx2gLwc9nVcL8Ky2gVX8SlKhc IyvC8Pcszfb4g4E21VRrb4zNIGGu6ow9LF/J9Wf2U2di79qMvcIBU2ZLsB8/UnjTzVBa aCdw== 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=MSn2BWcS5xNZf3Lz/yyDyW+CTC/jPegyIGo7yub9MWE=; fh=G1NI73xfDcVophzg1+e/pmkwSVc7WWCXN7V/bl5G28k=; b=O1QYkRCVkQgpoOzV28TsG/372kKJEdOkPLcfXi8l/APf2isDYATn7oHCe+aU0UbvoG +GK8DmwQbgQp9u1CVJOWqkAmPZWXHP61p2YL8RZNl6KtgyhfsFgNAU+yHOyGTdlFI21W jn3UmIe2oGB/G/nT1qJf5PpvDlsFxcgjxXkoPn+Dc/3Abt6Rj4UASo6ndq9BKbz/DG6b tWx2ZA2vJFjFNz2+j8MgfP+Qz8T6tw6/pFkIYnSsVtg8rr84Jb8pqvteUAMDlDpGtHF3 w5gea3b6UzyTgfGhAI2aBI/mIelli42nqY7q0HXPvp/5RnfUFJcbRmXSWiIuPfp3BF/C xtwA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qicIxw1E; 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 ada2fe7eead31-4d3d6bfcfedsi1229050137.269.2025.04.25.14.02.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 14:02:17 -0700 (PDT) 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=qicIxw1E; 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 590C03858D3C for ; Fri, 25 Apr 2025 21:02:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 590C03858D3C 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=qicIxw1E X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id 7948E3858D20 for ; Fri, 25 Apr 2025 20:56:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7948E3858D20 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 7948E3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::530 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614585; cv=none; b=wcg5Dp8bVFX8clb8pWOvuIlY+dnKJVhBHxgmg9zF5UNacypIuvbDlcHs0Nw55ONgTtHjHatbpEz9qvCnmEvnk5B0iSPpDEPIcp7sDCv8oqM+phq8ZfOURLBxkwLqZ57CpH5sTO4cN81HKigQXB6wEXDLkzlqqX/hCUYoWeMOVr0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614585; c=relaxed/simple; bh=qNHr5sSyUeNkn33kqd91JVDzD+fbrMhYg0SAoWAVRMA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=c/I9jUSjQXFYdugoewYt50FI3JL3ugKcbMBIcNijr4IJvfjjRjShxAUObzEdT5dlgpLYku92pV4nU/O8B8gOjTrCpx1Ql5MZMmBEKKuv6MMENgiqkjYhd+x07uiqMjoppS+MycSwKG3Pj6gZKDkfYx9RqKVY/5SJCqHpY3aWKvk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7948E3858D20 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-b13e0471a2dso2073041a12.2 for ; Fri, 25 Apr 2025 13:56:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745614584; x=1746219384; 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=MSn2BWcS5xNZf3Lz/yyDyW+CTC/jPegyIGo7yub9MWE=; b=qicIxw1EBvcvguKM1xVSmHWQuzT4NrrlKtcs78TS6rPUr/wXKHj+ZXtZgl05tosfEM uhCm8pB//6uiPLVxtsPK3u1bMbjkaNO0U28Fc+FykYkANNtgHRaq/hv65AroNVi9hU9T Pd5VgMarkb1LyY8Nlxygg7iPlP+0mut1ZlMO3lHknUs+1fmnfPkLSHM0vJd1guZ56Y4H isMtu/7KIV7FhH7ePSWXL1zQJ129FVX67Y9zPr4jMBc40rzoUPcCdAIffEKRG54xkwsl 1Y762piuCWD2Ul5bRagpDEf+i342Wd8M92ZVI6fpVGRmZImQhuNwdIYlYJ4Q8b7izRvn KxwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745614584; x=1746219384; 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=MSn2BWcS5xNZf3Lz/yyDyW+CTC/jPegyIGo7yub9MWE=; b=b7oUk8t8IdDdp7aygBlwddU0FCb12EKnPhJR+zYk4F0HF6wx1z1Ljv+ro51ejnPcQz YM/Fr0uCJ7Hho3rLNvODzfITx2VubJLCSorWWViL7sBrnNVDG2nWdUXsCot+2yJ+q5Zc FC9tgsMxWtLnPRmVspegTbofGgLw2Tl8n4ESXxlV0mrN8uCJAWuP46z18VDEnF8DnM5+ olZxIGBkJJSaBIHIOtEHQtXiF+57tuMXAjIddabviTbhG/frr/AYu9bO60qK7+NT0E9s KfXwtKqImtj7WtkrSPkAv0SKK95it8sIBfoie8FsUKWGra85V2sqXyZaRJ8r2Dm7rfgn zKAA== X-Gm-Message-State: AOJu0YxD7U89VR4jsWRLCr3usGDeFKeUm9iCM0ZzccHgcKno+aTOPuBb kblgT6CJ1sbek0y/JQaV+I+eOF62KDU8UYR/k/76KHBjqKZDHNz4rfL9g74big55/UjJlbeDKCU + X-Gm-Gg: ASbGncuvwRqk2G2jl4U1cen4Q4dDQra6WBF7WWTOEGW6BLU4VgOpmYiozyA2XJkNnmz TGW9dZlwgXGsyG4U8EKvY62Lqz6kwORG2q27o+paegm209RxjTlNzr1VfgZGoloUf8dI+nRuzrQ a4GMavKSgpoLB0wsE8RR0XBJWiw3Tw0yhxeD1/GPHijai1wmH38wnmlHiTtsxvMKgjQenGSvikZ KePRs7lj4KEkIsnGatL+HAKndl/gMKTXRa/R29Yu9RAiznsxKmUEHwfcrsxtcgxh+xqXVu6utoD L6BBYN4JsXqf8Mc/NW/I0u4Gr2F0OsIozfpI37k6LYn1Z6NzHcuCug== X-Received: by 2002:a17:90b:2f0f:b0:2eb:140d:f6df with SMTP id 98e67ed59e1d1-30a012ed038mr1373373a91.1.1745614584089; Fri, 25 Apr 2025 13:56:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 13:56:23 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann Subject: [PATCH 1/8] math: Fix UB on atanhf Date: Fri, 25 Apr 2025 17:54:22 -0300 Message-ID: <20250425205618.360232-2-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 unsigned 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_atanhf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdeps/ieee754/flt-32/e_atanhf.c b/sysdeps/ieee754/flt-32/e_atanhf.c index 5138408324..eeb1aae6a1 100644 --- a/sysdeps/ieee754/flt-32/e_atanhf.c +++ b/sysdeps/ieee754/flt-32/e_atanhf.c @@ -3,7 +3,7 @@ Copyright (c) 2023-2024 Alexei Sibidanov. The original version of this file was copied from the CORE-MATH -project (file src/binary32/acosh/acoshf.c, revision bc385c2). +project (file src/binary32/acosh/acoshf.c, revision 4d6192d2). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -135,7 +135,7 @@ __ieee754_atanhf (float x) } double sgn = s[ux >> 31]; unsigned int e = ax >> 24; - unsigned int md = ((ux << 8) | 1 << 31) >> (126 - e); + unsigned int md = ((ux << 8) | 1U << 31) >> (126 - e); unsigned int mn = -md; int nz = __builtin_clz (mn) + 1; mn <<= nz; 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); From patchwork Fri Apr 25 20:54:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 884427 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4158267wrs; Fri, 25 Apr 2025 13:57:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUCqrZbVs3iZAUfqtwZxO2jvQKhrQW9TEB9/vq8BhmgmEv1GNIjNrW9XbvoKzeWg6wvbk6K1w==@linaro.org X-Google-Smtp-Source: AGHT+IHZYpwO9ZvCzmr1Se5p1qItpEKVAev0cN/gwjlWwDtz82fMRoKiGFO7Vl/VtBVEi9m1IXox X-Received: by 2002:a05:622a:48d:b0:477:6e8e:138e with SMTP id d75a77b69052e-4801c1cca03mr60278151cf.2.1745614649702; Fri, 25 Apr 2025 13:57:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1745614649; cv=pass; d=google.com; s=arc-20240605; b=Ev4Nlx2W+LiXgtQ+2O0N3NSr2SjbF7VOWVg+a7C9hKAfhBkQ+V2fftD+FwBjZCXIVx eICnJB8EPcvHwD0rtoQ+SNWBaR9Qh65IWgZPq9XB5RombXgi482upzsRHzT8QcVaqU0H KLGmYPiCNl65vGuJ5wVxf8tkPZrOPM0fZ92HdcLN37ibfmD6zY/qTNXzPBHGOGb/UNra 3ux0r4uXX4Lxj2t6Q1Y7eZvAJK2i5BN4Te4/7xXPlAu4qUORbcr8yjXWZNIiSRhbme0D YyeLwdqe74uEAZxQ9HMs79PYMe1lVAJbOjNJyfpAFu+i6AnpscSs18cHF4YwlsvelIaK oHJw== 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=O19g8dCrg0VX9iMKniSDwvZTuYaneI2hizWx5weqllY=; fh=G1NI73xfDcVophzg1+e/pmkwSVc7WWCXN7V/bl5G28k=; b=HIcO5AHUKblZxXb76LabaCmwOUHrD4FIedx+vv6aj4vJiP8saYna/yTg8YwctaCI4G wxgVNS0r0tSBu3xNoeNKePzSv9gf0htcQEPAm5CdhNC0ej6zrdM7lrty0v55AL68ETU+ xRkSzfXJ18JaeZnpCNvpruiGS9kMMRe9ZrB5C09Cg/RKZJU/3Re1uSbIP3zQg39oee3J rVrXP6uPduJsrspzC73BypAz6tUVoK9InfKxyohPfAXOy/gGw47GAYIw63tepmX+veDN zUmmbstWj5eb9VuXWLPWcet53B5wOYU+LZf198t7/F3AU3673Pj3NvNreIKrDEGJCB0M 4H6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lGSw3pzR; 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 d75a77b69052e-47ea2bab139si47112431cf.647.2025.04.25.13.57.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 13:57:29 -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=lGSw3pzR; 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 406473858408 for ; Fri, 25 Apr 2025 20:57:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 406473858408 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=lGSw3pzR X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by sourceware.org (Postfix) with ESMTPS id 6D38F3858433 for ; Fri, 25 Apr 2025 20:56:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D38F3858433 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 6D38F3858433 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614588; cv=none; b=V1dyK9ikSsRMZ2hLZyiUT0VJsfGQh1tCLiLWUcBGIeCVzpaR+FUL8IRoxiuVKUdtdTKG19DG+8XiUKt0QzTlLPIb2YV/uLw8UOeGRNMzNFzITr81K/4InKviETrkxJnBNMrNkxujW4M6tNu8LA055rqkQDGnc7WooReEU6/EGfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614588; c=relaxed/simple; bh=RNwrzZhUxkslVysONB4oXGCiumP5AsblB39YCaeeFmw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pa7Jvb+ZdX92yI1+mybrNPpNKqlh+qZuNdvpm5eUVAAjGpuchXs9ZGX+PzTktCHWY1uFlA6drqrG6Xg8b+t1/TCGC6EXicmltxP9QVJ+YhiVnRsCFNIeW2/Rf4g2qysAmRYyTEC7IVgjmLtcgh69KyiZz8x1WT+Gud0HeVzyvdM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D38F3858433 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-30384072398so2532259a91.0 for ; Fri, 25 Apr 2025 13:56:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745614587; x=1746219387; 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=O19g8dCrg0VX9iMKniSDwvZTuYaneI2hizWx5weqllY=; b=lGSw3pzRMJnxFng6Pv69jYhVfpqSplB9dP2xs+J6JhDpTgXd2Q577gA1TmKe/ljBWd CYabwADXMfJijyPHAidh0Mu/wXXAq4JTN6wUil8vw9nfTEQbGO/GpkvAWh2gds/pmVNh qSxnC5z4fwxr5Py2AjH0Yz/7XC3InyrD7tdu5Ar5p/L8S2ezsClUi6J8h2NgjY9pS0Rx vmLzJU+OXYxWDsuxr735SHuqTdh2l6LA4buy9FzJnBUFJxsAEDDk/ZXcbS9bhZ736t7M Q2f/SkO82l12MfNolbgyqN5Anz9tUCjGwYkoYnl2byYXGNKTCvoff/Viv0Iyokq/sU6x eKbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745614587; x=1746219387; 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=O19g8dCrg0VX9iMKniSDwvZTuYaneI2hizWx5weqllY=; b=eHuHcoOcwcLkzEtXMU1yhlIsaGFeZLdRvU2govfzONu+J2MhV+RxKVq2dOloPovSU0 ynwbdvxN1AfQ7Tvc/S3VGrQSGBb33RoDJgWOBgmssSmlbb1j+KHeozyx8kKjJSjwamQd VJICHM14kHp+1Mw7mqVpTkPKyVqHmWS0HA7OjrePGKD5JLqLA7UFKOC8AL/6bA5ubWiE j0t2RIsNA25Wx+InZcBHGKyj63IMEugAmG/hyfXScykav/niEKsTbQH7gCNEbxkmpNRJ /qB0+nGTXuW4RIL3YXdSu9qdRgUgMO553LRgpiYa31fdB3BIDG3IKhTOnQ9KIkZ2KkgR q0Nw== X-Gm-Message-State: AOJu0Yzm1t+54Iw47x5qzpRMwLE2Ovl7WxJzjtsNgHwQbLnJ1rin45ys 1sgVyCL0U+LDxtDzGys1sLBaQoGkSPZXaY/HueEjKeYzNETnCFjryU1bIWniNsDC3clq8uPuY3x / X-Gm-Gg: ASbGnctxNxKSTPT7llPLv1cprbzDaTH9fEy9RZiWEQzrozLzFwO2yAHwr/Lv4JEUXOa DjN4DxNEaPvHprOgMY7g1+KpFnHOgT8YyhiUiPL3tKKwVT2tx0Vm0VvZN0tRAUdG9jAdZKbcGxi P7vH6thZaFL8pOttJ0fO0cKioRUbIO8AJsz/uN0WsxEIYLgxFlvIxLvIiXrJHluW+A0KeGeAuEg VC7/E4lfQtJ8EJVPwwhHk0svDeaJXvf0R8RBRCiDct7nnaZldoRKpE+HymIeCyW1LCBcq3M3aVn bw4tLikzlsMNWRL8R9BcvQloN8ls19GikOmbg8FGuw21VendC+SRSg== X-Received: by 2002:a17:90b:3ccf:b0:303:75a7:26a4 with SMTP id 98e67ed59e1d1-309f7da1e3emr6478620a91.7.1745614587040; Fri, 25 Apr 2025 13:56:27 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 13:56:26 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann Subject: [PATCH 3/8] math: Fix UB on logf Date: Fri, 25 Apr 2025 17:54:24 -0300 Message-ID: <20250425205618.360232-4-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 a literal instead. It syncs with OPTIMIZED-ROUTINES commit 0f87f607b976820ef41fe64d004fe67dc7af8236. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. --- sysdeps/ieee754/flt-32/e_logf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/ieee754/flt-32/e_logf.c b/sysdeps/ieee754/flt-32/e_logf.c index 6a595cf7f0..207151c76a 100644 --- a/sysdeps/ieee754/flt-32/e_logf.c +++ b/sysdeps/ieee754/flt-32/e_logf.c @@ -70,7 +70,7 @@ __logf (float x) tmp = ix - OFF; i = (tmp >> (23 - LOGF_TABLE_BITS)) % N; k = (int32_t) tmp >> 23; /* arithmetic shift */ - iz = ix - (tmp & 0x1ff << 23); + iz = ix - (tmp & 0xff800000); invc = T[i].invc; logc = T[i].logc; z = (double_t) asfloat (iz); From patchwork Fri Apr 25 20:54:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 884438 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4163227wrs; Fri, 25 Apr 2025 14:08:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV4p6QNDbMpOGOUuTaHcvvrK7oNbDVe9JbbgGUn+D6OjbhK5xlqGYBjPzt4UwYIVBJ5be0zDg==@linaro.org X-Google-Smtp-Source: AGHT+IExUvy+aRo8IE6kxi5h3zE7zKTciQxWxewYLnF61oHoahJGU7APXEZH5xpRXPmr4WMHtxfH X-Received: by 2002:a05:620a:280e:b0:7c5:60c7:346 with SMTP id af79cd13be357-7c9606a4940mr534046585a.10.1745615326259; Fri, 25 Apr 2025 14:08:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1745615326; cv=pass; d=google.com; s=arc-20240605; b=eVNgxuvQpN380TOWXiWbEusCZor+gkngxUj1BVQMvQ4akYnmZAYJVqV94eJG5JJpPu yteFOnRyZj1aFcEXBRcEqI70Dj7qlHAGZYwdYf1KdDvf/MpxAYJ5H/osDeKW1t7fLret XOA8V9MHq71lJ463bvPa7YnW8q3VHtE1ZwbGM8k414gtbnqw9wBxocCjAZ4J0dDiWRii IE45wa9LoMgnAm/CRErY+pYk/qhxnRBt0MXiKsHHzfJOCnvudicr8/GBDlfT3sdSuFH0 LG9s09jUXHeoQ9pyo7AKTs1fN/3GYSMtgDao7VU47KT1X/Zb6wRVT0UFa7O2eXFOH1sl OWUA== 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=01H+rQTEPf01M3TmKsN9OSy1bDgqGGCTtO3nA5kc/eA=; fh=G1NI73xfDcVophzg1+e/pmkwSVc7WWCXN7V/bl5G28k=; b=WU8ghbw9vKR3B89dtzw/RDwQsmthE+SPsWexxTGB5PeX1a1OaAoAN1swBs1YCZRFt7 iVC1kvbEg8PP6YaKHIR/j0txFsfKZ89nl1DExWk4KOyV8W+chbvTwTt55r0uPTf0ma+n vztT67BADJsSDD29q/FbmXS/fhtpd56AX1qUCRw4Ca8H0Cu3PXh2JxQxJbJkakMop+g7 EglC93vpJc9O61CNGrMhX/vqODvq0YU1tl+aAoKSJiOW8gMqFRypeuVobqPdRQ2tHoRk xweEBIwZ/rWqXrGW/lv8i6SnReC7H1uogIm2LPrkN3FnsC7CmMCSqzkKxAdUv2LeYGXS nxEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VQL+e7QN; 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 af79cd13be357-7c958c9f172si454113785a.4.2025.04.25.14.08.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 14:08:46 -0700 (PDT) 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=VQL+e7QN; 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 D40343857B91 for ; Fri, 25 Apr 2025 21:08:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D40343857B91 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=VQL+e7QN X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id A5A8C3858C60 for ; Fri, 25 Apr 2025 20:56:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A5A8C3858C60 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 A5A8C3858C60 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::530 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614589; cv=none; b=lOI1uFoVDuaiBURiDTr6yg5NJGY4I9qRvZf8FAb+jzylj3lGIoDaS4FyKmKam2bl+txpBMA4j1GGDpBSjvpXkSiEOdk0OQskyVZx9RQnmybFtVekj3yFYF9f+pDlaWb7Y6Ws2iShrm1hompJSCro+E35claU/He/z0oEFuZikDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614589; c=relaxed/simple; bh=6efWClQUE2QYz5QQNayHua3HEjR8bmp0o9VB4pW7x/A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Ex+XFGCXL2aCd5/VjeOqnHfFePBaSRE5n92+Dr/H7tMn/LysKXGw7sCBbadWCqsGSZPFsFqFXjIaOyk2rdIQsHDB/ZtTk6qHwET5GBMC8VXRbgZuQ0tgmo2D7u5PBFRelBtWaLuVbMUzV1hVdJeSR4YZQl69nhktkpjw6lb6fvQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A5A8C3858C60 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-b0b2ce7cc81so2685101a12.3 for ; Fri, 25 Apr 2025 13:56:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745614588; x=1746219388; 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=01H+rQTEPf01M3TmKsN9OSy1bDgqGGCTtO3nA5kc/eA=; b=VQL+e7QNLEhFpFrAWgivfgEX0FSIjWiAZA9arX7+y+XBTyeDD+zujSdM3IOK/bsNJG jp6E8/+oeO2CtgUFXNdH3G+HCo0puQkE6Hk96N5UAJFEBDMmMIBLTTRwuzKku9/2gNDU 5YHHi3c0pCoiWIZ5udc9rs4MQSiP40GpWIaPImo/9/4iqRDcsZQpI2GaaOkf2leYeNEX bM4FEFXovRHmwCNzaOKHyeR3KkybtajiVfyaxRpayBg6+9NA9BPi8FNCcFBlDLBqwi5B Qa/o6seHA48aJUl+OsQVeGcweM1fUMzflZW14c+GqcRgKyIzOlVslPChInp9Nx65gIHq 6V5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745614588; x=1746219388; 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=01H+rQTEPf01M3TmKsN9OSy1bDgqGGCTtO3nA5kc/eA=; b=QSlrQshltl8CAs1vHMLXZTlCCnclTRycQWjyAws9YuZneqjFT12kkx4HZIFqu1jCbu ZWslZhuoBKuWIXdzeBHuW5HRMUEoTjZwxCMUiIA0oy6WRAmUTAWUwW3lMuL4R2CdgZJI n5JhbHfc1j8h9s9xqjJmlyRf8antHXO88tCWaqvAwpl6AOoxuTUrOH2KvacZPhlnQIoG Mi1FJ6vqy82AIXjuZlFebtSKvMOCt+hTaAgyF/aWjt0A0EeRxXZOYekDFt/vi6JPdGhc 6JWzExHgOouL2i4keCmaPrZg3vrdC5jFOYA0gMuEHXAxHl9w7bsKW94q4lJxxaMHLgBZ 1Qrw== X-Gm-Message-State: AOJu0YwWrJ8PQZnSLPVoZ08/oFaDzWw8yf234XlFVrWqwhm3yH3WLf5z lUsLdZIzk30MfjPwMp+si28OwjYWWgm06T9tp209MehaGJJhbusKH+URg4lpdT02gSDB16Gw6Ci J X-Gm-Gg: ASbGncuNiFONbuMUT4ZUuzEFKLCS02J42VwChNPi43xsUXYTYEt/Hqp2h1VNr2rzKVP GUapU4Mn0PpodZpaNdFPsJP70FJHNo4SgwOeRWhi7+CvEzC5TzJku+wxlRCkW/wX3vaPLEp2BKm ahmyQKz4K8v53QyhzeQk3ygqO2766HjOLdUwfBexZCgVJOUnHKGfJDdPhaQPnwd7aAtFRMBZYo0 ov0p1MUTfpnu1AiQhYv6A6RRHUiTkglXr4o0slG5+eWHuI8ZOv0Q/wUJln3iT46SUXQlUTxdfaJ KRulNGkdaXAAlkMoYGNxWHJhIoeXXWPuIUDeGysKAempT2z31Yd4QA== X-Received: by 2002:a17:90b:57c3:b0:301:6343:1626 with SMTP id 98e67ed59e1d1-309f7d98b13mr5610357a91.1.1745614588526; Fri, 25 Apr 2025 13:56:28 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 13:56:28 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann Subject: [PATCH 4/8] math: Fix UB on sinhf Date: Fri, 25 Apr 2025 17:54:25 -0300 Message-ID: <20250425205618.360232-5-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 bbfabd99. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. --- sysdeps/ieee754/flt-32/e_sinhf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sysdeps/ieee754/flt-32/e_sinhf.c b/sysdeps/ieee754/flt-32/e_sinhf.c index 754b84abe0..6c8c1db404 100644 --- a/sysdeps/ieee754/flt-32/e_sinhf.c +++ b/sysdeps/ieee754/flt-32/e_sinhf.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/sinh/sinhf.c, revision 572ecec). +project (file src/binary32/sinh/sinhf.c, revision bbfabd99). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -83,8 +83,8 @@ __ieee754_sinhf (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); From patchwork Fri Apr 25 20:54:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 884439 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4164291wrs; Fri, 25 Apr 2025 14:11:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXKExW9anvuhvKrB2EGg4/+/Yr3dz/bOgXPYkpXITGiQYYrGiAVkyM9CAZeZoDTqD1g/3GeJQ==@linaro.org X-Google-Smtp-Source: AGHT+IGBco+F3O7dMMYTcXM5oAAftyP2mhP2P1ULEkOrFzFyOpSYFDGNK0sR702H3kTDJIFB8dqc X-Received: by 2002:a05:6122:1d4d:b0:520:6773:e5ba with SMTP id 71dfb90a1353d-52a89d04550mr3414602e0c.2.1745615498463; Fri, 25 Apr 2025 14:11:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1745615498; cv=pass; d=google.com; s=arc-20240605; b=iO5SJRDxUhuTC+iS15PBrXMPCSDXGjCVzz/QVLrym9bEWUwbJbcecDmGAFC2OHQ0B7 DOstA9V3KPiaM432e2A32o6J0/Tt5WYDioWZSxAWp/pfaanMErUx6MZtjr3z7wzUiZpq teByBawyZehRlh2uFOsLKoLrS7WdUeJhZYpkoecU86rydWo0O0ISDO1vLqn/hFUJGtcH unggLoZp3M5AAeg/zCLCTPrgy0jyq1CZUFe/uq5uksYiniyw1HE9Hp4+ORReO5ZXTO2R ntfxeFdzUYSnrjBa6SyTxovI0Np7q2u8F1RIgqdcT7cwXExOI25v8R2OpCCPU7rjvSwn ci/w== 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=B3e4kHwzmveZeZCfH8hN+fGZaDmPTb1xtAaO9QsB3sw=; fh=G1NI73xfDcVophzg1+e/pmkwSVc7WWCXN7V/bl5G28k=; b=c6qidTpGhihd2+tb94Lo8VJt6MPTfUe7J5GWduE1GGBYkWplAf+6wvizEUiroARbiJ DuMLCrDnH8tRhDizc1Rs/NeH1uxQV/ICVi8fTH3P4pdJM6RwGrIUz1u4mmqMxpga0Uvs QmMHh8aBBlbaMPLHxrQ9atJk5Wp4xPOoXn/n2K1gs41b/WSjH4yWprr5lmU6KIbtIgS8 jW7VSrkTckCSXhxPpEM6UpT3jCbFLfq985a7EX+PYmVAVBoEMS2bTIW5VLJDpRXBZOXA qi3n7o9BtpaM0zuVLU92dfCsH6+6obTRpEBHdBu4wppHPm6Qnla6Dqz1j5PnDozitC8s rI7g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mwXA2Cut; 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 71dfb90a1353d-52a99208717si42763e0c.3.2025.04.25.14.11.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 14:11:38 -0700 (PDT) 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=mwXA2Cut; 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 CFCFD3858280 for ; Fri, 25 Apr 2025 21:11:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CFCFD3858280 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=mwXA2Cut X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id 424833858D38 for ; Fri, 25 Apr 2025 20:56:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 424833858D38 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 424833858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614591; cv=none; b=X4iON8/mqsFSSlCAilqyy8/RMSa8Dx2gR1Dp/KeO4xArA1URDk7etD/D3/1emK/Quv7MpfrjuxGJwdPNMThKWTtlMt6uO/vcR6XWCKJ0htka0a/IkrHm8UUiumbxByBF6L6vxuTWwq6bZyVrxYErTeR/K3q3aMTn9ybetaA6GG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614591; c=relaxed/simple; bh=utHSoV114+P5f6HjQg/QITFnsQ7ol6NhU5l2XPy+t4g=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=B5S263TYT08sVVcP7Ndm4/bYyFf+YcbpovkuLLBr4wMBu3x4T3MBPCUZLhDl41zPtGbvAIG/fwpts2F18E7gIzyMd/t03GdfAjAW/yK/l2vQfx7O2NISfSnEnj6lIxxT6mqJEnH8P9XDip16F/0tbSmqfXn0jOx9jof5v1JkJbE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 424833858D38 Received: by mail-pg1-x52f.google.com with SMTP id 41be03b00d2f7-af5139ad9a2so1885299a12.1 for ; Fri, 25 Apr 2025 13:56:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745614590; x=1746219390; 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=B3e4kHwzmveZeZCfH8hN+fGZaDmPTb1xtAaO9QsB3sw=; b=mwXA2CutWLMo4HYXOjllXqVUyg8ogyiBP6BsN51dQQwKkdBV0ZmmGcDxA5OkrwJkEe eZCse0/6eTo1Xid3tlSyVcsiPX8epA0YLBAHmUZsYmRvpkFjPkjqksVs9/sfEUrs/QXh jtD55v19Z/UA5xwi1Cg5V3WKeYAeCY1pyB73rlh38rmmRhJSiomOHLAfcwJMz4v5GmQq yth4rbRJU1fTNszZo4y0tlTK6NAeBdM/jd/ZUkBSNeppODec5leWD4hd+HJL1hWY4193 1j/DLJBjgP8qfWmcfoeQYKcAnZnLzsOqKBOBJKjcuwAx5sdScj40O9LsMmV9Pis7gsbb qWrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745614590; x=1746219390; 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=B3e4kHwzmveZeZCfH8hN+fGZaDmPTb1xtAaO9QsB3sw=; b=Al+Z86DWlznBQjDaPTcXiRN4oT11xlISMHyO7xLtYbRy/4GccunaTe7ig64QTtNLw5 z5rMginOkkl5Hkstmq/Yilq/0v7INpqEm8fr7+ukfu7CbxmjfXH24kMXKdkuwwXlUuzA 8jIz8J2j3hj02N2kv1Os1EY/YGVSlMAs47HHug2sCWhp7LV+5pKRRd2LTqQHG5bzIcCD 0zcIZaffXZVidlhi73kQOxwta39A1aJV5MbUSo8IwSDEqnYkKMMaYTiXUegrC2aW5/Bz yx4XL91iioOZTAOf7ZoFlgeTX0MnbLCE8/SZEZ6nzIGDpve9zQYmyg7F4Cwt1DxU1Qrz PTRw== X-Gm-Message-State: AOJu0YxUIs666mCLlVzOGrZc43sbvBQ8TRkcdSeaYKskdI+ymgy4Gioz F9rW7Cn0u2G9B9fJif5m3LN1I6Dnwx4ph8AwF4gBdY6jT16TYvJ+CgabdC0NIGORLJ0Y6e3675S o X-Gm-Gg: ASbGncttSaXQeiE6fP5ME2kMg7xrsTu0gp4PBfSOTWxPh+HSxHBNwPemkgDysumGcj8 V0KaTddzgnZFLZrIxBKB29pvGVwNWAiqXyi079EInCXr+62dYbYz0s69Vlpr0mGHffBvpM95eeD IcS9+hlSU5Winnt6x2K4WGZhI9yR4jUSyVllSV9eOc2ZyCc2tDk/wpy+nEO18kylFUU8WSk7wQt IscjDwsNkMFq6jOwelWRgZE2El3ghreF81iakHJ4TasHHVOZtVK6J3VYfxpje+I+Ek/nKcBwzOS 6UhbJtS6cXHZ/saxJ0RlSLG9F3cNaNZdiSsa0jdoOVHbZTGJ3ds+/w== X-Received: by 2002:a17:90b:4d04:b0:2ee:c2b5:97a0 with SMTP id 98e67ed59e1d1-309f7e60775mr5635077a91.25.1745614589969; Fri, 25 Apr 2025 13:56:29 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 13:56:29 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann Subject: [PATCH 5/8] math: Fix UB on cbrtf Date: Fri, 25 Apr 2025 17:54:26 -0300 Message-ID: <20250425205618.360232-6-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 'int64_t', use unsigned instead. It syncs with CORE-MATH commit f7c7408d1749ec2859ea249495af699359ae559b. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. --- sysdeps/ieee754/flt-32/s_cbrtf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sysdeps/ieee754/flt-32/s_cbrtf.c b/sysdeps/ieee754/flt-32/s_cbrtf.c index 5a7a9a952d..df9e888c1f 100644 --- a/sysdeps/ieee754/flt-32/s_cbrtf.c +++ b/sysdeps/ieee754/flt-32/s_cbrtf.c @@ -3,7 +3,7 @@ Copyright (c) 2023, 2024 Alexei Sibidanov. The original version of this file was copied from the CORE-MATH -project (file src/binary32/cbrt/cbrtf.c, revision bc385c2). +project (file src/binary32/cbrt/cbrtf.c, revision f7c7408d). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -61,8 +61,8 @@ __cbrtf (float x) e += 899; uint32_t et = e / 3, it = e % 3; uint64_t isc = escale[it].u; - isc += (int64_t) (et - 342) << 52; - isc |= (int64_t) sgn << 63; + isc += (uint64_t) (et - 342) << 52; + isc |= (uint64_t) sgn << 63; double cvt2 = asdouble (isc); static const double c[] = { From patchwork Fri Apr 25 20:54:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 884430 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4158345wrs; Fri, 25 Apr 2025 13:57:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjW2N9aNyOwfu3n+41+QJgmqLPN8ewNTCFGF4uQnjZU/cccgN62tVTxqdZNzgm2HIuPFVuyQ==@linaro.org X-Google-Smtp-Source: AGHT+IGrGtdQKqIJoAgCVhj3O3Bcd0kHQ7riy8E9u2ytMmp0+l49ApOXWTqDtHMgzVizlS0NRdxp X-Received: by 2002:a05:620a:2984:b0:7c7:b5e9:6428 with SMTP id af79cd13be357-7c96687115cmr147422885a.22.1745614670291; Fri, 25 Apr 2025 13:57:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1745614670; cv=pass; d=google.com; s=arc-20240605; b=NiBcxXv/b3gamWPxgkjTAR3yCDhPKb7Lt2YSnNaHwqq//1Vn28R4o5W+XUE2TUF2IE 09cafPnD66+e6WwlaBIiyYp79/yFW3hMflj5cVDSjLCRQv+XeuLLvle2DtSAm2wlhWzQ vkl3LEqEVfuw3ijRdPP01zxEmvjda5+f6agcgqQeLd/aaIom0Ajoumj40lw/pgKM7/r0 0mDC4qzPh09O4q57VLnz7nN2hNr6RgP8NiNvkUbLAC67fhTnYk5zrWEx6EfC/VliKVmV azkauZ66n33+vg7Tf8qbPWrqj37Z2zUxNel+weCxQrnxcuxcOrLesD5WCanI44RwnBtM Mv0g== 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=LNoqOXWaK/YGvBTeS9gxQQ3in7EFwcCryPT+dlptFkI=; fh=G1NI73xfDcVophzg1+e/pmkwSVc7WWCXN7V/bl5G28k=; b=aDOgF1JcvGOrw1gqxR8OOrj8Ib8YuYC8w5h0lqpHV6YvGX5r2/a6bHa6H5H8qi8yTx qv1I8dJnJSwDX0auHidmBjUvfaAamjd2JAkYjzxtq3z35J7xfvKFrtqL6e670KanPd+l TTUOsW6bDbzC/5x1hXiwT6YGjsTHlfx9qY0/10x0cdeppz44qf70evRMTFfKlmOPLEG3 YZVFK4t4u0JCFWDOFRmgRS1Jfw/8WeNJEEDzQiG4XYTLCAHDaCJCSGwvc94MGAwBboAQ SUhImWqYeSU/HmBwjqHmxJwEsKBRX2TceErYw/Xm3WXnLHiZU8GuXeTzT+j0zDnOpSbS huXg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QOCh2NYd; 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-7c958e9fdf0si431712685a.412.2025.04.25.13.57.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 13:57:50 -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=QOCh2NYd; 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 DD7C83858408 for ; Fri, 25 Apr 2025 20:57:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DD7C83858408 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=QOCh2NYd X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by sourceware.org (Postfix) with ESMTPS id E58833858031 for ; Fri, 25 Apr 2025 20:56:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E58833858031 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 E58833858031 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::534 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614593; cv=none; b=Yl5d5eeIpL+KzcvAOBLmLwG91W9uGU1A0uvxiSBQ0r4kxdu3BoyGyVFpXTgQqPxDd1F71tHJa9Rq2QbNXyvLnpfagmEcaPwgRwQt9ZxKF8A+6LvnawOwkXr7YTlPgmEJPx5Q7UED+5tJxCS3Pvua8vSEcKQCAqDrQoQcLQr32vI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614593; c=relaxed/simple; bh=85sgPp/DLHga5o7g4/LQV5cFfD7qqmDhE3pU4eJmz7Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rI5t9eE2nKZLxOxe9GKrsBxECfJmRUIKO1HQEzvVAUsEhG2U1X6OE0ahO6jD01g6T8BzZ4UnXNf5xTzyufFb+LfBTlpTgDIOVSoeJLc3+9qU8HRQRM4NrymdAibvE9wjiV6UcpNAJQ+9mX92CCeQe2OdxuSf7JQ7bBQDHdqW7+c= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E58833858031 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-7fd35b301bdso3415938a12.2 for ; Fri, 25 Apr 2025 13:56:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745614591; x=1746219391; 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=LNoqOXWaK/YGvBTeS9gxQQ3in7EFwcCryPT+dlptFkI=; b=QOCh2NYdFN4zJCjILTyefRE4BlAdqAXg6k8M6VlSjTMMkkR3LNrQAmgPcEUZCJ5Nv3 aCg5YfnoCzOc7N50IZdiEHYxMNsDe0HshOOT8OyXhltttmqMzWLZ3zaJM9ExVhv3kq2u EI24izKDjyYaSlnZuUCQeLRe7Ydn0mcJTg/9/SgjCsAYViJn83VIjgcZ7KrJcUUPrKbM oTeqUh5y0gOkFrEC26itJ2s5C80UweBHRMVOoOa043Tv/kBEaqbt61tE6uVVU5/iJ6il Aw46prX6SwObES5hpFBNZ2rlYa7FfSgDqqw0+zLZpEVegRsG5hAOSF4b+/YMyZLTs248 SZcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745614591; x=1746219391; 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=LNoqOXWaK/YGvBTeS9gxQQ3in7EFwcCryPT+dlptFkI=; b=bttEtWPtIxC6Bud/x+FeGnDFFXQvrs9mmaFB7QjPitCMYwcP36u90tHP54Z6kdsbXQ +8lBfKKBMq4FdURtGCRBt+F9uXsUCYdKSEnpppCYZmFohKGEjHnmNojr9QZnfHZKbPgO gijUrXiq6to98tXsZQIoPc489frnmABAOQu1cmZ/0wj4I7c0QgIh6PiIO5xTKg1XlDHW 559tVPnanJ5PhIAXjAX+q/QNP0vtq3DNWnh5KrhcZIABpnwI+FPy9bC53l23OqWZfGX/ YnQSUsx7xc08uUgOkQU9gpaSYUqba7OMJ2HG8sjUv3cpJoXQeLgjZu8U9z6FT6fWHFl0 JKeA== X-Gm-Message-State: AOJu0Yx7y7dfR9jfe5Gu9XtOj48MUAb7yT4Jivt0SBKTwSZSynCbrNg8 Y6VbnThFc2mHmI0844/oWcZwM2VjBebnWbe8eOROjtgF62KFerjgOG4ZBARenu4OuBlLZWURQtx T X-Gm-Gg: ASbGnctlhesKUEvw9+Ee3OH03ryBtQZA1kA2PRMV/AV49HV7HKO7AAkzZYxrEG1fRWR /xCCltBpD8KdwgVInr2sO/MIAMmMiPiJSdeV5UQmNQLVY+V2YDOaPQDDRzHUkHEW5d+1KkIA8CH uipL5j5/X2wAJ+VLalrLUhFCVHVkjEkeBLwSWek2GijvHftGcTlOcN7MD7LYBQwTE2wSGf4BuiA RMJBcLCgtcxPNsA2iQlPwoL3uK9BOT/2ldE9376+N/yp+HHUnvIJLvYIt6JSwLHvBYNxk999s7p GV/z7vhH7OgzGGHb5BIjCTSMBrMzJJePAINkYVxb1O2Ph4bwX+qewQ== X-Received: by 2002:a17:90b:2e03:b0:2ee:db1a:2e3c with SMTP id 98e67ed59e1d1-30a012ffafdmr1390963a91.1.1745614591421; Fri, 25 Apr 2025 13:56:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 13:56:31 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann Subject: [PATCH 6/8] math: Fix UB on cospif Date: Fri, 25 Apr 2025 17:54:27 -0300 Message-ID: <20250425205618.360232-7-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 uint32_t instead. It syncs with CORE-MATH commit bbfabd993a71b049c210b0febfd06d18369fadc1. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. --- sysdeps/ieee754/flt-32/s_cospif.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sysdeps/ieee754/flt-32/s_cospif.c b/sysdeps/ieee754/flt-32/s_cospif.c index 1e838037e1..eb4a10f57f 100644 --- a/sysdeps/ieee754/flt-32/s_cospif.c +++ b/sysdeps/ieee754/flt-32/s_cospif.c @@ -3,7 +3,7 @@ Copyright (c) 2022-2025 Alexei Sibidanov. The original version of this file was copied from the CORE-MATH -project (src/binary32/cospi/cospif.c, revision f786e13). +project (src/binary32/cospi/cospif.c, revision bbfabd99). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -58,10 +58,10 @@ __cospif (float x) { if (__glibc_unlikely (p > 63)) return 1.0f; - int32_t iq = m << (p - 32); + int32_t iq = (uint32_t)m << (p - 32); return S[(iq + 32) & 127]; } - int32_t k = m << p; + int32_t k = (uint32_t)m << p; if (__glibc_unlikely (k == 0)) { int32_t iq = m >> (32 - p); From patchwork Fri Apr 25 20:54:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 884434 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4160734wrs; Fri, 25 Apr 2025 14:03:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbIJ1VpotBE0H8lZF3R523aj25BRWEIJvfMpz7npe55PcYFtNIIeBwq9WnFCYCWZ3xbAvqLg==@linaro.org X-Google-Smtp-Source: AGHT+IFP6Eksz5a7PTVm/WFhkohWCjyEa0NC1usE7p3ypDr1IxMlEh9Mo8g6+2DggiK0zojsXlXm X-Received: by 2002:a05:6102:4688:b0:4c6:d008:7349 with SMTP id ada2fe7eead31-4d54574b608mr2221830137.21.1745614995408; Fri, 25 Apr 2025 14:03:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1745614995; cv=pass; d=google.com; s=arc-20240605; b=HZruMy49VFXhlqpuRigICZ6gUCIHn1eFuQ98O+1nN5zcHPgxmmfGogbUuW6DfmLcaB vfZ9FlsNtNrtYT6Pt3KB845P2O0DbqgcoupN8K66v4UHTkexjy2OKJYeXboImHGUkGtf Lrrrkxe+rWjXekZyyge7rBag7peV13yg2IrySZnRvJ28rcHL7Ep7oIZnBtyCiMAh4KNM hM52OjlrZbLrizxIlagmgn0eW1uiDssCwge8H5rH2g3O8yU6bFxuucfwzgrzBAdpeOyp P0znY1NYkhDrGV1qS9m12BGEVkhTCNKpU5QNwvdrHShoksXUDUnOOI7atsQUFWleLfUZ jNFQ== 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=V4X/2MZXYepUZZVl2pwqDwjUR+DvpncOQqNLloXzDDo=; fh=G1NI73xfDcVophzg1+e/pmkwSVc7WWCXN7V/bl5G28k=; b=acDjrfBXTCRLpTCMyCuKHTQ9nKS7VrHz46aIu1U/WVMnfVSAVx1eEYmJXEbAjos+jv w2vuL8iBAS9Qb6eaVv7mVplR1emSJYrw3FvgsCTRBrPFZJM3xZf0ht3gjjumG1div0ov Sl4+CpNsylXfUJbusPeMi9vTauHTl3oFYsmvrXDD1PdOMslpFf0H2oYWdcKQSRS5So++ GiwjroH5/masOF9S0ddOpm8hTCMej0UxL4wc/Ufrh6WuHrpIvmlwebM0mBz4eznwxv0h zhmr6QAhT2U5zyvsHsgtWwoaN1yhKCFLfFa0Ha0fguo3WyaOWrtCtlJpB8FfXghxeN02 Va0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u5cRl6Xa; 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 ada2fe7eead31-4d3d79b1151si1494988137.611.2025.04.25.14.03.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 14:03:15 -0700 (PDT) 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=u5cRl6Xa; 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 DFBEC3858408 for ; Fri, 25 Apr 2025 21:03:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFBEC3858408 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=u5cRl6Xa X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by sourceware.org (Postfix) with ESMTPS id 3A8923858408 for ; Fri, 25 Apr 2025 20:56:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A8923858408 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 3A8923858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::536 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614594; cv=none; b=wCCu25RrLzVPBZgHGViucjktPJKzuF2gb0LjPp0dOlu18S7bjNGym0CsMjUt+WPslwACN3e9NAO7L+sZKEjobU7GXyzG4/icnLgu8ZqJjZfN+Q2J1qxBpE+TQRR4i01GgJ6vceMXtwHZum708IjT20eHpLx8T+/RMmM7Gssi5H4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614594; c=relaxed/simple; bh=ZiMQp2KWgUokv2Z0JAzDy0JoHYxJ6dhKRhEk/6npGZ8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=euGo/SLC9zcVbKvhouq7YrcNVMEv/fD0vLLzBNYfpBGSVt2msUvS5NBr3hBcvU51EBh7DtJkqVDZMXvF+akhr9USEtRlMsqIcERNCAzK6iCYmTjqGvcxPrlSX6zHTBGmSufsm2H3YzHEvfTunuHOMQ5op+Kcm6ogI4mybp9Ab3Q= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A8923858408 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-b0b2d1f2845so2002589a12.3 for ; Fri, 25 Apr 2025 13:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745614593; x=1746219393; 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=V4X/2MZXYepUZZVl2pwqDwjUR+DvpncOQqNLloXzDDo=; b=u5cRl6Xaz1n5EBJatTgmRAIQ2wv7I7tfPJI1jVISHZXt693BmDUuPg5PxiFMhXn0yF +oZoZy7i4X4F5nCXSocMobBKG+GM5n8FI61kFVVDwovm/t/FvXXw4f64Q8pqd3bTYsu0 rwQzCwxfOvENIKvlzuBJUqYNMrOT9/F8e4NaZUkdcZDdlMa1Jliopi7njXR6/y09CwYW 6evcxLoKlcLhmU5n2xTTGHphGVQaO5Zucj8dvl2JlduJHpG2/J6w3Smgq+I2FE1AR8Fm NMywDAbOFj6Slu5wkTfs2R9QtZawHl2lAtd6OeTFAXRsAnXejYXtFwT1onrzPTB58Y3K sC5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745614593; x=1746219393; 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=V4X/2MZXYepUZZVl2pwqDwjUR+DvpncOQqNLloXzDDo=; b=uohzgTV9DDLijqB3PapnTLOvxrXRJ/yyzwOE8urvdWcztIumMucBSXu565PQUHg10e QEXh0IO9TZ9CGWy2W59GrtiW4aX8iVH23qHIm/MXxW+VfhFBt5ky+Ne480oYR3jBXC4Z neIGv7fyFh8BoJgVWwP0B3jTWj8vSqQHM4g5pqX1l1yG5o9SjvZgn3+LVbeEG21WnRlq BhLkrjcRKTK1RkqM6cc4WIZnLB3UBYqzW1DChU5RqEXI6yGGnnY23ZdbvAqWsZJUSWuS 1dWCPCo7OYLseZ4PzVzOllQgQHe7t4vyhUYtziQ3C0uz8XTHkgkXy55hYLWPTbhsSzgj SyjQ== X-Gm-Message-State: AOJu0Yzqy6+AjkyhRX3gal9qR7atZKEdwL7A8arMdjX+1RFa+D2TkVfu I3+U90FOoeaGY5Gx1Gwqfow4hz5jGmNuQRMhoFe6BPB2Nz5PI/Ow1Yo9eWSGE0vUzk0u2I4Qn1X 7 X-Gm-Gg: ASbGnctI7Z1fZpezn58/Rupzhz3TdZCzpOInvtp9fpM6MsNFK+BiHHoxNJD+NPjkTYY xNnU2w0EVJgqKdB8P8k24yG0eQBTmWZ5hnuNaItKKeDCX3U6iqxpS2DbtiKLHPjG/bidA44ZJDL urF1cvB3fkSd1wBL+O7VbmXK+PUW8c8jkHv8r22YY4BLMmTDFn47gvcmcH4SqKLAZzj+ZcYqtl/ 9jMXfTaHpFEZujTzyG+oHmKGt3uNOj4Jt6wnU42EOmrX9aPOaeooZb9MuBORNeHvhp9ro882R2A QUPZZr5d77yePVnUAMN2/MbAKVeLOtLHUCbg6KQmZrvcXeX7XP8WWw== X-Received: by 2002:a17:90b:4ecf:b0:301:9f62:a944 with SMTP id 98e67ed59e1d1-309f8e0fad5mr5563805a91.33.1745614592886; Fri, 25 Apr 2025 13:56:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 13:56:32 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann Subject: [PATCH 7/8] math: Fix UB on erfcf Date: Fri, 25 Apr 2025 17:54:28 -0300 Message-ID: <20250425205618.360232-8-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 d0a2be200cbc1344d800d9ef0ebee9ad67dd3ad8. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. --- sysdeps/ieee754/flt-32/s_erfcf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdeps/ieee754/flt-32/s_erfcf.c b/sysdeps/ieee754/flt-32/s_erfcf.c index 3dae2a0b0e..955f129148 100644 --- a/sysdeps/ieee754/flt-32/s_erfcf.c +++ b/sysdeps/ieee754/flt-32/s_erfcf.c @@ -3,7 +3,7 @@ Copyright (c) 2023, 2024 Alexei Sibidanov. This file is part of the CORE-MATH project -project (file src/binary32/erfc/erfcf.c revision bc385c2). +project (file src/binary32/erfc/erfcf.c revision d0a2be20). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -142,7 +142,7 @@ __erfcf (float xf) const double ln2l = 0x1.cf79abd6f5dc8p-47; uint64_t jt = asuint64 (fma (x2, iln2, -(1024 + 0x1p-8))); int64_t j = (int64_t) (jt << 12) >> 48; - double S = asdouble (((j >> 7) + (0x3ff | sgn << 11)) << 52); + double S = asdouble ((uint64_t)((j >> 7) + (0x3ff | sgn << 11)) << 52); static const double ch[] = { -0x1.ffffffffff333p-2, 0x1.5555555556a14p-3, -0x1.55556666659b4p-5, From patchwork Fri Apr 25 20:54:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 884437 Delivered-To: patch@linaro.org Received: by 2002:a5d:474d:0:b0:38f:210b:807b with SMTP id o13csp4162785wrs; Fri, 25 Apr 2025 14:07:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWC4zs+5nWWxzqosE/Y17SGvJNVpdO3VM6MysK+X11DyL9IzjDHURVESngGp4XcyMxugOc17w==@linaro.org X-Google-Smtp-Source: AGHT+IFARPhr4S+lPwA3rYytKEm3wESQO67rREJXS+zmJMnQGdLY7VvLNAhnFu9BiZ451SOxxtPh X-Received: by 2002:a05:620a:1901:b0:7c0:a264:4de1 with SMTP id af79cd13be357-7c958659f5emr1304688285a.24.1745615258882; Fri, 25 Apr 2025 14:07:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1745615258; cv=pass; d=google.com; s=arc-20240605; b=QdLtUM9jPjEy0GqRNgK4e4LhyzOacYwXZT8ONZfxVdhV9ZcgetUzHYEMsJ84cAr6+l 9ffSJsfVP/RJdAM3a3BHPvke3i3gJimvbS3ryiHZUVxF81uYLQwTXRH3pz1FL8S3IvdN DHwk1n51zWO92M8WkummgNiGgt6kLy2eLwqDZqq0UvBd93SMWPYSgzboZK7Ge3oO94e7 QrwQHGJchBLBwDPGMgbrA0aEJgC7dijEPe8bb/crQtGqvPYfD+N/7lysCsqmGJeTeWGy toByvVyYvsba4o5/5FsccwKqN1SslP75qXlyITr4iu+3WsuL1dA+QcT9aR25rzwK9yjN lWhA== 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=ubuUsMj7bmKcyFiTkMozmyTf7Wr2IDa7nHThg/B7e1M=; fh=G1NI73xfDcVophzg1+e/pmkwSVc7WWCXN7V/bl5G28k=; b=VHDDGEizm6lz+xhn1H859AtMdJKxhmszGMk0eKV5Is+rI3K1Y79Bs9wHLtQ0R1rSz1 4ZHHZANCm4ikFppV2lSiADOgwwyFGwo/rY1WZLItnQ4KH5tI9xJHgg10+18WxwrmGmzT 2pheL7KBLu49KfgsXXD0/LVOTe8B9+cEZlKOy3CYaafr3ZK8IrHTtypcqA7T6oLVWZrP km/ofxvr/eTd4cCx8EJr8GICIOj0DnChiqpCAh7AkyKlhkWXeuxYOUpZs2w3GTIuhyjp I1s+iTXEznrD/FpGn3BCzdwaTyDM2lBhrG/6rwlHGyVZbadcSw4UMYyRm7f9VcSMjN2o AISA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d1ErA1oH; 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-7c958ea362fsi428711185a.421.2025.04.25.14.07.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 14:07:38 -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=d1ErA1oH; 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 76ECD385843B for ; Fri, 25 Apr 2025 21:07:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76ECD385843B 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=d1ErA1oH X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by sourceware.org (Postfix) with ESMTPS id 9C78F3858D20 for ; Fri, 25 Apr 2025 20:56:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C78F3858D20 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 9C78F3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614595; cv=none; b=DiX08nVKHr/ATZcFSudXlHm7x/kSkNMKPEOLQ2L8zYG8iKt21KY+vmiLZ4MryNvmnYBoFAUU+OomL0mnYyj3kHAFbiiZJyTRwAo/3I6cyIvn35/ITQKRHNVfyXNMPBJ1xelqK1FeDM/BGbEwSBi1R84qIzc0qTVuimGx//j3Ct8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745614595; c=relaxed/simple; bh=jKgcMM/BhciH08GuxwcC035chb2TmAHPm1Mpp+VKBj8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kAFydi251y6QzDPSMUSyGJAhuvLk4SerIkfOYcNBcdLYKWf/bsO382RRwaOsUipcvOl5NsKxVqVQkuqMaUUc3zcvX5MarWGqchvD2o+7du3nEYXowCkslHbwrNmwccKbQc8ubUCr1D4LzHeMadqHeSg8L542FBbv+q5lXYlfVj8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C78F3858D20 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-30863b48553so3623390a91.0 for ; Fri, 25 Apr 2025 13:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1745614594; x=1746219394; 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=ubuUsMj7bmKcyFiTkMozmyTf7Wr2IDa7nHThg/B7e1M=; b=d1ErA1oHwbdtrAhUMAAIBZaP5oJ1/ox44Pxo2WDmItEq9YQajuFB2HrsT4w5lgukS0 Vn42jXymirNmN1p2k5l0qs43wBWctsthkBC/ftMp9xSKW2RLp0csDayWrwj96Cp/vBD5 EVpl4GlZRrn0KSNGjcVbgA7m2mGUGzAImjPTOfaoyWgM0AlPTQBRWGxOlGJM0dbhk1XT PP7FTThGVXHdbcJ8XiElmLx+CryX+te0plS80XUZ1IJJ8ftVlQACAleKvfL7nbElzyJU CLioPlslV2DA5uTzAjhXX8fCuKlWFuuXaC56ZqQGm3X1LcIr7PyKHFmBRDTrG7q95nWB n4rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745614594; x=1746219394; 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=ubuUsMj7bmKcyFiTkMozmyTf7Wr2IDa7nHThg/B7e1M=; b=mQwMEX5qZ6XDlOvKwS0aYckR587uPENeYhyqnjaEIBvRzWH80Po9QXRue+nx78Kwu+ AxIhch+IHLgr//xjNeslAI1yY8HTJjMTrbTOkPX4Aw4owVCvXMsTc4WvD6rYU1XwQA1c L8PYHoa+OHkyRdLIJGivfkl6zNA5NmWYDkXBBLNh4fe7RZ7QAxgSn2dejV/ZqaeY8sQa 0X7c6OpIPuxyMY9i4jrR/4G9VGDDELptvCt3MmN9szwOFUR65hlap+dFj3AI1Tu71B7p GHo29dC4lGIAZQ2J/j4vCCJqJBydA5bZZo0gh4KPtO2lQOWwQmmM4yesscie23ltZtN9 iIwA== X-Gm-Message-State: AOJu0Ywd4lNlp4w0f0c7nbq7a9kKdu7QyJQtAbZoru+jXBZFWTOQ3CgX 8gqfL2p/l20JER9VWkEfXTiR81QhgzfbLhfO4hJasH4rmse9h8wYjk8sT+F61K02jwWjh6Punst 1 X-Gm-Gg: ASbGncugKXY2e4YYH2StV8HOm6zt5FFHdu2P8Mbxay2olhCxxdCDwJ2+XPNRN7cGAWv n5peBqBFSL/Gf5sHnvjD2wKBIngWm8NgM7o57G+MmN9QJCphF3e+fRLy6xbgx8nbwytSdyWy/lQ JLbzj4NxneqieP+a5Fd9jow2OA0fUJ+F2jYXUBgkvaYLHH5QDPLBHYAEtHZWifMZYlhywu3E5p4 0JGV9DZhFwl72sHp/V2jGqrSpeOBq1BA/DSDFuSuQlkC1NXXlXMLHSq3b467KiR3TAGwhV6bf8T 14iE2SxSKAZN/I2GZoO1eqT0YvmUOxOEVlomBcH78Ij4rOUIBiQ7yg== X-Received: by 2002:a17:90b:2f45:b0:2fa:3174:e344 with SMTP id 98e67ed59e1d1-309ee3f9db1mr11359035a91.14.1745614594369; Fri, 25 Apr 2025 13:56:34 -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.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Apr 2025 13:56:34 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann Subject: [PATCH 8/8] math: Fix UB on sinpif Date: Fri, 25 Apr 2025 17:54:29 -0300 Message-ID: <20250425205618.360232-9-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 uint32_t instead. It syncs with CORE-MATH commit bbfabd99. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. --- sysdeps/ieee754/flt-32/s_sinpif.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sysdeps/ieee754/flt-32/s_sinpif.c b/sysdeps/ieee754/flt-32/s_sinpif.c index 99a8bbbcf3..c0d15e777b 100644 --- a/sysdeps/ieee754/flt-32/s_sinpif.c +++ b/sysdeps/ieee754/flt-32/s_sinpif.c @@ -3,7 +3,7 @@ Copyright (c) 2022-2025 Alexei Sibidanov. The original version of this file was copied from the CORE-MATH -project (src/binary32/sinpi/sinpif.c, revision f786e13). +project (src/binary32/sinpi/sinpif.c, revision bbfabd99. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -51,7 +51,7 @@ __sinpif (float x) { if (__glibc_unlikely (s < -6)) return copysignf (0.0f, x); - int32_t iq = m << (-s - 1); + int32_t iq = (uint32_t)m << (-s - 1); iq &= 127; if (iq == 0 || iq == 64) return copysignf (0.0f, x); @@ -63,10 +63,10 @@ __sinpif (float x) return z * (0x1.921fb54442d18p+1 + z2 * (-0x1.4abbce625be53p+2)); } int32_t si = 25 - s; - if (__glibc_unlikely (si >= 0 && (m << si) == 0)) + if (__glibc_unlikely (si >= 0 && ((uint32_t)m << si) == 0)) return copysignf (0.0f, x); - int32_t k = m << (31 - s); + int32_t k = (uint32_t)m << (31 - s); double z = k, z2 = z * z; double fs = SN[0] + z2 * (SN[1] + z2 * SN[2]); double fc = CN[0] + z2 * (CN[1] + z2 * CN[2]);