Skip to contentSkip to conversation

proc/sysctl: add shared variables for range check

PATCH Alexey Dobriyan 3 participants 3 messages Jul 2, 2019 – Jul 3, 2019 VFS

lore
Share & tools
lore
#0 lore raw

Review struct ctl_table epoll_table[] = { · line 304

Quoted 11 lines
(quoted diff) +1 -2
-static long zero;
 static long long_max = LONG_MAX;
 
 struct ctl_table epoll_table[] = {
@@ -301,7 +300,7 @@ struct ctl_table epoll_table[] = {
                .maxlen         = sizeof(max_user_watches),
                .mode           = 0644,
                .proc_handler   = proc_doulongvec_minmax,
-               .extra1         = &zero,
+               .extra1         = SYSCTL_ZERO,
                .extra2         = &long_max,

This looks wrong: proc_doulongvec_minmax() expects "long"s. The whole patch needs rechecking.

Quoted 3 lines
(quoted diff) +3 -0
+/* shared constants to be used in various sysctls */
+const =======>int<========== sysctl_vals[] = { 0, 1, INT_MAX };
+EXPORT_SYMBOL(sysctl_vals);
#1 lore raw
Quoted 16 lines · Alexey Dobriyan

Review struct ctl_table epoll_table[] = { · line 304

Quoted 12 lines
(quoted diff) +1 -2
-static long zero;
 static long long_max = LONG_MAX;
 
 struct ctl_table epoll_table[] = {
@@ -301,7 +300,7 @@ struct ctl_table epoll_table[] = {
                .maxlen         = sizeof(max_user_watches),
                .mode           = 0644,
                .proc_handler   = proc_doulongvec_minmax,
-               .extra1         = &zero,
+               .extra1         = SYSCTL_ZERO,
                .extra2         = &long_max,

This looks wrong: proc_doulongvec_minmax() expects "long"s. The whole patch needs rechecking.

Quoted 3 lines

Review struct ctl_table epoll_table[] = {

Quoted 3 lines
(quoted diff) +3 -0
+/* shared constants to be used in various sysctls */
+const =======>int<========== sysctl_vals[] = { 0, 1, INT_MAX };
+EXPORT_SYMBOL(sysctl_vals);

Yes, you're right, that chunk must be dropped.
Anyway I've checked the patch, this was the only long field touched.

Regards,

Signature · 2 lines
Matteo Croce
per aspera ad upstream
#2 lore raw
Quoted 17 lines · On Tue, 2 Jul 2019 19:21:33 +0200 Matteo Croce <[email protected]> wrote:
Quoted 16 lines · Alexey Dobriyan

Review struct ctl_table epoll_table[] = { · line 304

Quoted 12 lines
(quoted diff) +1 -2
-static long zero;
 static long long_max = LONG_MAX;
 
 struct ctl_table epoll_table[] = {
@@ -301,7 +300,7 @@ struct ctl_table epoll_table[] = {
                .maxlen         = sizeof(max_user_watches),
                .mode           = 0644,
                .proc_handler   = proc_doulongvec_minmax,
-               .extra1         = &zero,
+               .extra1         = SYSCTL_ZERO,
                .extra2         = &long_max,

This looks wrong: proc_doulongvec_minmax() expects "long"s. The whole patch needs rechecking.

Quoted 6 lines
Quoted 3 lines

Review struct ctl_table epoll_table[] = {

Quoted 3 lines
(quoted diff) +3 -0
+/* shared constants to be used in various sysctls */
+const =======>int<========== sysctl_vals[] = { 0, 1, INT_MAX };
+EXPORT_SYMBOL(sysctl_vals);

Yes, you're right, that chunk must be dropped.
Anyway I've checked the patch, this was the only long field touched.

Yup.

akpm3:/usr/src/25> find . -name "*.c" | xargs grep -C4 SYSCTL_ZERO|grep long

./fs/eventpoll.c-               .proc_handler   = proc_doulongvec_minmax,
./fs/eventpoll.c-               .extra2         = &long_max,

I did this:

fs/eventpoll.c renamed from fs/eventpoll.c~proc-sysctl-add-shared-variables-for-range-check-fix-4 +2 -1
@@ -291,6 +291,7 @@ static LIST_HEAD(tfile_check_list);
 
 #include <linux/sysctl.h>
 
+static long long_zero;
 static long long_max = LONG_MAX;
 
 struct ctl_table epoll_table[] = {
@@ -300,7 +301,7 @@ struct ctl_table epoll_table[] = {
 		.maxlen		= sizeof(max_user_watches),
 		.mode		= 0644,
 		.proc_handler	= proc_doulongvec_minmax,
-		.extra1		= SYSCTL_ZERO,
+		.extra1		= &long_zero,
 		.extra2		= &long_max,
 	},
 	{ }

I renamed it to avoid using "&zero," in this situation.