From: Valdis.Kletnieks@vt.edu
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
serue@us.ibm.com
Subject: Re: [PATCH][RFC] Simple tamper-proof device filesystem.
Date: Mon, 07 Jan 2008 12:09:40 -0500 [thread overview]
Message-ID: <6879.1199725780@turing-police.cc.vt.edu> (raw)
In-Reply-To: Your message of "Sun, 06 Jan 2008 15:20:00 +0900." <200801061520.JEF52626.LFHMtSQJOOVFFO@I-love.SAKURA.ne.jp>
[-- Attachment #1: Type: text/plain, Size: 4406 bytes --]
On Sun, 06 Jan 2008 15:20:00 +0900, Tetsuo Handa said:
> --- linux-2.6-mm.orig/fs/ramfs/inode.c
> +++ linux-2.6-mm/fs/ramfs/inode.c
> @@ -36,6 +36,20 @@
> #include <asm/uaccess.h>
> #include "internal.h"
>
> +static struct inode *__ramfs_get_inode(struct super_block *sb, int mode,
> + dev_t dev, bool tmpfs_with_mac);
> +
> +#define TMPFS_WITH_MAC 1
> +#define TMPFS_WITHOUT_MAC 0
> +#include <linux/quotaops.h>
> +
> +#ifdef CONFIG_SYAORAN
> +#include "syaoran.h"
> +#include "syaoran_init.c"
> +#include "syaoran_main.c"
> +#include "syaoran_debug.c"
> +#endif
Ouch. The .c files should generally be built into their own .o files and
then the Makefile should do something like
obj-$(CONFIG_SYAORAN) += syaoran.o
unless there's *really* good reasons for including .c files (such as an
otherwise-messy variable-namespace issue or similar).
Also, has this been double-checked to Do The Right Thing if you have
*two* instances of ramfs mounted, one with Syaoran and one without? I don't
know the code well enough to know if you found *all* the places you need
something like:
> - inode = ramfs_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0);
> +#ifdef CONFIG_SYAORAN
> + /*** SYAORAN start. ***/
> + if (dir->i_sb->s_op == &syaoran_ops) {
> + if (syaoran_may_create_node(dentry, S_IFLNK, 0) < 0)
> + return -EPERM;
> + inode = syaoran_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0);
> + /*** SYAORAN end. ***/
> + } else
> +#endif
> + inode = ramfs_get_inode(dir->i_sb, S_IFLNK|S_IRWXUGO, 0);
(incidentally, all of these should probably be abstracted into a helper
function that's 'static inline' so we have just one #ifdef in the definition
in a .h file, and none in open .c code).
Similarly for other places you have #ifdef CONFIG_ in ramfs .c code - see if
you can abstract it out.
> +/*
> + * Original tmpfs doesn't set ramfs_dir_inode_operations.setattr field.
> + * Now I'm setting the field to share tmpfs/rootfs/syaoran code.
Question for the audience: *should* ramfs set that field so setattr works
on ramfs (even if it's just a stub similar to the SELinux fscontext= mount
stuff)?
Question for Tetsuo: What happens to this code if somebody actually does the
above change?
> --- linux-2.6-mm.orig/fs/Kconfig
> +++ linux-2.6-mm/fs/Kconfig
> @@ -978,6 +978,24 @@ config TMPFS_POSIX_ACL
> + "Applications using well-known device locations under /dev
> + get the device they want" (e.g. an application that accesses
> + /dev/null can always get a character special device
> + with major=1 and minor=3).
This should say "will always get", not "can always", as this code will
mandate, rather than just make possible.
> + The list of possible combinations of filename and its attributes
> + that can exist on this filesystem is defined at mount time
> + using a configuration file.
The format of this file needs to be documented. I'm not terribly thrilled by
the idea of passing a file to be read by the kernel, but I also understand
that if it isn't done before mount, you have a race condition betweet the
mount and the load. Perhaps write some configfs code so that you can
'mount /configfs; cat config.file > /configfs/syaoran; mount -t syaoran"?
Similarly, it looks like you create your debug files inside the ramfs - that
is probably a bad idea and possibly can exhaust resources. Convert it to
use debugfs instead?
> + if (!filename) {
> + printk(KERN_INFO "SYAORAN: Missing config-file path.\n");
> + return -EINVAL;
Does this (and the code right after Do The Right Thing if somebody does this:
mount -t syaoran -o noatime,noexec /some/path
(I admit not knowing if mount options common to all mounts are stripped out
by the VFS code or passed down to this code).
Or even worse, "-o noatime,accept=/some/path/ramfs.cfg"?
> + f = open_pathname(AT_FDCWD, filename, O_RDONLY, 0600);
> + if (IS_ERR(f)) {
> + printk(KERN_INFO "SYAORAN: Can't open '%s'\n", filename);
> + return -EINVAL;
> + }
Does this do what you think it does if run in a chroot process or if
some creative person does "accept=../../path/to/bad_data.cfg"?
That printk should be KERN_ERR, I think.
That's all that's immediately obvious to me - somebody who actually understands
the filesystem code better will probably need to review it for all the stuff
I missed before it can be included.
[-- Attachment #2: Type: application/pgp-signature, Size: 226 bytes --]
next prev parent reply other threads:[~2008-01-07 17:09 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-23 14:44 Tetsuo Handa
2007-12-31 20:02 ` Serge E. Hallyn
2008-01-01 2:16 ` Tetsuo Handa
2008-01-06 6:20 ` Tetsuo Handa
2008-01-06 6:26 ` Willy Tarreau
2008-01-06 7:36 ` Tetsuo Handa
2008-01-06 7:45 ` Willy Tarreau
2008-01-06 15:20 ` Tetsuo Handa
2008-01-07 20:37 ` Indan Zupancic
2008-01-08 13:50 ` Tetsuo Handa
2008-01-08 15:47 ` Indan Zupancic
2008-01-09 4:39 ` Tetsuo Handa
2008-01-09 13:59 ` Indan Zupancic
2008-01-09 23:08 ` Serge E. Hallyn
2008-01-10 1:06 ` Indan Zupancic
2008-01-10 4:57 ` Tetsuo Handa
2008-01-10 23:05 ` Indan Zupancic
2008-01-11 8:46 ` Tetsuo Handa
2008-01-11 12:22 ` Indan Zupancic
2008-01-11 14:05 ` Tetsuo Handa
2008-01-11 14:46 ` Lennart Sorensen
2008-01-07 17:09 ` Valdis.Kletnieks [this message]
2008-01-08 13:50 ` Tetsuo Handa
2008-01-09 5:04 ` Valdis.Kletnieks
2008-01-09 6:26 ` Tetsuo Handa
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=6879.1199725780@turing-police.cc.vt.edu \
--to=valdis.kletnieks@vt.edu \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=serue@us.ibm.com \
/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®