Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp384114rdh; Wed, 7 Feb 2024 07:32:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFWeYwjLE8SP6RSRwRAvMDETvfZ/nkCHCU7ev6hHHWIh01VvZopgHEEFd3x1LUhjYQIwEf9 X-Received: by 2002:a05:6122:3a0b:b0:4bf:fe7f:1c56 with SMTP id fp11-20020a0561223a0b00b004bffe7f1c56mr2971580vkb.7.1707319962517; Wed, 07 Feb 2024 07:32:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707319962; cv=pass; d=google.com; s=arc-20160816; b=dJFwZeGgVbzVQhwP6ds0rRhm4SI6cVTXaSUxllSvjUUzneDe1iRqcoHjdST5+/jRVM jj4aFU2n7Mt2eukw4SHB144zv96KsqADWKozWBH+7DNm7TxuNFFR7//HXbGH/mujdq2S BJJ+bSniGcBZAWAajVmB2pFRPeAC84PtBf3y8lfpwqwY5Noz8MklhCFhEvPTNRz6afAF 0743xpndl153SRrROLIUweioK4xRcGhQLAs5KEfdWaTewJwkSdCg8c41mQMHYYrBA7ib e/U5BU8wHXD0UzkqaNx2sv44/xRXoogM1XEGVBaET+qkn2u0UXdIT91R1xZd9lVlIGOM Ka+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=/ApcE6XEwaWfmGJrrnfNX8OxegVZFovON3wNgR1SCis=; fh=ExLZQynnfmCHVYGEjtCcONjF0W5AybwTceaaELlDCEE=; b=R7kAObNOrEi/2mDZ8msVyD4uq2kRZVvpvlYuEzh+UbsUuFGpJVFNQmM/jGqWplTq+K VrbFGskZIXgb5sQhHohs+1jUMBAr6dLZeK0m7P7fJrvmAbPniyG1l4WfykVb7B1Ij3lW mCE6CDfxFUjKpDiOprcYmcNvjgdU7gjN1fn8SrBc19ZPELGRQvg/XNGKHX6vtj5npwo3 o6k2JDuziImtB+ijID4WmGp/2sRn25Z14vKTr6RR3eYOri3yPd5vmGGEZK7bBl8kOR8t /brJyofC/Qt+2je0YSR6loc7cClT360kB2+a0XljDAqq1tzJVzeVxO7wD05SUkS+LTPF xuTg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=g77QhICE; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-56724-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56724-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=2; AJvYcCXnZx5xIckyhLK2j4iJ8kkbb95JLIN3nYnxhS5oOyaloHJ+LFLl2GV7H7jiyg0YinaXaFl0TbFNy7uAJyH1DmcQqvJXWeTuX+KlwIA4tA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id r13-20020a05612206ad00b004b7179785a1si221039vkq.25.2024.02.07.07.32.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 07:32:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56724-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=g77QhICE; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-56724-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56724-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4038A1C21D0A for ; Wed, 7 Feb 2024 15:32:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DA857FBBE; Wed, 7 Feb 2024 15:32:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g77QhICE" Received: from mail-ed1-f46.google.com (mail-ed1-f46.google.com [209.85.208.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E36B97F7D9; Wed, 7 Feb 2024 15:32:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707319954; cv=none; b=azQPo9pT2yDemMN+OYUgr/eW9TMR8PQNU/PHUyHHH9GQc9eICO4pUkns2YawJL+nN2OCw+FKEWY4SUgN/hORlkC6jhgsYz+K8uBXMRdrk0YQHAjyqDQiBVGBQHqkS2kGrKoD8vzLCPcdru3gboiefqddRo7EylWdaMwPXP/+vJ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707319954; c=relaxed/simple; bh=/ApcE6XEwaWfmGJrrnfNX8OxegVZFovON3wNgR1SCis=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Jin71yFCg/s5KpvnStI9nSJWoDpdCAaToA/TTB9v5fpquQJn/Gep5ybKrjCWBZhJRN5uUinnZiqKmuDCHY2NYbLM628p2iBwvFZVCv+cIJvGkA9pCYcAHDz9+DaBRuTG+YUmYy1Btu9JqPOe4eGofJdL8kLz+fXlZtLofGHNZL0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=g77QhICE; arc=none smtp.client-ip=209.85.208.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ed1-f46.google.com with SMTP id 4fb4d7f45d1cf-5600c43caddso819826a12.2; Wed, 07 Feb 2024 07:32:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707319951; x=1707924751; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/ApcE6XEwaWfmGJrrnfNX8OxegVZFovON3wNgR1SCis=; b=g77QhICE1Tf5OUcCaJtNG0zVScu+uWvW6Z4UbWADcmd6RoV6ZPaFgHV2BjqqtkI99U zG3l2nqrwZSk3pv2vqTeVsAa3Lk/r4bjTBjAy9yjNg1CuXvjWu7/HJw5Jt5BzAyBnA0r usA8a1Dd9H9PyvbYjYO7XjSyZdcWWh198UUnlC8FhgRNtlX9Ou0VdAlNrP8jPw+pYUwV 9RlcTo/JNyCU6KyTjcPBtfRH4C0yVVhbujQQoYcLTibOIlhjyy1Ldq8cpxsVlGn2Hqe9 VvG+CRt1DgQmbSVaYnoNkSvrlIpw4jp+qVZpE8pRnyDwlMfI4XAHpOEMs83GkRATpFkb fRIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707319951; x=1707924751; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/ApcE6XEwaWfmGJrrnfNX8OxegVZFovON3wNgR1SCis=; b=HsVsd+5JFJ3yTItdJjQQScbVKE686Og59/6cS6NgtbeNz5bMnj8nLrzEZlooPG/hOH 5n88ThJIJWjNT825HHeCJzRkYkFCfEJ4Or6bg8oNsngoYPPQcbnAXpFefWKcUd7Nz5Y/ qhBJPfV2tuT8Xywyvyb7ah7GtwCGtVBvRE+ukhEVYNN1AhwG69VDwl4vQ+rWFTxb+WYm DOLw2VHhaAHHYVfmeXuCS94KYQDKyreLJs/XSuPZdlkFbAM1AMvleeGDUUfoicX5uXDX gW3x6b+qPWYdGfmaK8V2d5Pdkxq8ywZ9MM2RggKLnN5g6yZW79YLwKRLkUnRy0g5BGja 0qjQ== X-Gm-Message-State: AOJu0YxkLgMomLUc2vkSV2WNek1uajiE5AZrWAHsIEMf7rrNEybyN5vN mgmHmQWR2iiqcgtLdZRkZ4XWb2kZi/OJbrtvb/DRUMtJ5RHoQsbrMDQ78fC3J7hFpuUuBAo9nPT NZkM40qhFljm1vIBDhftjq6Q6U/8= X-Received: by 2002:a17:906:f192:b0:a38:41ab:651c with SMTP id gs18-20020a170906f19200b00a3841ab651cmr3228401ejb.17.1707319950996; Wed, 07 Feb 2024 07:32:30 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240207152317.do.560-kees@kernel.org> <20240207152422.3855315-3-keescook@chromium.org> In-Reply-To: <20240207152422.3855315-3-keescook@chromium.org> From: Andy Shevchenko Date: Wed, 7 Feb 2024 17:31:54 +0200 Message-ID: Subject: Re: [PATCH v5 3/3] overflow: Introduce wrapping_inc() and wrapping_dec() To: Kees Cook Cc: Andy Shevchenko , Rasmus Villemoes , Marco Elver , Eric Biggers , Mark Rutland , "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org, Andrew Morton , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 7, 2024 at 5:24=E2=80=AFPM Kees Cook wr= ote: > > This allows replacements of the idioms "var +=3D offset" and "var -=3D of= fset" > with the wrapping_inc() and wrapping_dec() helpers respectively. They > will avoid wrap-around sanitizer instrumentation. > > Add to the selftests to validate behavior and lack of side-effects. I would expect inc/dec to add/subtract 1. So, to me the terminology is confusing. The list of the C/C++ operators on Wikipedia describes above as +=3D Assignment by sum -=3D Assignment by difference Hence the proposal is to have wrapping_sum() wrapping_diff() --=20 With Best Regards, Andy Shevchenko