From patchwork Fri Feb 10 15:43:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Horman X-Patchwork-Id: 140672 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 8B0F7B6EEC for ; Sat, 11 Feb 2012 02:44:12 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758023Ab2BJPoK (ORCPT ); Fri, 10 Feb 2012 10:44:10 -0500 Received: from charlotte.tuxdriver.com ([70.61.120.58]:58490 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755175Ab2BJPoJ (ORCPT ); Fri, 10 Feb 2012 10:44:09 -0500 Received: from hmsreliant.think-freely.org ([2001:470:8:a08:7aac:c0ff:fec2:933b] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1Rvsdl-0008K0-Ov; Fri, 10 Feb 2012 10:44:07 -0500 From: Neil Horman To: netdev@vger.kernel.org Cc: Neil Horman , Li Zefan , "David S. Miller" Subject: [PATCH 1/3] netprio_cgroup: fix an off-by-one bug Date: Fri, 10 Feb 2012 10:43:36 -0500 Message-Id: <1328888618-16208-2-git-send-email-nhorman@tuxdriver.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1328888618-16208-1-git-send-email-nhorman@tuxdriver.com> References: <1328888618-16208-1-git-send-email-nhorman@tuxdriver.com> X-Spam-Score: -2.9 (--) X-Spam-Status: No Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org # mount -t cgroup xxx /mnt # mkdir /mnt/tmp # cat /mnt/tmp/net_prio.ifpriomap lo 0 eth0 0 virbr0 0 # echo 'lo 999' > /mnt/tmp/net_prio.ifpriomap # cat /mnt/tmp/net_prio.ifpriomap lo 999 eth0 0 virbr0 4101267344 We got weired output, because we exceeded the boundary of the array. We may even crash the kernel.. Origionally-authored-by: Li Zefan Signed-off-by: Li Zefan Signed-off-by: Neil Horman CC: "David S. Miller" --- net/core/netprio_cgroup.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c index 9ae183a..72c6387 100644 --- a/net/core/netprio_cgroup.c +++ b/net/core/netprio_cgroup.c @@ -108,7 +108,7 @@ static void extend_netdev_table(struct net_device *dev, u32 new_len) static void update_netdev_tables(void) { struct net_device *dev; - u32 max_len = atomic_read(&max_prioidx); + u32 max_len = atomic_read(&max_prioidx) + 1; struct netprio_map *map; rtnl_lock();