mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Martin Brandenburg <martin@omnibond.com>
To: andy.shevchenko@gmail.com, hubcap@omnibond.com,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Cc: Martin Brandenburg <martin@omnibond.com>
Subject: [PATCH] orangefs: strncpy -> strscpy
Date: Fri,  8 Apr 2016 13:33:21 -0400	[thread overview]
Message-ID: <1460136801-32480-1-git-send-email-martin@omnibond.com> (raw)
In-Reply-To: <alpine.BSO.2.20.1604081308020.3028@tp.mkb.name>

It would have been possible for a rogue client-core to send in a symlink
target which is not NUL terminated. This returns EIO if the client-core
gives us corrupt data.

Leave debugfs and superblock code as is for now.

Other dcache.c and namei.c strncpy instances are safe because
ORANGEFS_NAME_MAX = NAME_MAX + 1; there is always enough space for a
name plus a NUL byte.

Signed-off-by: Martin Brandenburg <martin@omnibond.com>
---
 fs/orangefs/orangefs-utils.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c
index 40f5163..f392a6a 100644
--- a/fs/orangefs/orangefs-utils.c
+++ b/fs/orangefs/orangefs-utils.c
@@ -315,9 +315,13 @@ int orangefs_inode_getattr(struct inode *inode, int new, int size)
 			inode->i_size = (loff_t)strlen(new_op->
 			    downcall.resp.getattr.link_target);
 			orangefs_inode->blksize = (1 << inode->i_blkbits);
-			strlcpy(orangefs_inode->link_target,
+			ret = strscpy(orangefs_inode->link_target,
 			    new_op->downcall.resp.getattr.link_target,
 			    ORANGEFS_NAME_MAX);
+			if (ret == -E2BIG) {
+				ret = -EIO;
+				goto out;
+			}
 			inode->i_link = orangefs_inode->link_target;
 		}
 		break;
-- 
1.8.3.1

  reply	other threads:[~2016-04-08 17:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-04 20:26 [PATCH 1/3] orangefs: clean up truncate ctime and mtime setting Martin Brandenburg
2016-04-04 20:26 ` [PATCH 2/3] orangefs: strncpy -> strlcpy Martin Brandenburg
2016-04-07 18:39   ` Andy Shevchenko
2016-04-07 19:43     ` Mike Marshall
2016-04-08 15:34       ` martin
2016-04-08 16:02         ` Andy Shevchenko
2016-04-08 17:16           ` martin
2016-04-08 17:33             ` Martin Brandenburg [this message]
2016-04-04 20:26 ` [PATCH 3/3] orangefs: remove unused variable Martin Brandenburg

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=1460136801-32480-1-git-send-email-martin@omnibond.com \
    --to=martin@omnibond.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=hubcap@omnibond.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®