Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3245792rdh; Thu, 28 Sep 2023 06:47:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7ULeSTl8o2vn61g/83YWTeahU7dymWTOuW5Aufu4D7900WDAVnF9l88T1gtrTU1B7docJ X-Received: by 2002:a17:902:ec90:b0:1c5:ba50:2b14 with SMTP id x16-20020a170902ec9000b001c5ba502b14mr1411917plg.12.1695908853305; Thu, 28 Sep 2023 06:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695908853; cv=none; d=google.com; s=arc-20160816; b=nkQhjbhSE3ia5Rc45x3+KYoVpS+qd++FOwgA7zDe34zoy/iyhEO2vOP1qFnROfAMcO u56Bbcc2ld31gglY6MmHeqHTTTd+m7p+MybRMuLt4lQ3kCE0sQwS5nAwbzA90wA/uDvc XE8U6wV7Kq3pOCcOy3Fl44TAELbEBcENN9GZwQfj4vbgbzDhso1GLGI/04rNVnCHNzEg G3+AfF/q5zqpNZlYe4WkgWIz0uNWW5yXnIsmHihOg9M7EpgdXnp0tda6goNYge96tHlP 9mhlWoFJQGZBoiyLPEiI6JnhrYfT9pMzwcvkjra/jeDouR3QTT7NaZGvQIOI+J61wZjS ITbg== 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; bh=3e9HEXjldskV9MEuUG7i9fvJC4lJ+pypYWxd8wVWduI=; fh=0s5vfmZDbl1esSnUK0ZxnNhgSQTQAi6eA0fFHaF7pEg=; b=NKcz1M3bsFwny00ihuZ+fchrhl0qRF9hVLfEbJS19Yik8rg33tPSjcFuDd6SzjSZHd IkNMQkpfGXlD8d1DfMpFw5UN9vCsG6KN52IZ4V3dEhkkXWkUBN2VkKxnVa7EOX2Lt7UQ DbEagKBApPI5IAB6/seQFnehru+IntWwdkjvimYC8ymsrlOtO9AJ6+6dpeXf+3NWgLoE iw6skx73aewNxdsIsEk8Xv5nOXb9mZlCVVWJUOL0yoen/O7CVkgusKg4yV9sPdIdfpAU JQ5/UeYkFcAGBW2dbUE0/jxD2lbPL53l/3JTpoPF3JYpWt7UFShooa70pPgn6uvXY/fh jJYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id i2-20020a17090332c200b001c72b13a1cbsi4423021plr.352.2023.09.28.06.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 06:47:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id A685680A2812; Thu, 28 Sep 2023 06:40:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232260AbjI1NkX (ORCPT + 99 others); Thu, 28 Sep 2023 09:40:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232207AbjI1NkX (ORCPT ); Thu, 28 Sep 2023 09:40:23 -0400 Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [IPv6:2001:780:45:1d:225:90ff:fe52:c662]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 805C211F; Thu, 28 Sep 2023 06:40:20 -0700 (PDT) Received: from [78.30.34.192] (port=35960 helo=gnumonks.org) by ganesha.gnumonks.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qlrFW-0028r0-1Y; Thu, 28 Sep 2023 15:40:16 +0200 Date: Thu, 28 Sep 2023 15:40:13 +0200 From: Pablo Neira Ayuso To: joao@overdrivepizza.com Cc: netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kadlec@netfilter.org, fw@strlen.de, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, rkannoth@marvell.com, wojciech.drewek@intel.com, steen.hegenlund@microhip.com, keescook@chromium.org, Joao Moreira Subject: Re: [PATCH v3 1/2] Make loop indexes unsigned Message-ID: References: <20230927164715.76744-1-joao@overdrivepizza.com> <20230927164715.76744-2-joao@overdrivepizza.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230927164715.76744-2-joao@overdrivepizza.com> X-Spam-Score: -1.9 (-) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 28 Sep 2023 06:40:37 -0700 (PDT) On Wed, Sep 27, 2023 at 09:47:14AM -0700, joao@overdrivepizza.com wrote: > From: Joao Moreira > > Both flow_rule_alloc and offload_action_alloc functions received an > unsigned num_actions parameters which are then operated within a loop. > The index of this loop is declared as a signed int. If it was possible > to pass a large enough num_actions to these functions, it would lead to > an out of bounds write. > > After checking with maintainers, it was mentioned that front-end will > cap the num_actions value and that it is not possible to reach this > function with such a large number. Yet, for correctness, it is still > better to fix this. > > This issue was observed by the commit author while reviewing a write-up > regarding a CVE within the same subsystem [1]. > > 1 - https://nickgregory.me/post/2022/03/12/cve-2022-25636/ > > Signed-off-by: Joao Moreira > --- > net/core/flow_offload.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/net/core/flow_offload.c b/net/core/flow_offload.c > index bc5169482710..bc3f53a09d8f 100644 > --- a/net/core/flow_offload.c > +++ b/net/core/flow_offload.c > @@ -10,7 +10,7 @@ > struct flow_rule *flow_rule_alloc(unsigned int num_actions) > { > struct flow_rule *rule; > - int i; > + unsigned int i; With the 2^8 cap, I don't think this patch is required anymore. > > rule = kzalloc(struct_size(rule, action.entries, num_actions), > GFP_KERNEL); > @@ -31,7 +31,7 @@ EXPORT_SYMBOL(flow_rule_alloc); > struct flow_offload_action *offload_action_alloc(unsigned int num_actions) > { > struct flow_offload_action *fl_action; > - int i; > + unsigned int i; > > fl_action = kzalloc(struct_size(fl_action, action.entries, num_actions), > GFP_KERNEL); > -- > 2.42.0 >