Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1568101lqo; Sat, 18 May 2024 08:42:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWyzRUAP1PDKetHde8/CDU7Vbr1x7C8h7e+drXdmNZF2tDRNuJcDrb7to53dInYrjZ7WppJt5qkz/arLrNLr6MM6Oxa7wvP1N9/YPxiog== X-Google-Smtp-Source: AGHT+IEx9fV1bKT80J7OK0j1U2XOi0TodDyBmvV2O8xcaYj4Y9q0H96KJ4xTrAtxp1fDAdndzUVQ X-Received: by 2002:a17:902:9890:b0:1e5:3d8a:75fd with SMTP id d9443c01a7336-1ef44162e66mr250129955ad.69.1716046935554; Sat, 18 May 2024 08:42:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716046935; cv=pass; d=google.com; s=arc-20160816; b=VxX4OpgdupSuizrWwzu5MRkNR+IHLSdUC/2f7+7ISXzixykX4wzWv32FxWAQyKuBTj m2qSEsbdQFfuwSO2LdErKUtTi4ywODaZHojs6e+Xvp3TMF31ZarVFMqQ9XfnX/X99XpZ ZpKIcRu/y8l1snhRmMIpNsCfi3BwLDrXT44mzPg/PW1TOT3kE2p9yuN52+W1MNwYsg+A yS9IPaeM1sRIeOyo/7Nr1cEM60LhTZC6LBPdiIZeIAMFZ8g5K/d251+fwuD6e53vPTQt 0QRJkn/SDAh7RV5Yt3WWDtCvhfEG3aqcTJj4wQnfwWePAkORbqjYbDhizgZtL6uPBYuD nljA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=KEiRFn1zMsvA/RzSGsTpNHMl4lP5BT6qwK22Hk4Utow=; fh=R3PquC1o8EANYrgriXIIxQ6M7onD1/HGa+eaenn5qKc=; b=jlNrL4YKgj8uyrtSqFEPpcick6nIzh2HmXB69cMljAn0eLgmSq5AiPgvnSYG7uMpUq kqW/1A74qX0Yrw4+/pdFzggH5UJVusq/3ZVfSFAeR9o59g4hBaooN8MGRxgLtoTI/djd DOdK4VxaV1EwfuYUdZLWL+rMVkpvPwo/4C1zQAcz7F5h/yYBSiaD/uWwNM3x6tvXyUhR YIuSrRy589uLYQTbR9s5IGDwLAruJqJxCy073kb9v+Dd8iLFvWCm8Th/PiUGu1gEghuK +2lN96bxjBO2MlwP/ZwKfOneibQg1FKDMqngjXZ7wGYJpR+sklFVfAU/YOLLBcZGhBM6 qZ5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-182903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182903-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c14c7f0si46965395ad.498.2024.05.18.08.42.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 May 2024 08:42:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-182903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182903-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1EBE4282185 for ; Sat, 18 May 2024 15:42:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A074E45025; Sat, 18 May 2024 15:42:09 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) (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 4639E1DFC5 for ; Sat, 18 May 2024 15:42:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.58.85.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716046929; cv=none; b=CB1+1KGZkRfFpL14RaoQy9vR3H5CzI3wlJ+BYxoXAa//ixn2S3MsT3dVMuJPtEnxMIOpyuKBKO806lOca3gTiTUczMa1tBAsx+Z65h9rHUQCpGtF+tBjBhVBXM7yA5iln1SPZJJ/4y+vXEckoikXANlpj43jg/C5N4zQpiDwhoI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716046929; c=relaxed/simple; bh=KEiRFn1zMsvA/RzSGsTpNHMl4lP5BT6qwK22Hk4Utow=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=kjgt/HKO8Ejzr7zzwYvvl8QaExQJ0/WamU7IpBSMVI3hT72Z5qGhFspJ2e73SCOJp4MGL+UZQOAxRvDUl8L+RYPA9n7NXwUp5fF2gPJRr8zQWzdo5ZFArpb+uARKjvdh6HlR76u0R55cVsGxK6XBeqk1ibuGeaB80uLMOZqXO/o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM; spf=pass smtp.mailfrom=aculab.com; arc=none smtp.client-ip=185.58.85.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aculab.com Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-8-4PZfaOVqP-eUYUtpx8xdag-1; Sat, 18 May 2024 16:40:13 +0100 X-MC-Unique: 4PZfaOVqP-eUYUtpx8xdag-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Sat, 18 May 2024 16:39:41 +0100 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Sat, 18 May 2024 16:39:41 +0100 From: David Laight To: 'Dan Carpenter' , Kees Cook CC: Linus Torvalds , Justin Stitt , Peter Zijlstra , Mark Rutland , "linux-hardening@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "llvm@lists.linux.dev" Subject: RE: [RFC] Mitigating unexpected arithmetic overflow Thread-Topic: [RFC] Mitigating unexpected arithmetic overflow Thread-Index: AQHapdsGNoLb3Ne/oEmjTsfdfTDWz7GdI4ug Date: Sat, 18 May 2024 15:39:41 +0000 Message-ID: References: <202404291502.612E0A10@keescook> <039d54d6-8aa2-4e5b-829b-69002cff35d3@moroto.mountain> <202405131203.F7B97F5E38@keescook> <0480d602-3ad7-4f8e-a480-9860d56eab30@suswa.mountain> In-Reply-To: <0480d602-3ad7-4f8e-a480-9860d56eab30@suswa.mountain> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 RnJvbTogRGFuIENhcnBlbnRlcg0KPiBTZW50OiAxNCBNYXkgMjAyNCAwOTo0NQ0KPiANCj4gU25p cHBlZCBhbGwgdGhlIGJpdHMgd2hlcmUgeW91IGFyZSBjbGVhcmx5IGNvcnJlY3QuDQo+IA0KPiBP biBNb24sIE1heSAxMywgMjAyNCBhdCAxMjo0MzozN1BNIC0wNzAwLCBLZWVzIENvb2sgd3JvdGU6 DQo+ID4gPiBkcml2ZXJzL3VzYi9jbGFzcy91c2J0bWMuYzo4NTIgdXNidG1jX2dlbmVyaWNfcmVh ZCgpIHdhcm46IHBvdGVudGlhbCBpbnRlZ2VyIG92ZXJmbG93IGZyb20gdXNlcg0KPiAnbWF4X3Ry YW5zZmVyX3NpemUgKyAxJw0KPiA+ID4gICAgODQyICAgICAgICAgICAgICAgICAgICogd01heFBh Y2tldFNpemUg4oCTIDEpIHRvIGF2b2lkIHNlbmRpbmcgYSB6ZXJvLWxlbmd0aA0KPiA+ID4gICAg ODQzICAgICAgICAgICAgICAgICAgICogcGFja2V0DQo+ID4gPiAgICA4NDQgICAgICAgICAgICAg ICAgICAgKi8NCj4gPiA+ICAgIDg0NSAgICAgICAgICAgICAgICAgIHJlbWFpbmluZyA9IHRyYW5z ZmVyX3NpemU7DQo+ID4gPiAgICA4NDYgICAgICAgICAgICAgICAgICBpZiAoKG1heF90cmFuc2Zl cl9zaXplICUgZGF0YS0+d01heFBhY2tldFNpemUpID09IDApDQo+ID4gPiAgICA4NDcgICAgICAg ICAgICAgICAgICAgICAgICAgIG1heF90cmFuc2Zlcl9zaXplICs9IChkYXRhLT53TWF4UGFja2V0 U2l6ZSAtIDEpOw0KPiA+ID4gICAgODQ4ICAgICA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