Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp1174767rwe; Thu, 1 Sep 2022 13:52:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR7g5qvzKgb5gFuMzJNX4/Hry8C3c8/PYVZaUZuZALC48uRtECOcoQU69uIZYjtW04hXQ9MM X-Received: by 2002:a17:906:770d:b0:73c:a08f:593c with SMTP id q13-20020a170906770d00b0073ca08f593cmr26266898ejm.182.1662065537746; Thu, 01 Sep 2022 13:52:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662065537; cv=none; d=google.com; s=arc-20160816; b=BzvVwG4nCDxolseNMC4H1MbA3V2s/wzvvlw7uzvsmak6nuZuGcPu08ANcV3F68e1rq tu+oNw8UTdy/x6EU/robO1xoj2qaYeREfxNOa8aOsb4ljPnL7BMIWL5gWGnzJYtBwllf tU9af65KFIabFyoH+j1bUYjTFUKwWufwDjN1ekLb7gQHlR6E2WOznEjJZIELEh246KyK mmNHZwI/Jt8dXgQbb0Bq/DXpdl4sTaX07WYvbmiIBTnBbED1zb0zUJc17ktFpaGnYn20 wLE24CfhtDLY5VcpLEKrj+9XdWcg8nmRbE2n8D2IfcHoM5GJjkb8Iy/hKgs4XvGSlOD8 TQGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=WEkndHZhrhK3pVaPkFBAUDj1NKcoXnIAgAp2eAD9Qi0=; b=R0dKD8+Gmt8AQUem0veUSFzoPTNVV5VXmUwl+UvfDdO1IU/rX/bxLeE9OKSBMOYRfz MpvXDhrz+0I2ATVjT6Fjeoy4zUKXQ+0RxBSVBRczR0j4F89vU5kuU/939AdQlFF7rb8S vNYko4rAj7SnCIbKxivXLG3/XvIbHLPC9vaEmAg6ctKiXbKa7rlAtUyfM1e2oJ/wKCNU TMShcFNY6sCoJjTEh6JIbj1r1+PhMXY7z516hwdSFZvi5/pxG4DAwwxsJqFSXqw5LFbn LMAmsJ9MI6fKqLoluL36N47sSYRfuGlMRxjhQfIJDDYIR4JMm9BKPWLFW54orKgRcejY 4Q8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dxNzcJKV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qf28-20020a1709077f1c00b00730a1f55ac8si200252ejc.821.2022.09.01.13.51.51; Thu, 01 Sep 2022 13:52:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dxNzcJKV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234379AbiIATtV (ORCPT + 99 others); Thu, 1 Sep 2022 15:49:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233456AbiIATtT (ORCPT ); Thu, 1 Sep 2022 15:49:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B57399C21D; Thu, 1 Sep 2022 12:49:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 492C261E58; Thu, 1 Sep 2022 19:49:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1CBD8C433C1; Thu, 1 Sep 2022 19:49:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662061757; bh=DtcurkmNbe3mZsUd1jvvBGlCULoNGj3rYq35TfQpP1Q=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dxNzcJKVGgwLiqhieRIUxxlMR/sJQ1gBJbYk0YgNiiFDg0RH9Qg+jr1SB/801Ai37 tpea3dZ4Ff9fnnhbW7NSnp0zobEJmnW/fd6j0spU2DgzJqnVbmqeICfLWil/YsHReT 96hax3xvTsZyoVQzRFrG+n2/1lvOZmkqzFpHjgHAVIRIaOqM9U/AsjVthwrfuA8aTL jWieYQsv2PCVBvOkvDxNfpsvSeiAZNstWucyEiQS4UD1UfMWwcVogwrGfVBHap6q8j jbox5XDnEVlHSeYyQUaJAwe+t8BEi851KFLdxVIBCGnBOKnr+7O8asEIWfvA/OX0Nk XwV6r0dkacKtw== Date: Thu, 1 Sep 2022 12:49:15 -0700 From: Jakub Kicinski To: Kees Cook Cc: "David S. Miller" , Eric Dumazet , Paolo Abeni , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , syzbot , Yajun Deng , netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, Oliver Hartkopp , Harshit Mogalapalli , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH 1/2] netlink: Bounds-check nlmsg_len() Message-ID: <20220901124915.24ebc067@kernel.org> In-Reply-To: <202208312324.F2F8B28CA@keescook> References: <20220901030610.1121299-1-keescook@chromium.org> <20220901030610.1121299-2-keescook@chromium.org> <20220831201825.378d748d@kernel.org> <202208312324.F2F8B28CA@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 31 Aug 2022 23:27:08 -0700 Kees Cook wrote: > This would catch corrupted values... > > Is the concern the growth in image size? The check_sub_overflow() isn't > large at all -- it's just adding a single overflow bit test. The WARNs > are heavier, but they're all out-of-line. It turns the most obvious function into a noodle bar :( Looking at this function in particular is quite useful, because it clearly indicates that the nlmsg_len includes the header. How about we throw in a WARN_ON_ONCE(nlh->nlmsg_len < NLMSG_HDRLEN || nlh->nlmsg_len > INT_MAX); but leave the actual calculation human readable C?