* cgroup was converted to kernfs that supports xattr natively and doesn't have simple 'security.' namespace handler. So using just 'security.' name in setxattr syscall returns EOPNOTSUPP.
Also, * adding 'trusted.' name to the test - should be valid xattr name. * silent warnings about comparison between signed and unsigned int. Signed-off-by: Alexey Kodanev <alexey.koda...@oracle.com> --- v2: rearrange keys in tkeys[], move 'security.' to the top; use strcmp() to find 'security.' in setup. .../kernel/controllers/cgroup_xattr/cgroup_xattr.c | 32 +++++++++++++++---- 1 files changed, 25 insertions(+), 7 deletions(-) diff --git a/testcases/kernel/controllers/cgroup_xattr/cgroup_xattr.c b/testcases/kernel/controllers/cgroup_xattr/cgroup_xattr.c index d21656f..5951198 100644 --- a/testcases/kernel/controllers/cgroup_xattr/cgroup_xattr.c +++ b/testcases/kernel/controllers/cgroup_xattr/cgroup_xattr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved. + * Copyright (c) 2013-2015 Oracle and/or its affiliates. All Rights Reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -63,9 +63,10 @@ struct tst_key { }; /* only security.* & trusted.* are valid key names */ -static const struct tst_key tkeys[] = { - { .name = "trusted.test", .good = 1, }, +static struct tst_key tkeys[] = { { .name = "security.", .good = 1, }, + { .name = "trusted.test", .good = 1, }, + { .name = "trusted.", .good = 1, }, { .name = "user.", .good = 0, }, { .name = "system.", .good = 0, }, }; @@ -152,6 +153,20 @@ void setup(int argc, char *argv[]) "Test must be run with kernel 3.7 or newer"); } + if (tst_kvercmp(3, 15, 0) >= 0) { + /* In kernel v3.15 cgroup was converted to kernfs + * that doesn't provide simple security namespace handlers. + * Setting just 'security.' should return EOPNOTSUPP. + */ + unsigned int i; + for (i = 0; i < ARRAY_SIZE(tkeys); ++i) { + if (!strcmp(tkeys[i].name, "security.")) { + tkeys[i].good = 0; + break; + } + } + } + int value_size = DEFAULT_VALUE_SIZE; if (nflag) { if (sscanf(narg, "%i", &value_size) != 1) @@ -270,8 +285,11 @@ int mount_cgroup(void) * additional "xattr" option. In that case, mount will succeed, * but xattr won't be supported in the new mount anyway. * Should be removed as soon as a fix committed to upstream. + * + * But not applicable for kernels >= 3.15 where xattr supported + * natively. */ - if (hier != 0) + if (hier != 0 && tst_kvercmp(3, 15, 0) < 0) continue; int i, found = 0; @@ -321,7 +339,7 @@ int mount_cgroup(void) static int set_xattrs(const char *file) { - int i, err, fail, res = 0; + unsigned int i, err, fail, res = 0; for (i = 0; i < ARRAY_SIZE(tkeys); ++i) { err = setxattr(file, tkeys[i].name, @@ -343,7 +361,7 @@ static int set_xattrs(const char *file) static int get_xattrs(const char *file) { - int i, fail, res = 0; + unsigned int i, fail, res = 0; for (i = 0; i < ARRAY_SIZE(tkeys); ++i) { /* get value size */ @@ -366,7 +384,7 @@ static int get_xattrs(const char *file) "Can't get buffer of key %s", tkeys[i].name); } - fail = val.size != size || + fail = val.size != (size_t)size || strncmp(val.buf, xval, val.size) != 0; res |= fail; -- 1.7.1 ------------------------------------------------------------------------------ Monitor 25 network devices or servers for free with OpManager! OpManager is web-based network management software that monitors network devices and physical & virtual servers, alerts via email & sms for fault. Monitor 25 devices for free with no restriction. Download now http://ad.doubleclick.net/ddm/clk/292181274;119417398;o _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list