> Hi,
>
> the "hack" below in proc_file_read() fs/proc/generic.c (2.4.5)
> irritates me:
>
> If I do use "start" for a pointer into a memory area
> allocated in read_proc, will it be always guaranteed
> that (start > page)?
>
> If no, this will IMO lead to spuriously wrong output.
> If yes, I'd like to understand why.
Shhh ;-) Last time that hack was mentioned, someone wanted to _remove_
it. It's a very nice little hack to have around, and IKD uses it.
-Mike
diff -urN linux-2.4.4.virgin/fs/proc/generic.c linux-2.4.4.ikd.mike/fs/proc/generic.c
--- linux-2.4.4.virgin/fs/proc/generic.c Mon Dec 11 22:45:42 2000
+++ linux-2.4.4.ikd/fs/proc/generic.c Sun Dec 17 07:58:56 2000
@@ -104,6 +104,11 @@
* return the bytes, and set `start' to the desired offset
* as an unsigned int. - Paul.Russell@rustcorp.com.au
*/
+ /* Ensure that the data will fit when using the ppos hack,
+ * otherwise userland receives truncated data.
+ */
+ if (n > count-1 && start && start < page)
+ break;
n -= copy_to_user(buf, start < page ? page : start, n);
if (n == 0) {
if (retval == 0)
-
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/