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 D82CDC83F01 for ; Thu, 31 Aug 2023 13:38:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344654AbjHaNiJ (ORCPT ); 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) 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.