Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[PATCH] i386: fix file_read_actor() and pipe_read() for original i386 systems

The __copy_to_user_inatomic() calls in file_read_actor() and pipe_read()
are broken on original i386 machines, where WP-works-ok == false, as
__copy_to_user_inatomic() on such systems calls functions which might
sleep and/or contain cond_resched() calls inside of a kmap_atomic()
region.

The original check for WP-works-ok was in access_ok(), but got moved
during the 2.5 series to fix a race vs. swap.

Return the number of bytes to copy in the case where we are in an atomic
region, so the non atomic code pathes in file_read_actor() and
pipe_read() are taken.

This could be optimized to avoid the kmap_atomicby moving the check for
WP-works-ok into fault_in_pages_writeable(), but this is more intrusive
and can be done later.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Thomas Gleixner and committed by
Linus Torvalds
b6a8b316 f991519c

+9
+9
arch/i386/lib/usercopy.c
··· 10 10 #include <linux/blkdev.h> 11 11 #include <linux/module.h> 12 12 #include <linux/backing-dev.h> 13 + #include <linux/interrupt.h> 13 14 #include <asm/uaccess.h> 14 15 #include <asm/mmx.h> 15 16 ··· 720 719 #ifndef CONFIG_X86_WP_WORKS_OK 721 720 if (unlikely(boot_cpu_data.wp_works_ok == 0) && 722 721 ((unsigned long )to) < TASK_SIZE) { 722 + /* 723 + * When we are in an atomic section (see 724 + * mm/filemap.c:file_read_actor), return the full 725 + * length to take the slow path. 726 + */ 727 + if (in_atomic()) 728 + return n; 729 + 723 730 /* 724 731 * CPU does not honor the WP bit when writing 725 732 * from supervisory mode, and due to preemption or SMP,