* [PATCH] ubifs: prefer kstrtobool_from_user() over custom helper
@ 2026-04-02 8:13 Dmitry Antipov
2026-04-02 11:18 ` Zhihao Cheng
0 siblings, 1 reply; 16+ messages in thread
From: Dmitry Antipov @ 2026-04-02 8:13 UTC (permalink / raw)
To: Richard Weinberger; +Cc: Zhihao Cheng, linux-mtd, Dmitry Antipov
Adjust 'dfs_file_write()' and 'dfs_global_file_write()' to prefer generic
'kstrtobool_from_user()' over an ad-hoc 'interpret_user_input()' helper,
thus making the latter not needed anymore.
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
fs/ubifs/debug.c | 44 ++++++++++----------------------------------
1 file changed, 10 insertions(+), 34 deletions(-)
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 160c16aa7b6e..252cf82012cf 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2732,39 +2732,14 @@ static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,
return provide_user_output(val, u, count, ppos);
}
-/**
- * interpret_user_input - interpret user debugfs file input.
- * @u: user-provided buffer with the input
- * @count: buffer size
- *
- * This is a helper function which interpret user input to a boolean UBIFS
- * debugfs file. Returns %0 or %1 in case of success and a negative error code
- * in case of failure.
- */
-static int interpret_user_input(const char __user *u, size_t count)
-{
- size_t buf_size;
- char buf[8];
-
- buf_size = min_t(size_t, count, (sizeof(buf) - 1));
- if (copy_from_user(buf, u, buf_size))
- return -EFAULT;
-
- if (buf[0] == '1')
- return 1;
- else if (buf[0] == '0')
- return 0;
-
- return -EINVAL;
-}
-
static ssize_t dfs_file_write(struct file *file, const char __user *u,
size_t count, loff_t *ppos)
{
struct ubifs_info *c = file->private_data;
struct ubifs_debug_info *d = c->dbg;
struct dentry *dent = file->f_path.dentry;
- int val;
+ bool val;
+ int ret;
if (file->f_path.dentry == d->dfs_dump_lprops) {
ubifs_dump_lprops(c);
@@ -2781,9 +2756,9 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
return count;
}
- val = interpret_user_input(u, count);
- if (val < 0)
- return val;
+ ret = kstrtobool_from_user(u, count, &val);
+ if (unlikely(ret))
+ return ret;
if (dent == d->dfs_chk_gen)
d->chk_gen = val;
@@ -2926,11 +2901,12 @@ static ssize_t dfs_global_file_write(struct file *file, const char __user *u,
size_t count, loff_t *ppos)
{
struct dentry *dent = file->f_path.dentry;
- int val;
+ bool val;
+ int ret;
- val = interpret_user_input(u, count);
- if (val < 0)
- return val;
+ ret = kstrtobool_from_user(u, count, &val);
+ if (unlikely(ret))
+ return ret;
if (dent == dfs_chk_gen)
ubifs_dbg.chk_gen = val;
--
2.53.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH] ubifs: prefer kstrtobool_from_user() over custom helper
2026-04-02 8:13 [PATCH] ubifs: prefer kstrtobool_from_user() over custom helper Dmitry Antipov
@ 2026-04-02 11:18 ` Zhihao Cheng
2026-04-03 16:37 ` [PATCH v2 1/2] " Dmitry Antipov
0 siblings, 1 reply; 16+ messages in thread
From: Zhihao Cheng @ 2026-04-02 11:18 UTC (permalink / raw)
To: Dmitry Antipov, Richard Weinberger; +Cc: linux-mtd
在 2026/4/2 16:13, Dmitry Antipov 写道:
> Adjust 'dfs_file_write()' and 'dfs_global_file_write()' to prefer generic
> 'kstrtobool_from_user()' over an ad-hoc 'interpret_user_input()' helper,
> thus making the latter not needed anymore.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> fs/ubifs/debug.c | 44 ++++++++++----------------------------------
> 1 file changed, 10 insertions(+), 34 deletions(-)
>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
> index 160c16aa7b6e..252cf82012cf 100644
> --- a/fs/ubifs/debug.c
> +++ b/fs/ubifs/debug.c
> @@ -2732,39 +2732,14 @@ static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,
> return provide_user_output(val, u, count, ppos);
> }
>
> -/**
> - * interpret_user_input - interpret user debugfs file input.
> - * @u: user-provided buffer with the input
> - * @count: buffer size
> - *
> - * This is a helper function which interpret user input to a boolean UBIFS
> - * debugfs file. Returns %0 or %1 in case of success and a negative error code
> - * in case of failure.
> - */
> -static int interpret_user_input(const char __user *u, size_t count)
> -{
> - size_t buf_size;
> - char buf[8];
> -
> - buf_size = min_t(size_t, count, (sizeof(buf) - 1));
> - if (copy_from_user(buf, u, buf_size))
> - return -EFAULT;
> -
> - if (buf[0] == '1')
> - return 1;
> - else if (buf[0] == '0')
> - return 0;
> -
> - return -EINVAL;
> -}
> -
> static ssize_t dfs_file_write(struct file *file, const char __user *u,
> size_t count, loff_t *ppos)
> {
> struct ubifs_info *c = file->private_data;
> struct ubifs_debug_info *d = c->dbg;
> struct dentry *dent = file->f_path.dentry;
> - int val;
> + bool val;
> + int ret;
>
> if (file->f_path.dentry == d->dfs_dump_lprops) {
> ubifs_dump_lprops(c);
> @@ -2781,9 +2756,9 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
> return count;
> }
>
> - val = interpret_user_input(u, count);
> - if (val < 0)
> - return val;
> + ret = kstrtobool_from_user(u, count, &val);
> + if (unlikely(ret))
> + return ret;
>
> if (dent == d->dfs_chk_gen)
> d->chk_gen = val;
> @@ -2926,11 +2901,12 @@ static ssize_t dfs_global_file_write(struct file *file, const char __user *u,
> size_t count, loff_t *ppos)
> {
> struct dentry *dent = file->f_path.dentry;
> - int val;
> + bool val;
> + int ret;
>
> - val = interpret_user_input(u, count);
> - if (val < 0)
> - return val;
> + ret = kstrtobool_from_user(u, count, &val);
> + if (unlikely(ret))
> + return ret;
>
> if (dent == dfs_chk_gen)
> ubifs_dbg.chk_gen = val;
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v2 1/2] ubifs: prefer kstrtobool_from_user() over custom helper
2026-04-02 11:18 ` Zhihao Cheng
@ 2026-04-03 16:37 ` Dmitry Antipov
2026-04-03 16:37 ` [PATCH v2 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate Dmitry Antipov
0 siblings, 1 reply; 16+ messages in thread
From: Dmitry Antipov @ 2026-04-03 16:37 UTC (permalink / raw)
To: Zhihao Cheng; +Cc: Richard Weinberger, linux-mtd, Dmitry Antipov
Adjust 'dfs_file_write()' and 'dfs_global_file_write()' to prefer generic
'kstrtobool_from_user()' over an ad-hoc 'interpret_user_input()' helper,
thus making the latter not needed anymore.
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v2: add Reviewed-by: and bump version to match the series
---
fs/ubifs/debug.c | 44 ++++++++++----------------------------------
1 file changed, 10 insertions(+), 34 deletions(-)
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 160c16aa7b6e..252cf82012cf 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2732,39 +2732,14 @@ static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,
return provide_user_output(val, u, count, ppos);
}
-/**
- * interpret_user_input - interpret user debugfs file input.
- * @u: user-provided buffer with the input
- * @count: buffer size
- *
- * This is a helper function which interpret user input to a boolean UBIFS
- * debugfs file. Returns %0 or %1 in case of success and a negative error code
- * in case of failure.
- */
-static int interpret_user_input(const char __user *u, size_t count)
-{
- size_t buf_size;
- char buf[8];
-
- buf_size = min_t(size_t, count, (sizeof(buf) - 1));
- if (copy_from_user(buf, u, buf_size))
- return -EFAULT;
-
- if (buf[0] == '1')
- return 1;
- else if (buf[0] == '0')
- return 0;
-
- return -EINVAL;
-}
-
static ssize_t dfs_file_write(struct file *file, const char __user *u,
size_t count, loff_t *ppos)
{
struct ubifs_info *c = file->private_data;
struct ubifs_debug_info *d = c->dbg;
struct dentry *dent = file->f_path.dentry;
- int val;
+ bool val;
+ int ret;
if (file->f_path.dentry == d->dfs_dump_lprops) {
ubifs_dump_lprops(c);
@@ -2781,9 +2756,9 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
return count;
}
- val = interpret_user_input(u, count);
- if (val < 0)
- return val;
+ ret = kstrtobool_from_user(u, count, &val);
+ if (unlikely(ret))
+ return ret;
if (dent == d->dfs_chk_gen)
d->chk_gen = val;
@@ -2926,11 +2901,12 @@ static ssize_t dfs_global_file_write(struct file *file, const char __user *u,
size_t count, loff_t *ppos)
{
struct dentry *dent = file->f_path.dentry;
- int val;
+ bool val;
+ int ret;
- val = interpret_user_input(u, count);
- if (val < 0)
- return val;
+ ret = kstrtobool_from_user(u, count, &val);
+ if (unlikely(ret))
+ return ret;
if (dent == dfs_chk_gen)
ubifs_dbg.chk_gen = val;
--
2.53.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v2 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate
2026-04-03 16:37 ` [PATCH v2 1/2] " Dmitry Antipov
@ 2026-04-03 16:37 ` Dmitry Antipov
2026-04-07 2:37 ` Zhihao Cheng
0 siblings, 1 reply; 16+ messages in thread
From: Dmitry Antipov @ 2026-04-03 16:37 UTC (permalink / raw)
To: Zhihao Cheng; +Cc: Richard Weinberger, linux-mtd, Dmitry Antipov
Go closer to the modern kernel API and use 'strscpy()' and 'kmemdup_nul()'
over an ad-hoc ensure-to-have-'\0' quirks where appropriate.
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v2: initial version to join the series
---
fs/ubifs/journal.c | 18 ++++++------------
fs/ubifs/replay.c | 3 +--
fs/ubifs/super.c | 8 ++------
3 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index e28ab4395e5c..fa13e988e8b2 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -729,8 +729,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
dent->inum = deletion ? 0 : cpu_to_le64(inode->i_ino);
dent->type = get_dent_type(inode->i_mode);
dent->nlen = cpu_to_le16(fname_len(nm));
- memcpy(dent->name, fname_name(nm), fname_len(nm));
- dent->name[fname_len(nm)] = '\0';
+ strscpy(dent->name, fname_name(nm), fname_len(nm));
set_dent_cookie(c, dent);
zero_dent_node_unused(dent);
@@ -1232,8 +1231,7 @@ int ubifs_jnl_xrename(struct ubifs_info *c, const struct inode *fst_dir,
dent1->inum = cpu_to_le64(fst_inode->i_ino);
dent1->type = get_dent_type(fst_inode->i_mode);
dent1->nlen = cpu_to_le16(fname_len(snd_nm));
- memcpy(dent1->name, fname_name(snd_nm), fname_len(snd_nm));
- dent1->name[fname_len(snd_nm)] = '\0';
+ strscpy(dent1->name, fname_name(snd_nm), fname_len(snd_nm));
set_dent_cookie(c, dent1);
zero_dent_node_unused(dent1);
ubifs_prep_grp_node(c, dent1, dlen1, 0);
@@ -1248,8 +1246,7 @@ int ubifs_jnl_xrename(struct ubifs_info *c, const struct inode *fst_dir,
dent2->inum = cpu_to_le64(snd_inode->i_ino);
dent2->type = get_dent_type(snd_inode->i_mode);
dent2->nlen = cpu_to_le16(fname_len(fst_nm));
- memcpy(dent2->name, fname_name(fst_nm), fname_len(fst_nm));
- dent2->name[fname_len(fst_nm)] = '\0';
+ strscpy(dent2->name, fname_name(fst_nm), fname_len(fst_nm));
set_dent_cookie(c, dent2);
zero_dent_node_unused(dent2);
ubifs_prep_grp_node(c, dent2, dlen2, 0);
@@ -1424,8 +1421,7 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
dent->inum = cpu_to_le64(old_inode->i_ino);
dent->type = get_dent_type(old_inode->i_mode);
dent->nlen = cpu_to_le16(fname_len(new_nm));
- memcpy(dent->name, fname_name(new_nm), fname_len(new_nm));
- dent->name[fname_len(new_nm)] = '\0';
+ strscpy(dent->name, fname_name(new_nm), fname_len(new_nm));
set_dent_cookie(c, dent);
zero_dent_node_unused(dent);
ubifs_prep_grp_node(c, dent, dlen1, 0);
@@ -1446,8 +1442,7 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
dent2->type = DT_UNKNOWN;
}
dent2->nlen = cpu_to_le16(fname_len(old_nm));
- memcpy(dent2->name, fname_name(old_nm), fname_len(old_nm));
- dent2->name[fname_len(old_nm)] = '\0';
+ strscpy(dent2->name, fname_name(old_nm), fname_len(old_nm));
set_dent_cookie(c, dent2);
zero_dent_node_unused(dent2);
ubifs_prep_grp_node(c, dent2, dlen2, 0);
@@ -1897,8 +1892,7 @@ int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host,
xent->inum = 0;
xent->type = get_dent_type(inode->i_mode);
xent->nlen = cpu_to_le16(fname_len(nm));
- memcpy(xent->name, fname_name(nm), fname_len(nm));
- xent->name[fname_len(nm)] = '\0';
+ strscpy(xent->name, fname_name(nm), fname_len(nm));
zero_dent_node_unused(xent);
ubifs_prep_grp_node(c, xent, xlen, 0);
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index a9a568f4a868..cb1c3fafa5c5 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -463,8 +463,7 @@ static int insert_dent(struct ubifs_info *c, int lnum, int offs, int len,
r->sqnum = sqnum;
key_copy(c, key, &r->key);
fname_len(&r->nm) = nlen;
- memcpy(nbuf, name, nlen);
- nbuf[nlen] = '\0';
+ strscpy(nbuf, name, nlen);
fname_name(&r->nm) = nbuf;
list_add_tail(&r->list, &c->replay_list);
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 03bf924756ca..da2f1067f054 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -168,13 +168,11 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
inode->i_op = &ubifs_file_inode_operations;
inode->i_fop = &ubifs_file_operations;
if (ui->xattr) {
- ui->data = kmalloc(ui->data_len + 1, GFP_NOFS);
+ ui->data = kmemdup_nul(ino->data, ui->data_len, GFP_NOFS);
if (!ui->data) {
err = -ENOMEM;
goto out_ino;
}
- memcpy(ui->data, ino->data, ui->data_len);
- ((char *)ui->data)[ui->data_len] = '\0';
} else if (ui->data_len != 0) {
err = 10;
goto out_invalid;
@@ -194,13 +192,11 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
err = 12;
goto out_invalid;
}
- ui->data = kmalloc(ui->data_len + 1, GFP_NOFS);
+ ui->data = kmemdup_nul(ino->data, ui->data_len, GFP_NOFS);
if (!ui->data) {
err = -ENOMEM;
goto out_ino;
}
- memcpy(ui->data, ino->data, ui->data_len);
- ((char *)ui->data)[ui->data_len] = '\0';
break;
case S_IFBLK:
case S_IFCHR:
--
2.53.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v2 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate
2026-04-03 16:37 ` [PATCH v2 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate Dmitry Antipov
@ 2026-04-07 2:37 ` Zhihao Cheng
2026-04-07 16:05 ` [PATCH v3 1/2] ubifs: prefer kstrtobool_from_user() over custom helper Dmitry Antipov
0 siblings, 1 reply; 16+ messages in thread
From: Zhihao Cheng @ 2026-04-07 2:37 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: Richard Weinberger, linux-mtd
在 2026/4/4 0:37, Dmitry Antipov 写道:
> Go closer to the modern kernel API and use 'strscpy()' and 'kmemdup_nul()'
> over an ad-hoc ensure-to-have-'\0' quirks where appropriate.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> v2: initial version to join the series
> ---
> fs/ubifs/journal.c | 18 ++++++------------
> fs/ubifs/replay.c | 3 +--
> fs/ubifs/super.c | 8 ++------
> 3 files changed, 9 insertions(+), 20 deletions(-)
>
> diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> index e28ab4395e5c..fa13e988e8b2 100644
> --- a/fs/ubifs/journal.c
> +++ b/fs/ubifs/journal.c
> @@ -729,8 +729,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
> dent->inum = deletion ? 0 : cpu_to_le64(inode->i_ino);
> dent->type = get_dent_type(inode->i_mode);
> dent->nlen = cpu_to_le16(fname_len(nm));
> - memcpy(dent->name, fname_name(nm), fname_len(nm));
> - dent->name[fname_len(nm)] = '\0';
> + strscpy(dent->name, fname_name(nm), fname_len(nm));
The 'size' param in strscpy() is the size of dst buf, not the string
name length.
> set_dent_cookie(c, dent);
>
> zero_dent_node_unused(dent);
> @@ -1232,8 +1231,7 @@ int ubifs_jnl_xrename(struct ubifs_info *c, const struct inode *fst_dir,
> dent1->inum = cpu_to_le64(fst_inode->i_ino);
> dent1->type = get_dent_type(fst_inode->i_mode);
> dent1->nlen = cpu_to_le16(fname_len(snd_nm));
> - memcpy(dent1->name, fname_name(snd_nm), fname_len(snd_nm));
> - dent1->name[fname_len(snd_nm)] = '\0';
> + strscpy(dent1->name, fname_name(snd_nm), fname_len(snd_nm));
> set_dent_cookie(c, dent1);
> zero_dent_node_unused(dent1);
> ubifs_prep_grp_node(c, dent1, dlen1, 0);
> @@ -1248,8 +1246,7 @@ int ubifs_jnl_xrename(struct ubifs_info *c, const struct inode *fst_dir,
> dent2->inum = cpu_to_le64(snd_inode->i_ino);
> dent2->type = get_dent_type(snd_inode->i_mode);
> dent2->nlen = cpu_to_le16(fname_len(fst_nm));
> - memcpy(dent2->name, fname_name(fst_nm), fname_len(fst_nm));
> - dent2->name[fname_len(fst_nm)] = '\0';
> + strscpy(dent2->name, fname_name(fst_nm), fname_len(fst_nm));
> set_dent_cookie(c, dent2);
> zero_dent_node_unused(dent2);
> ubifs_prep_grp_node(c, dent2, dlen2, 0);
> @@ -1424,8 +1421,7 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
> dent->inum = cpu_to_le64(old_inode->i_ino);
> dent->type = get_dent_type(old_inode->i_mode);
> dent->nlen = cpu_to_le16(fname_len(new_nm));
> - memcpy(dent->name, fname_name(new_nm), fname_len(new_nm));
> - dent->name[fname_len(new_nm)] = '\0';
> + strscpy(dent->name, fname_name(new_nm), fname_len(new_nm));
> set_dent_cookie(c, dent);
> zero_dent_node_unused(dent);
> ubifs_prep_grp_node(c, dent, dlen1, 0);
> @@ -1446,8 +1442,7 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
> dent2->type = DT_UNKNOWN;
> }
> dent2->nlen = cpu_to_le16(fname_len(old_nm));
> - memcpy(dent2->name, fname_name(old_nm), fname_len(old_nm));
> - dent2->name[fname_len(old_nm)] = '\0';
> + strscpy(dent2->name, fname_name(old_nm), fname_len(old_nm));
> set_dent_cookie(c, dent2);
> zero_dent_node_unused(dent2);
> ubifs_prep_grp_node(c, dent2, dlen2, 0);
> @@ -1897,8 +1892,7 @@ int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host,
> xent->inum = 0;
> xent->type = get_dent_type(inode->i_mode);
> xent->nlen = cpu_to_le16(fname_len(nm));
> - memcpy(xent->name, fname_name(nm), fname_len(nm));
> - xent->name[fname_len(nm)] = '\0';
> + strscpy(xent->name, fname_name(nm), fname_len(nm));
> zero_dent_node_unused(xent);
> ubifs_prep_grp_node(c, xent, xlen, 0);
>
> diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
> index a9a568f4a868..cb1c3fafa5c5 100644
> --- a/fs/ubifs/replay.c
> +++ b/fs/ubifs/replay.c
> @@ -463,8 +463,7 @@ static int insert_dent(struct ubifs_info *c, int lnum, int offs, int len,
> r->sqnum = sqnum;
> key_copy(c, key, &r->key);
> fname_len(&r->nm) = nlen;
> - memcpy(nbuf, name, nlen);
> - nbuf[nlen] = '\0';
> + strscpy(nbuf, name, nlen);
> fname_name(&r->nm) = nbuf;
>
> list_add_tail(&r->list, &c->replay_list);
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 03bf924756ca..da2f1067f054 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -168,13 +168,11 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
> inode->i_op = &ubifs_file_inode_operations;
> inode->i_fop = &ubifs_file_operations;
> if (ui->xattr) {
> - ui->data = kmalloc(ui->data_len + 1, GFP_NOFS);
> + ui->data = kmemdup_nul(ino->data, ui->data_len, GFP_NOFS);
> if (!ui->data) {
> err = -ENOMEM;
> goto out_ino;
> }
> - memcpy(ui->data, ino->data, ui->data_len);
> - ((char *)ui->data)[ui->data_len] = '\0';
> } else if (ui->data_len != 0) {
> err = 10;
> goto out_invalid;
> @@ -194,13 +192,11 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
> err = 12;
> goto out_invalid;
> }
> - ui->data = kmalloc(ui->data_len + 1, GFP_NOFS);
> + ui->data = kmemdup_nul(ino->data, ui->data_len, GFP_NOFS);
> if (!ui->data) {
> err = -ENOMEM;
> goto out_ino;
> }
> - memcpy(ui->data, ino->data, ui->data_len);
> - ((char *)ui->data)[ui->data_len] = '\0';
> break;
> case S_IFBLK:
> case S_IFCHR:
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v3 1/2] ubifs: prefer kstrtobool_from_user() over custom helper
2026-04-07 2:37 ` Zhihao Cheng
@ 2026-04-07 16:05 ` Dmitry Antipov
2026-04-07 16:05 ` [PATCH v3 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate Dmitry Antipov
0 siblings, 1 reply; 16+ messages in thread
From: Dmitry Antipov @ 2026-04-07 16:05 UTC (permalink / raw)
To: Zhihao Cheng; +Cc: Richard Weinberger, linux-mtd, Dmitry Antipov
Adjust 'dfs_file_write()' and 'dfs_global_file_write()' to prefer generic
'kstrtobool_from_user()' over an ad-hoc 'interpret_user_input()' helper,
thus making the latter not needed anymore.
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v3: bump version to match the series
v2: add Reviewed-by: and bump version to match the series
---
fs/ubifs/debug.c | 44 ++++++++++----------------------------------
1 file changed, 10 insertions(+), 34 deletions(-)
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 160c16aa7b6e..252cf82012cf 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2732,39 +2732,14 @@ static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,
return provide_user_output(val, u, count, ppos);
}
-/**
- * interpret_user_input - interpret user debugfs file input.
- * @u: user-provided buffer with the input
- * @count: buffer size
- *
- * This is a helper function which interpret user input to a boolean UBIFS
- * debugfs file. Returns %0 or %1 in case of success and a negative error code
- * in case of failure.
- */
-static int interpret_user_input(const char __user *u, size_t count)
-{
- size_t buf_size;
- char buf[8];
-
- buf_size = min_t(size_t, count, (sizeof(buf) - 1));
- if (copy_from_user(buf, u, buf_size))
- return -EFAULT;
-
- if (buf[0] == '1')
- return 1;
- else if (buf[0] == '0')
- return 0;
-
- return -EINVAL;
-}
-
static ssize_t dfs_file_write(struct file *file, const char __user *u,
size_t count, loff_t *ppos)
{
struct ubifs_info *c = file->private_data;
struct ubifs_debug_info *d = c->dbg;
struct dentry *dent = file->f_path.dentry;
- int val;
+ bool val;
+ int ret;
if (file->f_path.dentry == d->dfs_dump_lprops) {
ubifs_dump_lprops(c);
@@ -2781,9 +2756,9 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
return count;
}
- val = interpret_user_input(u, count);
- if (val < 0)
- return val;
+ ret = kstrtobool_from_user(u, count, &val);
+ if (unlikely(ret))
+ return ret;
if (dent == d->dfs_chk_gen)
d->chk_gen = val;
@@ -2926,11 +2901,12 @@ static ssize_t dfs_global_file_write(struct file *file, const char __user *u,
size_t count, loff_t *ppos)
{
struct dentry *dent = file->f_path.dentry;
- int val;
+ bool val;
+ int ret;
- val = interpret_user_input(u, count);
- if (val < 0)
- return val;
+ ret = kstrtobool_from_user(u, count, &val);
+ if (unlikely(ret))
+ return ret;
if (dent == dfs_chk_gen)
ubifs_dbg.chk_gen = val;
--
2.53.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v3 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate
2026-04-07 16:05 ` [PATCH v3 1/2] ubifs: prefer kstrtobool_from_user() over custom helper Dmitry Antipov
@ 2026-04-07 16:05 ` Dmitry Antipov
2026-04-08 6:09 ` Zhihao Cheng
0 siblings, 1 reply; 16+ messages in thread
From: Dmitry Antipov @ 2026-04-07 16:05 UTC (permalink / raw)
To: Zhihao Cheng; +Cc: Richard Weinberger, linux-mtd, Dmitry Antipov
Go closer to the modern kernel API and use 'strscpy()' and 'kmemdup_nul()'
over an ad-hoc ensure-to-have-'\0' quirks where appropriate.
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v3: fix strscpy() usage as noticed by Zhihao
v2: initial version to join the series
---
fs/ubifs/journal.c | 18 ++++++------------
fs/ubifs/replay.c | 3 +--
fs/ubifs/super.c | 8 ++------
3 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index e28ab4395e5c..b8c4ab8990c2 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -729,8 +729,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
dent->inum = deletion ? 0 : cpu_to_le64(inode->i_ino);
dent->type = get_dent_type(inode->i_mode);
dent->nlen = cpu_to_le16(fname_len(nm));
- memcpy(dent->name, fname_name(nm), fname_len(nm));
- dent->name[fname_len(nm)] = '\0';
+ strscpy(dent->name, fname_name(nm), dent->nlen + 1);
set_dent_cookie(c, dent);
zero_dent_node_unused(dent);
@@ -1232,8 +1231,7 @@ int ubifs_jnl_xrename(struct ubifs_info *c, const struct inode *fst_dir,
dent1->inum = cpu_to_le64(fst_inode->i_ino);
dent1->type = get_dent_type(fst_inode->i_mode);
dent1->nlen = cpu_to_le16(fname_len(snd_nm));
- memcpy(dent1->name, fname_name(snd_nm), fname_len(snd_nm));
- dent1->name[fname_len(snd_nm)] = '\0';
+ strscpy(dent1->name, fname_name(snd_nm), dent1->nlen + 1);
set_dent_cookie(c, dent1);
zero_dent_node_unused(dent1);
ubifs_prep_grp_node(c, dent1, dlen1, 0);
@@ -1248,8 +1246,7 @@ int ubifs_jnl_xrename(struct ubifs_info *c, const struct inode *fst_dir,
dent2->inum = cpu_to_le64(snd_inode->i_ino);
dent2->type = get_dent_type(snd_inode->i_mode);
dent2->nlen = cpu_to_le16(fname_len(fst_nm));
- memcpy(dent2->name, fname_name(fst_nm), fname_len(fst_nm));
- dent2->name[fname_len(fst_nm)] = '\0';
+ strscpy(dent2->name, fname_name(fst_nm), dent2->nlen + 1);
set_dent_cookie(c, dent2);
zero_dent_node_unused(dent2);
ubifs_prep_grp_node(c, dent2, dlen2, 0);
@@ -1424,8 +1421,7 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
dent->inum = cpu_to_le64(old_inode->i_ino);
dent->type = get_dent_type(old_inode->i_mode);
dent->nlen = cpu_to_le16(fname_len(new_nm));
- memcpy(dent->name, fname_name(new_nm), fname_len(new_nm));
- dent->name[fname_len(new_nm)] = '\0';
+ strscpy(dent->name, fname_name(new_nm), dent->nlen + 1);
set_dent_cookie(c, dent);
zero_dent_node_unused(dent);
ubifs_prep_grp_node(c, dent, dlen1, 0);
@@ -1446,8 +1442,7 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
dent2->type = DT_UNKNOWN;
}
dent2->nlen = cpu_to_le16(fname_len(old_nm));
- memcpy(dent2->name, fname_name(old_nm), fname_len(old_nm));
- dent2->name[fname_len(old_nm)] = '\0';
+ strscpy(dent2->name, fname_name(old_nm), dent2->nlen + 1);
set_dent_cookie(c, dent2);
zero_dent_node_unused(dent2);
ubifs_prep_grp_node(c, dent2, dlen2, 0);
@@ -1897,8 +1892,7 @@ int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host,
xent->inum = 0;
xent->type = get_dent_type(inode->i_mode);
xent->nlen = cpu_to_le16(fname_len(nm));
- memcpy(xent->name, fname_name(nm), fname_len(nm));
- xent->name[fname_len(nm)] = '\0';
+ strscpy(xent->name, fname_name(nm), xent->nlen + 1);
zero_dent_node_unused(xent);
ubifs_prep_grp_node(c, xent, xlen, 0);
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index a9a568f4a868..ef6ae63792d1 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -463,8 +463,7 @@ static int insert_dent(struct ubifs_info *c, int lnum, int offs, int len,
r->sqnum = sqnum;
key_copy(c, key, &r->key);
fname_len(&r->nm) = nlen;
- memcpy(nbuf, name, nlen);
- nbuf[nlen] = '\0';
+ strscpy(nbuf, name, nlen + 1);
fname_name(&r->nm) = nbuf;
list_add_tail(&r->list, &c->replay_list);
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 03bf924756ca..da2f1067f054 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -168,13 +168,11 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
inode->i_op = &ubifs_file_inode_operations;
inode->i_fop = &ubifs_file_operations;
if (ui->xattr) {
- ui->data = kmalloc(ui->data_len + 1, GFP_NOFS);
+ ui->data = kmemdup_nul(ino->data, ui->data_len, GFP_NOFS);
if (!ui->data) {
err = -ENOMEM;
goto out_ino;
}
- memcpy(ui->data, ino->data, ui->data_len);
- ((char *)ui->data)[ui->data_len] = '\0';
} else if (ui->data_len != 0) {
err = 10;
goto out_invalid;
@@ -194,13 +192,11 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
err = 12;
goto out_invalid;
}
- ui->data = kmalloc(ui->data_len + 1, GFP_NOFS);
+ ui->data = kmemdup_nul(ino->data, ui->data_len, GFP_NOFS);
if (!ui->data) {
err = -ENOMEM;
goto out_ino;
}
- memcpy(ui->data, ino->data, ui->data_len);
- ((char *)ui->data)[ui->data_len] = '\0';
break;
case S_IFBLK:
case S_IFCHR:
--
2.53.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v3 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate
2026-04-07 16:05 ` [PATCH v3 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate Dmitry Antipov
@ 2026-04-08 6:09 ` Zhihao Cheng
2026-04-09 4:56 ` [PATCH v4 1/2] ubifs: prefer kstrtobool_from_user() over custom helper Dmitry Antipov
0 siblings, 1 reply; 16+ messages in thread
From: Zhihao Cheng @ 2026-04-08 6:09 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: Richard Weinberger, linux-mtd
在 2026/4/8 0:05, Dmitry Antipov 写道:
> Go closer to the modern kernel API and use 'strscpy()' and 'kmemdup_nul()'
> over an ad-hoc ensure-to-have-'\0' quirks where appropriate.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> v3: fix strscpy() usage as noticed by Zhihao
> v2: initial version to join the series
> ---
> fs/ubifs/journal.c | 18 ++++++------------
> fs/ubifs/replay.c | 3 +--
> fs/ubifs/super.c | 8 ++------
> 3 files changed, 9 insertions(+), 20 deletions(-)
>
> diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> index e28ab4395e5c..b8c4ab8990c2 100644
> --- a/fs/ubifs/journal.c
> +++ b/fs/ubifs/journal.c
> @@ -729,8 +729,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
> dent->inum = deletion ? 0 : cpu_to_le64(inode->i_ino);
> dent->type = get_dent_type(inode->i_mode);
> dent->nlen = cpu_to_le16(fname_len(nm));
> - memcpy(dent->name, fname_name(nm), fname_len(nm));
> - dent->name[fname_len(nm)] = '\0';
> + strscpy(dent->name, fname_name(nm), dent->nlen + 1);
The 'dent->nlen' is a little endian type, cannot be used directly.
> set_dent_cookie(c, dent);
>
> zero_dent_node_unused(dent);
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH v4 1/2] ubifs: prefer kstrtobool_from_user() over custom helper
2026-04-08 6:09 ` Zhihao Cheng
@ 2026-04-09 4:56 ` Dmitry Antipov
2026-04-09 4:56 ` [PATCH v4 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate Dmitry Antipov
0 siblings, 1 reply; 16+ messages in thread
From: Dmitry Antipov @ 2026-04-09 4:56 UTC (permalink / raw)
To: Zhihao Cheng; +Cc: Richard Weinberger, linux-mtd, Dmitry Antipov
Adjust 'dfs_file_write()' and 'dfs_global_file_write()' to prefer generic
'kstrtobool_from_user()' over an ad-hoc 'interpret_user_input()' helper,
thus making the latter not needed anymore.
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v3 and upwards: bump version to match the series
v2: add Reviewed-by: and bump version to match the series
---
fs/ubifs/debug.c | 44 ++++++++++----------------------------------
1 file changed, 10 insertions(+), 34 deletions(-)
diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c
index 160c16aa7b6e..252cf82012cf 100644
--- a/fs/ubifs/debug.c
+++ b/fs/ubifs/debug.c
@@ -2732,39 +2732,14 @@ static ssize_t dfs_file_read(struct file *file, char __user *u, size_t count,
return provide_user_output(val, u, count, ppos);
}
-/**
- * interpret_user_input - interpret user debugfs file input.
- * @u: user-provided buffer with the input
- * @count: buffer size
- *
- * This is a helper function which interpret user input to a boolean UBIFS
- * debugfs file. Returns %0 or %1 in case of success and a negative error code
- * in case of failure.
- */
-static int interpret_user_input(const char __user *u, size_t count)
-{
- size_t buf_size;
- char buf[8];
-
- buf_size = min_t(size_t, count, (sizeof(buf) - 1));
- if (copy_from_user(buf, u, buf_size))
- return -EFAULT;
-
- if (buf[0] == '1')
- return 1;
- else if (buf[0] == '0')
- return 0;
-
- return -EINVAL;
-}
-
static ssize_t dfs_file_write(struct file *file, const char __user *u,
size_t count, loff_t *ppos)
{
struct ubifs_info *c = file->private_data;
struct ubifs_debug_info *d = c->dbg;
struct dentry *dent = file->f_path.dentry;
- int val;
+ bool val;
+ int ret;
if (file->f_path.dentry == d->dfs_dump_lprops) {
ubifs_dump_lprops(c);
@@ -2781,9 +2756,9 @@ static ssize_t dfs_file_write(struct file *file, const char __user *u,
return count;
}
- val = interpret_user_input(u, count);
- if (val < 0)
- return val;
+ ret = kstrtobool_from_user(u, count, &val);
+ if (unlikely(ret))
+ return ret;
if (dent == d->dfs_chk_gen)
d->chk_gen = val;
@@ -2926,11 +2901,12 @@ static ssize_t dfs_global_file_write(struct file *file, const char __user *u,
size_t count, loff_t *ppos)
{
struct dentry *dent = file->f_path.dentry;
- int val;
+ bool val;
+ int ret;
- val = interpret_user_input(u, count);
- if (val < 0)
- return val;
+ ret = kstrtobool_from_user(u, count, &val);
+ if (unlikely(ret))
+ return ret;
if (dent == dfs_chk_gen)
ubifs_dbg.chk_gen = val;
--
2.53.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [PATCH v4 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate
2026-04-09 4:56 ` [PATCH v4 1/2] ubifs: prefer kstrtobool_from_user() over custom helper Dmitry Antipov
@ 2026-04-09 4:56 ` Dmitry Antipov
2026-04-10 1:06 ` Zhihao Cheng
0 siblings, 1 reply; 16+ messages in thread
From: Dmitry Antipov @ 2026-04-09 4:56 UTC (permalink / raw)
To: Zhihao Cheng; +Cc: Richard Weinberger, linux-mtd, Dmitry Antipov
Go closer to the modern kernel API and use 'strscpy()' and 'kmemdup_nul()'
over an ad-hoc ensure-to-have-'\0' quirks where appropriate.
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v4: once again to not forget a filesystem-native (little) to CPU endian swap
v3: fix strscpy() usage as noticed by Zhihao
v2: initial version to join the series
---
fs/ubifs/journal.c | 18 ++++++------------
fs/ubifs/replay.c | 3 +--
fs/ubifs/super.c | 8 ++------
3 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
index e28ab4395e5c..43e19c83ad6d 100644
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -729,8 +729,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
dent->inum = deletion ? 0 : cpu_to_le64(inode->i_ino);
dent->type = get_dent_type(inode->i_mode);
dent->nlen = cpu_to_le16(fname_len(nm));
- memcpy(dent->name, fname_name(nm), fname_len(nm));
- dent->name[fname_len(nm)] = '\0';
+ strscpy(dent->name, fname_name(nm), le16_to_cpu(dent->nlen) + 1);
set_dent_cookie(c, dent);
zero_dent_node_unused(dent);
@@ -1232,8 +1231,7 @@ int ubifs_jnl_xrename(struct ubifs_info *c, const struct inode *fst_dir,
dent1->inum = cpu_to_le64(fst_inode->i_ino);
dent1->type = get_dent_type(fst_inode->i_mode);
dent1->nlen = cpu_to_le16(fname_len(snd_nm));
- memcpy(dent1->name, fname_name(snd_nm), fname_len(snd_nm));
- dent1->name[fname_len(snd_nm)] = '\0';
+ strscpy(dent1->name, fname_name(snd_nm), le16_to_cpu(dent1->nlen) + 1);
set_dent_cookie(c, dent1);
zero_dent_node_unused(dent1);
ubifs_prep_grp_node(c, dent1, dlen1, 0);
@@ -1248,8 +1246,7 @@ int ubifs_jnl_xrename(struct ubifs_info *c, const struct inode *fst_dir,
dent2->inum = cpu_to_le64(snd_inode->i_ino);
dent2->type = get_dent_type(snd_inode->i_mode);
dent2->nlen = cpu_to_le16(fname_len(fst_nm));
- memcpy(dent2->name, fname_name(fst_nm), fname_len(fst_nm));
- dent2->name[fname_len(fst_nm)] = '\0';
+ strscpy(dent2->name, fname_name(fst_nm), le16_to_cpu(dent2->nlen) + 1);
set_dent_cookie(c, dent2);
zero_dent_node_unused(dent2);
ubifs_prep_grp_node(c, dent2, dlen2, 0);
@@ -1424,8 +1421,7 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
dent->inum = cpu_to_le64(old_inode->i_ino);
dent->type = get_dent_type(old_inode->i_mode);
dent->nlen = cpu_to_le16(fname_len(new_nm));
- memcpy(dent->name, fname_name(new_nm), fname_len(new_nm));
- dent->name[fname_len(new_nm)] = '\0';
+ strscpy(dent->name, fname_name(new_nm), le16_to_cpu(dent->nlen) + 1);
set_dent_cookie(c, dent);
zero_dent_node_unused(dent);
ubifs_prep_grp_node(c, dent, dlen1, 0);
@@ -1446,8 +1442,7 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
dent2->type = DT_UNKNOWN;
}
dent2->nlen = cpu_to_le16(fname_len(old_nm));
- memcpy(dent2->name, fname_name(old_nm), fname_len(old_nm));
- dent2->name[fname_len(old_nm)] = '\0';
+ strscpy(dent2->name, fname_name(old_nm), le16_to_cpu(dent2->nlen) + 1);
set_dent_cookie(c, dent2);
zero_dent_node_unused(dent2);
ubifs_prep_grp_node(c, dent2, dlen2, 0);
@@ -1897,8 +1892,7 @@ int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host,
xent->inum = 0;
xent->type = get_dent_type(inode->i_mode);
xent->nlen = cpu_to_le16(fname_len(nm));
- memcpy(xent->name, fname_name(nm), fname_len(nm));
- xent->name[fname_len(nm)] = '\0';
+ strscpy(xent->name, fname_name(nm), le16_to_cpu(xent->nlen) + 1);
zero_dent_node_unused(xent);
ubifs_prep_grp_node(c, xent, xlen, 0);
diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
index a9a568f4a868..ef6ae63792d1 100644
--- a/fs/ubifs/replay.c
+++ b/fs/ubifs/replay.c
@@ -463,8 +463,7 @@ static int insert_dent(struct ubifs_info *c, int lnum, int offs, int len,
r->sqnum = sqnum;
key_copy(c, key, &r->key);
fname_len(&r->nm) = nlen;
- memcpy(nbuf, name, nlen);
- nbuf[nlen] = '\0';
+ strscpy(nbuf, name, nlen + 1);
fname_name(&r->nm) = nbuf;
list_add_tail(&r->list, &c->replay_list);
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index 03bf924756ca..da2f1067f054 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -168,13 +168,11 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
inode->i_op = &ubifs_file_inode_operations;
inode->i_fop = &ubifs_file_operations;
if (ui->xattr) {
- ui->data = kmalloc(ui->data_len + 1, GFP_NOFS);
+ ui->data = kmemdup_nul(ino->data, ui->data_len, GFP_NOFS);
if (!ui->data) {
err = -ENOMEM;
goto out_ino;
}
- memcpy(ui->data, ino->data, ui->data_len);
- ((char *)ui->data)[ui->data_len] = '\0';
} else if (ui->data_len != 0) {
err = 10;
goto out_invalid;
@@ -194,13 +192,11 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
err = 12;
goto out_invalid;
}
- ui->data = kmalloc(ui->data_len + 1, GFP_NOFS);
+ ui->data = kmemdup_nul(ino->data, ui->data_len, GFP_NOFS);
if (!ui->data) {
err = -ENOMEM;
goto out_ino;
}
- memcpy(ui->data, ino->data, ui->data_len);
- ((char *)ui->data)[ui->data_len] = '\0';
break;
case S_IFBLK:
case S_IFCHR:
--
2.53.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate
2026-04-09 4:56 ` [PATCH v4 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate Dmitry Antipov
@ 2026-04-10 1:06 ` Zhihao Cheng
2026-04-10 5:57 ` Richard Weinberger
0 siblings, 1 reply; 16+ messages in thread
From: Zhihao Cheng @ 2026-04-10 1:06 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: Richard Weinberger, linux-mtd
在 2026/4/9 12:56, Dmitry Antipov 写道:
> Go closer to the modern kernel API and use 'strscpy()' and 'kmemdup_nul()'
> over an ad-hoc ensure-to-have-'\0' quirks where appropriate.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> v4: once again to not forget a filesystem-native (little) to CPU endian swap
> v3: fix strscpy() usage as noticed by Zhihao
> v2: initial version to join the series
> ---
> fs/ubifs/journal.c | 18 ++++++------------
> fs/ubifs/replay.c | 3 +--
> fs/ubifs/super.c | 8 ++------
> 3 files changed, 9 insertions(+), 20 deletions(-)
>
> diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c
> index e28ab4395e5c..43e19c83ad6d 100644
> --- a/fs/ubifs/journal.c
> +++ b/fs/ubifs/journal.c
> @@ -729,8 +729,7 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
> dent->inum = deletion ? 0 : cpu_to_le64(inode->i_ino);
> dent->type = get_dent_type(inode->i_mode);
> dent->nlen = cpu_to_le16(fname_len(nm));
> - memcpy(dent->name, fname_name(nm), fname_len(nm));
> - dent->name[fname_len(nm)] = '\0';
> + strscpy(dent->name, fname_name(nm), le16_to_cpu(dent->nlen) + 1);
I think we can use 'fname_len(nm) + 1' to replace
'le16_to_cpu(dent->nlen) + 1'.
> set_dent_cookie(c, dent);
>
> zero_dent_node_unused(dent);
> @@ -1232,8 +1231,7 @@ int ubifs_jnl_xrename(struct ubifs_info *c, const struct inode *fst_dir,
> dent1->inum = cpu_to_le64(fst_inode->i_ino);
> dent1->type = get_dent_type(fst_inode->i_mode);
> dent1->nlen = cpu_to_le16(fname_len(snd_nm));
> - memcpy(dent1->name, fname_name(snd_nm), fname_len(snd_nm));
> - dent1->name[fname_len(snd_nm)] = '\0';
> + strscpy(dent1->name, fname_name(snd_nm), le16_to_cpu(dent1->nlen) + 1);
> set_dent_cookie(c, dent1);
> zero_dent_node_unused(dent1);
> ubifs_prep_grp_node(c, dent1, dlen1, 0);
> @@ -1248,8 +1246,7 @@ int ubifs_jnl_xrename(struct ubifs_info *c, const struct inode *fst_dir,
> dent2->inum = cpu_to_le64(snd_inode->i_ino);
> dent2->type = get_dent_type(snd_inode->i_mode);
> dent2->nlen = cpu_to_le16(fname_len(fst_nm));
> - memcpy(dent2->name, fname_name(fst_nm), fname_len(fst_nm));
> - dent2->name[fname_len(fst_nm)] = '\0';
> + strscpy(dent2->name, fname_name(fst_nm), le16_to_cpu(dent2->nlen) + 1);
> set_dent_cookie(c, dent2);
> zero_dent_node_unused(dent2);
> ubifs_prep_grp_node(c, dent2, dlen2, 0);
> @@ -1424,8 +1421,7 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
> dent->inum = cpu_to_le64(old_inode->i_ino);
> dent->type = get_dent_type(old_inode->i_mode);
> dent->nlen = cpu_to_le16(fname_len(new_nm));
> - memcpy(dent->name, fname_name(new_nm), fname_len(new_nm));
> - dent->name[fname_len(new_nm)] = '\0';
> + strscpy(dent->name, fname_name(new_nm), le16_to_cpu(dent->nlen) + 1);
> set_dent_cookie(c, dent);
> zero_dent_node_unused(dent);
> ubifs_prep_grp_node(c, dent, dlen1, 0);
> @@ -1446,8 +1442,7 @@ int ubifs_jnl_rename(struct ubifs_info *c, const struct inode *old_dir,
> dent2->type = DT_UNKNOWN;
> }
> dent2->nlen = cpu_to_le16(fname_len(old_nm));
> - memcpy(dent2->name, fname_name(old_nm), fname_len(old_nm));
> - dent2->name[fname_len(old_nm)] = '\0';
> + strscpy(dent2->name, fname_name(old_nm), le16_to_cpu(dent2->nlen) + 1);
> set_dent_cookie(c, dent2);
> zero_dent_node_unused(dent2);
> ubifs_prep_grp_node(c, dent2, dlen2, 0);
> @@ -1897,8 +1892,7 @@ int ubifs_jnl_delete_xattr(struct ubifs_info *c, const struct inode *host,
> xent->inum = 0;
> xent->type = get_dent_type(inode->i_mode);
> xent->nlen = cpu_to_le16(fname_len(nm));
> - memcpy(xent->name, fname_name(nm), fname_len(nm));
> - xent->name[fname_len(nm)] = '\0';
> + strscpy(xent->name, fname_name(nm), le16_to_cpu(xent->nlen) + 1);
> zero_dent_node_unused(xent);
> ubifs_prep_grp_node(c, xent, xlen, 0);
>
> diff --git a/fs/ubifs/replay.c b/fs/ubifs/replay.c
> index a9a568f4a868..ef6ae63792d1 100644
> --- a/fs/ubifs/replay.c
> +++ b/fs/ubifs/replay.c
> @@ -463,8 +463,7 @@ static int insert_dent(struct ubifs_info *c, int lnum, int offs, int len,
> r->sqnum = sqnum;
> key_copy(c, key, &r->key);
> fname_len(&r->nm) = nlen;
> - memcpy(nbuf, name, nlen);
> - nbuf[nlen] = '\0';
> + strscpy(nbuf, name, nlen + 1);
> fname_name(&r->nm) = nbuf;
>
> list_add_tail(&r->list, &c->replay_list);
> diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
> index 03bf924756ca..da2f1067f054 100644
> --- a/fs/ubifs/super.c
> +++ b/fs/ubifs/super.c
> @@ -168,13 +168,11 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
> inode->i_op = &ubifs_file_inode_operations;
> inode->i_fop = &ubifs_file_operations;
> if (ui->xattr) {
> - ui->data = kmalloc(ui->data_len + 1, GFP_NOFS);
> + ui->data = kmemdup_nul(ino->data, ui->data_len, GFP_NOFS);
> if (!ui->data) {
> err = -ENOMEM;
> goto out_ino;
> }
> - memcpy(ui->data, ino->data, ui->data_len);
> - ((char *)ui->data)[ui->data_len] = '\0';
> } else if (ui->data_len != 0) {
> err = 10;
> goto out_invalid;
> @@ -194,13 +192,11 @@ struct inode *ubifs_iget(struct super_block *sb, unsigned long inum)
> err = 12;
> goto out_invalid;
> }
> - ui->data = kmalloc(ui->data_len + 1, GFP_NOFS);
> + ui->data = kmemdup_nul(ino->data, ui->data_len, GFP_NOFS);
> if (!ui->data) {
> err = -ENOMEM;
> goto out_ino;
> }
> - memcpy(ui->data, ino->data, ui->data_len);
> - ((char *)ui->data)[ui->data_len] = '\0';
> break;
> case S_IFBLK:
> case S_IFCHR:
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate
2026-04-10 1:06 ` Zhihao Cheng
@ 2026-04-10 5:57 ` Richard Weinberger
2026-04-10 11:55 ` Dmitry Antipov
` (2 more replies)
0 siblings, 3 replies; 16+ messages in thread
From: Richard Weinberger @ 2026-04-10 5:57 UTC (permalink / raw)
To: chengzhihao1, Dmitry Antipov; +Cc: linux-mtd
----- Ursprüngliche Mail -----
> Von: "chengzhihao1" <chengzhihao1@huawei.com>
> An: "Dmitry Antipov" <dmantipov@yandex.ru>
> CC: "richard" <richard@nod.at>, "linux-mtd" <linux-mtd@lists.infradead.org>
> Gesendet: Freitag, 10. April 2026 03:06:39
> Betreff: Re: [PATCH v4 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate
> 在 2026/4/9 12:56, Dmitry Antipov 写道:
>> Go closer to the modern kernel API and use 'strscpy()' and 'kmemdup_nul()'
>> over an ad-hoc ensure-to-have-'\0' quirks where appropriate.
>>
>> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Dmitry, how are you testing these changes?
Thanks,
//richard
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate
2026-04-10 5:57 ` Richard Weinberger
@ 2026-04-10 11:55 ` Dmitry Antipov
2026-04-10 12:00 ` Dmitry Antipov
2026-04-13 13:24 ` Dmitry Antipov
2 siblings, 0 replies; 16+ messages in thread
From: Dmitry Antipov @ 2026-04-10 11:55 UTC (permalink / raw)
To: Richard Weinberger, chengzhihao1; +Cc: linux-mtd
On Fri, 2026-04-10 at 07:57 +0200, Richard Weinberger wrote:
> Dmitry, how are you testing these changes?
Build with:
CONFIG_KASAN=y
CONFIG_MTD_NAND_NANDSIM=m
CONFIG_MTD_UBI=m
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_MTD_UBI_BEB_LIMIT=20
CONFIG_UBIFS_FS=m
CONFIG_UBIFS_FS_ADVANCED_COMPR=y
CONFIG_UBIFS_FS_LZO=y
CONFIG_UBIFS_FS_ZLIB=y
CONFIG_UBIFS_FS_ZSTD=y
CONFIG_UBIFS_ATIME_SUPPORT=y
CONFIG_UBIFS_FS_XATTR=y
CONFIG_UBIFS_FS_SECURITY=y
CONFIG_UBIFS_FS_AUTHENTICATION=y
and boot (QEMU VM), then:
# modprobe nandsim second_id_byte=0xdc third_id_byte=0x80 fourth_id_byte=0x1d
[ 24.282259] [nandsim] warning: read_byte: unexpected data output cycle, state is STATE_READY return 0x0
[ 24.282787] [nandsim] warning: read_byte: unexpected data output cycle, state is STATE_READY return 0x0
[ 24.283441] [nandsim] warning: read_byte: unexpected data output cycle, state is STATE_READY return 0x0
[ 24.284083] [nandsim] warning: read_byte: unexpected data output cycle, state is STATE_READY return 0x0
[ 24.284783] [nandsim] warning: read_byte: unexpected data output cycle, state is STATE_READY return 0x0
[ 24.285473] nand: device found, Manufacturer ID: 0x98, Chip ID: 0xdc
[ 24.285932] nand: Toshiba NAND 512MiB 3,3V 8-bit
[ 24.286275] nand: 512 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB size: 64
[ 24.286749] flash size: 512 MiB
[ 24.286925] page size: 2048 bytes
[ 24.287104] OOB area size: 64 bytes
[ 24.287337] sector size: 128 KiB
[ 24.287578] pages number: 262144
[ 24.287817] pages per sector: 64
[ 24.288068] bus width: 8
[ 24.288269] bits in sector size: 17
[ 24.288527] bits in page size: 11
[ 24.288775] bits in OOB size: 6
[ 24.289024] flash size with OOB: 540672 KiB
[ 24.289334] page address bytes: 5
[ 24.289572] sector address bytes: 3
[ 24.289837] options: 0x8
[ 24.290676] Scanning device for bad blocks
[ 24.311973] Creating 1 MTD partitions on "NAND 512MiB 3,3V 8-bit":
[ 24.312376] 0x000000000000-0x000020000000 : "NAND simulator partition 0"
# modprobe ubi mtd=0
[ 44.884572] ubi0: attaching mtd0
[ 44.893002] ubi0: scanning is finished
[ 44.893308] ubi0: empty MTD device detected
[ 44.947667] ubi0: attached mtd0 (name "NAND 512MiB 3,3V 8-bit", size 512 MiB)
[ 44.948231] ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
[ 44.948719] ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[ 44.949206] ubi0: VID header offset: 512 (aligned 512), data offset: 2048
[ 44.949686] ubi0: good PEBs: 4096, bad PEBs: 0, corrupted PEBs: 0
[ 44.950113] ubi0: user volume: 0, internal volumes: 1, max. volumes count: 128
[ 44.950639] ubi0: max/mean erase counter: 0/0, WL threshold: 4096, image sequence number: 3902257690
[ 44.951285] ubi0: available PEBs: 4012, total reserved PEBs: 84, PEBs reserved for bad PEB handling: 80
[ 44.951946] ubi0: background thread "ubi_bgt0d" started, PID 1022
# ubimkvol /dev/ubi0 -N test -m
Set volume size to 517644288
Volume ID 0, size 4012 LEBs (517644288 bytes, 493.6 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "test", alignment 1
# mount -t ubifs ubi0:test /mnt/ubifs
[ 122.812026] UBIFS (ubi0:0): default file-system created
[ 122.812377] UBIFS (ubi0:0): Mounting in unauthenticated mode
[ 122.813415] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" started, PID 1053
[ 122.813963] UBIFS (ubi0:0): UBIFS: mounted UBI device 0, volume 0, name "test"
[ 122.814334] UBIFS (ubi0:0): LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 122.814849] UBIFS (ubi0:0): FS size: 515579904 bytes (491 MiB, 3996 LEBs), max 4012 LEBs, journal size 25804800 bytes (24 MiB, 200 LEBs)
[ 122.815701] UBIFS (ubi0:0): reserved for root: 4952683 bytes (4836 KiB)
[ 122.816225] UBIFS (ubi0:0): media format: w5/r0 (latest is w5/r0), UUID 999464F1-4417-4523-B773-57C6EBD728DC, small LPT model
[ 122.817041] UBIFS (ubi0:0): full atime support is enabled.
# cp -a [~390M source tree] /mnt/ubifs
# diff -ur [tree] /mnt/ubifs/[copy of that tree] ; no output hopefully means OK
# umount /mnt/ubifs
[ 179.322533] UBIFS (ubi0:0): un-mount UBI device 0
[ 179.323801] UBIFS (ubi0:0): background thread "ubifs_bgt0_0" stops
# mount -t ubifs ubi0:test /mnt/ubifs
[ 185.313439] UBIFS (ubi0:0): Mounting in unauthenticated mode
...
# diff -ur [tree] /mnt/ubifs/[copy of that tree] ; likewise
etc.
Dmitry
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate
2026-04-10 5:57 ` Richard Weinberger
2026-04-10 11:55 ` Dmitry Antipov
@ 2026-04-10 12:00 ` Dmitry Antipov
2026-04-16 3:30 ` Zhihao Cheng
2026-04-13 13:24 ` Dmitry Antipov
2 siblings, 1 reply; 16+ messages in thread
From: Dmitry Antipov @ 2026-04-10 12:00 UTC (permalink / raw)
To: Richard Weinberger, chengzhihao1; +Cc: linux-mtd
On Fri, 2026-04-10 at 07:57 +0200, Richard Weinberger wrote:
> Dmitry, how are you testing these changes?
Build with:
CONFIG_KASAN=y
CONFIG_MTD_NAND_NANDSIM=m
CONFIG_MTD_UBI=m
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_MTD_UBI_BEB_LIMIT=20
CONFIG_UBIFS_FS=m
CONFIG_UBIFS_FS_ADVANCED_COMPR=y
CONFIG_UBIFS_FS_LZO=y
CONFIG_UBIFS_FS_ZLIB=y
CONFIG_UBIFS_FS_ZSTD=y
CONFIG_UBIFS_ATIME_SUPPORT=y
CONFIG_UBIFS_FS_XATTR=y
CONFIG_UBIFS_FS_SECURITY=y
CONFIG_UBIFS_FS_AUTHENTICATION=y
and boot (QEMU VM). Then use nandsim to create ~512M ubifs volume:
# modprobe nandsim second_id_byte=0xdc third_id_byte=0x80 fourth_id_byte=0x1d
# modprobe ubi mtd=0
# ubimkvol /dev/ubi0 -N test -m
Set volume size to 517644288
Volume ID 0, size 4012 LEBs (517644288 bytes, 493.6 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "test", alignment 1
# mount -t ubifs ubi0:test /mnt/ubifs
And do basic consistency check with something like:
# cp -a [~390M source tree] /mnt/ubifs
# diff -ur [tree] /mnt/ubifs/[copy of that tree] ; no output hopefully means OK
# umount /mnt/ubifs
# mount -t ubifs ubi0:test /mnt/ubifs
# diff -ur [tree] /mnt/ubifs/[copy of that tree] ; likewise
etc.
Dmitry
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate
2026-04-10 5:57 ` Richard Weinberger
2026-04-10 11:55 ` Dmitry Antipov
2026-04-10 12:00 ` Dmitry Antipov
@ 2026-04-13 13:24 ` Dmitry Antipov
2 siblings, 0 replies; 16+ messages in thread
From: Dmitry Antipov @ 2026-04-13 13:24 UTC (permalink / raw)
To: Richard Weinberger, chengzhihao1; +Cc: linux-mtd
On Fri, 2026-04-10 at 07:57 +0200, Richard Weinberger wrote:
> Dmitry, how are you testing these changes?
# modprobe nandsim second_id_byte=0xdc third_id_byte=0x80 fourth_id_byte=0x1d
# modprobe ubi mtd=0
# ubimkvol /dev/ubi0 -N test -m
Set volume size to 517644288
Volume ID 0, size 4012 LEBs (517644288 bytes, 493.6 MiB), LEB size 129024
bytes (126.0 KiB), dynamic, name "test", alignment 1
# mount -t ubifs ubi0:test /mnt/ubifs
# cp -a [~390M source tree] /mnt/ubifs
# diff -ur [tree] /mnt/ubifs/[tree]
# umount /mnt/ubifs
# sync
# mount /mnt/ubifs
# diff -ur [tree] /mnt/ubifs/[tree]
etc, etc. And yes, I'm aware of fsck.ubifs since 2.3.0 of mtd-utils.
Dmitry
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH v4 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate
2026-04-10 12:00 ` Dmitry Antipov
@ 2026-04-16 3:30 ` Zhihao Cheng
0 siblings, 0 replies; 16+ messages in thread
From: Zhihao Cheng @ 2026-04-16 3:30 UTC (permalink / raw)
To: Dmitry Antipov, Richard Weinberger; +Cc: linux-mtd
在 2026/4/10 20:00, Dmitry Antipov 写道:
> On Fri, 2026-04-10 at 07:57 +0200, Richard Weinberger wrote:
>
>> Dmitry, how are you testing these changes?
>
> Build with:
>
> CONFIG_KASAN=y
Hi, Dmitry
I'm pleasure with CONFIG_KASAN=y, and a fsstress test(>8h) for ubifs is
still needed.
>
> CONFIG_MTD_NAND_NANDSIM=m
>
> CONFIG_MTD_UBI=m
> CONFIG_MTD_UBI_WL_THRESHOLD=4096
> CONFIG_MTD_UBI_BEB_LIMIT=20
> CONFIG_UBIFS_FS=m
> CONFIG_UBIFS_FS_ADVANCED_COMPR=y
> CONFIG_UBIFS_FS_LZO=y
> CONFIG_UBIFS_FS_ZLIB=y
> CONFIG_UBIFS_FS_ZSTD=y
> CONFIG_UBIFS_ATIME_SUPPORT=y
> CONFIG_UBIFS_FS_XATTR=y
> CONFIG_UBIFS_FS_SECURITY=y
> CONFIG_UBIFS_FS_AUTHENTICATION=y
>
> and boot (QEMU VM). Then use nandsim to create ~512M ubifs volume:
>
> # modprobe nandsim second_id_byte=0xdc third_id_byte=0x80 fourth_id_byte=0x1d
> # modprobe ubi mtd=0
> # ubimkvol /dev/ubi0 -N test -m
> Set volume size to 517644288
> Volume ID 0, size 4012 LEBs (517644288 bytes, 493.6 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "test", alignment 1
> # mount -t ubifs ubi0:test /mnt/ubifs
>
> And do basic consistency check with something like:
>
> # cp -a [~390M source tree] /mnt/ubifs
> # diff -ur [tree] /mnt/ubifs/[copy of that tree] ; no output hopefully means OK
> # umount /mnt/ubifs
> # mount -t ubifs ubi0:test /mnt/ubifs
> # diff -ur [tree] /mnt/ubifs/[copy of that tree] ; likewise
>
> etc.
>
> Dmitry
> .
>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2026-04-16 3:30 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02 8:13 [PATCH] ubifs: prefer kstrtobool_from_user() over custom helper Dmitry Antipov
2026-04-02 11:18 ` Zhihao Cheng
2026-04-03 16:37 ` [PATCH v2 1/2] " Dmitry Antipov
2026-04-03 16:37 ` [PATCH v2 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate Dmitry Antipov
2026-04-07 2:37 ` Zhihao Cheng
2026-04-07 16:05 ` [PATCH v3 1/2] ubifs: prefer kstrtobool_from_user() over custom helper Dmitry Antipov
2026-04-07 16:05 ` [PATCH v3 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate Dmitry Antipov
2026-04-08 6:09 ` Zhihao Cheng
2026-04-09 4:56 ` [PATCH v4 1/2] ubifs: prefer kstrtobool_from_user() over custom helper Dmitry Antipov
2026-04-09 4:56 ` [PATCH v4 2/2] ubifs: use strscpy() and kmemdup_nul() where appropriate Dmitry Antipov
2026-04-10 1:06 ` Zhihao Cheng
2026-04-10 5:57 ` Richard Weinberger
2026-04-10 11:55 ` Dmitry Antipov
2026-04-10 12:00 ` Dmitry Antipov
2026-04-16 3:30 ` Zhihao Cheng
2026-04-13 13:24 ` Dmitry Antipov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox