2009-09-26 19:27:49

by Samuel Thibault

[permalink] [raw]
Subject: [PATCH,TRIVIAL] Fix csum_ipv6_magic asm memory clobber

Just like ip_fast_csum, the assembly snippet in csum_ipv6_magic needs a
memory clobber, as it is only passed the address of the buffer, not a
memory reference to the buffer itself.

Signed-Off-By: Samuel Thibault <[email protected]>
Cc: [email protected]

diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
index 7c5ef8b..46fc474 100644
--- a/arch/x86/include/asm/checksum_32.h
+++ b/arch/x86/include/asm/checksum_32.h
@@ -161,7 +161,8 @@ static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
"adcl $0, %0 ;\n"
: "=&r" (sum)
: "r" (saddr), "r" (daddr),
- "r" (htonl(len)), "r" (htonl(proto)), "0" (sum));
+ "r" (htonl(len)), "r" (htonl(proto)), "0" (sum)
+ : "memory");

return csum_fold(sum);
}


2009-09-30 22:42:10

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH,TRIVIAL] Fix csum_ipv6_magic asm memory clobber

On Sat, 26 Sep 2009 21:27:48 +0200
Samuel Thibault <[email protected]> wrote:

> Just like ip_fast_csum, the assembly snippet in csum_ipv6_magic needs a
> memory clobber, as it is only passed the address of the buffer, not a
> memory reference to the buffer itself.
>
> Signed-Off-By: Samuel Thibault <[email protected]>
> Cc: [email protected]
>
> diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
> index 7c5ef8b..46fc474 100644
> --- a/arch/x86/include/asm/checksum_32.h
> +++ b/arch/x86/include/asm/checksum_32.h
> @@ -161,7 +161,8 @@ static inline __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
> "adcl $0, %0 ;\n"
> : "=&r" (sum)
> : "r" (saddr), "r" (daddr),
> - "r" (htonl(len)), "r" (htonl(proto)), "0" (sum));
> + "r" (htonl(len)), "r" (htonl(proto)), "0" (sum)
> + : "memory");
>
> return csum_fold(sum);
> }

You describe it as "trivial" and also cc [email protected]. These things
are contradictory!

Maybe backporting it is a good idea from a sleep-soundly-at-night POV.
I don't know..

2009-09-30 22:46:08

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH,TRIVIAL] Fix csum_ipv6_magic asm memory clobber

On 09/30/2009 03:40 PM, Andrew Morton wrote:
>
> You describe it as "trivial" and also cc [email protected]. These things
> are contradictory!
>
> Maybe backporting it is a good idea from a sleep-soundly-at-night POV.
> I don't know..
>

/me suspects it was supposed to mean "trivially correct", which isn't
really what "trivial" means. This is a potentially serious bug and
should be treated as such.

-hpa

2009-09-30 23:01:42

by Samuel Thibault

[permalink] [raw]
Subject: Re: [PATCH,TRIVIAL] Fix csum_ipv6_magic asm memory clobber

H. Peter Anvin, le Wed 30 Sep 2009 15:45:15 -0700, a ?crit :
> On 09/30/2009 03:40 PM, Andrew Morton wrote:
> > You describe it as "trivial" and also cc [email protected]. These things
> > are contradictory!
> >
> > Maybe backporting it is a good idea from a sleep-soundly-at-night POV.
> > I don't know..
>
> /me suspects it was supposed to mean "trivially correct",

Yes.

> which isn't really what "trivial" means.

Ah.

> This is a potentially serious bug and should be treated as such.

Yes. Actually it hit Hurd's pfinetv4 when we tried to compile it with
gcc-4.3 (bogus checksums).

Samuel

2009-09-30 23:20:21

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH,TRIVIAL] Fix csum_ipv6_magic asm memory clobber

On Thu, 1 Oct 2009 01:01:38 +0200
Samuel Thibault <[email protected]> wrote:

> Actually it hit Hurd's pfinetv4 when we tried to compile it with
> gcc-4.3 (bogus checksums).

That's important information! I updated the changelog and added the
Cc:stable, thanks.


Full patch for netdev benefit:


From: Samuel Thibault <[email protected]>

Just like ip_fast_csum, the assembly snippet in csum_ipv6_magic needs a
memory clobber, as it is only passed the address of the buffer, not a
memory reference to the buffer itself.

This caused failures in Hurd's pfinetv4 when we tried to compile it with
gcc-4.3 (bogus checksums).

Signed-off-by: Samuel Thibault <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---

arch/x86/include/asm/checksum_32.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff -puN arch/x86/include/asm/checksum_32.h~x86-fix-csum_ipv6_magic-asm-memory-clobber arch/x86/include/asm/checksum_32.h
--- a/arch/x86/include/asm/checksum_32.h~x86-fix-csum_ipv6_magic-asm-memory-clobber
+++ a/arch/x86/include/asm/checksum_32.h
@@ -161,7 +161,8 @@ static inline __sum16 csum_ipv6_magic(co
"adcl $0, %0 ;\n"
: "=&r" (sum)
: "r" (saddr), "r" (daddr),
- "r" (htonl(len)), "r" (htonl(proto)), "0" (sum));
+ "r" (htonl(len)), "r" (htonl(proto)), "0" (sum)
+ : "memory");

return csum_fold(sum);
}
_

2009-09-30 23:22:15

by David Miller

[permalink] [raw]
Subject: Re: [PATCH,TRIVIAL] Fix csum_ipv6_magic asm memory clobber

From: Andrew Morton <[email protected]>
Date: Wed, 30 Sep 2009 16:19:39 -0700

> From: Samuel Thibault <[email protected]>
>
> Just like ip_fast_csum, the assembly snippet in csum_ipv6_magic needs a
> memory clobber, as it is only passed the address of the buffer, not a
> memory reference to the buffer itself.
>
> This caused failures in Hurd's pfinetv4 when we tried to compile it with
> gcc-4.3 (bogus checksums).
>
> Signed-off-by: Samuel Thibault <[email protected]>
> Signed-off-by: Andrew Morton <[email protected]>

I'm happy to see this go in via the x86 tree, and thus:

Acked-by: David S. Miller <[email protected]>

2009-09-30 23:46:33

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH,TRIVIAL] Fix csum_ipv6_magic asm memory clobber

On 09/30/2009 04:22 PM, David Miller wrote:
> From: Andrew Morton <[email protected]>
> Date: Wed, 30 Sep 2009 16:19:39 -0700
>
>> From: Samuel Thibault <[email protected]>
>>
>> Just like ip_fast_csum, the assembly snippet in csum_ipv6_magic needs a
>> memory clobber, as it is only passed the address of the buffer, not a
>> memory reference to the buffer itself.
>>
>> This caused failures in Hurd's pfinetv4 when we tried to compile it with
>> gcc-4.3 (bogus checksums).
>>
>> Signed-off-by: Samuel Thibault <[email protected]>
>> Signed-off-by: Andrew Morton <[email protected]>
>
> I'm happy to see this go in via the x86 tree, and thus:
>
> Acked-by: David S. Miller <[email protected]>

I'll put it in x86/urgent tonight or early tomorrow morning (just about
to leave for the airport.)

-hpa