Re: v2.6.28-rc1: readlink /proc/*/exe returns uninitialized data to userspace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 04, 2008 at 01:07:57PM +0300, Alexey Dobriyan wrote:
> On Tue, Nov 04, 2008 at 01:00:50PM +0300, Alexey Dobriyan wrote:
> > On Tue, Nov 04, 2008 at 10:39:19AM +0100, Vegard Nossum wrote:
> > > # uname -a
> > > Linux ubuntu 2.6.28-rc2-next-20081031 #60 SMP Sat Nov 1 13:19:49 CET
> > > 2008 i686 GNU/Linux
> > > # prelink -mRf /sbin/udevd
> > > # ./a.out /proc/4764/exe
> > > warning: /proc/4764/exe: got return value 38, expected 11
> > > 2f7362696e2f756465766400fffffffffdfffffffffffff7ffffbfff202864656c6574656429
> > > /sbin/udevd                  (deleted)
> > 
> > reproduced
> 
> prelink does
> 
> 	rename("/sbin/udevd.#prelink#.N6pvOJ", "/sbin/udevd")

OK, here is obvious (lame) reproducer, second readlink returns 32 while first
returns 18:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main(void)
{
	int fd, fd1;
	char buf[64], buf1[64], img[42000];
	ssize_t len;

	fd = open("/proc/self/exe", O_RDONLY);

	readlink("/proc/self/exe", buf, sizeof(buf));
	strcpy(buf1, buf);
	strcat(buf1, ".xxx");
	unlink(buf1);
	fd1 = open(buf1, O_WRONLY|O_CREAT);
	len = read(fd, img, sizeof(img));
	close(fd);
	write(fd1, img, len);
	close(fd1);
	rename(buf1, buf);

	readlink("/proc/self/exe", buf, sizeof(buf));

	return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux