* sysfs_ops show vector: size of buffer not required? @ 2010-01-24 7:41 Himanshu Chauhan 2010-01-26 4:36 ` Greg KH 0 siblings, 1 reply; 5+ messages in thread From: Himanshu Chauhan @ 2010-01-24 7:41 UTC (permalink / raw) To: Linux Kernel; +Cc: Kernel Newbies, Greg Kroah 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? 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? Thanks Best Regards Himanshu ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sysfs_ops show vector: size of buffer not required? 2010-01-24 7:41 sysfs_ops show vector: size of buffer not required? Himanshu Chauhan @ 2010-01-26 4:36 ` Greg KH 2010-01-26 6:31 ` Himanshu Chauhan 0 siblings, 1 reply; 5+ messages in thread From: Greg KH @ 2010-01-26 4:36 UTC (permalink / raw) To: Himanshu Chauhan; +Cc: Linux Kernel, Kernel Newbies 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sysfs_ops show vector: size of buffer not required? 2010-01-26 4:36 ` Greg KH @ 2010-01-26 6:31 ` Himanshu Chauhan 2010-01-26 15:29 ` Greg KH 0 siblings, 1 reply; 5+ messages in thread From: Himanshu Chauhan @ 2010-01-26 6:31 UTC (permalink / raw) To: Greg KH; +Cc: Himanshu Chauhan, Linux Kernel, Kernel Newbies On Mon, Jan 25, 2010 at 08:36:46PM -0800, Greg KH wrote: > 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 was talking in context of usb/ip's show_status. It writes a lot of data into this buffer. Which seems to over flow the buffer. But anyways, I will check if it can be reduced or at least be splitted into differnt device attributes. BTW, Greg, Did you take a look at other patches I had sent? Are are worth or I need rework? Regards Himanshu ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sysfs_ops show vector: size of buffer not required? 2010-01-26 6:31 ` Himanshu Chauhan @ 2010-01-26 15:29 ` Greg KH 2010-01-26 17:10 ` Himanshu Chauhan 0 siblings, 1 reply; 5+ messages in thread From: Greg KH @ 2010-01-26 15:29 UTC (permalink / raw) To: Himanshu Chauhan; +Cc: Himanshu Chauhan, Linux Kernel, Kernel Newbies On Tue, Jan 26, 2010 at 12:01:27PM +0530, Himanshu Chauhan wrote: > On Mon, Jan 25, 2010 at 08:36:46PM -0800, Greg KH wrote: > > 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 was talking in context of usb/ip's show_status. It writes a lot of data > into this buffer. Then it needs to be fixed. Again, it must be, one value per file, that is the sysfs rule. > Which seems to over flow the buffer. But anyways, I will check if it > can be reduced or at least be splitted into differnt device > attributes. That would be great. > BTW, Greg, Did you take a look at other patches I had sent? Are are worth or > I need rework? They are in my "to-apply" queue that I will be flushing out in the next few days. thanks, greg k-h ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: sysfs_ops show vector: size of buffer not required? 2010-01-26 15:29 ` Greg KH @ 2010-01-26 17:10 ` Himanshu Chauhan 0 siblings, 0 replies; 5+ messages in thread From: Himanshu Chauhan @ 2010-01-26 17:10 UTC (permalink / raw) To: Greg KH; +Cc: Himanshu Chauhan, Linux Kernel, Kernel Newbies On Tue, Jan 26, 2010 at 07:29:24AM -0800, Greg KH wrote: > On Tue, Jan 26, 2010 at 12:01:27PM +0530, Himanshu Chauhan wrote: > > On Mon, Jan 25, 2010 at 08:36:46PM -0800, Greg KH wrote: > > > 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 was talking in context of usb/ip's show_status. It writes a lot of data > > into this buffer. > > Then it needs to be fixed. Again, it must be, one value per file, that > is the sysfs rule. > > > Which seems to over flow the buffer. But anyways, I will check if it > > can be reduced or at least be splitted into differnt device > > attributes. > > That would be great. Okay, I will do that. > > > BTW, Greg, Did you take a look at other patches I had sent? Are are worth or > > I need rework? > > They are in my "to-apply" queue that I will be flushing out in the next > few days. Thanks Greg. Regards Himanshu ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-01-26 17:27 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-01-24 7:41 sysfs_ops show vector: size of buffer not required? Himanshu Chauhan 2010-01-26 4:36 ` Greg KH 2010-01-26 6:31 ` Himanshu Chauhan 2010-01-26 15:29 ` Greg KH 2010-01-26 17:10 ` Himanshu Chauhan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox