mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Fixed endless loop for `p/x *(int *)0xf0000000'. kvm_uread() in
gdb was cloned from the buggy version of kvm_uread() in libkvm and had the same bugs. It looped endlessly on EOF and checked errno without setting it in the lseek() error check. The first bug caused gdb to loop endlessly for reads from addresses between the end of the user area and the start of the kernel text. kvm_uread() should not be used for addresses beyond the end of the user area, but is due to bugs elsewhere.
This commit is contained in:
parent
941b2747b6
commit
8c2c0a1d2f
3 changed files with 30 additions and 21 deletions
|
|
@ -578,11 +578,8 @@ kvm_uread (core_kd, p, memaddr, myaddr, len)
|
|||
|
||||
if (devmem)
|
||||
{
|
||||
cp = myaddr;
|
||||
|
||||
sprintf (procfile, "/proc/%d/mem", p->p_pid);
|
||||
fd = open (procfile, O_RDONLY, 0);
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
error ("cannot open %s", procfile);
|
||||
|
|
@ -590,12 +587,13 @@ kvm_uread (core_kd, p, memaddr, myaddr, len)
|
|||
return (0);
|
||||
}
|
||||
|
||||
cp = myaddr;
|
||||
while (len > 0)
|
||||
{
|
||||
if (lseek (fd, memaddr, 0) == -1 && errno != 0)
|
||||
errno = 0;
|
||||
if (lseek (fd, (off_t)memaddr, 0) == -1 && errno != 0)
|
||||
{
|
||||
error ("invalid address (%x) in %s",
|
||||
memaddr, procfile);
|
||||
error ("invalid address (%x) in %s", memaddr, procfile);
|
||||
break;
|
||||
}
|
||||
amount = read (fd, cp, len);
|
||||
|
|
@ -604,13 +602,18 @@ kvm_uread (core_kd, p, memaddr, myaddr, len)
|
|||
error ("error reading %s", procfile);
|
||||
break;
|
||||
}
|
||||
if (amount == 0)
|
||||
{
|
||||
error ("EOF reading %s", procfile);
|
||||
break;
|
||||
}
|
||||
cp += amount;
|
||||
memaddr += amount;
|
||||
len -= amount;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
return (ssize_t) (cp - myaddr);
|
||||
return ((ssize_t) (cp - myaddr));
|
||||
}
|
||||
else
|
||||
return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
|
||||
|
|
|
|||
|
|
@ -578,11 +578,8 @@ kvm_uread (core_kd, p, memaddr, myaddr, len)
|
|||
|
||||
if (devmem)
|
||||
{
|
||||
cp = myaddr;
|
||||
|
||||
sprintf (procfile, "/proc/%d/mem", p->p_pid);
|
||||
fd = open (procfile, O_RDONLY, 0);
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
error ("cannot open %s", procfile);
|
||||
|
|
@ -590,12 +587,13 @@ kvm_uread (core_kd, p, memaddr, myaddr, len)
|
|||
return (0);
|
||||
}
|
||||
|
||||
cp = myaddr;
|
||||
while (len > 0)
|
||||
{
|
||||
if (lseek (fd, memaddr, 0) == -1 && errno != 0)
|
||||
errno = 0;
|
||||
if (lseek (fd, (off_t)memaddr, 0) == -1 && errno != 0)
|
||||
{
|
||||
error ("invalid address (%x) in %s",
|
||||
memaddr, procfile);
|
||||
error ("invalid address (%x) in %s", memaddr, procfile);
|
||||
break;
|
||||
}
|
||||
amount = read (fd, cp, len);
|
||||
|
|
@ -604,13 +602,18 @@ kvm_uread (core_kd, p, memaddr, myaddr, len)
|
|||
error ("error reading %s", procfile);
|
||||
break;
|
||||
}
|
||||
if (amount == 0)
|
||||
{
|
||||
error ("EOF reading %s", procfile);
|
||||
break;
|
||||
}
|
||||
cp += amount;
|
||||
memaddr += amount;
|
||||
len -= amount;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
return (ssize_t) (cp - myaddr);
|
||||
return ((ssize_t) (cp - myaddr));
|
||||
}
|
||||
else
|
||||
return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
|
||||
|
|
|
|||
|
|
@ -578,11 +578,8 @@ kvm_uread (core_kd, p, memaddr, myaddr, len)
|
|||
|
||||
if (devmem)
|
||||
{
|
||||
cp = myaddr;
|
||||
|
||||
sprintf (procfile, "/proc/%d/mem", p->p_pid);
|
||||
fd = open (procfile, O_RDONLY, 0);
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
error ("cannot open %s", procfile);
|
||||
|
|
@ -590,12 +587,13 @@ kvm_uread (core_kd, p, memaddr, myaddr, len)
|
|||
return (0);
|
||||
}
|
||||
|
||||
cp = myaddr;
|
||||
while (len > 0)
|
||||
{
|
||||
if (lseek (fd, memaddr, 0) == -1 && errno != 0)
|
||||
errno = 0;
|
||||
if (lseek (fd, (off_t)memaddr, 0) == -1 && errno != 0)
|
||||
{
|
||||
error ("invalid address (%x) in %s",
|
||||
memaddr, procfile);
|
||||
error ("invalid address (%x) in %s", memaddr, procfile);
|
||||
break;
|
||||
}
|
||||
amount = read (fd, cp, len);
|
||||
|
|
@ -604,13 +602,18 @@ kvm_uread (core_kd, p, memaddr, myaddr, len)
|
|||
error ("error reading %s", procfile);
|
||||
break;
|
||||
}
|
||||
if (amount == 0)
|
||||
{
|
||||
error ("EOF reading %s", procfile);
|
||||
break;
|
||||
}
|
||||
cp += amount;
|
||||
memaddr += amount;
|
||||
len -= amount;
|
||||
}
|
||||
|
||||
close (fd);
|
||||
return (ssize_t) (cp - myaddr);
|
||||
return ((ssize_t) (cp - myaddr));
|
||||
}
|
||||
else
|
||||
return (kernel_core_file_hook (core_kd, memaddr, myaddr, len));
|
||||
|
|
|
|||
Loading…
Reference in a new issue