Skip to content

Commit f153c22

Browse files
svens-s390ebiederm
authored andcommitted
ucounts: add missing data type changes
commit f9c82a4 ("Increase size of ucounts to atomic_long_t") changed the data type of ucounts/ucounts_max to long, but missed to adjust a few other places. This is noticeable on big endian platforms from user space because the /proc/sys/user/max_*_names files all contain 0. v4 - Made the min and max constants long so the sysctl values are actually settable on little endian machines. -- EWB Fixes: f9c82a4 ("Increase size of ucounts to atomic_long_t") Signed-off-by: Sven Schnelle <svens@linux.ibm.com> Tested-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Linux Kernel Functional Testing <lkft@linaro.org> Acked-by: Alexey Gladkov <legion@kernel.org> v1: https://lkml.kernel.org/r/20210721115800.910778-1-svens@linux.ibm.com v2: https://lkml.kernel.org/r/20210721125233.1041429-1-svens@linux.ibm.com v3: https://lkml.kernel.org/r/20210730062854.3601635-1-svens@linux.ibm.com Link: https://lkml.kernel.org/r/8735rijqlv.fsf_-_@disp2133 Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
1 parent 345daff commit f153c22

3 files changed

Lines changed: 33 additions & 20 deletions

File tree

fs/notify/fanotify/fanotify_user.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,27 @@ static int fanotify_max_queued_events __read_mostly;
5454

5555
#include <linux/sysctl.h>
5656

57+
static long ft_zero = 0;
58+
static long ft_int_max = INT_MAX;
59+
5760
struct ctl_table fanotify_table[] = {
5861
{
5962
.procname = "max_user_groups",
6063
.data = &init_user_ns.ucount_max[UCOUNT_FANOTIFY_GROUPS],
61-
.maxlen = sizeof(int),
64+
.maxlen = sizeof(long),
6265
.mode = 0644,
63-
.proc_handler = proc_dointvec_minmax,
64-
.extra1 = SYSCTL_ZERO,
66+
.proc_handler = proc_doulongvec_minmax,
67+
.extra1 = &ft_zero,
68+
.extra2 = &ft_int_max,
6569
},
6670
{
6771
.procname = "max_user_marks",
6872
.data = &init_user_ns.ucount_max[UCOUNT_FANOTIFY_MARKS],
69-
.maxlen = sizeof(int),
73+
.maxlen = sizeof(long),
7074
.mode = 0644,
71-
.proc_handler = proc_dointvec_minmax,
72-
.extra1 = SYSCTL_ZERO,
75+
.proc_handler = proc_doulongvec_minmax,
76+
.extra1 = &ft_zero,
77+
.extra2 = &ft_int_max,
7378
},
7479
{
7580
.procname = "max_queued_events",

fs/notify/inotify/inotify_user.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,27 @@ struct kmem_cache *inotify_inode_mark_cachep __read_mostly;
5555

5656
#include <linux/sysctl.h>
5757

58+
static long it_zero = 0;
59+
static long it_int_max = INT_MAX;
60+
5861
struct ctl_table inotify_table[] = {
5962
{
6063
.procname = "max_user_instances",
6164
.data = &init_user_ns.ucount_max[UCOUNT_INOTIFY_INSTANCES],
62-
.maxlen = sizeof(int),
65+
.maxlen = sizeof(long),
6366
.mode = 0644,
64-
.proc_handler = proc_dointvec_minmax,
65-
.extra1 = SYSCTL_ZERO,
67+
.proc_handler = proc_doulongvec_minmax,
68+
.extra1 = &it_zero,
69+
.extra2 = &it_int_max,
6670
},
6771
{
6872
.procname = "max_user_watches",
6973
.data = &init_user_ns.ucount_max[UCOUNT_INOTIFY_WATCHES],
70-
.maxlen = sizeof(int),
74+
.maxlen = sizeof(long),
7175
.mode = 0644,
72-
.proc_handler = proc_dointvec_minmax,
73-
.extra1 = SYSCTL_ZERO,
76+
.proc_handler = proc_doulongvec_minmax,
77+
.extra1 = &it_zero,
78+
.extra2 = &it_int_max,
7479
},
7580
{
7681
.procname = "max_queued_events",

kernel/ucount.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,17 @@ static struct ctl_table_root set_root = {
5858
.permissions = set_permissions,
5959
};
6060

61-
#define UCOUNT_ENTRY(name) \
62-
{ \
63-
.procname = name, \
64-
.maxlen = sizeof(int), \
65-
.mode = 0644, \
66-
.proc_handler = proc_dointvec_minmax, \
67-
.extra1 = SYSCTL_ZERO, \
68-
.extra2 = SYSCTL_INT_MAX, \
61+
static long ue_zero = 0;
62+
static long ue_int_max = INT_MAX;
63+
64+
#define UCOUNT_ENTRY(name) \
65+
{ \
66+
.procname = name, \
67+
.maxlen = sizeof(long), \
68+
.mode = 0644, \
69+
.proc_handler = proc_doulongvec_minmax, \
70+
.extra1 = &ue_zero, \
71+
.extra2 = &ue_int_max, \
6972
}
7073
static struct ctl_table user_table[] = {
7174
UCOUNT_ENTRY("max_user_namespaces"),

0 commit comments

Comments
 (0)