From: Renaud Barbier <renaud.barbier@ge.com>
To: barebox@lists.infradead.org
Subject: Re: [PATCH 13/13] ubifs: update implementation from u-boot v2016.03
Date: Tue, 19 Jul 2016 12:41:49 +0100 [thread overview]
Message-ID: <578E11FD.6050408@ge.com> (raw)
In-Reply-To: <1458208829-25570-14-git-send-email-alexander.stein@systec-electronic.com>
I just tested the v2016.07 version.
I noticed that the readlink function returns an empty variable and found
that symlink that used to appear as:
OWBOOT> / ls -l /mnt/
lrwxrwxrwx 7 active -> primary
drwxr-xr-x 472 primary
now appears as:
OWBOOT> / ls -l /mnt/
drwxr-xr-x 472 active
drwxr-xr-x 472 primary
It is due the ubifs_findfile function resolving the symlink as when the
code under "if ((inode->i_mode & S_IFMT) == S_IFLNK) {" is commented
out, the link is resolved by the ubifs_readlink entry point.
In another hand, it looks like ubifs_readlink does not deal with symlink
recursion.
On 17/03/2016 10:00, Alexander Stein wrote:
> -static struct inode *ubifs_findfile(struct super_block *sb, const char *filename)
> +static unsigned long ubifs_findfile(struct super_block *sb, const char *filename)
> {
> int ret;
> char *next;
> char fpath[128];
> + char symlinkpath[128];
> char *name = fpath;
> unsigned long root_inum = 1;
> unsigned long inum;
> - struct inode *inode = 0;
> + int symlink_count = 0; /* Don't allow symlink recursion */
> + char link_name[64];
>
> strcpy(fpath, filename);
>
> @@ -238,9 +514,12 @@ static struct inode *ubifs_findfile(struct super_block *sb, const char *filename
> */
> inum = root_inum;
> if (!name || *name == '\0')
> - return ubifs_iget(sb, 1);
> + return inum;
>
> for (;;) {
> + struct inode *inode;
> + struct ubifs_inode *ui;
> +
> /* Extract the actual part from the pathname. */
> next = strchr(name, '/');
> if (next) {
> @@ -248,13 +527,41 @@ static struct inode *ubifs_findfile(struct super_block *sb, const char *filename
> while (*next == '/')
> *(next++) = '\0';
> }
> +
> ret = ubifs_finddir(sb, name, root_inum, &inum);
> if (!ret)
> - break;
> -
> + return 0;
> inode = ubifs_iget(sb, inum);
> +
> if (!inode)
> - break;
> + return 0;
> + ui = ubifs_inode(inode);
> +
> + if ((inode->i_mode & S_IFMT) == S_IFLNK) {
> + char buf[128];
> +
> + /* We have some sort of symlink recursion, bail out */
> + if (symlink_count++ > 8) {
> + printf("Symlink recursion, aborting\n");
> + return 0;
> + }
> + memcpy(link_name, ui->data, ui->data_len);
> + link_name[ui->data_len] = '\0';
> +
> + if (link_name[0] == '/') {
> + /* Absolute path, redo everything without
> + * the leading slash */
> + next = name = link_name + 1;
> + root_inum = 1;
> + continue;
> + }
> + /* Relative to cur dir */
> + sprintf(buf, "%s/%s",
> + link_name, next == NULL ? "" : next);
> + memcpy(symlinkpath, buf, sizeof(buf));
> + next = name = symlinkpath;
> + continue;
> + }
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2016-07-19 11:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-17 10:00 [PATCH 00/13] ubifs update Alexander Stein
2016-03-17 10:00 ` [PATCH 01/13] mtd: cfi-flash: Set MTD's writebufsize Alexander Stein
2016-03-17 10:00 ` [PATCH 02/13] mtd: ubi: Set max_write_size to actual value read from flash Alexander Stein
2016-03-17 10:00 ` [PATCH 03/13] rbtree: Update to u-boot v2016.03 Alexander Stein
2016-03-17 10:00 ` [PATCH 04/13] printk: Add printk_once Alexander Stein
2016-03-17 10:00 ` [PATCH 05/13] Add list_sort from u-boot v2016.03 Alexander Stein
2016-03-17 10:00 ` [PATCH 06/13] printk: Add pr_cont Alexander Stein
2016-03-17 10:00 ` [PATCH 07/13] compiler*.h: include/linux/compiler*.h with Linux 4.5 Alexander Stein
2016-03-17 10:00 ` [PATCH 08/13] module.h: Add THIS_MODULE Alexander Stein
2016-03-17 10:00 ` [PATCH 09/13] ARM: Add atomic.h from u-boot v2016.03 Alexander Stein
2016-03-17 10:00 ` [PATCH 10/13] Move GFP_NOFS to barebox-wrapper Alexander Stein
2016-03-17 10:00 ` [PATCH 11/13] barebox-wrapper: Implement kfree and vfree as static inline functions Alexander Stein
2016-03-30 6:19 ` Sascha Hauer
2016-03-17 10:00 ` [PATCH 12/13] barebox-wrapper: Add kcalloc and __vmalloc Alexander Stein
2016-03-17 10:00 ` [PATCH 13/13] ubifs: update implementation from u-boot v2016.03 Alexander Stein
2016-07-19 11:41 ` Renaud Barbier [this message]
2016-07-21 6:30 ` Sascha Hauer
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=578E11FD.6050408@ge.com \
--to=renaud.barbier@ge.com \
--cc=barebox@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.