All of lore.kernel.org
 help / color / mirror / Atom feed
From: j.neuschaefer@gmx.net (Jonathan Neuschäfer)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Does Linux process exist information leakage?
Date: Tue, 17 Jan 2012 00:45:29 +0100	[thread overview]
Message-ID: <20120116234529.GA1542@debian.debian> (raw)
In-Reply-To: <CAFB9KM1PWSw1A=PAfLc-0sr3Xq1UUtqmUaCZ1_eTj=xRkn_7XA@mail.gmail.com>

On Mon, Jan 16, 2012 at 01:19:22PM -0500, Scott Lovenberg wrote:
> Let me walk you guys through how this bug could be exploited.
> The file that you want to access is blocked from you by file system
> permissions.  The root user (uid==0) can access this file (that contains
> credentials) and read it into memory that it has malloc()'ed.  After the
> process running as root is done, it free()'s the memory without zeroing it
> out.  Now you (you clever hacker) spawn a process that requests memory in
> large hunks.  It then searches for the string "password=" in that memory.
>  Since the memory was free()'ed back to the pool without being changed, it
> still contains the original information that was in the file that you
> cannot read.  Does this make sense, or should I go into t a bit more detail?

But can you actually get this dirty memory on Linux?

I know two sources of memory that are used by malloc. One is brk(), the
other is mmapped pages of /dev/zero. With /dev/zero it's obvious that
you get empty pages (all-zero); with brk I wasn't sure so I wrote the
test program below and ran it. I didn't find any dirty (non-zero) memory.

Thanks,
	Jonathan Neusch?fer


--
#include <unistd.h>
#include <stdio.h>

#define BLOCKSZ (1024 * 1024) /* one Mibi */

int main(void)
{
	int maxmb = 1024;
	unsigned i;
	void *BRK;

	BRK = sbrk(0);

	for (i = 0; i < maxmb; i++) {
		void *block = sbrk(BLOCKSZ);
		unsigned j, *p;

		if (block == (void *) -1) {
			printf("sbrk failed after %u blocks (%u bytes)\n", i, i * BLOCKSZ);
			break;
		}

		for (p = block, j = BLOCKSZ/sizeof(unsigned int); j--; p++)
			if (*p)
				printf("found data@BRK+%p: %u\n", ((void *)p) - BRK, *p);
	}

	return 0;
}

  reply	other threads:[~2012-01-16 23:45 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-11 12:53 Does Linux process exist information leakage? 夏业添
2012-01-11 16:23 ` Jonathan Neuschäfer
2012-01-11 16:45 ` Dave Hylands
2012-01-11 17:52   ` Scott Lovenberg
2012-01-12  2:14     ` 夏业添
2012-01-12 17:00     ` Jonathan Neuschäfer
2012-01-16 18:19       ` Scott Lovenberg
2012-01-16 23:45         ` Jonathan Neuschäfer [this message]
2012-01-19 14:47           ` Scott Lovenberg
2012-01-16 18:45       ` Greg Freemyer
2012-01-16 20:44         ` Scott Lovenberg
2012-01-12  2:05   ` 夏业添
2012-01-11 18:44 ` Greg Freemyer
2012-01-19 20:23   ` Rik van Riel
     [not found] ` <CAOfVmNFuBCjWb7-5rJaU7ksgcU8LyAW15JiEwa2PigZL3zC0aw@mail.gmail.com>
2012-01-12  2:30   ` 夏业添
2012-01-18  1:53 ` Fredrick
     [not found]   ` <CAOfVmNFN-GLDwkfLKG11iw7-p6KerDmyoMxV1oSD5WSYJMXc0g@mail.gmail.com>
2012-01-18 11:43     ` beyond.hack
2012-01-19  1:27   ` 夏业添
2012-01-19  7:12     ` SaNtosh kuLkarni
2012-01-19  8:37       ` SaNtosh kuLkarni
2012-01-20  6:52     ` Fredrick
2012-01-19 14:48   ` Scott Lovenberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120116234529.GA1542@debian.debian \
    --to=j.neuschaefer@gmx.net \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.