Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757157Ab0KKVeM (ORCPT ); Thu, 11 Nov 2010 16:34:12 -0500 Received: from smtp-out.google.com ([216.239.44.51]:16985 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753090Ab0KKVeK (ORCPT ); Thu, 11 Nov 2010 16:34:10 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=google.com; s=beta; h=date:from:x-x-sender:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version:content-type; b=oO6rqkGag83c0s8PSg+gkvVOvw1Yw3i/O4i/IMPXZQTw0YNhKH3Y94LayOBZWVvcJ9 EQXkPb5A+1fJUS0CAjoQ== Date: Thu, 11 Nov 2010 13:34:05 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Vasiliy Kulikov cc: Andrew Morton , kernel-janitors@vger.kernel.org, =?UTF-8?Q?Andr=C3=A9_Goddard_Rosa?= , Joe Perches , Frederic Weisbecker , Bjorn Helgaas , linux-kernel@vger.kernel.org Subject: Re: [PATCH] lib: vsprintf: fix invalid arg check In-Reply-To: <20101111210251.GA26283@albatros> Message-ID: References: <1289421490-23950-1-git-send-email-segooon@gmail.com> <20101110130834.02496b48.akpm@linux-foundation.org> <20101111083408.GA3471@albatros> <20101111210251.GA26283@albatros> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-System-Of-Record: true Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 831 Lines: 22 On Fri, 12 Nov 2010, Vasiliy Kulikov wrote: > OK, if the main reason here is return value type, then the correct > handling should be: > > /* Reject out-of-range values early. Large positive sizes are > used for unknown buffer sizes. */ > - if (WARN_ON_ONCE((int) size < 0)) > + if (WARN_ON_ONCE(size > INT_MAX) > return 0; > > This should catch all underflows and too big integers. > That is equivalent since size_t is always unsigned; if you'd like to change it, it should be presented only as a style change. More important would be writing a less cryptic comment :) -- 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/