From patchwork Sat Dec 17 01:05:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 131945 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D6AFE1007D7 for ; Sat, 17 Dec 2011 12:05:36 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756656Ab1LQBFc (ORCPT ); Fri, 16 Dec 2011 20:05:32 -0500 Received: from mail.solarflare.com ([216.237.3.220]:6079 "EHLO ocex02.SolarFlarecom.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752496Ab1LQBFb (ORCPT ); Fri, 16 Dec 2011 20:05:31 -0500 Received: from [10.17.20.137] (10.17.20.137) by ocex02.SolarFlarecom.com (10.20.40.31) with Microsoft SMTP Server (TLS) id 14.1.355.2; Fri, 16 Dec 2011 17:05:30 -0800 Subject: [PATCH net] gianfar: Reject out-of-range RX NFC locations From: Ben Hutchings To: David Miller , Sebastian =?ISO-8859-1?Q?P=F6hn?= CC: Organization: Solarflare Communications Date: Sat, 17 Dec 2011 01:05:27 +0000 Message-ID: <1324083927.2798.34.camel@bwh-desktop> MIME-Version: 1.0 X-Mailer: Evolution 2.32.2 (2.32.2-1.fc14) X-Originating-IP: [10.17.20.137] X-TM-AS-Product-Ver: SMEX-10.0.0.1412-6.800.1017-18586.005 X-TM-AS-Result: No--9.170600-0.000000-31 X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Currently the driver only uses location values to maintain an ordered list of filters. There is nothing to stop the list becoming longer than the filer hardware can support - the driver will report an error, but will not roll back the change! Make it reject location values >= MAX_FILER_IDX, consistent with the range that gfar_get_cls_all() reports. Signed-off-by: Ben Hutchings Reviewed-by: Sebastian Pöhn --- [Re-sent to what I hope is a current address for Sebastian.] This has not been tested in any way, as I don't have a suitable compiler installed. Sebastian, please could you review this? Ben. drivers/net/ethernet/freescale/gianfar_ethtool.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c index 5890f4b..5a3b2e5 100644 --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c @@ -1692,8 +1692,9 @@ static int gfar_set_nfc(struct net_device *dev, struct ethtool_rxnfc *cmd) ret = gfar_set_hash_opts(priv, cmd); break; case ETHTOOL_SRXCLSRLINS: - if (cmd->fs.ring_cookie != RX_CLS_FLOW_DISC && - cmd->fs.ring_cookie >= priv->num_rx_queues) { + if ((cmd->fs.ring_cookie != RX_CLS_FLOW_DISC && + cmd->fs.ring_cookie >= priv->num_rx_queues) || + cmd->fs.location >= MAX_FILER_IDX) { ret = -EINVAL; break; }