mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Heckenbach <f.heckenbach@fh-soft.de>
To: linux-kernel@vger.kernel.org
Subject: procfs gives read/write access to RO/WO pipes
Date: Fri, 2 Jul 2010 21:35:50 +0200	[thread overview]
Message-ID: <1278099350.18949.339668@goedel.fjf.gnu.de> (raw)

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;
}

                 reply	other threads:[~2010-07-02 20:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1278099350.18949.339668@goedel.fjf.gnu.de \
    --to=f.heckenbach@fh-soft.de \
    --cc=linux-kernel@vger.kernel.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 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®