From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by sourceware.org (Postfix) with ESMTPS id 6CBF33858CDB for ; Sun, 24 Sep 2023 04:00:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6CBF33858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-41808baf6abso14211571cf.3 for ; Sat, 23 Sep 2023 21:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695528017; x=1696132817; darn=gcc.gnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=WgOInjWAL8+M3Syxm1H+qWV8xAQ0bHK39cr4eJuXufc=; b=mAGVnE6qHutcz8FcuPLI3g78NaIBOMOvaxpWrBJttkBv+KiWoe6/WQNEsuyRfbdksJ hMOiM2TycV9dcE9UpjVbeOupalttOFRnXoCjx3ob6pwSoIVyWFOiwnXqlQt6qgpNt2bI p6E6goIATte9w3ngFKtgA3KcQb7ISJ8IXnoLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695528017; x=1696132817; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WgOInjWAL8+M3Syxm1H+qWV8xAQ0bHK39cr4eJuXufc=; b=AVlTxQ/K93R8mAGSafrNgPFwl46fopSAr5qKOJ1KzbnO4PZQrCCaDrs41r97wdAREP m5tKC7jSHOhf/aZSM4FfZ5p3OMg3Q8IqKraodpW/GoTCwWs6nX3s3Y8S0Upb0UCTrJpt H0SrQcYZT/sWARVNHphaG0aa8cA81uE/dQZXC0mElh54184/hmlwPKfbK48KE7ZWd02W zuz+5FPIX7m7DUlmVILe2aYVo1w+8EaIFzjcXOLc7khU4gpWW8u0Or99+GFZq9olt0Ii +NFVVtiDqYoMMO0wc1+y1rQ55SggFESXm5tlJKMSLM5v8f9AnWbaTuaLzYGphrTD7O5D YD2A== X-Gm-Message-State: AOJu0YzJRsflG9GQwgfJf4lgqeRedaqKtiVQ0SG2p6h+uWEtNlzBk9kY /NwCaD3Sense5v7FKQEmSupSSfh/op8XZ6xgD7Y= X-Google-Smtp-Source: AGHT+IHsope3nAgX6UqE/fztcRAdJTMDg5mVQEOea/hPM/jNQXrkdM40tjVA0vNKTtYvWjMoL/HTwg== X-Received: by 2002:a05:620a:2955:b0:76e:f3a3:4ae1 with SMTP id n21-20020a05620a295500b0076ef3a34ae1mr4071861qkp.52.1695528017382; Sat, 23 Sep 2023 21:00:17 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id c14-20020aa7880e000000b0069100e70943sm5618694pfo.24.2023.09.23.21.00.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 21:00:16 -0700 (PDT) Date: Sat, 23 Sep 2023 21:00:16 -0700 From: Kees Cook To: Martin Uecker Cc: gcc@gcc.gnu.org Subject: Re: Question on -fwrapv and -fwrapv-pointer Message-ID: <202309232056.3235206E@keescook> References: <202309151107.C2F7D9A01@keescook> <228be10b14dabe4e8216f9f93da99f629328b3e0.camel@gmail.com> <202309201328.5732A76E@keescook> <902dc33093f80f0ad6200a3aa2c69982cfb880a8.camel@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <902dc33093f80f0ad6200a3aa2c69982cfb880a8.camel@gmail.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Sep 20, 2023 at 11:16:21PM +0200, Martin Uecker wrote: > I meant something else: Why wasn't an unsigned type > used in the first place? If all "counter" variables were > signed and all "modulo" variables unsigned, one could already  > diagnose overflow reliably. > > I was trying to understand if there are generally > valid reasons for using unsigned integers for "counters". > or whether this is just a historical mistake in the > kernel. There isn't a common guideline in the kernel coding style for this, so it's mostly arbitrary. :( > (and thank you for your explanations) Sure thing! Thanks for your (and everyone's) help clarifying this whole area. :) -Kees -- Kees Cook