From patchwork Sun Oct 13 05:21:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seif Mazareeb X-Patchwork-Id: 283052 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 AEF5A2C035B for ; Sun, 13 Oct 2013 16:22:01 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752221Ab3JMFV5 (ORCPT ); Sun, 13 Oct 2013 01:21:57 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:31507 "EHLO mx0a-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751278Ab3JMFV4 convert rfc822-to-8bit (ORCPT ); Sun, 13 Oct 2013 01:21:56 -0400 Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.14.5/8.14.5) with SMTP id r9D5Lql2007499; Sat, 12 Oct 2013 22:21:52 -0700 Received: from sc-owa01.marvell.com ([199.233.58.136]) by mx0a-0016f401.pphosted.com with ESMTP id 1fexe8b94c-1 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT); Sat, 12 Oct 2013 22:21:52 -0700 Received: from SC-vEXCH2.marvell.com ([10.93.76.134]) by SC-OWA01.marvell.com ([10.93.76.21]) with mapi; Sat, 12 Oct 2013 22:21:51 -0700 From: Seif Mazareeb To: Paul Moore CC: "davem@davemloft.net" , "netdev@vger.kernel.org" , "thomas.petazzoni@free-electrons.com" , Dmitri Epshtein Date: Sat, 12 Oct 2013 22:21:50 -0700 Subject: RE: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL Thread-Topic: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL Thread-Index: Ac7HQjtEuIyEc0LqROSRTsl5yBHs5QAkd6Rg Message-ID: <0DB595A2CB707F458400BE9663B6A72269C00479DF@SC-VEXCH2.marvell.com> References: <0DB595A2CB707F458400BE9663B6A72269C0047793@SC-VEXCH2.marvell.com> <11516872.z0JUlZSHlI@sifl> <0DB595A2CB707F458400BE9663B6A72269C0047841@SC-VEXCH2.marvell.com> <2291823.ee0I8c00DA@olly> In-Reply-To: <2291823.ee0I8c00DA@olly> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.10.8794, 1.0.431, 0.0.0000 definitions=2013-10-13_01:2013-10-11, 2013-10-13, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1305240000 definitions=main-1310120191 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function could loop forever in the main loop if opt[opt_iter +1] == 0, this will causing a kernel crash in an SMP system, since the CPU executing this function will stall /not respond to IPIs. This problem can be reproduced by running the IP Stack Integrity Checker (http://isic.sourceforge.net) using the following command on a Linux machine connected to DUT: "icmpsic -s rand -d -r 123456" wait (1-2 min) Signed-off-by: Seif Mazareeb Acked-by: Paul Moore --- include/net/cipso_ipv4.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) -- 1.8.1.2 -----Original Message----- From: Paul Moore [mailto:paul@paul-moore.com] Sent: Saturday, October 12, 2013 4:57 AM To: Seif Mazareeb Cc: davem@davemloft.net; netdev@vger.kernel.org; thomas.petazzoni@free-electrons.com; Dmitri Epshtein Subject: Re: [PATCH 1/1] net: fix cipso packet validation when !NETLABEL On Friday, October 11, 2013 2:04:10 PM Seif Mazareeb wrote: > When CONFIG_NETLABEL is disabled, the cipso_v4_validate() function > could loop forever in the main loop if opt[opt_iter +1] == 0, this > will causing a kernel crash in an SMP system, since the CPU executing > this function will stall /not respond to IPIs. > > This problem can be reproduced by running the IP Stack Integrity > Checker > (http://isic.sourceforge.net) using the following command on a Linux > machine connected to DUT: > > "icmpsic -s rand -d -r 123456" > wait (1-2 min) > > Signed-off-by: Seif Mazareeb > --- > include/net/cipso_ipv4.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h index > a7a683e..286b7da 100644 > --- a/include/net/cipso_ipv4.h > +++ b/include/net/cipso_ipv4.h > @@ -290,6 +290,7 @@ static inline int cipso_v4_validate(const struct > sk_buff *skb, unsigned char err_offset = 0; > u8 opt_len = opt[1]; > u8 opt_iter; > + u8 tag_len; > > if (opt_len < 8) { > err_offset = 1; > @@ -302,7 +303,8 @@ static inline int cipso_v4_validate(const struct > sk_buff *skb, } > > for (opt_iter = 6; opt_iter < opt_len;) { > - if (opt[opt_iter + 1] > (opt_len - opt_iter)) { > + tag_len = opt[opt_iter + 1]; > + if ((tag_len == 0) || (opt[opt_iter + 1] > (opt_len - > opt_iter))) { err_offset = opt_iter + 1; > goto out; > } You should also use 'tag_len' inside the for-loop, and after the if-block, where we increment 'opt_iter'. See my original reply for an example. -- paul moore www.paul-moore.com -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h index a7a683e..a8c2ef6 100644 --- a/include/net/cipso_ipv4.h +++ b/include/net/cipso_ipv4.h @@ -290,6 +290,7 @@ static inline int cipso_v4_validate(const struct sk_buff *skb, unsigned char err_offset = 0; u8 opt_len = opt[1]; u8 opt_iter; + u8 tag_len; if (opt_len < 8) { err_offset = 1; @@ -302,11 +303,12 @@ static inline int cipso_v4_validate(const struct sk_buff *skb, } for (opt_iter = 6; opt_iter < opt_len;) { - if (opt[opt_iter + 1] > (opt_len - opt_iter)) { + tag_len = opt[opt_iter + 1]; + if ((tag_len == 0) || (opt[opt_iter + 1] > (opt_len - opt_iter))) { err_offset = opt_iter + 1; goto out; } - opt_iter += opt[opt_iter + 1]; + opt_iter += tag_len; } out: