Mailing List Archive

Problem backing up HP switches on RHEL 6.2 (x86_64) -- patch included
On 2010-06-25 a change was checked in to GNU libc that changes how
memcpy works on certain architectures. Previously it copied overlapping
memory regions correctly; now it doesn't.

The net result for rancid is that backups of HP switches don't work on
e.g. RedHat Enterprise Linux with glibc-2.12-1.47 (x86_64). The output
gets garbled, and rancid fails to complete the backup process in many
cases. The cause appears to be memcpy calls in hpuifilter.

The patch below appears to solve the problem (at least our backups look
OK again); I've simply replaced all memcpy calls with calls to memmove;
probably some of them don't need to be replaced, but I don't see any
harm in doing so -- memmove may be a little slower, but I doubt that
this is a bottleneck in rancid.

Unified diff follows below.

David Byers
Linköping University



--- hpuifilter.c 2012-02-08 09:45:18.427498055 +0100
+++ hpuifilter_org.c 2012-02-08 08:30:28.856503169 +0100
@@ -367,7 +367,7 @@
break;
} else if (bytes > 0) {
hlen -= bytes;
- memmove(hbuf, hbuf + bytes, hlen + 1);
+ memcpy(hbuf, hbuf + bytes, hlen + 1);
if (hlen < 1)
pfds[2].events &= ~POLLOUT;
}
@@ -423,7 +423,7 @@
break;
} else if (bytes > 0) {
tlen -= bytes;
- memmove(tbuf, tbuf + bytes, tlen + 1);
+ memcpy(tbuf, tbuf + bytes, tlen + 1);
if (tlen < 1)
pfds[1].events &= ~POLLOUT;
}
@@ -593,7 +593,7 @@
if (len - pmatch[0].rm_eo <= 0) {
buf[pmatch[0].rm_so] = '\0';
} else {
- memmove(buf + pmatch[0].rm_so, buf + pmatch[0].rm_eo,
+ memcpy(buf + pmatch[0].rm_so, buf + pmatch[0].rm_eo,
len - pmatch[0].rm_eo + 1);
}
len -= pmatch[0].rm_eo - pmatch[0].rm_so;
@@ -616,7 +616,7 @@
if (len - pmatch[0].rm_eo == 0) {
buf[pmatch[0].rm_so] = '\0';
} else {
- memmove(buf + pmatch[0].rm_so, buf + pmatch[0].rm_eo,
+ memcpy(buf + pmatch[0].rm_so, buf + pmatch[0].rm_eo,
len - pmatch[0].rm_eo + 1);
}
len -= pmatch[0].rm_eo - pmatch[0].rm_so;
_______________________________________________
Rancid-discuss mailing list
Rancid-discuss@shrubbery.net
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Re: Problem backing up HP switches on RHEL 6.2 (x86_64) -- patch included [ In reply to ]
Wed, Feb 08, 2012 at 12:52:12PM +0100, David Byers:
> On 2010-06-25 a change was checked in to GNU libc that changes how
> memcpy works on certain architectures. Previously it copied overlapping
> memory regions correctly; now it doesn't.
>
> The net result for rancid is that backups of HP switches don't work on
> e.g. RedHat Enterprise Linux with glibc-2.12-1.47 (x86_64). The output
> gets garbled, and rancid fails to complete the backup process in many
> cases. The cause appears to be memcpy calls in hpuifilter.
>
> The patch below appears to solve the problem (at least our backups look
> OK again); I've simply replaced all memcpy calls with calls to memmove;
> probably some of them don't need to be replaced, but I don't see any
> harm in doing so -- memmove may be a little slower, but I doubt that
> this is a bottleneck in rancid.

Oh, you are a gentleman and a scholar. Thanks! It must now be using block
copy ops.
_______________________________________________
Rancid-discuss mailing list
Rancid-discuss@shrubbery.net
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Re: Problem backing up HP switches on RHEL 6.2 (x86_64) -- patch included [ In reply to ]
This patch works, though the diff provided was done in the wrong
direction.

--andy
_______________________________________________
Rancid-discuss mailing list
Rancid-discuss@shrubbery.net
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
Re: Problem backing up HP switches on RHEL 6.2 (x86_64) -- patch included [ In reply to ]
On 02/09/2012 01:27 AM, Andy Cobaugh wrote:
> This patch works, though the diff provided was done in the wrong
> direction.

Yeah. Sorry about that; I was a bit rushed yesterday.

--
David Byers.
_______________________________________________
Rancid-discuss mailing list
Rancid-discuss@shrubbery.net
http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss