From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Gustavo A. R. Silva" Subject: Re: [PATCH v2] net: dsa: mv88e6xxx: hwtstamp: fix potential negative array index read Date: Fri, 16 Feb 2018 11:49:43 -0600 Message-ID: References: <20180215183139.GA23076@embeddedor.com> <20180216154846.7ge6seynwxjkopmp@localhost> <20180216155617.ykf77vq45bxejfg3@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Brandon Streiff , Andrew Lunn , Vivien Didelot , Florian Fainelli , netdev@vger.kernel.org, linux-kernel@vger.kernel.org To: Richard Cochran Return-path: In-Reply-To: <20180216155617.ykf77vq45bxejfg3@localhost> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On 02/16/2018 09:56 AM, Richard Cochran wrote: > On Fri, Feb 16, 2018 at 07:48:46AM -0800, Richard Cochran wrote: >> On Thu, Feb 15, 2018 at 12:31:39PM -0600, Gustavo A. R. Silva wrote: >>> _port_ is being used as index to array port_hwtstamp before verifying >>> it is a non-negative number and a valid index at line 209 and 258: >>> >>> if (port < 0 || port >= mv88e6xxx_num_ports(chip)) >>> >>> Fix this by checking _port_ before using it as index to array >>> port_hwtstamp. >> >> NAK. Port is already known to be valid in the callers. > > And so the real bug is the pointless range checking tests. I would > welcome patches to remove those. > I just sent a patch for this. Thank you both, Andrew and Richard for the feedback. -- Gustavo