Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1298797 > unrolled thread
| Started by | Jaegeuk Kim <jaegeuk@kernel.org> |
|---|---|
| First post | 2015-12-29 00:40 +0100 |
| Last post | 2015-12-30 01:50 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH 1/3] f2fs: early check broken symlink length in the encrypted case Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-29 00:40 +0100
RE: [f2fs-dev] [PATCH 1/3] f2fs: early check broken symlink length in the encrypted case Chao Yu <chao2.yu@samsung.com> - 2015-12-29 03:00 +0100
Re: [f2fs-dev] [PATCH 1/3] f2fs: early check broken symlink length in the encrypted case Jaegeuk Kim <jaegeuk@kernel.org> - 2015-12-30 01:50 +0100
| From | Jaegeuk Kim <jaegeuk@kernel.org> |
|---|---|
| Date | 2015-12-29 00:40 +0100 |
| Subject | [PATCH 1/3] f2fs: early check broken symlink length in the encrypted case |
| Message-ID | <qKPyp-zX-9@gated-at.bofh.it> |
If link is broken, its len is zero, and we don't need to move forward.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/namei.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index fb41c80..5cc4128 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -931,7 +931,7 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void **cook
{
struct page *cpage = NULL;
char *caddr, *paddr = NULL;
- struct f2fs_str cstr;
+ struct f2fs_str cstr = FSTR_INIT(NULL, 0);
struct f2fs_str pstr = FSTR_INIT(NULL, 0);
struct inode *inode = d_inode(dentry);
struct f2fs_encrypted_symlink_data *sd;
@@ -952,6 +952,12 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void **cook
/* Symlink is encrypted */
sd = (struct f2fs_encrypted_symlink_data *)caddr;
cstr.len = le16_to_cpu(sd->len);
+
+ /* this is broken symlink case */
+ if (cstr.len == 0) {
+ res = -ENOENT;
+ goto errout;
+ }
cstr.name = kmalloc(cstr.len, GFP_NOFS);
if (!cstr.name) {
res = -ENOMEM;
@@ -960,7 +966,7 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void **cook
memcpy(cstr.name, sd->encrypted_path, cstr.len);
/* this is broken symlink case */
- if (cstr.name[0] == 0 && cstr.len == 0) {
+ if (cstr.name[0] == 0) {
res = -ENOENT;
goto errout;
}
--
2.5.4 (Apple Git-61)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Chao Yu <chao2.yu@samsung.com> |
|---|---|
| Date | 2015-12-29 03:00 +0100 |
| Subject | RE: [f2fs-dev] [PATCH 1/3] f2fs: early check broken symlink length in the encrypted case |
| Message-ID | <qKRJU-24Y-1@gated-at.bofh.it> |
| In reply to | #1298797 |
Hi Jaegeuk,
> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Tuesday, December 29, 2015 7:32 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim
> Subject: [f2fs-dev] [PATCH 1/3] f2fs: early check broken symlink length in the encrypted case
>
> If link is broken, its len is zero, and we don't need to move forward.
>
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
> fs/f2fs/namei.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index fb41c80..5cc4128 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -931,7 +931,7 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void
> **cook
> {
> struct page *cpage = NULL;
> char *caddr, *paddr = NULL;
> - struct f2fs_str cstr;
> + struct f2fs_str cstr = FSTR_INIT(NULL, 0);
> struct f2fs_str pstr = FSTR_INIT(NULL, 0);
> struct inode *inode = d_inode(dentry);
> struct f2fs_encrypted_symlink_data *sd;
> @@ -952,6 +952,12 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void
> **cook
> /* Symlink is encrypted */
> sd = (struct f2fs_encrypted_symlink_data *)caddr;
> cstr.len = le16_to_cpu(sd->len);
> +
> + /* this is broken symlink case */
> + if (cstr.len == 0) {
This case seems rare, can we add unlikely here?
> + res = -ENOENT;
> + goto errout;
> + }
> cstr.name = kmalloc(cstr.len, GFP_NOFS);
> if (!cstr.name) {
> res = -ENOMEM;
> @@ -960,7 +966,7 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void
> **cook
> memcpy(cstr.name, sd->encrypted_path, cstr.len);
>
> /* this is broken symlink case */
> - if (cstr.name[0] == 0 && cstr.len == 0) {
> + if (cstr.name[0] == 0) {
ditto.
Thanks,
> res = -ENOENT;
> goto errout;
> }
> --
> 2.5.4 (Apple Git-61)
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jaegeuk Kim <jaegeuk@kernel.org> |
|---|---|
| Date | 2015-12-30 01:50 +0100 |
| Subject | Re: [f2fs-dev] [PATCH 1/3] f2fs: early check broken symlink length in the encrypted case |
| Message-ID | <qLd7I-7Ke-3@gated-at.bofh.it> |
| In reply to | #1298821 |
Hi Chao,
On Tue, Dec 29, 2015 at 09:52:49AM +0800, Chao Yu wrote:
> Hi Jaegeuk,
>
> > -----Original Message-----
> > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> > Sent: Tuesday, December 29, 2015 7:32 AM
> > To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> > linux-f2fs-devel@lists.sourceforge.net
> > Cc: Jaegeuk Kim
> > Subject: [f2fs-dev] [PATCH 1/3] f2fs: early check broken symlink length in the encrypted case
> >
> > If link is broken, its len is zero, and we don't need to move forward.
> >
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> > fs/f2fs/namei.c | 10 ++++++++--
> > 1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> > index fb41c80..5cc4128 100644
> > --- a/fs/f2fs/namei.c
> > +++ b/fs/f2fs/namei.c
> > @@ -931,7 +931,7 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void
> > **cook
> > {
> > struct page *cpage = NULL;
> > char *caddr, *paddr = NULL;
> > - struct f2fs_str cstr;
> > + struct f2fs_str cstr = FSTR_INIT(NULL, 0);
> > struct f2fs_str pstr = FSTR_INIT(NULL, 0);
> > struct inode *inode = d_inode(dentry);
> > struct f2fs_encrypted_symlink_data *sd;
> > @@ -952,6 +952,12 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void
> > **cook
> > /* Symlink is encrypted */
> > sd = (struct f2fs_encrypted_symlink_data *)caddr;
> > cstr.len = le16_to_cpu(sd->len);
> > +
> > + /* this is broken symlink case */
> > + if (cstr.len == 0) {
>
> This case seems rare, can we add unlikely here?
Agreed.
Will change them.
Thanks,
>
> > + res = -ENOENT;
> > + goto errout;
> > + }
> > cstr.name = kmalloc(cstr.len, GFP_NOFS);
> > if (!cstr.name) {
> > res = -ENOMEM;
> > @@ -960,7 +966,7 @@ static const char *f2fs_encrypted_follow_link(struct dentry *dentry, void
> > **cook
> > memcpy(cstr.name, sd->encrypted_path, cstr.len);
> >
> > /* this is broken symlink case */
> > - if (cstr.name[0] == 0 && cstr.len == 0) {
> > + if (cstr.name[0] == 0) {
>
> ditto.
>
> Thanks,
>
> > res = -ENOENT;
> > goto errout;
> > }
> > --
> > 2.5.4 (Apple Git-61)
> >
> >
> > ------------------------------------------------------------------------------
> > _______________________________________________
> > Linux-f2fs-devel mailing list
> > Linux-f2fs-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web