mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* procfs gives read/write access to RO/WO pipes
@ 2010-07-02 19:35 Frank Heckenbach
  0 siblings, 0 replies; only message in thread
From: Frank Heckenbach @ 2010-07-02 19:35 UTC (permalink / raw)
  To: linux-kernel

Using /proc/*/fd, you can get read/write access to a pipe that you
have read-only or write-only access to. The program below
demonstrates this. It reads and writes through the "0" fd.
Tested with 2.6.34, i686.

At first sight, it doesn't look too serious if a program can write
to its own readable pipe, or read from its writeable pipe, but
perhaps I'm just not creative enough to see an exploit. Also, I
don't know it it might affect other file types where it might be a
real problem. At least, it does seem to violate the permissions.

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

int main ()
{
  char a, n[64];
  int p[2], f, r;
  pipe (p);
  sprintf (n, "/proc/self/fd/%i", p[0]);
  f = open (n, O_RDWR);
  write (f, "x", 1);
  r = read (f, &a, 1);
  fprintf (stderr, "%i %c\n", r, a);
  return 0;
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-07-02 20:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-02 19:35 procfs gives read/write access to RO/WO pipes Frank Heckenbach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®