From: Xi Wang <xi.wang@gmail.com>
To: Sage Weil <sage@newdream.net>
Cc: ceph-devel@vger.kernel.org, Xi Wang <xi.wang@gmail.com>
Subject: [PATCH 3/3] ceph: avoid panic with mismatched symbolic link sizes in fill_inode()
Date: Wed, 14 Dec 2011 15:24:33 -0500 [thread overview]
Message-ID: <1323894273-13904-4-git-send-email-xi.wang@gmail.com> (raw)
In-Reply-To: <1323894273-13904-1-git-send-email-xi.wang@gmail.com>
Return -EINVAL with mismatched iinfo->symlink_len and inode->i_size.
Also use kstrndup rather than kmalloc/memcpy.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
---
fs/ceph/inode.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 87fb132..d100cd6 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -678,18 +678,18 @@ static int fill_inode(struct inode *inode,
case S_IFLNK:
inode->i_op = &ceph_symlink_iops;
if (!ci->i_symlink) {
- int symlen = iinfo->symlink_len;
+ u32 symlen = iinfo->symlink_len;
char *sym;
- BUG_ON(symlen != inode->i_size);
spin_unlock(&ci->i_ceph_lock);
+ err = -EINVAL;
+ if (symlen != inode->i_size)
+ goto out;
err = -ENOMEM;
- sym = kmalloc(symlen+1, GFP_NOFS);
+ sym = kstrndup(iinfo->symlink, symlen, GFP_NOFS);
if (!sym)
goto out;
- memcpy(sym, iinfo->symlink, symlen);
- sym[symlen] = 0;
spin_lock(&ci->i_ceph_lock);
if (!ci->i_symlink)
--
1.7.5.4
prev parent reply other threads:[~2011-12-14 20:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-14 20:24 [PATCH 0/3] ceph: fix multiple out-of-bounds checks Xi Wang
2011-12-14 20:24 ` [PATCH 1/3] ceph: fix out-of-bounds pointers in parse_reply_info() Xi Wang
2011-12-14 20:24 ` [PATCH 2/3] ceph: fix bounds check macros ceph_decode_need and ceph_encode_need Xi Wang
2012-04-18 14:13 ` Alex Elder
2012-04-18 17:53 ` Sage Weil
2012-04-18 18:41 ` Alex Elder
2011-12-14 20:24 ` Xi Wang [this message]
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=1323894273-13904-4-git-send-email-xi.wang@gmail.com \
--to=xi.wang@gmail.com \
--cc=ceph-devel@vger.kernel.org \
--cc=sage@newdream.net \
/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