Re: [PATCH] Errenous use of memset and memcpy

From: Arun Sharma <arun.sharma_at_intel.com>
Date: 2005-03-04 07:53:18
On 2/22/2005 9:37 AM, Bjorn Helgaas wrote:
> On Sun, 2005-02-20 at 11:38 +0100, Alexander Nyberg wrote:
>> ===== arch/ia64/ia32/ia32_signal.c 1.35 vs edited =====
>> --- 1.35/arch/ia64/ia32/ia32_signal.c	2005-01-25 21:23:45 +01:00
>> +++ edited/arch/ia64/ia32/ia32_signal.c	2005-02-20 11:32:55 +01:00
>> @@ -460,9 +460,9 @@ __ia32_rt_sigsuspend (compat_sigset_t *s
>>  	sigset_t oldset, set;
>>  
>>  	scr->scratch_unat = 0;	/* avoid leaking kernel bits to user level */
>> -	memset(&set, 0, sizeof(&set));
>> +	memset(&set, 0, sizeof(sigset_t));
> 
> To check that the above is correct, you have to go look up
> the declaration of "set".  Why not do this:
> 
> +	memset(&set, 0, sizeof(set));
> 
> which is clearly correct, regardless of the declaration?
>

Agree and I think memcpy is just fine. Tony, please apply the attached patch.

	-Arun


- Fix the incorrect argument to sizeof()
- memcpy should always succeed because it's a kernel space to kernel space copy.

Signed-off-by: Arun Sharma <arun.sharma@intel.com>

--- linux-2.6-cvs/arch/ia64/ia32/ia32_signal.c	3 Feb 2005 18:29:45 -0000	1.25
+++ linux-2.6-cvs/arch/ia64/ia32/ia32_signal.c	2 Mar 2005 23:43:09 -0000
@@ -460,10 +460,9 @@
 	sigset_t oldset, set;
 
 	scr->scratch_unat = 0;	/* avoid leaking kernel bits to user level */
-	memset(&set, 0, sizeof(&set));
+	memset(&set, 0, sizeof(set));
 
-	if (memcpy(&set.sig, &sset->sig, sigsetsize))
-		return -EFAULT;
+	memcpy(&set.sig, &sset->sig, sigsetsize);
 
 	sigdelsetmask(&set, ~_BLOCKABLE);
 
-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Thu Mar 3 16:02:20 2005

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:36 EST