Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp371427rdf; Fri, 3 Nov 2023 03:26:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGE5M+kof3WHDCnKw37eC253HXMQrWrrJI42saOkB69p9VEYTNDuB1C2c1zBu4GryD/bSfl X-Received: by 2002:a05:6a20:160e:b0:181:6b3d:ca1c with SMTP id l14-20020a056a20160e00b001816b3dca1cmr2451310pzj.3.1699007188250; Fri, 03 Nov 2023 03:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699007188; cv=none; d=google.com; s=arc-20160816; b=GC6fdB/o+77kS4DRVhWLVw37oZLjVkSSPNnI+DV2Rzi1Ujcbog3n0K3yc16LOe1vE/ DjlYYCRCk+jao/ofHIaod6tk7M3tlwdlKf4BFTtQbuWPy3Ll8nYKP5yofPaiK1umIGCi APsZXwqHex9LRsAD1GfOaUfm36x5Lzaauo8Ly19OTwaIr5rtAHUdbSVSrPJWzvMCnRbd ldeVDr3RMpydkFfK/+ZXPYOMMPgBfI4kZSmCpRqWPttbb2n71yYZTddMSme3MRO5c0HV mzLzV1s1Q5cTqQB9mNeoqAU0d9Dm7nZGaQ5k36wZB9TTLcZ3sRsvrrP4IsemTmD5TzWH XCgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=k1PE7oBOG7NmwWEzhwEycfw5xjGWjNKyI8pbKsn0nVA=; fh=xV34X0mjuQduhUsbTwURsdI8rqzGdB054G25KhUd5q0=; b=gNUpsMEQFsWaEf1jcgETWurKpSBMt6UyF7izQbuqP4riah/vjXWgYdjTJxwRZA2fO2 BzoQA+aBlHy4cI9TcyqYo13pH9P0c5Ad43qghpJjJSMw+Ijk/Y4YFHVDizqD3dn0IjfG m3BzNgMJ+v75RQBBOjMtsua9ES9CdjN8jKi9ZoPaHd9xZ/epnhoizzEV4Va7MBXyss0B HnOoNndDyQL9TpX3vfuvi3Uto3M7CO/LpZpk2RjOKiw2ReFEHstM6RZwc7JVoxkCgfOd gv1TZ0gcztCxi0rJGK/mlj6v4tRMTHj6J3tMrZN/ovYCVSO7K+DcEgt3jPIzIq1MZvfY 4myQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id c17-20020a6566d1000000b005b91a58721esi1258058pgw.316.2023.11.03.03.26.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 03:26:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 80C9C838B3F5; Fri, 3 Nov 2023 03:26:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346241AbjKCK0C (ORCPT + 99 others); Fri, 3 Nov 2023 06:26:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232511AbjKCKZ6 (ORCPT ); Fri, 3 Nov 2023 06:25:58 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:237:300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9523D4E; Fri, 3 Nov 2023 03:25:54 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1qyrN4-00055B-3O; Fri, 03 Nov 2023 11:25:46 +0100 Date: Fri, 3 Nov 2023 11:25:46 +0100 From: Florian Westphal To: Pablo Neira Ayuso Cc: Florian Westphal , Dan Carpenter , Jozsef Kadlecsik , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH net] netfilter: nf_tables: fix pointer math issue in nft_byteorder_eval() Message-ID: <20231103102546.GB8035@breakpoint.cc> References: <15fdceb5-2de5-4453-98b3-cfa9d486e8da@moroto.mountain> <20231103091801.GA8035@breakpoint.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 03 Nov 2023 03:26:12 -0700 (PDT) Pablo Neira Ayuso wrote: > On Fri, Nov 03, 2023 at 10:18:01AM +0100, Florian Westphal wrote: > > Dan Carpenter wrote: > > > The problem is in nft_byteorder_eval() where we are iterating through a > > > loop and writing to dst[0], dst[1], dst[2] and so on... On each > > > iteration we are writing 8 bytes. But dst[] is an array of u32 so each > > > element only has space for 4 bytes. That means that every iteration > > > overwrites part of the previous element. > > > > > > I spotted this bug while reviewing commit caf3ef7468f7 ("netfilter: > > > nf_tables: prevent OOB access in nft_byteorder_eval") which is a related > > > issue. I think that the reason we have not detected this bug in testing > > > is that most of time we only write one element. > > > > LGTM, thanks Dan. We will route this via nf.git. > > Thanks for your patch. > > One question, is this update really required? I think so, yes. Part of this bug here is that this helper-niceness masks whats really happening in the caller (advancing in strides of 'u32', rather than 'u64').