Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2383607pxb; Mon, 20 Sep 2021 20:55:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvqHAdqUuMJRz4Tydyv6K9/0MQO95BQ1cNbYF6TDlLbwQr/+EXQC2iXW/5vX7DNw2+yOWi X-Received: by 2002:a17:907:244a:: with SMTP id yw10mr31889161ejb.571.1632196539873; Mon, 20 Sep 2021 20:55:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632196539; cv=none; d=google.com; s=arc-20160816; b=eSwqwNKpGKnNDQyW5/3icXI7a3pPyQ0puN2rK2HNVskhul3qicRj2LZ39KKtBEySSx Z5jywpoToVazBx+08ZU2YDP/NBZOhQ2DWlfZCdDr14fp/e5Kx1wG0caKLNgfafnWAU+Y GAZLgNKX2hcAqoALh3GSJoVLAI3Eqy2liFiDtPWjT3EhhetbGnP1Exr6zgP9Tp2LvhYJ h82de6/a4oILIlUTd1ssG2wMMUc59FNGDUP6NW5SJzDVyKdYIt1W6mTo+/A7Mki1qkXj TqY+cQlnYJ5qoK7VIQFMbIyvOihZ9S/glsNIdNHDp/FjNjG+RqE6ogS31eynqvob3fAG QbyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=iWhoWBW+6i3JSlaA/8K89arcAnj7wf0LVk0B/HGuZ4E=; b=M3BrnmVQpeV1YqauBxUSZNTdORQJav1LRmrcy6dD0UbN4CHH/jU/leM1OD1T4UUHmJ /NdyDT60ICKcZT/g67pKLMI+I7SdgcccN9WuSGY5pjv/UfClajc37TFCzKyBcPMgSEBO +75Pv31oPdrzUqrSyVC/TlGCMx+QDyn/J6Sw7vW+bPmNKhNo4n4a0qGxdvIUE5qXvZvS ikwL1XQvbqA6X17urtg+2TrlXKqRTrCdG+7tQ1FnyqyCHugY7nlVBSx3ZO/Q4j6fsSuI i0/V/9krawT4V2hQ/WNzzJ2kaPHSk7NgKdpYomm+aXt5mIKHWlwYUl9bMutrwJMnkXEt TnrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XMVRtqGD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si18200472ejo.706.2021.09.20.20.55.16; Mon, 20 Sep 2021 20:55:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XMVRtqGD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230475AbhIUBe2 (ORCPT + 99 others); Mon, 20 Sep 2021 21:34:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229892AbhIUBeQ (ORCPT ); Mon, 20 Sep 2021 21:34:16 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4875AC0611DD for ; Mon, 20 Sep 2021 11:08:57 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id n2so9014219plk.12 for ; Mon, 20 Sep 2021 11:08:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iWhoWBW+6i3JSlaA/8K89arcAnj7wf0LVk0B/HGuZ4E=; b=XMVRtqGDgddJ9vmZtXl+N9v3wZWQz8TsekFurV+IhOoFVVk2LuP86HJ3JUlObyYKm5 vOoC54qa29lMWiPGJe2N2EUYMSnylo49Z16fOr26DSDVnTIfJDkqpM8wuQd6PNh/Ab5f 12fZvtZeKCazWZW5L8F3NdOMcFnn/0ObVd/QQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iWhoWBW+6i3JSlaA/8K89arcAnj7wf0LVk0B/HGuZ4E=; b=dbafQpP64f+eBKI/gXTA2qfrQGrEZ/AXGI4xMHvbfHPhK6WDrmDRpUr1P3Crmgrwmj blmwDnDTbDoWVWFVDYhJcsAogVypvIeW1ge5Q2qHYCb9/Qk2lQZiv14MlVhAy/bgLfPB ayNzqFmi+hIO2W96Rvj6RsFpABxWBvnF76dZj6vUdU/lV0ymGzhvVQgJkzWr2iU2FHTq ZzQXCHqeipzVdxOSDM+kGExz2zGawo7a5TCqIeya5PRtgdYDx5bzOoC6DeuODDFArF/i 6oIo2PgoVkHil+7NTr9iq3ANPFZzLVsJ1DH7Wi7iyd62E3Mk1WmQ5a8k/NLyJprSFMEG jzEA== X-Gm-Message-State: AOAM532Czouh1tT8xdfRGzWjpm9H4ENcK/JfezE0kQG2ckDDR1ATEDG/ c0eIAYi+RWhCgAFn7E0bBJHxuw== X-Received: by 2002:a17:90b:3a8a:: with SMTP id om10mr301445pjb.223.1632161336832; Mon, 20 Sep 2021 11:08:56 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id g3sm133895pjm.22.2021.09.20.11.08.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Sep 2021 11:08:55 -0700 (PDT) From: Kees Cook To: Rasmus Villemoes Cc: Kees Cook , "Gustavo A. R. Silva" , Nathan Chancellor , Jason Gunthorpe , Nick Desaulniers , Leon Romanovsky , Keith Busch , Len Baker , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH 0/2] overflow: Implement size_t saturating arithmetic helpers Date: Mon, 20 Sep 2021 11:08:51 -0700 Message-Id: <20210920180853.1825195-1-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=685; h=from:subject; bh=FeG5PlfVQOLm7yYHENWE55wzEyBQPrLEryzPdosJgs4=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBhSM402j4bi/2udxuIImKCgmvR1/RMVmE5NfB0uQe9 ov29NnCJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYUjONAAKCRCJcvTf3G3AJkCqD/ 9wne1Eptj0PIivZbRY8lVn4JyDC7UhAQr4gHCOyvPKbQ8YuHJZwKGwTftmmeOU9iR4vmLtg729JALP OGU249kFWYyRLcDTQYhN8IDTZAFOuWr49twoJAkugw0Oh1T+OQX64DMHeLxaqhNQVhEpmDVtfSuLIp Z6350Ufx3WfpKutOlwTN/snYSetedt/sXo7ebW3IEQQ3KjgraTlhQF2IlUvYnMpxx7NJLMdG66wSwD Od2hMQw/XKGRmRh3fJpRptzhA/oUGkKiGKFrFxyReQ9BdUacnYOLO8MLncsQ4DTRO7lVeFt42hgwQ5 PUtsstbbVYlGZ3RKmUj973T8/9+WDXs2je27S3nut+/uu/vY2d+Ehww1WhMUnmj0qoOQlGOTCKIWHI WxMQ0oMaKpBWIDjiHg4snsjgLxIC0RSwvNfnTmt8Blr/krbwZcRyoP3k/RWUI1JqEnuAmWI+cJ7NBq dFu7S4MC0718Q+hS2WQMaKFACmrH3HQT2mbvh1H5t6q518HbWEsFf4vbEUb7EbH1D31KG/DifLRjh9 KJLFUFHnumgao8bYjXwynF9v8tdUXDfXXNY2QIDWKhWYRVfqO2cMZOoxfpVsstai+aMRERT/7kzkMq KayOgWm9jy+bO7UvQv5WXgR17VZZT6XNxvVCZ++hQYmwJ7S+w25PbZBhywAw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, While doing more array_size() scans on the kernel, and reviewing recent struct_size() work[1], it became clear we needed helpers to perform composed saturating add and multiplies. This creates those helpers and updates the self tests to check them. Thanks, -Kees [1] https://lore.kernel.org/lkml/?q=%22open-coded+arithmetic%22 Kees Cook (2): overflow: Implement size_t saturating arithmetic helpers test_overflow: Regularize test reporting output include/linux/overflow.h | 140 ++++++++++++++++++++++++--------------- lib/test_overflow.c | 111 ++++++++++++++++++++++++------- 2 files changed, 175 insertions(+), 76 deletions(-) -- 2.30.2