Re: [PATCH v2 23/40] tile: enable sparse checks for get/put_user

From: Chris Metcalf
Date: Tue Jan 13 2015 - 10:55:52 EST


On 1/13/2015 4:45 AM, Michael S. Tsirkin wrote:
On Mon, Jan 12, 2015 at 07:08:36PM -0500, Chris Metcalf wrote:
The key changes are to copy the x86 definition of __inttype(), and then to
arrange to use an intermediate integral type that gets assigned to or from
the actual typed value so as to expose any sparse issues.

If this works for you, I'm happy to queue it in the tile tree, or I can
provide a proper git commit for you to include in your series, whichever
works better for you.
Please queue it up for 3.20. Extra __force is needed in a couple of
places - would you like to fix this up yourself, or do you want me to
write a patch on top?

I'll fold in your suggestions to my patch.

@@ -178,7 +178,7 @@ extern int fixup_exception(struct pt_regs *regs);
"9:" \
: "=r" (ret), "=r" (__a), "=&r" (__b) \
: "r" (ptr), "i" (-EFAULT)); \
- (x) = (__typeof(x))(__typeof((x)-(x))) \
+ (x) = (__typeof(x))(__inttype(x)) \
(((u64)__hi32(__a, __b) << 32) | \
__lo32(__a, __b)); \
})
This cast to __typeof(x) needs to be done with __force, otherwise
there will be a warning with bitwise types.

Actually, this place no longer needs any casting at all, on reflection.
I've changed the __get_user() code to do the "get" into an __inttype
uniformly, so __get_user_8 will always have a u64 type for "x" here.

I'll cc you on the updated patch, so if you'd like to add your
Reviewed-by tag to it, let me know.

--
Chris Metcalf, EZChip Semiconductor
http://www.ezchip.com

--
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/