Skip to content

Commit a56d313

Browse files
committed
Merge tag 'configfs-for-v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/a.hindborg/linux
Pull configfs updates from Andreas Hindborg: - Allow creation of rw files with custom permissions. This allows drivers to better protect secrets written through configfs - Fix a bug where an error condition did not cause an early return while populating attributes - Report ENOMEM rather than EFAULT when kvasprintf() fails in config_item_set_name() - Add a Rust API for configfs. This allows Rust drivers to use configfs through a memory safe interface * tag 'configfs-for-v6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/a.hindborg/linux: MAINTAINERS: add configfs Rust abstractions rust: configfs: add a sample demonstrating configfs usage rust: configfs: introduce rust support for configfs configfs: Correct error value returned by API config_item_set_name() configfs: Do not override creating attribute file failure in populate_attrs() configfs: Delete semicolon from macro type_print() definition configfs: Add CONFIGFS_ATTR_PERM helper
2 parents 5e82ed5 + c6b1908 commit a56d313

File tree

11 files changed

+1272
-5
lines changed

11 files changed

+1272
-5
lines changed

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5983,7 +5983,9 @@ S: Supported
59835983
T: git git://git.kernel.org/pub/scm/linux/kernel/git/a.hindborg/linux.git configfs-next
59845984
F: fs/configfs/
59855985
F: include/linux/configfs.h
5986+
F: rust/kernel/configfs.rs
59865987
F: samples/configfs/
5988+
F: samples/rust/rust_configfs.rs
59875989

59885990
CONGATEC BOARD CONTROLLER MFD DRIVER
59895991
M: Thomas Richard <[email protected]>

fs/configfs/dir.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ static int populate_attrs(struct config_item *item)
619619
break;
620620
}
621621
}
622-
if (t->ct_bin_attrs) {
622+
if (!error && t->ct_bin_attrs) {
623623
for (i = 0; (bin_attr = t->ct_bin_attrs[i]) != NULL; i++) {
624624
if (ops && ops->is_bin_visible && !ops->is_bin_visible(item, bin_attr, i))
625625
continue;
@@ -970,7 +970,7 @@ static void configfs_dump_one(struct configfs_dirent *sd, int level)
970970
{
971971
pr_info("%*s\"%s\":\n", level, " ", configfs_get_name(sd));
972972

973-
#define type_print(_type) if (sd->s_type & _type) pr_info("%*s %s\n", level, " ", #_type);
973+
#define type_print(_type) if (sd->s_type & _type) pr_info("%*s %s\n", level, " ", #_type)
974974
type_print(CONFIGFS_ROOT);
975975
type_print(CONFIGFS_DIR);
976976
type_print(CONFIGFS_ITEM_ATTR);

fs/configfs/item.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int config_item_set_name(struct config_item *item, const char *fmt, ...)
6666
name = kvasprintf(GFP_KERNEL, fmt, args);
6767
va_end(args);
6868
if (!name)
69-
return -EFAULT;
69+
return -ENOMEM;
7070
}
7171

7272
/* Free the old name, if necessary. */

include/linux/configfs.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,19 @@ struct configfs_attribute {
120120
ssize_t (*store)(struct config_item *, const char *, size_t);
121121
};
122122

123-
#define CONFIGFS_ATTR(_pfx, _name) \
123+
#define CONFIGFS_ATTR_PERM(_pfx, _name, _perm) \
124124
static struct configfs_attribute _pfx##attr_##_name = { \
125125
.ca_name = __stringify(_name), \
126-
.ca_mode = S_IRUGO | S_IWUSR, \
126+
.ca_mode = _perm, \
127127
.ca_owner = THIS_MODULE, \
128128
.show = _pfx##_name##_show, \
129129
.store = _pfx##_name##_store, \
130130
}
131131

132+
#define CONFIGFS_ATTR(_pfx, _name) CONFIGFS_ATTR_PERM( \
133+
_pfx, _name, S_IRUGO | S_IWUSR \
134+
)
135+
132136
#define CONFIGFS_ATTR_RO(_pfx, _name) \
133137
static struct configfs_attribute _pfx##attr_##_name = { \
134138
.ca_name = __stringify(_name), \

rust/bindings/bindings_helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/blk-mq.h>
1111
#include <linux/blk_types.h>
1212
#include <linux/blkdev.h>
13+
#include <linux/configfs.h>
1314
#include <linux/cpumask.h>
1415
#include <linux/cred.h>
1516
#include <linux/device/faux.h>

rust/helpers/mutex.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ void rust_helper_mutex_assert_is_held(struct mutex *mutex)
1717
{
1818
lockdep_assert_held(mutex);
1919
}
20+
21+
void rust_helper_mutex_destroy(struct mutex *lock)
22+
{
23+
mutex_destroy(lock);
24+
}

0 commit comments

Comments
 (0)