Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2705422rdb; Mon, 5 Feb 2024 15:22:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBszGhy3Ea7jSM3mJ8nEXqH1PXuMQewL5in6UwnWoX3RDrqyxfK3Sjj2u2VND1lkthge/w X-Received: by 2002:a17:906:882:b0:a37:1dee:a16f with SMTP id n2-20020a170906088200b00a371deea16fmr613683eje.71.1707175323686; Mon, 05 Feb 2024 15:22:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707175323; cv=pass; d=google.com; s=arc-20160816; b=jbrz7ckVdNCC7M+4bMUe6K8olUOI8zYL0OFTrkcVPAYuZPqx8417jGFf21IoCoemqH ZsKQizwbMBBVIA3LTLBb85UAm0aDG/DgUfOG9OCfnjQkvytTxRF4SMX/2XKxUtvEFaAR PPNFn3KvRRUtkRNB4peG9jEI0uGosX6qm9gcOR+re47YZ/v8AN+QnapxlgdU/38Cg3DF cZhTIOE0PFZDO08zKmBBxjsq20sSzYDanpS26IS6m6FQY/8avKuGMa6JD5qKerI+X5c0 fV2gj/ViA9kJgaCwbgyCUeXyfQDTR1e5I0/SWX6hrP1c7cXb/Prt+loENa0ePtEFLWjJ Otbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:references:in-reply-to :user-agent:subject:cc:to:from:date:dkim-signature; bh=tMfpYiB1v+fBCvXlEbNxp6+vJQztcxvgtWmfGNrEzH8=; fh=AmXBa1AnJitBH6woaAcyzx6L8SGDbKq3Y6EhVyLwNms=; b=KMJEu+BIMah+eTVYXfkndU3Wi9sVQYa0XK65MQJeIV5Jqh6UhSbdE13Pd4VZSKlrA4 SQ4/RyfFMc4gYSi0a2D3SOIAlp1i9vJr5d9AyCVP+oqNFBLf3cXlKmXl2I8raFPcCVVN CcYYxqmjeaCx8fNETZ6jqxBgxbY1GjASG2QjmaXJGuC91wmpDC29D9xcut8UWhhvEb/K g0iD4++3TJK3h9wXCU2lhOeL/3y4z8W0T6GajrXYloCRiW4cT/AuaLV+HQafk311aVDA hoTq4gxq1/V75/3Wkpa+08BpI9skxUOD7qp832FtYY8YjkFTy2HJKFUn/UuBlZwudOZb B5Lg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="BSqSdG/+"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-54079-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54079-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWUMNUZLy5j2Tk1AeEHtoYI+U8CmYSJ+j2gQTygc87nhHiwwnd/u2zXNDztq7fI4Lx17engygtbIMaonVq0fbSVjQYBPSsEeYwQeG9BSA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gx11-20020a170906f1cb00b00a317c932971si356078ejb.233.2024.02.05.15.22.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 15:22:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-54079-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="BSqSdG/+"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-54079-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-54079-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 522861F25963 for ; Mon, 5 Feb 2024 23:21:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7823548799; Mon, 5 Feb 2024 23:21:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="BSqSdG/+" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 908914CB46; Mon, 5 Feb 2024 23:21:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707175302; cv=none; b=UA7sov1aJtXRMdgP/I4M9JTepK621mB1JQXbE9GThqJh3h2Xy29reQF4kAtZqASb/i4QIUIouc22y8tWr1Q0CSOFa9vyTInJ/KgV988Dg6X003AOQBuV6AdVoWYuZc2WKE1X+ewWPjjyl6pNWLXXX5CHenG4T1UUKXcObopEjwM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707175302; c=relaxed/simple; bh=keU4XeIPQYtLjYA+XUF5R/i+XtY804wbrg0XFEEawuQ=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=rfMRvE+j1ghCXVAxT4kCzjW+E9eKl9cLmM262NzmsqGLNxQ4qZ3TZhHD+LyZpUOVgSBLAd+BAI81QpEG0hqrnDfnJS4SdiwrbaTuv0vKBUwRO249g/ju6VxLjo64TVt3ht+fM9TopIhjh+3NokSDG6MAba4LYH/y6w/1kGLlzdQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BSqSdG/+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0B5FC433F1; Mon, 5 Feb 2024 23:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707175302; bh=keU4XeIPQYtLjYA+XUF5R/i+XtY804wbrg0XFEEawuQ=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=BSqSdG/+IjNeLZT/yobOpOKgLLYBqZkW+p0i3Y5hBJsOcLSVJ0QWyTzrLMR5fZHRF HQnRjSwC5YSnwrtdURFazT9j8y1X/eDb0y0jSbqhAkFtY4XlWFDo9ZcWaLEdmfq2j3 0H+I2+moWyzUZgaXyU257N+Q8WQVRfiFxTqB0hknNxKRfdEjdBP4Tp1kx99jSWOCFB 1uZs5QZV10stLq/q6vJ2YEYsGlSwhmgUj7nmFjIIdW79YLeThoeRhhR4CN1dvK3Mm+ GA6KHvugi8hOO2wUyCOVn6uiQzJ1clzzNHH8jKVrCliFqPTq8hKXxY6LHKbwZSkHcn dNAdq6liJ+uBQ== Date: Mon, 05 Feb 2024 23:21:41 +0000 From: Kees Cook To: Eric Biggers , Kees Cook CC: linux-hardening@vger.kernel.org, Rasmus Villemoes , Mark Rutland , "Gustavo A. R. Silva" , Marco Elver , linux-kernel@vger.kernel.org Subject: =?US-ASCII?Q?Re=3A_=5BPATCH_v3_2/3=5D_overflow=3A_Introduce?= =?US-ASCII?Q?_add=5Fwrap=28=29=2C_sub=5Fwr?= =?US-ASCII?Q?ap=28=29=2C_and_mul=5Fwrap=28=29?= User-Agent: K-9 Mail for Android In-Reply-To: <20240205231712.GC2220@sol.localdomain> References: <20240205090854.make.507-kees@kernel.org> <20240205091233.1357377-2-keescook@chromium.org> <20240205202145.GB2220@sol.localdomain> <202402051443.A813E4D@keescook> <20240205231712.GC2220@sol.localdomain> Message-ID: <51025C22-0FEF-4047-BC36-EA7ED7A3BD62@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On February 5, 2024 11:17:12 PM GMT, Eric Biggers = wrote: >On Mon, Feb 05, 2024 at 02:44:14PM -0800, Kees Cook wrote: >> On Mon, Feb 05, 2024 at 12:21:45PM -0800, Eric Biggers wrote: >> > On Mon, Feb 05, 2024 at 01:12:30AM -0800, Kees Cook wrote: >> > > Subject: Re: [PATCH v3 2/3] overflow: Introduce add_wrap(), sub_wra= p(), and mul_wrap() >> >=20 >> > Maybe these should be called wrapping_add, wrapping_sub, and wrapping= _mul? >> > Those names are more grammatically correct, and Rust chose those name= s too=2E >>=20 >> Sure, that works for me=2E What bout the inc_wrap() and dec_wrap() name= s? >> I assume wrapping_inc() and wrapping_dec() ? >>=20 > >Yes, though I'm not sure those should exist at all=2E Maybe a +=3D b sho= uld just >become a =3D wrapping_add(a, b), instead of wrapping_inc(a, b)? >wrapping_inc(a, b) isn't as self-explanatory=2E Likewise for wrapping_de= c=2E It was to avoid repeating type information, as it would go from: var_a +=3D var_b; to: var_a =3D wrapping_add(typeof(var_a), var_a, var_b); Which repeats "var_a" 3 times=2E :| --=20 Kees Cook