mirror of
https://github.com/torvalds/linux.git
synced 2024-12-27 21:33:00 +00:00
sysctl-6.8-rc1
To help make the move of sysctls out of kernel/sysctl.c not incur a size penalty sysctl has been changed to allow us to not require the sentinel, the final empty element on the sysctl array. Joel Granados has been doing all this work. On the v6.6 kernel we got the major infrastructure changes required to support this. For v6.7 we had all arch/ and drivers/ modified to remove the sentinel. For v6.8-rc1 we get a few more updates for fs/ directory only. The kernel/ directory is left but we'll save that for v6.9-rc1 as those patches are still being reviewed. After that we then can expect also the removal of the no longer needed check for procname == NULL. Let us recap the purpose of this work: - this helps reduce the overall build time size of the kernel and run time memory consumed by the kernel by about ~64 bytes per array - the extra 64-byte penalty is no longer inncurred now when we move sysctls out from kernel/sysctl.c to their own files Thomas Weißschuh also sent a few cleanups, for v6.9-rc1 we expect to see further work by Thomas Weißschuh with the constificatin of the struct ctl_table. Due to Joel Granados's work, and to help bring in new blood, I have suggested for him to become a maintainer and he's accepted. So for v6.9-rc1 I look forward to seeing him sent you a pull request for further sysctl changes. This also removes Iurii Zaikin as a maintainer as he has moved on to other projects and has had no time to help at all. -----BEGIN PGP SIGNATURE----- iQJGBAABCgAwFiEENnNq2KuOejlQLZofziMdCjCSiKcFAmWdWDESHG1jZ3JvZkBr ZXJuZWwub3JnAAoJEM4jHQowkoinjJAP/jTNNoyzWisvrrvmXqR5txFGLOE+wW6x Xv9avuiM+DTHsH/wK8CkXEivwDqYNAZEHU7NEcolS5bJX/ddSRwN9b5aSVlCrUdX Ab4rXmpeSCNFp9zNszWJsDuBKIqjvsKw7qGleGtgZ2qAUHbbH30VROLWCggaee50 wU3icDLdwkasxrcMXy4Sq5dT5wYC4j/QelqBGIkYPT14Arl1im5zqPZ95gmO/s/6 mdicTAmq+hhAUfUBJBXRKtsvxY6CItxe55Q4fjpncLUJLHUw+VPVNoBKFWJlBwlh LO3liKFfakPSkil4/en+/+zuMByd0JBkIzIJa+Kk5kjpbHRhK0RkmU4+Y5G5spWN jjLfiv6RxInNaZ8EWQBMfjE95A7PmYDQ4TOH08+OvzdDIi6B0BB5tBGQpG9BnyXk YsLg1Uo4CwE/vn1/a9w0rhadjUInvmAryhb/uSJYFz/lmApLm2JUpY3/KstwGetb z+HmLstJb24Djkr6pH8DcjhzRBHeWQ5p0b4/6B+v1HqAUuEhdbyw1F2GrDywyF3R h/UOAaKLm1+ffdA246o9TejKiDU96qEzzXMaCzPKyestaRZuiyuYEMDhYbvtsMV5 zIdMJj5HQ+U1KHDv4IN99DEj7+/vjE3f4Sjo+POFpQeQ8/d+fxpFNqXVv449dgnb 6xEkkxsR0ElM =2qBt -----END PGP SIGNATURE----- Merge tag 'sysctl-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux Pull sysctl updates from Luis Chamberlain: "To help make the move of sysctls out of kernel/sysctl.c not incur a size penalty sysctl has been changed to allow us to not require the sentinel, the final empty element on the sysctl array. Joel Granados has been doing all this work. In the v6.6 kernel we got the major infrastructure changes required to support this. For v6.7 we had all arch/ and drivers/ modified to remove the sentinel. For v6.8-rc1 we get a few more updates for fs/ directory only. The kernel/ directory is left but we'll save that for v6.9-rc1 as those patches are still being reviewed. After that we then can expect also the removal of the no longer needed check for procname == NULL. Let us recap the purpose of this work: - this helps reduce the overall build time size of the kernel and run time memory consumed by the kernel by about ~64 bytes per array - the extra 64-byte penalty is no longer inncurred now when we move sysctls out from kernel/sysctl.c to their own files Thomas Weißschuh also sent a few cleanups, for v6.9-rc1 we expect to see further work by Thomas Weißschuh with the constificatin of the struct ctl_table. Due to Joel Granados's work, and to help bring in new blood, I have suggested for him to become a maintainer and he's accepted. So for v6.9-rc1 I look forward to seeing him sent you a pull request for further sysctl changes. This also removes Iurii Zaikin as a maintainer as he has moved on to other projects and has had no time to help at all" * tag 'sysctl-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux: sysctl: remove struct ctl_path sysctl: delete unused define SYSCTL_PERM_EMPTY_DIR coda: Remove the now superfluous sentinel elements from ctl_table array sysctl: Remove the now superfluous sentinel elements from ctl_table array fs: Remove the now superfluous sentinel elements from ctl_table array cachefiles: Remove the now superfluous sentinel element from ctl_table array sysclt: Clarify the results of selftest run sysctl: Add a selftest for handling empty dirs sysctl: Fix out of bounds access for empty sysctl registers MAINTAINERS: Add Joel Granados as co-maintainer for proc sysctl MAINTAINERS: remove Iurii Zaikin from proc sysctl
This commit is contained in:
commit
a05aea98d4
@ -17412,7 +17412,7 @@ F: tools/testing/selftests/proc/
|
||||
PROC SYSCTL
|
||||
M: Luis Chamberlain <mcgrof@kernel.org>
|
||||
M: Kees Cook <keescook@chromium.org>
|
||||
M: Iurii Zaikin <yzaikin@google.com>
|
||||
M: Joel Granados <j.granados@samsung.com>
|
||||
L: linux-kernel@vger.kernel.org
|
||||
L: linux-fsdevel@vger.kernel.org
|
||||
S: Maintained
|
||||
|
1
fs/aio.c
1
fs/aio.c
@ -239,7 +239,6 @@ static struct ctl_table aio_sysctls[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_doulongvec_minmax,
|
||||
},
|
||||
{}
|
||||
};
|
||||
|
||||
static void __init aio_sysctl_init(void)
|
||||
|
@ -19,7 +19,6 @@ static struct ctl_table cachefiles_sysctls[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_douintvec,
|
||||
},
|
||||
{}
|
||||
};
|
||||
|
||||
int __init cachefiles_register_error_injection(void)
|
||||
|
@ -36,7 +36,6 @@ static struct ctl_table coda_table[] = {
|
||||
.mode = 0600,
|
||||
.proc_handler = proc_dointvec
|
||||
},
|
||||
{}
|
||||
};
|
||||
|
||||
void coda_sysctl_init(void)
|
||||
|
@ -981,7 +981,6 @@ static struct ctl_table coredump_sysctls[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __init init_fs_coredump_sysctls(void)
|
||||
|
@ -191,7 +191,6 @@ static struct ctl_table fs_dcache_sysctls[] = {
|
||||
.mode = 0444,
|
||||
.proc_handler = proc_nr_dentry,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __init init_fs_dcache_sysctls(void)
|
||||
|
@ -69,7 +69,6 @@ static struct ctl_table pty_table[] = {
|
||||
.data = &pty_count,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{}
|
||||
};
|
||||
|
||||
struct pts_mount_opts {
|
||||
|
@ -322,7 +322,6 @@ static struct ctl_table epoll_table[] = {
|
||||
.extra1 = &long_zero,
|
||||
.extra2 = &long_max,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static void __init epoll_sysctls_init(void)
|
||||
|
@ -2165,7 +2165,6 @@ static struct ctl_table fs_exec_sysctls[] = {
|
||||
.extra1 = SYSCTL_ZERO,
|
||||
.extra2 = SYSCTL_TWO,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __init init_fs_exec_sysctls(void)
|
||||
|
@ -130,7 +130,6 @@ static struct ctl_table fs_stat_sysctls[] = {
|
||||
.extra1 = &sysctl_nr_open_min,
|
||||
.extra2 = &sysctl_nr_open_max,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __init init_fs_stat_sysctls(void)
|
||||
|
@ -129,7 +129,6 @@ static struct ctl_table inodes_sysctls[] = {
|
||||
.mode = 0444,
|
||||
.proc_handler = proc_nr_inodes,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __init init_fs_inode_sysctls(void)
|
||||
|
@ -473,7 +473,6 @@ static struct ctl_table nlm_sysctls[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
#endif /* CONFIG_SYSCTL */
|
||||
|
@ -111,7 +111,6 @@ static struct ctl_table locks_sysctls[] = {
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
#endif /* CONFIG_MMU */
|
||||
{}
|
||||
};
|
||||
|
||||
static int __init init_fs_locks_sysctls(void)
|
||||
|
@ -1071,7 +1071,6 @@ static struct ctl_table namei_sysctls[] = {
|
||||
.extra1 = SYSCTL_ZERO,
|
||||
.extra2 = SYSCTL_TWO,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __init init_fs_namei_sysctls(void)
|
||||
|
@ -5447,7 +5447,6 @@ static struct ctl_table fs_namespace_sysctls[] = {
|
||||
.proc_handler = proc_dointvec_minmax,
|
||||
.extra1 = SYSCTL_ONE,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __init init_fs_namespace_sysctls(void)
|
||||
|
@ -34,7 +34,6 @@ static struct ctl_table nfs4_cb_sysctls[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
int nfs4_register_sysctl(void)
|
||||
|
@ -29,7 +29,6 @@ static struct ctl_table nfs_cb_sysctls[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
int nfs_register_sysctl(void)
|
||||
|
@ -29,7 +29,6 @@ static struct ctl_table dnotify_sysctls[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
{}
|
||||
};
|
||||
static void __init dnotify_sysctl_init(void)
|
||||
{
|
||||
|
@ -86,7 +86,6 @@ static struct ctl_table fanotify_table[] = {
|
||||
.proc_handler = proc_dointvec_minmax,
|
||||
.extra1 = SYSCTL_ZERO
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static void __init fanotify_sysctls_init(void)
|
||||
|
@ -85,7 +85,6 @@ static struct ctl_table inotify_table[] = {
|
||||
.proc_handler = proc_dointvec_minmax,
|
||||
.extra1 = SYSCTL_ZERO
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static void __init inotify_sysctls_init(void)
|
||||
|
@ -28,7 +28,6 @@ static struct ctl_table ntfs_sysctls[] = {
|
||||
.mode = 0644, /* Mode, proc handler. */
|
||||
.proc_handler = proc_dointvec
|
||||
},
|
||||
{}
|
||||
};
|
||||
|
||||
/* Storage for the sysctls header. */
|
||||
|
@ -658,7 +658,6 @@ static struct ctl_table ocfs2_nm_table[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dostring,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct ctl_table_header *ocfs2_table_header;
|
||||
|
@ -1507,7 +1507,6 @@ static struct ctl_table fs_pipe_sysctls[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_doulongvec_minmax,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -44,7 +44,7 @@ static struct ctl_table sysctl_mount_point[] = {
|
||||
*/
|
||||
struct ctl_table_header *register_sysctl_mount_point(const char *path)
|
||||
{
|
||||
return register_sysctl_sz(path, sysctl_mount_point, 0);
|
||||
return register_sysctl(path, sysctl_mount_point);
|
||||
}
|
||||
EXPORT_SYMBOL(register_sysctl_mount_point);
|
||||
|
||||
@ -71,7 +71,6 @@ static struct ctl_table root_table[] = {
|
||||
.procname = "",
|
||||
.mode = S_IFDIR|S_IRUGO|S_IXUGO,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
static struct ctl_table_root sysctl_table_root = {
|
||||
.default_set.dir.header = {
|
||||
@ -233,7 +232,8 @@ static int insert_header(struct ctl_dir *dir, struct ctl_table_header *header)
|
||||
return -EROFS;
|
||||
|
||||
/* Am I creating a permanently empty directory? */
|
||||
if (sysctl_is_perm_empty_ctl_table(header->ctl_table)) {
|
||||
if (header->ctl_table_size > 0 &&
|
||||
sysctl_is_perm_empty_ctl_table(header->ctl_table)) {
|
||||
if (!RB_EMPTY_ROOT(&dir->root))
|
||||
return -EINVAL;
|
||||
sysctl_set_perm_empty_ctl_header(dir_h);
|
||||
@ -1213,6 +1213,10 @@ static bool get_links(struct ctl_dir *dir,
|
||||
struct ctl_table_header *tmp_head;
|
||||
struct ctl_table *entry, *link;
|
||||
|
||||
if (header->ctl_table_size == 0 ||
|
||||
sysctl_is_perm_empty_ctl_table(header->ctl_table))
|
||||
return true;
|
||||
|
||||
/* Are there links available for every entry in table? */
|
||||
list_for_each_table_entry(entry, header) {
|
||||
const char *procname = entry->procname;
|
||||
|
@ -2969,7 +2969,6 @@ static struct ctl_table fs_dqstats_table[] = {
|
||||
.proc_handler = proc_dointvec,
|
||||
},
|
||||
#endif
|
||||
{ },
|
||||
};
|
||||
|
||||
static int __init dquot_init(void)
|
||||
|
@ -26,7 +26,6 @@ static struct ctl_table fs_shared_sysctls[] = {
|
||||
.extra1 = SYSCTL_ZERO,
|
||||
.extra2 = SYSCTL_MAXOLDUID,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static int __init init_fs_sysctls(void)
|
||||
|
@ -45,7 +45,6 @@ static struct ctl_table vm_userfaultfd_table[] = {
|
||||
.extra1 = SYSCTL_ZERO,
|
||||
.extra2 = SYSCTL_ONE,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -24,7 +24,6 @@ static struct ctl_table fsverity_sysctl_table[] = {
|
||||
.extra2 = SYSCTL_ONE,
|
||||
},
|
||||
#endif
|
||||
{ }
|
||||
};
|
||||
|
||||
static void __init fsverity_init_sysctl(void)
|
||||
|
@ -206,8 +206,6 @@ static struct ctl_table xfs_table[] = {
|
||||
.extra2 = &xfs_params.stats_clear.max
|
||||
},
|
||||
#endif /* CONFIG_PROC_FS */
|
||||
|
||||
{}
|
||||
};
|
||||
|
||||
int
|
||||
|
@ -210,11 +210,6 @@ struct ctl_table_root {
|
||||
int (*permissions)(struct ctl_table_header *head, struct ctl_table *table);
|
||||
};
|
||||
|
||||
/* struct ctl_path describes where in the hierarchy a table is added */
|
||||
struct ctl_path {
|
||||
const char *procname;
|
||||
};
|
||||
|
||||
#define register_sysctl(path, table) \
|
||||
register_sysctl_sz(path, table, ARRAY_SIZE(table))
|
||||
|
||||
@ -255,8 +250,6 @@ extern int unaligned_enabled;
|
||||
extern int unaligned_dump_stack;
|
||||
extern int no_unaligned_warning;
|
||||
|
||||
#define SYSCTL_PERM_EMPTY_DIR (1 << 0)
|
||||
|
||||
#else /* CONFIG_SYSCTL */
|
||||
|
||||
static inline void register_sysctl_init(const char *path, struct ctl_table *table)
|
||||
|
@ -35,6 +35,8 @@ static struct {
|
||||
struct ctl_table_header *test_h_setup_node;
|
||||
struct ctl_table_header *test_h_mnt;
|
||||
struct ctl_table_header *test_h_mnterror;
|
||||
struct ctl_table_header *empty_add;
|
||||
struct ctl_table_header *empty;
|
||||
} sysctl_test_headers;
|
||||
|
||||
struct test_sysctl_data {
|
||||
@ -130,7 +132,6 @@ static struct ctl_table test_table[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_do_large_bitmap,
|
||||
},
|
||||
{ }
|
||||
};
|
||||
|
||||
static void test_sysctl_calc_match_int_ok(void)
|
||||
@ -184,7 +185,6 @@ static struct ctl_table test_table_unregister[] = {
|
||||
.mode = 0644,
|
||||
.proc_handler = proc_dointvec_minmax,
|
||||
},
|
||||
{}
|
||||
};
|
||||
|
||||
static int test_sysctl_run_unregister_nested(void)
|
||||
@ -220,6 +220,25 @@ static int test_sysctl_run_register_mount_point(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct ctl_table test_table_empty[] = { };
|
||||
|
||||
static int test_sysctl_run_register_empty(void)
|
||||
{
|
||||
/* Tets that an empty dir can be created */
|
||||
sysctl_test_headers.empty_add
|
||||
= register_sysctl("debug/test_sysctl/empty_add", test_table_empty);
|
||||
if (!sysctl_test_headers.empty_add)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Test that register on top of an empty dir works */
|
||||
sysctl_test_headers.empty
|
||||
= register_sysctl("debug/test_sysctl/empty_add/empty", test_table_empty);
|
||||
if (!sysctl_test_headers.empty)
|
||||
return -ENOMEM;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __init test_sysctl_init(void)
|
||||
{
|
||||
int err;
|
||||
@ -233,6 +252,10 @@ static int __init test_sysctl_init(void)
|
||||
goto out;
|
||||
|
||||
err = test_sysctl_run_register_mount_point();
|
||||
if (err)
|
||||
goto out;
|
||||
|
||||
err = test_sysctl_run_register_empty();
|
||||
|
||||
out:
|
||||
return err;
|
||||
@ -248,6 +271,10 @@ static void __exit test_sysctl_exit(void)
|
||||
unregister_sysctl_table(sysctl_test_headers.test_h_mnt);
|
||||
if (sysctl_test_headers.test_h_mnterror)
|
||||
unregister_sysctl_table(sysctl_test_headers.test_h_mnterror);
|
||||
if (sysctl_test_headers.empty)
|
||||
unregister_sysctl_table(sysctl_test_headers.empty);
|
||||
if (sysctl_test_headers.empty_add)
|
||||
unregister_sysctl_table(sysctl_test_headers.empty_add);
|
||||
}
|
||||
|
||||
module_exit(test_sysctl_exit);
|
||||
|
@ -35,6 +35,7 @@ ALL_TESTS="$ALL_TESTS 0007:1:1:boot_int:1"
|
||||
ALL_TESTS="$ALL_TESTS 0008:1:1:match_int:1"
|
||||
ALL_TESTS="$ALL_TESTS 0009:1:1:unregister_error:0"
|
||||
ALL_TESTS="$ALL_TESTS 0010:1:1:mnt/mnt_error:0"
|
||||
ALL_TESTS="$ALL_TESTS 0011:1:1:empty_add:0"
|
||||
|
||||
function allow_user_defaults()
|
||||
{
|
||||
@ -63,7 +64,7 @@ function check_production_sysctl_writes_strict()
|
||||
else
|
||||
old_strict=$(cat ${WRITES_STRICT})
|
||||
if [ "$old_strict" = "1" ]; then
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
else
|
||||
echo "FAIL, strict value is 0 but force to 1 to continue" >&2
|
||||
echo "1" > ${WRITES_STRICT}
|
||||
@ -225,7 +226,7 @@ run_numerictests()
|
||||
echo "FAIL" >&2
|
||||
exit 1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
echo -n "Checking sysctl is not set to test value ... "
|
||||
@ -233,7 +234,7 @@ run_numerictests()
|
||||
echo "FAIL" >&2
|
||||
exit 1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
echo -n "Writing sysctl from shell ... "
|
||||
@ -242,7 +243,7 @@ run_numerictests()
|
||||
echo "FAIL" >&2
|
||||
exit 1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
echo -n "Resetting sysctl to original value ... "
|
||||
@ -251,7 +252,7 @@ run_numerictests()
|
||||
echo "FAIL" >&2
|
||||
exit 1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
# Now that we've validated the sanity of "set_test" and "set_orig",
|
||||
@ -265,7 +266,7 @@ run_numerictests()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
echo -n "Writing middle of sysctl after synchronized seek ... "
|
||||
@ -275,7 +276,7 @@ run_numerictests()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
echo -n "Writing beyond end of sysctl ... "
|
||||
@ -285,7 +286,7 @@ run_numerictests()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
echo -n "Writing sysctl with multiple long writes ... "
|
||||
@ -296,14 +297,14 @@ run_numerictests()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
}
|
||||
|
||||
check_failure()
|
||||
{
|
||||
echo -n "Testing that $1 fails as expected..."
|
||||
echo -n "Testing that $1 fails as expected ... "
|
||||
reset_vals
|
||||
TEST_STR="$1"
|
||||
orig="$(cat $TARGET)"
|
||||
@ -314,7 +315,7 @@ check_failure()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
}
|
||||
@ -356,7 +357,7 @@ run_wideint_tests()
|
||||
# Your test must accept digits 3 and 4 to use this
|
||||
run_limit_digit()
|
||||
{
|
||||
echo -n "Checking ignoring spaces up to PAGE_SIZE works on write ..."
|
||||
echo -n "Checking ignoring spaces up to PAGE_SIZE works on write ... "
|
||||
reset_vals
|
||||
|
||||
LIMIT=$((MAX_DIGITS -1))
|
||||
@ -368,11 +369,11 @@ run_limit_digit()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
|
||||
echo -n "Checking passing PAGE_SIZE of spaces fails on write ..."
|
||||
echo -n "Checking passing PAGE_SIZE of spaces fails on write ... "
|
||||
reset_vals
|
||||
|
||||
LIMIT=$((MAX_DIGITS))
|
||||
@ -384,7 +385,7 @@ run_limit_digit()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
}
|
||||
@ -392,7 +393,7 @@ run_limit_digit()
|
||||
# You are using an int
|
||||
run_limit_digit_int()
|
||||
{
|
||||
echo -n "Testing INT_MAX works ..."
|
||||
echo -n "Testing INT_MAX works ... "
|
||||
reset_vals
|
||||
TEST_STR="$INT_MAX"
|
||||
echo -n $TEST_STR > $TARGET
|
||||
@ -401,11 +402,11 @@ run_limit_digit_int()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
|
||||
echo -n "Testing INT_MAX + 1 will fail as expected..."
|
||||
echo -n "Testing INT_MAX + 1 will fail as expected ... "
|
||||
reset_vals
|
||||
let TEST_STR=$INT_MAX+1
|
||||
echo -n $TEST_STR > $TARGET 2> /dev/null
|
||||
@ -414,11 +415,11 @@ run_limit_digit_int()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
|
||||
echo -n "Testing negative values will work as expected..."
|
||||
echo -n "Testing negative values will work as expected ... "
|
||||
reset_vals
|
||||
TEST_STR="-3"
|
||||
echo -n $TEST_STR > $TARGET 2> /dev/null
|
||||
@ -426,7 +427,7 @@ run_limit_digit_int()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
}
|
||||
@ -442,7 +443,7 @@ run_limit_digit_int_array()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
|
||||
@ -459,7 +460,7 @@ run_limit_digit_int_array()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
|
||||
@ -477,7 +478,7 @@ run_limit_digit_int_array()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
|
||||
@ -494,7 +495,7 @@ run_limit_digit_int_array()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
}
|
||||
@ -502,7 +503,7 @@ run_limit_digit_int_array()
|
||||
# You are using an unsigned int
|
||||
run_limit_digit_uint()
|
||||
{
|
||||
echo -n "Testing UINT_MAX works ..."
|
||||
echo -n "Testing UINT_MAX works ... "
|
||||
reset_vals
|
||||
TEST_STR="$UINT_MAX"
|
||||
echo -n $TEST_STR > $TARGET
|
||||
@ -511,11 +512,11 @@ run_limit_digit_uint()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
|
||||
echo -n "Testing UINT_MAX + 1 will fail as expected..."
|
||||
echo -n "Testing UINT_MAX + 1 will fail as expected ... "
|
||||
reset_vals
|
||||
TEST_STR=$(($UINT_MAX+1))
|
||||
echo -n $TEST_STR > $TARGET 2> /dev/null
|
||||
@ -524,11 +525,11 @@ run_limit_digit_uint()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
|
||||
echo -n "Testing negative values will not work as expected ..."
|
||||
echo -n "Testing negative values will not work as expected ... "
|
||||
reset_vals
|
||||
TEST_STR="-3"
|
||||
echo -n $TEST_STR > $TARGET 2> /dev/null
|
||||
@ -537,7 +538,7 @@ run_limit_digit_uint()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
test_rc
|
||||
}
|
||||
@ -551,7 +552,7 @@ run_stringtests()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
echo -n "Writing middle of sysctl after unsynchronized seek ... "
|
||||
@ -561,7 +562,7 @@ run_stringtests()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
echo -n "Checking sysctl maxlen is at least $MAXLEN ... "
|
||||
@ -572,7 +573,7 @@ run_stringtests()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
echo -n "Checking sysctl keeps original string on overflow append ... "
|
||||
@ -583,7 +584,7 @@ run_stringtests()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
echo -n "Checking sysctl stays NULL terminated on write ... "
|
||||
@ -594,7 +595,7 @@ run_stringtests()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
echo -n "Checking sysctl stays NULL terminated on overwrite ... "
|
||||
@ -605,7 +606,7 @@ run_stringtests()
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
fi
|
||||
|
||||
test_rc
|
||||
@ -650,7 +651,7 @@ run_bitmaptest() {
|
||||
fi
|
||||
done
|
||||
|
||||
echo -n "Checking bitmap handler... "
|
||||
echo -n "Checking bitmap handler ... "
|
||||
TEST_FILE=$(mktemp)
|
||||
echo -n "$TEST_STR" > $TEST_FILE
|
||||
|
||||
@ -665,7 +666,7 @@ run_bitmaptest() {
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
else
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
rc=0
|
||||
fi
|
||||
test_rc
|
||||
@ -742,89 +743,111 @@ sysctl_test_0006()
|
||||
sysctl_test_0007()
|
||||
{
|
||||
TARGET="${SYSCTL}/$(get_test_target 0007)"
|
||||
echo -n "Testing if $TARGET is set to 1 ... "
|
||||
|
||||
if [ ! -f $TARGET ]; then
|
||||
echo "Skipping test for $TARGET as it is not present ..."
|
||||
echo -e "SKIPPING\n$TARGET is not present"
|
||||
return $ksft_skip
|
||||
fi
|
||||
|
||||
if [ -d $DIR ]; then
|
||||
echo "Boot param test only possible sysctl_test is built-in, not module:"
|
||||
echo -e "SKIPPING\nTest only possible if sysctl_test is built-in, not module:"
|
||||
cat $TEST_DIR/config >&2
|
||||
return $ksft_skip
|
||||
fi
|
||||
|
||||
echo -n "Testing if $TARGET is set to 1 ..."
|
||||
ORIG=$(cat "${TARGET}")
|
||||
|
||||
if [ x$ORIG = "x1" ]; then
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
return 0
|
||||
fi
|
||||
echo "FAIL"
|
||||
echo "Checking if /proc/cmdline contains setting of the expected parameter ..."
|
||||
|
||||
if [ ! -f /proc/cmdline ]; then
|
||||
echo "/proc/cmdline does not exist, test inconclusive"
|
||||
return 0
|
||||
echo -e "SKIPPING\nThere is no /proc/cmdline to check for paramter"
|
||||
return $ksft_skip
|
||||
fi
|
||||
|
||||
FOUND=$(grep -c "sysctl[./]debug[./]test_sysctl[./]boot_int=1" /proc/cmdline)
|
||||
if [ $FOUND = "1" ]; then
|
||||
echo "Kernel param found but $TARGET is not 1, TEST FAILED"
|
||||
echo -e "FAIL\nKernel param found but $TARGET is not 1." >&2
|
||||
rc=1
|
||||
test_rc
|
||||
fi
|
||||
|
||||
echo "Skipping test, expected kernel parameter missing."
|
||||
echo "To perform this test, make sure kernel is booted with parameter: sysctl.debug.test_sysctl.boot_int=1"
|
||||
echo -e "SKIPPING\nExpected kernel parameter missing."
|
||||
echo "Kernel must be booted with parameter: sysctl.debug.test_sysctl.boot_int=1"
|
||||
return $ksft_skip
|
||||
}
|
||||
|
||||
sysctl_test_0008()
|
||||
{
|
||||
TARGET="${SYSCTL}/$(get_test_target 0008)"
|
||||
echo -n "Testing if $TARGET is matched in kernel ... "
|
||||
|
||||
if [ ! -f $TARGET ]; then
|
||||
echo "Skipping test for $TARGET as it is not present ..."
|
||||
echo -e "SKIPPING\n$TARGET is not present"
|
||||
return $ksft_skip
|
||||
fi
|
||||
|
||||
echo -n "Testing if $TARGET is matched in kernel"
|
||||
ORIG_VALUE=$(cat "${TARGET}")
|
||||
|
||||
if [ $ORIG_VALUE -ne 1 ]; then
|
||||
echo "TEST FAILED"
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
test_rc
|
||||
fi
|
||||
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
return 0
|
||||
}
|
||||
|
||||
sysctl_test_0009()
|
||||
{
|
||||
TARGET="${SYSCTL}/$(get_test_target 0009)"
|
||||
echo -n "Testing if $TARGET unregistered correctly ..."
|
||||
echo -n "Testing if $TARGET unregistered correctly ... "
|
||||
if [ -d $TARGET ]; then
|
||||
echo "TEST FAILED"
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
test_rc
|
||||
fi
|
||||
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
return 0
|
||||
}
|
||||
|
||||
sysctl_test_0010()
|
||||
{
|
||||
TARGET="${SYSCTL}/$(get_test_target 0010)"
|
||||
echo -n "Testing that $TARGET was not created ..."
|
||||
echo -n "Testing that $TARGET was not created ... "
|
||||
if [ -d $TARGET ]; then
|
||||
echo "TEST FAILED"
|
||||
echo "FAIL" >&2
|
||||
rc=1
|
||||
test_rc
|
||||
fi
|
||||
|
||||
echo "ok"
|
||||
echo "OK"
|
||||
return 0
|
||||
}
|
||||
|
||||
sysctl_test_0011()
|
||||
{
|
||||
TARGET="${SYSCTL}/$(get_test_target 0011)"
|
||||
echo -n "Testing empty dir handling in ${TARGET} ... "
|
||||
if [ ! -d ${TARGET} ]; then
|
||||
echo -e "FAIL\nCould not create ${TARGET}" >&2
|
||||
rc=1
|
||||
test_rc
|
||||
fi
|
||||
|
||||
TARGET2="${TARGET}/empty"
|
||||
if [ ! -d ${TARGET2} ]; then
|
||||
echo -e "FAIL\nCould not create ${TARGET2}" >&2
|
||||
rc=1
|
||||
test_rc
|
||||
fi
|
||||
|
||||
echo "OK"
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -846,6 +869,7 @@ list_tests()
|
||||
echo "0008 x $(get_test_count 0008) - tests sysctl macro values match"
|
||||
echo "0009 x $(get_test_count 0009) - tests sysct unregister"
|
||||
echo "0010 x $(get_test_count 0010) - tests sysct mount point"
|
||||
echo "0011 x $(get_test_count 0011) - tests empty directories"
|
||||
}
|
||||
|
||||
usage()
|
||||
@ -934,7 +958,7 @@ function skip_test()
|
||||
if target_exists $TEST_TARGET $TEST_ID; then
|
||||
TEST_SKIP=$(get_test_skip_no_target $TEST_ID)
|
||||
if [[ $TEST_SKIP -eq "1" ]]; then
|
||||
echo "Target for test $TEST_ID: $TEST_TARGET not exist, skipping test ..."
|
||||
echo "Target $TEST_TARGET for test $TEST_ID does not exist ... SKIPPING"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user