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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5E19C433EF for ; Thu, 27 Jan 2022 10:05:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238895AbiA0KFZ (ORCPT ); Thu, 27 Jan 2022 05:05:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238891AbiA0KFZ (ORCPT ); Thu, 27 Jan 2022 05:05:25 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D82DC061714 for ; Thu, 27 Jan 2022 02:05:25 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id b1-20020a17090a990100b001b14bd47532so2473685pjp.0 for ; Thu, 27 Jan 2022 02:05:25 -0800 (PST) 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=LBOQjqTrRKyhdvBvzMylROfqbjWsRkHJwbCc+XSqEB4=; b=hU+y8UUCtnvmLs91gy6C7O0CCHoYJ2TYmaHx7LExtXnAX3g2ZUWGqWjQGO9/EoDTHL LKJm5G2IXBdaabWdTa5DJp52fycGA3iBYSheTFsR6/eT0zTGBJ9vL1CUM+YzZJ4QOml5 mjaQGcvCY2aRk+2I7XMu+2PSCwnYj1z7fGDwI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LBOQjqTrRKyhdvBvzMylROfqbjWsRkHJwbCc+XSqEB4=; b=3wnp29sFkz8vQlbv1hZWh0vn81Avs0S0y5Jz3MZaYcrMxYhzYJy03mLbgu/bVNTtn7 nDhboxGiL6RO65HaEWtKp+OtesP3PZ17y9kURhteG8ZXFLtNOzL/sAGlJrXZdSPe0A05 OrH0LHjLaMxUt8loqs74aGUD3SYOwnqAUwayoIM+OoIjsD8ofjD0Es1KR8KzJJilPFlq JSAoZIcA99PcEZ8OH6zfucYbj25BlfF3DC/NZ6p+QpQtISXNcMSIDV4grEoKc/iSagd+ 5q9XT8zrl9JVkmqEvynD3j+LNDSwdefzyfrnNsEu4rzFNokgGSFJKPQMWWs+yi2XL2GG wDCQ== X-Gm-Message-State: AOAM530Z0O3akAVk/orlZylCZqOyJrahm5MmVs3FcwzY+p70lvc52BWC wdhj5pPd9PcwhU6uvTfgYZJmGQ== X-Google-Smtp-Source: ABdhPJwHB0qa1O7m8UjQXGx1IEj/br7glW0Yig/xNOufSEf8geSAYNnvEm+sDvMzb7zRtZzMRbp7zw== X-Received: by 2002:a17:90b:1b46:: with SMTP id nv6mr3459486pjb.178.1643277924815; Thu, 27 Jan 2022 02:05:24 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id p42sm4980243pfw.71.2022.01.27.02.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 02:05:24 -0800 (PST) Date: Thu, 27 Jan 2022 02:05:23 -0800 From: Kees Cook To: Dan Carpenter Cc: "Gustavo A. R. Silva" , Viresh Kumar , Johan Hovold , Alex Elder , Greg Kroah-Hartman , greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH][next] staging: greybus: i2c: Use struct_size() helper in gb_i2c_operation_create() Message-ID: <202201270204.D460EC35@keescook> References: <20220121222250.GA73021@embeddedor> <202201241213.82E7D9F598@keescook> <20220126105404.GY1951@kadam> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220126105404.GY1951@kadam> Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Wed, Jan 26, 2022 at 01:54:04PM +0300, Dan Carpenter wrote: > On Mon, Jan 24, 2022 at 12:19:03PM -0800, Kees Cook wrote: > > This could still overflow if struct_size() returns SIZE_MAX. Perhaps: > > > > if (check_add_overflow(struct_size(request, ops, msg_count), > > data_out_size, &request_size)) > > request_size = SIZE_MAX; > > > > I should brush off the saturating arithmetic helpers series: > > https://lore.kernel.org/all/20210920180853.1825195-1-keescook@chromium.org/ > > Yes, please! Those seem like a million times easier to use. Here they are! :) Please review: https://lore.kernel.org/lkml/20220124232342.3113350-1-keescook@chromium.org/ Thanks! -- Kees Cook