Subject: Re: Register allocation in copy_to_user

From: [email-masked]
Date: Thu, 4 Oct 2001 17:11:45 +0200

[email-masked] wrote:
>
> Anyway, the attached patch solves this by explicitly building the
arguments
> to __copy_user in the argument registers ;-) instead of moving them
around.

This idea totally breaks, when the arguments (to copy_to_user) contain a
function call. We force the compiler to use a caller-saved register (like
a0)
across the function call. One place this happens is in net/ipv4/netfilter/
ip_tables.c/copy_entries_to_user().

The patch below fixes this, while preserving the original fix (for the tty
corruption). Although this is getting a little messy, the patch is not as
bad as it might seem. gcc will discard the extra temporary variables
(cu_to,
cu_from and cu_len) in far the most cases, and use them where necessary to
handle function calls.
Sorry, if this has caused any trouble.

-Tommy
(See attached file: uaccess.patch.gz)