Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp993301pxb; Thu, 15 Apr 2021 11:09:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5Q4C8Uw2NkWIZ22O2NbW3wbKYk10l+QanifunvRnd5GjRwRpyr//Haycy6XtioVvwOsWu X-Received: by 2002:a63:7c44:: with SMTP id l4mr4626563pgn.325.1618510169099; Thu, 15 Apr 2021 11:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618510169; cv=none; d=google.com; s=arc-20160816; b=Cls+W+Uci/lAz7eBgKG5U7kVksWVic9XA/HzOOopqyd6vEOSrquoAH+M9psBcdPUmR sjmJdM/KaJQYLy/5DPLQ9rh+8cZonEkF4cEH+fc1IJECadWkaU8MPSQiG0BcvBYgG6d/ A61Kx2u2SOYpuYvDb5O93xBHzhW9ZBdiLCwtTdQRz9IkMRLe8C7xwhzLiBV3U1p0A9Y3 uRaavWRGtHfkbgF1s7lAxC9imAiSAvJMIq2mBezdnTysxQC24mwg4G8boIhZvqi1Rmf7 BKx7hFmdJR4Yb3GbDoTDHVwv1nx3rMlAK4jke3cu+u6WSSFN+OwfUnZwVkA05QfJAEy1 jQ2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=ZmIKFqUHduSAESy/4PeOU4GLOIssUo9k0MhB+rtUuxQ=; b=ZdXjz4SUiwvcD3miVOZ/GV5jZIL/3WTqZ6f4+CUYYJIYe9ERyExFUswVD1fdEuFQQB MJPbYnjE5/xe/XUuZ0tN1x+B7HoRpj4AsPFKp8XUNMSa6zn17CeQboLkjRleQa08A14s cyJwz3c5TtJ+ZQxz3tKtXEJycW9B6z4ZN6vuo1mogb7gUvdIU40cuoXiLOLP8YK7ib5A MLEuJiXdiNjQrpfuSNXvFI26TOAKOv7xdWGM2zMALtaS/JaQwi3TZXq5+2r7RhbPYE/r Dmcdh2YPDpYzKIGUNLl1Q2PQoib8HVS29srUIe2AvfiU/IGk9G/AvG5HJlrN5o80EfbH GBIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PAAA1ea9; 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 b10si3919651pgs.202.2021.04.15.11.09.14; Thu, 15 Apr 2021 11:09:29 -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=PAAA1ea9; 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 S233134AbhDOSJA (ORCPT + 99 others); Thu, 15 Apr 2021 14:09:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233610AbhDOSI7 (ORCPT ); Thu, 15 Apr 2021 14:08:59 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06713C061760 for ; Thu, 15 Apr 2021 11:08:35 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id em21-20020a17090b0155b029014e204a81e6so5094475pjb.1 for ; Thu, 15 Apr 2021 11:08:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ZmIKFqUHduSAESy/4PeOU4GLOIssUo9k0MhB+rtUuxQ=; b=PAAA1ea9mxCTLUm8rMnTT5Bz5uVDe7aIm2+CS58Eq71KP7XnCrvhijNuLJxuEe90BQ gv101TXrm7o+GZO8H1bHUb13ljxphmsan9DDXjQ0mfKtiflDz8G3FoWYhAmlLYtJamNC AfRa4VoecAaE7wasorSg+6yvy22JlDtKF7w/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ZmIKFqUHduSAESy/4PeOU4GLOIssUo9k0MhB+rtUuxQ=; b=EwcFL6uQj8iBudGczoIzaWDvcPc+jYM0WWbaZixq/SfpcYn4WhBdHRAE4ULCCmwqev oXjUcd85WMdeKIr3prvS+6LByRB4szn/r6v+Vs+Kepdbo1Cy19iLOB3lCCeiKO0MwcBW WMKQo/2qW6YVu1OUEuedlMFfPMjNa0TLmv7pg+m9g3N3/0adZ07vljBynfXP12iPVkLy MmbzBSs0A55KfbbzS1zgHJhYHgQRrKidUwUCsi+H2u1OuDF2wElNE7G/TC6nKIWlWSuq dhFTwDd9+R/3c3aDjlsyYXY3FWPtEcJD+DkOJE5M5O/WdqRz/+G3wWkucCJMysvzungk FyIQ== X-Gm-Message-State: AOAM531FkWImp0zhQU/ivw6JxdNnmbWl9Ti48HkuTOgb+zbl6Ce/sKwT 8xuwRbjl4R9J7nM6a1Kw0tigPA== X-Received: by 2002:a17:902:eec5:b029:ea:bffe:2b06 with SMTP id h5-20020a170902eec5b02900eabffe2b06mr5413492plb.8.1618510115438; Thu, 15 Apr 2021 11:08:35 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x194sm2993217pfc.18.2021.04.15.11.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 11:08:34 -0700 (PDT) Date: Thu, 15 Apr 2021 11:08:31 -0700 From: Kees Cook To: David Laight Cc: Miguel Ojeda , Linus Torvalds , Miguel Ojeda , Greg Kroah-Hartman , "rust-for-linux@vger.kernel.org" , Linux Kbuild mailing list , "open list:DOCUMENTATION" , Linux Kernel Mailing List Subject: Re: [PATCH 00/13] [RFC] Rust support Message-ID: <202104151107.8E3D919@keescook> References: <20210414184604.23473-1-ojeda@kernel.org> <202104141820.7DDE15A30@keescook> <8eaa65020c0d44ed9122fed5acf945a0@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8eaa65020c0d44ed9122fed5acf945a0@AcuMS.aculab.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 15, 2021 at 08:26:21AM +0000, David Laight wrote: > ... > > Besides just FP, 128-bit, etc, I remain concerned about just basic > > math operations. C has no way to describe the intent of integer > > overflow, so the kernel was left with the only "predictable" result: > > wrap around. Unfortunately, this is wrong in most cases, and we're left > > with entire classes of vulnerability related to such overflows. > > I'm not sure any of the alternatives (except perhaps panic) > are much better. > Many years ago I used a COBOL system that skipped the assignment > if ADD X to Y (y += x) would overflow. > That gave a very hard to spot error when the sump of a long list > way a little too large. > If it had wrapped the error would be obvious. > > There are certainly places where saturate is good. > Mostly when dealing with analogue samples. > > I guess the problematic code is stuff that checks: > if (foo->size + constant > limit) goto error; > instead of: > if (foo->size > limit - constant) goto error; Right. This and alloc(size * count) are the primary offenders. :) -- Kees Cook