Skip to contentSkip to conversation

f2fs: Fix a system panic caused by f2fs_follow_link

PATCH Applied Yunlei He 2 participants 2 messages Nov 28, 2015 – Nov 30, 2015 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: Fix a system panic caused by f2fs_follow_link

In linux 3.10, we can not make sure the return value of nd_get_link function is valid. So this patch add a check before use it.

---
 fs/f2fs/namei.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/f2fs/namei.c +6 -1
index 336d43d..bfaec10 100644
@@ -319,13 +319,18 @@ fail:
 static void *f2fs_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
 	struct page *page;
+	char *link;
 
 	page = page_follow_link_light(dentry, nd);
 	if (IS_ERR(page))
 		return page;
 
+	link = nd_get_link(nd);
+	if (IS_ERR(link))
+		return link;
+
 	/* this is broken symlink case */
-	if (*nd_get_link(nd) == 0) {
+	if (*link == 0) {
 		kunmap(page);
 		page_cache_release(page);
 		return ERR_PTR(-ENOENT);
Signature · 4 lines
1.9.1


------------------------------------------------------------------------------
maintainer Applied
#1 lore raw

Hi Yunlei,

Merged into the new 3.10 repo:

http://git.kernel.org/cgit/linux/kernel/git/jaegeuk/f2fs-stable.git/log/?h=linux-3.10.y

Thanks,

Quoted 36 lines · Yunlei He

In linux 3.10, we can not make sure the return value of nd_get_link function is valid. So this patch add a check before use it.

---
 fs/f2fs/namei.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
fs/f2fs/namei.c +6 -1
index 336d43d..bfaec10 100644
@@ -319,13 +319,18 @@ fail:
 static void *f2fs_follow_link(struct dentry *dentry, struct nameidata *nd)
 {
 	struct page *page;
+	char *link;
 
 	page = page_follow_link_light(dentry, nd);
 	if (IS_ERR(page))
 		return page;
 
+	link = nd_get_link(nd);
+	if (IS_ERR(link))
+		return link;
+
 	/* this is broken symlink case */
-	if (*nd_get_link(nd) == 0) {
+	if (*link == 0) {
 		kunmap(page);
 		page_cache_release(page);
 		return ERR_PTR(-ENOENT);
Signature · 1 line
1.9.1

------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK. Use one codebase in this all-in-one HTML5 development environment. Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140