mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Libor Vanek <libor@conet.cz>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Read from file fails
Date: Tue, 4 May 2004 09:49:06 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.53.0405040947070.13706@chaos> (raw)
In-Reply-To: <20040504011957.GA20676@Loki>

On Tue, 4 May 2004, Libor Vanek wrote:

[SNIPPED...all]

Did you catch this information? If all you want to do is to
make a new version of a file, owned by the person who accesses the file
(like VAX/VMS), then you trap open with O_RDWR or O_CREAT or O_TRUNC
and make a copy with a numeral appended like: filename.typ;2.

You do this by making a shared object that does what you want.
The total affect upon user-mode code is a delayed (slow) open().


>From der.eremit@email.de Tue May  4 09:21:52 2004
To: Jan-Benedict Glaw <jbglaw@lug-owl.de>
From: Pascal Schmidt <der.eremit@email.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Reading from file in module fails

On Mon, 03 May 2004 14:50:10 +0200, you wrote in linux.kernel:

> That can all be done in userspace.
>
> $ export LD_PRELOAD=3Dlibcopyfilesbeforemodify.so
>
> You just need to program a library that provides all functions that
> modify files (eg. write, open with O_CREAT, ...) and you're done - 100%
> in userspace.

This won't catch asm programs that do syscalls by hand or statically
linked programs. If you really need to catch all write accesses, it
needs to be done in the kernel, probably as an LSM hook or something.

-- 
Ciao,
Pascal


Now, if you need to squirrel the file away to some secret location
owned by root, then you might want to use a kernel thread. It will
take the same time and delay the open the same amount.
Kernel mode is all about privilige, not about speed. A user-mode
program daemon that operates as root, could also perform the
same function by having the LD_PRELOAD code pipe information to
it. One needs to make sure that the daemon as finished copying
the file before the open() returns of it would be possible for
the original caller to trash the file before it was copied.

If I were given the task of; "Make sure that an idiot can't
delete his files in such a way they can't be restored....".
I'd use a daemon, simply because it's easier and more
interesting. Also, the daemon is configurable. It can read
some configuration file and the password file to find out
where to stash the "wastebaskets". You end up with an extensible
solution. Kernel mode programming is the last thing you want
to do, not the first. You can't access any of the 'C' runtime
library functions although there a few cloned for kernel
programming. It's a bitch to write your own string functions
in such a way that they catch all the corner cases that can
trash the kernel.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5557.45 BogoMips).
            Note 96.31% of all statistics are fiction.



  reply	other threads:[~2004-05-04 13:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-03  0:00 Libor Vanek
2004-05-03 13:11 ` Richard B. Johnson
2004-05-03 15:06   ` Libor Vanek
2004-05-04  0:47     ` Richard B. Johnson
2004-05-04  1:19       ` Libor Vanek
2004-05-04 13:49         ` Richard B. Johnson [this message]
2004-05-05 10:34           ` Libor Vanek
2004-05-04 14:31         ` Bart Samwel
2004-05-05  9:54           ` Libor Vanek
2004-05-05 10:04             ` Bart Samwel
2004-05-05 10:19               ` Libor Vanek
2004-05-05 10:45                 ` Bart Samwel
2004-05-05 11:22                   ` Libor Vanek
2004-05-05 11:50                     ` Bart Samwel
2004-05-05 10:54                 ` Denis Vlasenko
2004-05-05 11:58                   ` Michael Clark
2004-05-04 18:45         ` Paulo Marques
2004-05-05  9:47           ` Libor Vanek

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=Pine.LNX.4.53.0405040947070.13706@chaos \
    --to=root@chaos.analogic.com \
    --cc=libor@conet.cz \
    --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®