Received: by 2002:a05:7412:3210:b0:e2:908c:2ebd with SMTP id eu16csp833083rdb; Fri, 1 Sep 2023 05:45:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNLRUTKPsqGK8CUF2EG65YVVgk2HGEfZiVhmrb3bcMTpSb+W3r/+cqqIufV0A1M4IISwcM X-Received: by 2002:a17:907:272a:b0:992:7295:61c9 with SMTP id d10-20020a170907272a00b00992729561c9mr1704295ejl.69.1693572313066; Fri, 01 Sep 2023 05:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693572313; cv=none; d=google.com; s=arc-20160816; b=GfR0uZ4fQ4qRw1Hkzy4F+KmWfHebIdwXTizM5kPaSRpmTH1cRUKDobzRMVUenC4gGn WlcWgy0FKYxpFOJRDTy4AGX/dd581KPAAovF1t00srDTHNEIi4lgn+io8ufyYTBH3Hco CTswtgr8NC+30iGreRuHkwxeaiz/fv45Dzes1jQXCLatkJFIFUznRQiEH2MBVCeiwEmA BX6rUnQjEQeDL9B/ypYH/25B0Co9YYw3cBV7Mj0570DxquYh/peR8UK0yc/H3VVEQhvL jcaxS5z+8FzpMWVx8W4ZZQZEi8kDU0f0PF1k9V4fWqe8RsetaOqr1j5pSul+Jo1p/GRf ZQTg== 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=4QsKCPeQc+j/99WmmUmSAtXCqs0fX3zb8riDnk83Uh4=; fh=yb9ed9DT+D1BEg3Z1zq2of8eRS8l1ZQYqKhbtdgzRIs=; b=Vr6TUs7H1hFAXLdSznDJekYzfOY/0radyt3dGivNQ5IkpVuh/Rub+DfcrE5cZzz/Lp 2LSWcyLZAm2cx3bOwb0X6Pd17l81kK0h+uQac9HY+fSmA+bxPuAyb+RZ4th/0f6qRrHK ecAX/n8W1MyCgEAe+r7x4QxiR7v8p0R0JNstQxb9K3OChQFn03xdIYGimQqy+mYs8hnM Km5qfntmZ6VWy9LvFClWJYoKvvYMZfpD3Xj37xntUn1IyBPuBnckwxbX23FqYOUQwh41 F1EwUGbvj5CzaU+RXLpUpH9PzOEcFs1z3FGJQ78svv0y6RP58aINTKdKzo7/t2gH+JUB 84Hw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ew16-20020a170907951000b009889b69c1edsi2250921ejc.697.2023.09.01.05.45.05; Fri, 01 Sep 2023 05:45:13 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344078AbjHaNiJ (ORCPT + 29 others); Thu, 31 Aug 2023 09:38:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231305AbjHaNiI (ORCPT ); Thu, 31 Aug 2023 09:38:08 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:237:300::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A0651A2; Thu, 31 Aug 2023 06:38:05 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1qbhrq-0000RJ-9x; Thu, 31 Aug 2023 15:37:50 +0200 Date: Thu, 31 Aug 2023 15:37:50 +0200 From: Florian Westphal To: Wander Lairson Costa Cc: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Fernando Fernandez Mancera , "open list:NETFILTER" , "open list:NETFILTER" , "open list:NETWORKING [GENERAL]" , open list , Lucas Leong , stable@kernel.org Subject: Re: [PATCH nf v2] netfilter/osf: avoid OOB read Message-ID: <20230831133750.GB15759@breakpoint.cc> References: <20230831123931.60606-1-wander@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230831123931.60606-1-wander@redhat.com> 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 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 Wander Lairson Costa wrote: > > diff --git a/net/netfilter/nfnetlink_osf.c b/net/netfilter/nfnetlink_osf.c > index 8f1bfa6ccc2d..13fedf2aaa0f 100644 > --- a/net/netfilter/nfnetlink_osf.c > +++ b/net/netfilter/nfnetlink_osf.c > @@ -315,6 +315,9 @@ static int nfnl_osf_add_callback(struct sk_buff *skb, > > f = nla_data(osf_attrs[OSF_ATTR_FINGER]); > > + if (f->opt_num > ARRAY_SIZE(f->opt)) > + return -EINVAL; > + Hmm, this isn't enough; as far as I can see there is no validation whatsover. This should also check that all of: char genre[MAXGENRELEN]; char version[MAXGENRELEN]; char subtype[MAXGENRELEN]; ... have a NUL byte. You could use strnlen() == ARRAY_SIZE() -> EINVAL for those. Maybe there is more to be validated, I did not followup with all the nested structures buried in user_finger struct.