hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/libfs.c
....@@ -955,8 +955,8 @@
955955 EXPORT_SYMBOL_GPL(simple_attr_read);
956956
957957 /* interpret the buffer as a number to call the set function with */
958
-ssize_t simple_attr_write(struct file *file, const char __user *buf,
959
- size_t len, loff_t *ppos)
958
+static ssize_t simple_attr_write_xsigned(struct file *file, const char __user *buf,
959
+ size_t len, loff_t *ppos, bool is_signed)
960960 {
961961 struct simple_attr *attr;
962962 unsigned long long val;
....@@ -977,7 +977,10 @@
977977 goto out;
978978
979979 attr->set_buf[size] = '\0';
980
- ret = kstrtoull(attr->set_buf, 0, &val);
980
+ if (is_signed)
981
+ ret = kstrtoll(attr->set_buf, 0, &val);
982
+ else
983
+ ret = kstrtoull(attr->set_buf, 0, &val);
981984 if (ret)
982985 goto out;
983986 ret = attr->set(attr->data, val);
....@@ -987,8 +990,21 @@
987990 mutex_unlock(&attr->mutex);
988991 return ret;
989992 }
993
+
994
+ssize_t simple_attr_write(struct file *file, const char __user *buf,
995
+ size_t len, loff_t *ppos)
996
+{
997
+ return simple_attr_write_xsigned(file, buf, len, ppos, false);
998
+}
990999 EXPORT_SYMBOL_GPL(simple_attr_write);
9911000
1001
+ssize_t simple_attr_write_signed(struct file *file, const char __user *buf,
1002
+ size_t len, loff_t *ppos)
1003
+{
1004
+ return simple_attr_write_xsigned(file, buf, len, ppos, true);
1005
+}
1006
+EXPORT_SYMBOL_GPL(simple_attr_write_signed);
1007
+
9921008 /**
9931009 * generic_fh_to_dentry - generic helper for the fh_to_dentry export operation
9941010 * @sb: filesystem to do the file handle conversion on