[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170815163105.GH16375@orbyte.nwl.cc>
Date: Tue, 15 Aug 2017 18:31:05 +0200
From: Phil Sutter <phil@....cc>
To: Stephen Hemminger <stephen@...workplumber.org>
Cc: netdev@...r.kernel.org
Subject: Re: [iproute PATCH 05/51] iplink_can: Prevent overstepping array
bounds
On Tue, Aug 15, 2017 at 08:10:49AM -0700, Stephen Hemminger wrote:
> On Sat, 12 Aug 2017 14:04:24 +0200
> Phil Sutter <phil@....cc> wrote:
>
> > can_state_names array contains at most CAN_STATE_MAX fields, so allowing
> > an index to it to be equal to that number is wrong. While here, also
> > make sure the array is indeed that big so nothing bad happens if
> > CAN_STATE_MAX ever increases.
>
> No more speculative bug fixes.
I don't think a bit of speculation regarding forwards-compatibility is a
bad thing per se. In this case it is about the possibility for kernel
code to add a new state to enum can_state.
Older ip binaries will allow an index of CAN_STATE_MAX and therefore
access data beyond end of can-state_names array.
If you update linux headers but forget to add the new state to
can_state_names array, the same will happen even if the sanity check for
'state' value is being fixed as by my patch.
By specifying the size of can_state_names array upon definition,
can_print_opt() will just print a null pointer which printf() can
handle.
Cheers, Phil
Powered by blists - more mailing lists