Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756364Ab0DFDW7 (ORCPT ); Mon, 5 Apr 2010 23:22:59 -0400 Received: from kirsty.vergenet.net ([202.4.237.240]:46034 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751115Ab0DFDWx (ORCPT ); Mon, 5 Apr 2010 23:22:53 -0400 Date: Tue, 6 Apr 2010 13:22:49 +1000 From: Simon Horman To: wzt.wzt@gmail.com Cc: linux-kernel@vger.kernel.org, Wensong Zhang , Julian Anastasov , netdev@vger.kernel.org, lvs-devel@vger.kernel.org, Patrick McHardy Subject: Re: [PATCH] IPVS: replace sprintf to snprintf to avoid stack buffer overflow Message-ID: <20100406032248.GF30359@verge.net.au> References: <20100406025020.GA2741@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100406025020.GA2741@localhost.localdomain> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 992 Lines: 25 On Tue, Apr 06, 2010 at 10:50:20AM +0800, wzt.wzt@gmail.com wrote: > IPVS not check the length of pp->name, use sprintf will cause stack buffer overflow. > struct ip_vs_protocol{} declare name as char *, if register a protocol as: > struct ip_vs_protocol ip_vs_test = { > .name = "aaaaaaaa....128...aaa", > .debug_packet = ip_vs_tcpudp_debug_packet, > }; > > when called ip_vs_tcpudp_debug_packet(), sprintf(buf, "%s TRUNCATED", pp->name); > will cause stack buffer overflow. > > Signed-off-by: Zhitong Wang I think that the simple answer is, don't do that. But your patch seems entirely reasonable to me. Acked-by: Simon Horman Patrick, please consider merging this. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/