* PATCH: Fix poor pointer math in devinet_sysctl_register
@ 2005-11-16 23:23 Jordan Crouse
2005-11-17 6:14 ` Andrew Morton
2005-11-17 10:53 ` Mikael Pettersson
0 siblings, 2 replies; 5+ messages in thread
From: Jordan Crouse @ 2005-11-16 23:23 UTC (permalink / raw)
To: linux-kernel
This patch fixes pointer math that under certain circumstances, results
in really bad pointers. This was encountered on a system compiled for i486, so
other compilers may differ, but I don't think it hurts anyone.
Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
---
net/ipv4/devinet.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 4ec4b2c..7585fce 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -1454,7 +1454,7 @@ static void devinet_sysctl_register(stru
return;
memcpy(t, &devinet_sysctl, sizeof(*t));
for (i = 0; i < ARRAY_SIZE(t->devinet_vars) - 1; i++) {
- t->devinet_vars[i].data += (char *)p - (char *)&ipv4_devconf;
+ t->devinet_vars[i].data += (int)((char *)p - (char *)&ipv4_devconf);
t->devinet_vars[i].de = NULL;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: PATCH: Fix poor pointer math in devinet_sysctl_register
2005-11-16 23:23 PATCH: Fix poor pointer math in devinet_sysctl_register Jordan Crouse
@ 2005-11-17 6:14 ` Andrew Morton
2005-11-17 7:13 ` David S. Miller
2005-11-17 10:53 ` Mikael Pettersson
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2005-11-17 6:14 UTC (permalink / raw)
To: Jordan Crouse; +Cc: linux-kernel
"Jordan Crouse" <jordan.crouse@amd.com> wrote:
>
> This patch fixes pointer math that under certain circumstances, results
> in really bad pointers. This was encountered on a system compiled for i486, so
> other compilers may differ, but I don't think it hurts anyone.
>
> Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
> ---
>
> net/ipv4/devinet.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index 4ec4b2c..7585fce 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -1454,7 +1454,7 @@ static void devinet_sysctl_register(stru
> return;
> memcpy(t, &devinet_sysctl, sizeof(*t));
> for (i = 0; i < ARRAY_SIZE(t->devinet_vars) - 1; i++) {
> - t->devinet_vars[i].data += (char *)p - (char *)&ipv4_devconf;
> + t->devinet_vars[i].data += (int)((char *)p - (char *)&ipv4_devconf);
Confused. These appear to be equivalent (on 32-bit CPUs, anyway).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: Fix poor pointer math in devinet_sysctl_register
2005-11-17 6:14 ` Andrew Morton
@ 2005-11-17 7:13 ` David S. Miller
0 siblings, 0 replies; 5+ messages in thread
From: David S. Miller @ 2005-11-17 7:13 UTC (permalink / raw)
To: akpm; +Cc: jordan.crouse, linux-kernel
From: Andrew Morton <akpm@osdl.org>
Date: Wed, 16 Nov 2005 22:14:12 -0800
> "Jordan Crouse" <jordan.crouse@amd.com> wrote:
> > @@ -1454,7 +1454,7 @@ static void devinet_sysctl_register(stru
> > return;
> > memcpy(t, &devinet_sysctl, sizeof(*t));
> > for (i = 0; i < ARRAY_SIZE(t->devinet_vars) - 1; i++) {
> > - t->devinet_vars[i].data += (char *)p - (char *)&ipv4_devconf;
> > + t->devinet_vars[i].data += (int)((char *)p - (char *)&ipv4_devconf);
>
> Confused. These appear to be equivalent (on 32-bit CPUs, anyway).
Indeed, please describe the exact failure case when posting
such patches.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: Fix poor pointer math in devinet_sysctl_register
2005-11-16 23:23 PATCH: Fix poor pointer math in devinet_sysctl_register Jordan Crouse
2005-11-17 6:14 ` Andrew Morton
@ 2005-11-17 10:53 ` Mikael Pettersson
2005-11-17 15:04 ` Jordan Crouse
1 sibling, 1 reply; 5+ messages in thread
From: Mikael Pettersson @ 2005-11-17 10:53 UTC (permalink / raw)
To: Jordan Crouse; +Cc: linux-kernel
Jordan Crouse writes:
> This patch fixes pointer math that under certain circumstances, results
> in really bad pointers. This was encountered on a system compiled for i486, so
> other compilers may differ, but I don't think it hurts anyone.
>
> Signed-off-by: Jordan Crouse <jordan.crouse@amd.com>
> ---
>
> net/ipv4/devinet.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
> index 4ec4b2c..7585fce 100644
> --- a/net/ipv4/devinet.c
> +++ b/net/ipv4/devinet.c
> @@ -1454,7 +1454,7 @@ static void devinet_sysctl_register(stru
> return;
> memcpy(t, &devinet_sysctl, sizeof(*t));
> for (i = 0; i < ARRAY_SIZE(t->devinet_vars) - 1; i++) {
> - t->devinet_vars[i].data += (char *)p - (char *)&ipv4_devconf;
> + t->devinet_vars[i].data += (int)((char *)p - (char *)&ipv4_devconf);
> t->devinet_vars[i].de = NULL;
> }
This is the same code which broke due to a known gcc-4.0.0 bug:
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21173>. If you're
indeed using gcc-4.0.0, then it's time to upgrade.
/Mikael
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: Fix poor pointer math in devinet_sysctl_register
2005-11-17 10:53 ` Mikael Pettersson
@ 2005-11-17 15:04 ` Jordan Crouse
0 siblings, 0 replies; 5+ messages in thread
From: Jordan Crouse @ 2005-11-17 15:04 UTC (permalink / raw)
To: Mikael Pettersson; +Cc: linux-kernel
> This is the same code which broke due to a known gcc-4.0.0 bug:
> <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21173>. If you're
> indeed using gcc-4.0.0, then it's time to upgrade.
>
Indeed, I am using 4.0.0, so may indeed be it. I'll upgrade and take
another shot at it.
Thanks,
Jordan
--
Jordan Crouse
Senior Linux Engineer
AMD - Personal Connectivity Solutions Group
<www.amd.com/embeddedprocessors>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-11-17 15:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-16 23:23 PATCH: Fix poor pointer math in devinet_sysctl_register Jordan Crouse
2005-11-17 6:14 ` Andrew Morton
2005-11-17 7:13 ` David S. Miller
2005-11-17 10:53 ` Mikael Pettersson
2005-11-17 15:04 ` Jordan Crouse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox