At 11:57 AM 10/23/2002 +0200, Oliver Neukum wrote:
I'm fairly new to Linux kernel development. What is the proper locking mechanism to ensure that if two processes are potentially simultaneously executing a disconnect and proc read that no accesses to freed memory occurs? As soon as the proc read function starts executing, its data field may already refer to freed memory. A semaphore in a per-device structure that is freed during a disconnect would not work.> The risk being run here (root might change camuser's shutter speed on him / > disconnect at just the wrong time) is less than the benefit (the shutter > speed can be changed).No, most emphatically not. Risking data corruption due to accessing memory already freed is absolutely unacceptable, regardless of the features you gain. If you do this proc iopath, you do proper locking with all consequences. It's painful but necessary.
It might be possible if the data field refers to an entry of an array that will survive a disconnect (lives as long as the module does), but I bet that would still race if there was a simultaneous read and rmmod. I think it would also mean I'd have to limit the number of devices that could be plugged in ahead of time.
What is the painful-but-correct method?
-Joe
-------------------------------------------------------
This sf.net email is sponsored by: Influence the future of Java(TM) technology. Join the Java Community Process(SM) (JCP(SM)) program now. http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0002en
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel