From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93449C433B4 for ; Thu, 15 Apr 2021 18:08:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 732F9613B7 for ; Thu, 15 Apr 2021 18:08:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233995AbhDOSI7 (ORCPT ); Thu, 15 Apr 2021 14:08:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233052AbhDOSI7 (ORCPT ); Thu, 15 Apr 2021 14:08:59 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEC2CC061574 for ; Thu, 15 Apr 2021 11:08:35 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id u7so10722459plr.6 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=sfN3tTkz97XSM7mqpsX8RZgAjsTIlfihdkgcygdtO5bGH8su3OkLUgqpritWoiQ2cc LFW0DHndJPiIOdi/cxoAum8oK9KFLPxjAie14T/drZW1WIz6edTcIOkz9KFAxVMbbrAL LToMllhZps0W7LcCGF/ELJ2Pa96Urp5KxfpmLU9VCdCatzmlGEQ/ZwpwoTuTE0g/fB4x XZug4NJXp4kBi42i4fJxWQuP5U8z+rQWqH06qqOu0cAcx3VV4Q9Mm1X9CwHo3YKJ21kN IuL1ZLU3DI8Rc+26p6e5WsruXG8GwJ4DkUyvWY3ZXCYW4sCH0VyfSngWy3K7bxONRjXO iqIg== X-Gm-Message-State: AOAM532Fj/F7LE2hpMW2miqIjxkCvMnOnGP7Dwjq3MvmicpkWJCL5rPB iIwTsY7iv0iSTYHErQi5L+AT2g== X-Google-Smtp-Source: ABdhPJwV/iOPwRirOtIF2WPN0bS+rgljCqrBIoMJMtQGrpGIZKfWvo2Q4gixIqblVzkxGsqtn16B8g== 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: rust-for-linux@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