Message ID | 20240213220844.it.345-kees@kernel.org |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-64443-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp849638dyb; Tue, 13 Feb 2024 14:45:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWy53O1I+EctVHLg2xu7UJMZiz7Dhzm9rWc4ckXhhB3j8l+7z3t/GCWrIIXMMwPdAPhbRy0u5Brx9F7CF3B60IPrLe+ZQ== X-Google-Smtp-Source: AGHT+IF3mKH/wIDde0ZczqiAY1sehWZbXn4lEQaAuzTVITSQu84Dpx3Z6SqfEDsLK/3imL+8TfLU X-Received: by 2002:a05:6a21:3183:b0:19e:425e:ec56 with SMTP id za3-20020a056a21318300b0019e425eec56mr1163303pzb.24.1707864302322; Tue, 13 Feb 2024 14:45:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707864302; cv=pass; d=google.com; s=arc-20160816; b=OiutfdVHFiWRsMw+9rJcGqSvqEDQsrwV1hV/bayiwPmcdqT6FY6st+3dbOaL/4s+Zd JZ8IaQt2Qjm3Chd5axS/MN1cPVE/u8d+kpd9TnlWMB0bgNgsaTncpLTQg1SpITeSdPcJ JYVMrY3bL+bHIWj51wZOu3p+98Wq1g7VnDzQh6OJZCGTvqEMpIIqifJ8PNLASP6pMkYR O7YqAGMtk5fO3ZYl5LtS8QqCl3pFVE+Wik1L9MKAiUGqadZt0gt2RfyjHF7HmUYMYEWy jJ/7Z23NILU4I82doMDQ6aYizumv86moXbCg6cCsxLwkHCzsJQ7V33eNBhDjfEgpKhYF 2r/w== 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:date:subject:cc:to :from:dkim-signature; bh=6/l7cYejTBwG/ZbXfVuNOUK+p83wyeqabIOdAUG0DV4=; fh=Ci/UJYAO1wqttX0nlytg+zGBQU5iL71hEZMWrIN7oVY=; b=CZsMudc8QwSU9o3dEzfYvqmq72R2jJt8mdykcKOK2ptv2Vu/1hnJxi2qQIlYHw0MMq iW/7OGJfdPmUNyHBdHv/7OpDLsUMKIjp+/Zgsk6ZpSotrQoF4q3X2F52fTbD54jzaXxr jP6aflb54fbb0vX+eC3xsudmNUWGtWJCA6DBASOo57b5/9SnAOSSZvzwD2hbdFJCgfdB VpvP3JqK/EDtf4br/mC9TywwR0xoIKEHvTQBrjg9G0aJcwMs8kzv7+MlfnZV38EjZiFU U6mRLiFTqyyc6Niu60atgFlhPxSG48ct1lPbj7abs+Jx7Ku8UXRzzNCbfvOeYOWw/8gt Xkow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=L6j3IBWe; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-64443-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64443-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCV9fEbK1F374yO8NP6ng4kClbMrJiRYuaEtnenDLnCkrvLuISYFZksEQkgr0S/j+RooxiaFEUaYq1l51zdAtHnrmXZ8YQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id gl2-20020a17090b120200b002943cd1b20asi57261pjb.93.2024.02.13.14.45.01 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:45:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-64443-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=L6j3IBWe; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-64443-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-64443-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 4E342B29B32 for <ouuuleilei@gmail.com>; Tue, 13 Feb 2024 22:16:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BB3F6340D; Tue, 13 Feb 2024 22:11:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="L6j3IBWe" Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 60C55629E3 for <linux-kernel@vger.kernel.org>; Tue, 13 Feb 2024 22:11:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707862265; cv=none; b=u0hNBJuZKuBc4OBw1eTbF+r2NKT97z7AS42hv05FlBK5zZ7cAk6Prvh6kB+XgGqKB8ZGzjquVcy9Qgu4dLtYXKj/TzYGBtM4iFRgdILniFnnst92ye9Sksp/4jrrHPglK02EvY2ZGVfyHCFUCZbJyzDAKWnPtnRGVZYbG8RWWNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707862265; c=relaxed/simple; bh=gk9Sm9RrNWP7qFVWwHlEux51dUehEpnRcBtAM29pgs4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=pS3MPwNf3V7WSltzTMYlvHQ1w+JWai5kdnbO3fylOSLsH9nzgw/lHgmsH2sd3yuLZLNKB+ALiky5TD6B9nLIuTfkhfNgvXHkxYd2wYZVa5daWEc3WsAIDCumd+O683L6D+lLxFy0/Y30yGLmrgwTzpd8RtpdXeZbyfArXP51ZyI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=L6j3IBWe; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1d93edfa76dso39214615ad.1 for <linux-kernel@vger.kernel.org>; Tue, 13 Feb 2024 14:11:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707862262; x=1708467062; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6/l7cYejTBwG/ZbXfVuNOUK+p83wyeqabIOdAUG0DV4=; b=L6j3IBWef2o6ehNBNeBtrHiATS/+L4t2oXT0QZo3mDE0j6FGufyPLphJC3RAvJWuhD 6gjgAFNq3eTJV8tC+Dgtu+jKjVwQU8pbGa9lOcBewVPo7vunEbV9MG7/S/qwzx2/2UTb A7lpTW6H0Smmrz4guT9sAWiwm/8qPipmTpXrE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707862262; x=1708467062; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6/l7cYejTBwG/ZbXfVuNOUK+p83wyeqabIOdAUG0DV4=; b=udUXPay1fs7KPH/G+FkXrwGZg5kc6b0IT03f5OiXISglZv3tvN4+fgnmjl02nhxmDL bc5KTG+2Y4kS5gH/yobNNDjVWZTOHl5Mz4UwesEkzPCmBjvTxjMH9wdiH99VBFAjxXAY bVj6W07NfC7ZEl7kblRHtgtP4hf1EHh/y7n8QmcDmzzva5V2jXCef1VWZTiGckw19CYe LlJPT01GYZ+cjIsDmmkwVq0lSkoMwlSssHB5jqUhHT9fN23xTGjYq6sruLkv1aaMnEEQ kx1U0tDZGtMSGVzxekdg4QdTkpUvQZG3j9PeItYXTWRDv5zwv8LyfE/bRpU0IIrILfJT oI3w== X-Forwarded-Encrypted: i=1; AJvYcCWHcwItHjLg7+mbgt3TULqzqE+QaAq/5r91gEoI0JpUc9m9n+qe18N1r82feyejQV33TUubBiSwzKUi+0QimjRLaWmBfSUJK46wdsa5 X-Gm-Message-State: AOJu0YwF4PuoXQhEA2HZMnQbqksdfhRRAAvr70rAKkIMJjZns3abgiEp LBDKwUoC6Sn81mJBM7ShNTorQ67IsYwY7NyEN9Y7p4+5aBq9ZxAcZqPE7E8D8g== X-Received: by 2002:a17:903:280b:b0:1d9:a4ec:c5b2 with SMTP id kp11-20020a170903280b00b001d9a4ecc5b2mr775828plb.48.1707862262652; Tue, 13 Feb 2024 14:11:02 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCWtoxK5uvAlsQt2axOXVYoFte05bc2pnd1mWStQ74cxgrpyY7px//7+H1hDsFtVk4D4PiphUeDXk/DmNqffhGRz9g/4wIj3lsU4f8eqVRGIkYfP5wWMybFBecEMONYfIVdn1VlZIJ+/Fhl2eUSaaUStMU0TisdvdRpPo159ASIR64ymwCvionKnMl3yIAep+On4dWq2sRY2CxfIgkgniuXW8jBWGloPXopzP7RwVoATJQToHDvfIzBGqltODSzuPtkr/0mv2iNROiLD2Ba6VuYUZcnGsqZjJnBuODvG24B6MV3Nqy6WbYUGfZXmDoLtVuibWaD7d+49wg== Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id x13-20020a170902ec8d00b001d7222d8caasm2508776plg.50.2024.02.13.14.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Feb 2024 14:11:01 -0800 (PST) From: Kees Cook <keescook@chromium.org> To: Andy Shevchenko <andy@kernel.org> Cc: Kees Cook <keescook@chromium.org>, Rasmus Villemoes <rasmus.villemoes@prevas.dk>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Marco Elver <elver@google.com>, Eric Biggers <ebiggers@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v6 0/3] overflow: Introduce wrapping helpers Date: Tue, 13 Feb 2024 14:10:56 -0800 Message-Id: <20240213220844.it.345-kees@kernel.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1656; i=keescook@chromium.org; h=from:subject:message-id; bh=gk9Sm9RrNWP7qFVWwHlEux51dUehEpnRcBtAM29pgs4=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBly+jzxdRJEY5FqMROusW/9i6Wzp3o1ypZVJb7h YkSj1ZNhcSJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZcvo8wAKCRCJcvTf3G3A JgH/D/4vgtaPXk0KWcLTLiJHtP/4BVDnRMBnnjHRKPNZJTzFtr0xrvrvitXfOBUYmJ+Lx8HifKS He4LRsgMd/CYZOK9jKUwcXvby63qMhJBK1w1KIdbJ4Lw2BV92OSMkNSkGNsqA9uqEOVc05tlF2Z wQ9JpNsGUqMZUHXYMZrBXJbGMq3/E56iNAuokPIw77Ikofdl5wDgajp/nCUAEYUSoqW5sAnetJE stN6XyFY8TnPeBcSO7fWb9T28zKzLBcqpyBPM1u1U6w7F7l69XxwjifGQ8bfcQ7Bmge84Dz8smA JvURngdGXHC2hlHLEOxCuDWxgSAbEwDQDJwivzItmmLU6SG4qkNzOG5bc4ZgGyrzMiyqf8H008A 4r6h+woAQSQhuYNOWPGdZxHHO7r0bLdc2nfBIvKZ6JIxDy3P+9kynO3prHF7r/1KS2FiqxrFEJn QvEdsGBfjlqtG/5KMYy5owi91NA1jyRxlBTVnceQmxxdx1nwBqxtqtQK8OU51t2sK3TQ0lo7Z/X WPTxXk9O0LAJOkPoQvoC4HqMQrMJxYWA5bu2y2Ov4HsRExZL8qdWHIRQcniKlCZWwlC8MlEur8g u3DlvtXpA9lk4vLzGpf6di0u1AZq+pDdj/bFqGjqJcV+v0Z9+IkJKq94fDgXRL9SRpLvt3//7+u gVDUv70 hieHnvTg== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790825518565466055 X-GMAIL-MSGID: 1790825518565466055 |
Series | overflow: Introduce wrapping helpers | |
Message
Kees Cook
Feb. 13, 2024, 10:10 p.m. UTC
v6: rename wrapping_inc/dec to wraping_assign_add/sub (andy) v5: https://lore.kernel.org/all/20240207152317.do.560-kees@kernel.org/ v4: https://lore.kernel.org/all/20240206102354.make.081-kees@kernel.org/ v3: https://lore.kernel.org/all/20240205090854.make.507-kees@kernel.org/ v2: https://lore.kernel.org/all/20240130220218.it.154-kees@kernel.org/ v1: https://lore.kernel.org/all/20240129182845.work.694-kees@kernel.org/ Hi, In preparation for gaining instrumentation for signed[1], unsigned[2], and pointer[3] wrap-around, expand the overflow header to include wrap-around helpers that can be used to annotate arithmetic where wrapped calculations are expected (e.g. atomics). After spending time getting the unsigned integer wrap-around sanitizer running warning-free on a basic x86_64 boot[4], I think the add/sub/mul helpers first argument being the output type makes the most sense (as suggested by Rasmus). -Kees Link: https://github.com/KSPP/linux/issues/26 [1] Link: https://github.com/KSPP/linux/issues/27 [2] Link: https://github.com/KSPP/linux/issues/344 [3] Link: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=devel/overflow/enable-unsigned-sanitizer [4] Kees Cook (3): overflow: Adjust check_*_overflow() kern-doc to reflect results overflow: Introduce wrapping_add(), wrapping_sub(), and wrapping_mul() overflow: Introduce wrapping_assign_add() and wrapping_assign_sub() include/linux/overflow.h | 98 +++++++++++++++++++++++++++++++++++----- lib/overflow_kunit.c | 67 +++++++++++++++++++++++++-- 2 files changed, 149 insertions(+), 16 deletions(-)