mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kent Overstreet <kmo@daterainc.com>
To: torvalds@linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-bcache@vger.kernel.org
Cc: axboe@kernel.dk, Gabriel de Perthuis <g2p.code@gmail.com>,
	Kent Overstreet <kmo@daterainc.com>,
	stable@vger.kernel.org
Subject: [PATCH 03/11] bcache: Strip endline when writing the label through sysfs
Date: Mon, 23 Sep 2013 23:17:28 -0700	[thread overview]
Message-ID: <1380003456-19938-4-git-send-email-kmo@daterainc.com> (raw)
In-Reply-To: <1380003456-19938-1-git-send-email-kmo@daterainc.com>

From: Gabriel de Perthuis <g2p.code@gmail.com>

sysfs attributes with unusual characters have crappy failure modes
in Squeeze (udev 164); later versions of udev are unaffected.

This should make these characters more unusual.

Signed-off-by: Gabriel de Perthuis <g2p.code@gmail.com>
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Cc: linux-stable <stable@vger.kernel.org> # >= v3.10
---
 drivers/md/bcache/sysfs.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index 4fe6ab2..924dcfd 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -223,8 +223,13 @@ STORE(__cached_dev)
 	}
 
 	if (attr == &sysfs_label) {
-		/* note: endlines are preserved */
-		memcpy(dc->sb.label, buf, SB_LABEL_SIZE);
+		if (size > SB_LABEL_SIZE)
+			return -EINVAL;
+		memcpy(dc->sb.label, buf, size);
+		if (size < SB_LABEL_SIZE)
+			dc->sb.label[size] = '\0';
+		if (size && dc->sb.label[size - 1] == '\n')
+			dc->sb.label[size - 1] = '\0';
 		bch_write_bdev_super(dc, NULL);
 		if (dc->disk.c) {
 			memcpy(dc->disk.c->uuids[dc->disk.id].label,
-- 
1.8.4.rc3


  parent reply	other threads:[~2013-09-24  6:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-24  6:17 [PATCH] Bcache fixes - please apply Kent Overstreet
2013-09-24  6:17 ` [PATCH 01/11] block: Fix bio_copy_data() Kent Overstreet
2013-09-24  6:17 ` [PATCH 02/11] bcache: Fix a dumb journal discard bug Kent Overstreet
2013-09-24  6:17 ` Kent Overstreet [this message]
2013-09-24  6:17 ` [PATCH 04/11] bcache: Fix for when no journal entries are found Kent Overstreet
2013-09-24  6:17 ` [PATCH 05/11] bcache: Correct printf()-style format length modifier Kent Overstreet
2013-09-24  6:17 ` [PATCH 06/11] bcache: Fix a writeback performance regression Kent Overstreet
2013-09-24  6:17 ` [PATCH 07/11] bcache: Fix a flush/fua performance bug Kent Overstreet
2013-09-24  6:17 ` [PATCH 08/11] bcache: Fix a dumb CPU spinning bug in writeback Kent Overstreet
2013-09-24  6:17 ` [PATCH 09/11] bcache: Fix a shrinker deadlock Kent Overstreet
2013-09-24  6:17 ` [PATCH 10/11] bcache: Fix for handling overlapping extents when reading in a btree node Kent Overstreet
2013-09-24  6:17 ` [PATCH 11/11] bcache: Fix flushes in writeback mode Kent Overstreet

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=1380003456-19938-4-git-send-email-kmo@daterainc.com \
    --to=kmo@daterainc.com \
    --cc=axboe@kernel.dk \
    --cc=g2p.code@gmail.com \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.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®