Received: with ECARTIS (v1.0.0; list netdev); Thu, 09 Sep 2004 09:56:06 -0700 (PDT) Received: from cheetah.davemloft.net (mail@adsl-63-197-226-105.dsl.snfc21.pacbell.net [63.197.226.105]) by oss.sgi.com (8.13.0/8.13.0) with ESMTP id i89Gtxg1003371 for ; Thu, 9 Sep 2004 09:56:01 -0700 Received: from localhost ([127.0.0.1] helo=cheetah.davemloft.net ident=davem) by cheetah.davemloft.net with smtp (Exim 3.36 #1 (Debian)) id 1C5SCp-00032k-00; Thu, 09 Sep 2004 09:55:31 -0700 Date: Thu, 9 Sep 2004 09:55:31 -0700 From: "David S. Miller" To: Thomas Graf Cc: netdev@oss.sgi.com Subject: Re: [PATCH 2.6 NET] Catch wrong RTATTR_MAX with BUG() Message-Id: <20040909095531.331fd168.davem@davemloft.net> In-Reply-To: <20040909164346.GA18994@postel.suug.ch> References: <20040909164346.GA18994@postel.suug.ch> X-Mailer: Sylpheed version 0.9.12 (GTK+ 1.2.10; sparc-unknown-linux-gnu) X-Face: "_;p5u5aPsO,_Vsx"^v-pEq09'CU4&Dc1$fQExov$62l60cgCc%FnIwD=.UF^a>?5'9Kn[;433QFVV9M..2eN.@4ZWPGbdi<=?[:T>y?SD(R*-3It"Vj:)"dP Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-archive-position: 8560 X-ecartis-version: Ecartis v1.0.0 Sender: netdev-bounce@oss.sgi.com Errors-to: netdev-bounce@oss.sgi.com X-original-sender: davem@davemloft.net Precedence: bulk X-list: netdev Content-Length: 699 Lines: 30 On Thu, 9 Sep 2004 18:43:46 +0200 Thomas Graf wrote: > Catches outdated/invalid RTATTR_MAX and therefore avoids possible stack > corruption. Your test has an off by one error, but more importantly, it's probably better to do this at compile time with something like: extern void rtattr_max_too_small(void); ... void __init rtnetlink_init(void) { if (IFLA_MAX > RTATTR_MAX || IFA_MAX > RTATTR_MAX || RTA_MAX > RTATTR_MAX || NDA_MAX > RTATTR_MAX || TCA_MAX > RTATTR_MAX || TCAA_MAX > RTATTR_MAX) rtattr_max_too_small(); I would therefore accept a patch that did things this way. BUG()'ing at runtime for something like this is too rude. :) Thanks.