Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754524Ab0AZEqq (ORCPT ); Mon, 25 Jan 2010 23:46:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754485Ab0AZEqo (ORCPT ); Mon, 25 Jan 2010 23:46:44 -0500 Received: from kroah.org ([198.145.64.141]:48626 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753164Ab0AZEqo (ORCPT ); Mon, 25 Jan 2010 23:46:44 -0500 Date: Mon, 25 Jan 2010 20:36:46 -0800 From: Greg KH To: Himanshu Chauhan Cc: Linux Kernel , Kernel Newbies Subject: Re: sysfs_ops show vector: size of buffer not required? Message-ID: <20100126043646.GB32066@kroah.com> References: <20100124074118.GA4201@himanshu-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100124074118.GA4201@himanshu-laptop> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 984 Lines: 29 On Sun, Jan 24, 2010 at 01:11:18PM +0530, Himanshu Chauhan wrote: > Hi All, > > The sysfs_ops's show vector doesn't have a size of the > buffer given to the vector, while store on the other hand > has. What is the rationale behind it? If you need to check the size, you are doing something wrong. Seriously, that is the reason. A sysfs file should be a single value, which will never overflow the buffer. > I see most of the implementations doing strcpy in the > show vectors. Ill behaved driver might overwrite the > given buffer when size is not known. Should this be addressed > by providing the buffer size along with the buffer pointer? Nope. Again, a single value only, it easily fits into the buffer size. thanks, greg k-h -- 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/