lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Fri, 24 Aug 2012 17:20:48 +0530
From:	Prashant Shah <kerneldev100@...il.com>
To:	Dan Luedtke <mail@...rl.de>
Cc:	linux-fsdevel@...r.kernel.org, viro@...iv.linux.org.uk,
	akpm@...ux-foundation.org, chaosman@...ika.net, muthur@...il.com,
	kerolasa@....fi, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] fs: Introducing Lanyard Filesystem

Hi,

On Sun, Aug 19, 2012 at 5:08 AM, Dan Luedtke <mail@...rl.de> wrote:

> +
> +       /* allocate filesystem private data */
> +       fsi = kzalloc(sizeof(*fsi), GFP_KERNEL);
> +       if (!fsi)
> +               return -ENOMEM;
> +       spin_lock_init(&fsi->lock);
> +       sb->s_fs_info = fsi;
> +
> +       /* set blocksize to minimum size for fetching superblock */
> +       if (!sb_set_blocksize(sb, 1 << LANYFS_MIN_BLOCKSIZE)) {
> +               if (!silent)
> +                       lanyfs_err(sb, "error setting blocksize to %d bytes",
> +                                  1 << LANYFS_MIN_BLOCKSIZE);
> +               return -EIO;
> +       }
> +
> +       /* fetch superblock */
> +       bh = sb_bread(sb, LANYFS_SUPERBLOCK);
> +       if (!bh) {
> +               if (!silent)
> +                       lanyfs_err(sb, "error reading superblock");
> +               return -EIO;
> +       }
> +       lanysb = (struct lanyfs_sb *) bh->b_data;
> +
> +       /* check magic */
> +       if (lanysb->magic != cpu_to_le32(LANYFS_SUPER_MAGIC)) {
> +               if (!silent)
> +                       lanyfs_info(sb, "bad magic 0x%x",
> +                                   lanysb->magic);
> +               goto exit_invalid;
> +       }
> +       sb->s_magic = LANYFS_SUPER_MAGIC;
> +
> +       /* check block type */
> +       if (lanysb->type != LANYFS_TYPE_SB) {
> +               if (!silent)
> +                       lanyfs_err(sb, "bad block type 0x%x", lanysb->type);
> +               goto exit_invalid;
> +       }
> +
> +       /* check version */
> +       if (lanysb->major > LANYFS_MAJOR_VERSION) {
> +               if (!silent)
> +                       lanyfs_err(sb, "major version mismatch");
> +               goto exit_invalid;
> +       }
> +
> +       /* check address length */
> +       if (lanysb->addrlen < LANYFS_MIN_ADDRLEN ||
> +           lanysb->addrlen > LANYFS_MAX_ADDRLEN) {
> +               if (!silent)
> +                       lanyfs_err(sb, "unsupported address length");
> +               goto exit_invalid;
> +       }
> +       fsi->addrlen = lanysb->addrlen;
> +
> +       /* check blocksize */
> +       if (lanysb->blocksize < LANYFS_MIN_BLOCKSIZE ||
> +           lanysb->blocksize > LANYFS_MAX_BLOCKSIZE) {
> +               if (!silent)
> +                       lanyfs_err(sb, "unsupported blocksize");
> +               goto exit_invalid;
> +       }
> +       fsi->blocksize = lanysb->blocksize;
> +

> +
> +       /* release block buffer */
> +       brelse(bh);
> +
> +       /* parse mount options */
> +       save_mount_options(sb, options);
> +       err = lanyfs_super_options(sb, (char *) options, silent);
> +       if (err)
> +               return err;
> +
> +       /* set blocksize to correct size */
> +       if (!sb_set_blocksize(sb, 1 << fsi->blocksize)) {
> +               if (!silent)
> +                       lanyfs_err(sb, "error setting blocksize to %d bytes",
> +                                  1 << fsi->blocksize);
> +               return -EIO;
> +       }
> +       /* default flags */
> +       sb->s_maxbytes = 0xffffffff; /* TODO: hmmmmm */
> +       sb->s_op = &lanyfs_super_operations;
> +       sb->s_time_gran = 1;
> +       sb->s_flags = MS_NOSUID | MS_NOATIME | MS_NODIRATIME;
> +
> +       /* make root directory */
> +       inode = lanyfs_iget(sb, fsi->rootdir);
> +       if (!inode)
> +               return -ENOMEM;
> +
> +       sb->s_root = d_make_root(inode);
> +       if (!sb->s_root) {
> +               iput(inode);
> +               return -ENOMEM;
> +       }
> +       return 0;
> +
> +exit_invalid:
> +       brelse(bh);
> +       if (!silent)
> +               lanyfs_info(sb, "no valid lanyard filesystem found");
> +       return -EINVAL;
> +}

You should free the memory for "fsi" on error.

Regards.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ