hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/proc/proc_sysctl.c
....@@ -16,6 +16,7 @@
1616 #include <linux/module.h>
1717 #include <linux/bpf-cgroup.h>
1818 #include <linux/mount.h>
19
+#include <linux/kmemleak.h>
1920 #include "internal.h"
2021
2122 static const struct dentry_operations proc_sys_dentry_operations;
....@@ -27,6 +28,8 @@
2728 /* shared constants to be used in various sysctls */
2829 const int sysctl_vals[] = { 0, 1, INT_MAX };
2930 EXPORT_SYMBOL(sysctl_vals);
31
+const int android_gki_sysctl_vals[] = { -1, 0, 1, 2, 4, 100, 200, 1000, 3000, INT_MAX };
32
+EXPORT_SYMBOL(android_gki_sysctl_vals);
3033
3134 /* Support for permanently empty directories */
3235
....@@ -1105,6 +1108,11 @@
11051108 err |= sysctl_err(path, table, "array not allowed");
11061109 }
11071110
1111
+ if (table->proc_handler == proc_dou8vec_minmax) {
1112
+ if (table->maxlen != sizeof(u8))
1113
+ err |= sysctl_err(path, table, "array not allowed");
1114
+ }
1115
+
11081116 return err;
11091117 }
11101118
....@@ -1120,6 +1128,7 @@
11201128 (table->proc_handler == proc_douintvec) ||
11211129 (table->proc_handler == proc_douintvec_minmax) ||
11221130 (table->proc_handler == proc_dointvec_minmax) ||
1131
+ (table->proc_handler == proc_dou8vec_minmax) ||
11231132 (table->proc_handler == proc_dointvec_jiffies) ||
11241133 (table->proc_handler == proc_dointvec_userhz_jiffies) ||
11251134 (table->proc_handler == proc_dointvec_ms_jiffies) ||
....@@ -1380,6 +1389,38 @@
13801389 }
13811390 EXPORT_SYMBOL(register_sysctl);
13821391
1392
+/**
1393
+ * __register_sysctl_init() - register sysctl table to path
1394
+ * @path: path name for sysctl base
1395
+ * @table: This is the sysctl table that needs to be registered to the path
1396
+ * @table_name: The name of sysctl table, only used for log printing when
1397
+ * registration fails
1398
+ *
1399
+ * The sysctl interface is used by userspace to query or modify at runtime
1400
+ * a predefined value set on a variable. These variables however have default
1401
+ * values pre-set. Code which depends on these variables will always work even
1402
+ * if register_sysctl() fails. If register_sysctl() fails you'd just loose the
1403
+ * ability to query or modify the sysctls dynamically at run time. Chances of
1404
+ * register_sysctl() failing on init are extremely low, and so for both reasons
1405
+ * this function does not return any error as it is used by initialization code.
1406
+ *
1407
+ * Context: Can only be called after your respective sysctl base path has been
1408
+ * registered. So for instance, most base directories are registered early on
1409
+ * init before init levels are processed through proc_sys_init() and
1410
+ * sysctl_init().
1411
+ */
1412
+void __init __register_sysctl_init(const char *path, struct ctl_table *table,
1413
+ const char *table_name)
1414
+{
1415
+ struct ctl_table_header *hdr = register_sysctl(path, table);
1416
+
1417
+ if (unlikely(!hdr)) {
1418
+ pr_err("failed when register_sysctl %s to %s\n", table_name, path);
1419
+ return;
1420
+ }
1421
+ kmemleak_not_leak(hdr);
1422
+}
1423
+
13831424 static char *append_path(const char *path, char *pos, const char *name)
13841425 {
13851426 int namelen;