[PATCH v3] x86: fix ktermios-termio conversion

From: Arnd Bergmann
Date: Tue May 12 2009 - 07:34:06 EST


The legacy TCSETA{,W,F} ioctls failed to set the termio->c_line field
on x86. This adds a missing get_user.

The same ioctls also fail to report faulting user pointers, which
we keep ignoring.

Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
---

On Tuesday 12 May 2009, Alan Cox wrote:
> Arnd - can you send me a diff that keeps the existing horrible macro
> version, the existing __put_user usage and just fixes c_line ? It's
> worked for 15 years, its not worth the time being fancy with it.

I should probably have made my intention clearer. I'm sitting on a
series of patches [1] that generalize a lot of headers by making an
asm-generic version and falling back on this in all architectures that
have the same code.

The x86 SET_LOW_TERMIOS_BITS macro, besides its own stylistic problems,
only works on little-endian architectures and generates compiler warnings
on architectures on which get_user returns 'int __must_check'.
My asm-generic version fixes this by using the architecture independent
code I posted in this thread.

One of my later patches removes all x86 specific headers that are identical
to the asm-generic version. The termios.h header is almost identical,
so I first wanted to submit the patch to make it actually the same.

Arnd <><

[1] git.kernel.org:/pub/scm/linux/kernel/git/arnd/asm-generic.git

diff --git a/arch/x86/include/asm/termios.h b/arch/x86/include/asm/termios.h
index f729563..c4ee805 100644
--- a/arch/x86/include/asm/termios.h
+++ b/arch/x86/include/asm/termios.h
@@ -67,6 +67,7 @@ static inline int user_termio_to_kernel_termios(struct ktermios *termios,
SET_LOW_TERMIOS_BITS(termios, termio, c_oflag);
SET_LOW_TERMIOS_BITS(termios, termio, c_cflag);
SET_LOW_TERMIOS_BITS(termios, termio, c_lflag);
+ get_user(termios->c_line, &termio->c_line);
return copy_from_user(termios->c_cc, termio->c_cc, NCC);
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/