Skip to contentSkip to conversation

futex-2.5.42-A2

PATCH Martin Wirth 2 participants 2 messages Oct 16, 2002

lore
Share & tools
lore
#0 lore raw

(My first reply seems to have been lost, so lets try a second time)

Quoted 10 lines

Um, this test existed for a reason:

Review

Quoted 6 lines
(quoted diff) +2 -3
-	/* Must be "naturally" aligned, and not on page boundary. */
-	if ((pos_in_page % __alignof__(int)) != 0
-	    || pos_in_page + sizeof(int) > PAGE_SIZE)
+	/* Must be "naturally" aligned */
+	if (pos_in_page % sizeof(int))
 		return -EINVAL;

If you do this, *please* add:

Quoted 3 lines
	/* Above check not sufficient if align of int < size.  Break link. */
	if (__alignof__(int) < sizeof(int)) {
	extern void __error_small_int_align();
Quoted 1 line
	__error_small_int_align();
Quoted 1 line
	}

I suggested to tighten the above test, because if __alignof__(int) < sizeof(int) the test leads to sporadic user space errors if the futex variable accidentally crosses a page boundary. The only sane way to control this is to force the user space compiler to use __alignof__(int) == sizeof(int) for futex variables.

Anyway, the test dates back to times when the futex code did atomic operations on the user space variable. But this is gone. The present code only touches users space by get_user which does its on checks. So from the point of keeping the kernel in a sane state we could drop the test completely.

Martin

#1 lore raw
Quoted 7 lines · Martin Wirth
Quoted 2 lines
	if (__alignof__(int) < sizeof(int)) {
	extern void __error_small_int_align();

I suggested to tighten the above test, because if __alignof__(int) < sizeof(int) the test leads to sporadic user space errors if the futex variable accidentally crosses a page boundary. [...]

i think you misunderstood Rusty's suggestion - what he suggests is to fail the kernel compile with a linker error if alignof(int) < sizeof(int). This is a pure compile-time thing, it does not relate to the alignment of the futex variable in any way.

Quoted 5 lines

Anyway, the test dates back to times when the futex code did atomic operations on the user space variable. But this is gone. The present code only touches users space by get_user which does its on checks. So from the point of keeping the kernel in a sane state we could drop the test completely.

actually, i think it's still important to do the alignment check to enforce userspace to use sane alignment. We dont want one futex variable out of 1000 potential futex to be misaligned, missed and blamed on the kernel.

Ingo