lkml.org 
[lkml]   [2018]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] add some safety checks for label store interface of flash dev in sysfs
Date
do some checks on the label's length and ending.

Signed-off-by: Dongbo Cao <cdbdyx@163.com>
---
drivers/md/bcache/sysfs.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index e64c718f..cce793ef 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -447,8 +447,15 @@ STORE(__bch_flash_dev)
}

if (attr == &sysfs_label) {
+ if (size > SB_LABEL_SIZE)
+ return -EINVAL;
memcpy(u->label, buf, SB_LABEL_SIZE);
- bch_uuid_write(d->c);
+ if (size < SB_LABEL_SIZE)
+ u->label[size] = '\0';
+ if (size && u->label[size - 1] == '\n')
+ u->label[size - 1] = '\0';
+ if(d->c)
+ bch_uuid_write(d->c);
}

if (attr == &sysfs_unregister) {
--
2.17.1

\
 
 \ /
  Last update: 2018-09-14 12:13    [W:0.045 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site