]> git.ipfire.org Git - thirdparty/libcgroup.git/log
thirdparty/libcgroup.git
3 weeks agoapi.c: prevent array out-of-bounds access in cgroup_parse_rules_file main
Mikhail Dmitrichenko [Wed, 11 Jun 2025 13:50:03 +0000 (16:50 +0300)] 
api.c: prevent array out-of-bounds access in cgroup_parse_rules_file

In the function src/api.c/cgroup_parse_rules_file, the condition of loop:

for (i = 0; lst->tail->controllers[i]; i++)
        cgroup_dbg(" %s", lst->tail->controllers[i]);

allows accessing lst->tail->controllers[MAX_MNT_ELEMENTS] if
lst->tail->controllers is full and lacks a terminating NULL.

Add explicit bounds checking (i < MAX_MNT_ELEMENTS) while maintaining
the NULL check. This ensures that there will never be reading past the
array boundaries regardless of its content.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 weeks agoapi.c: prevent array out-of-bounds access in cgroup_create_template_group
Mikhail Dmitrichenko [Wed, 11 Jun 2025 13:37:46 +0000 (16:37 +0300)] 
api.c: prevent array out-of-bounds access in cgroup_create_template_group

In the function src/api.c/cgroup_create_template_group,
the loop condition:

while (tmp->controllers[i] != NULL) {

allows accessing tmp->controllers[MAX_MNT_ELEMENTS] if tmp->controllers
is full and lacks a terminating NULL.

Add explicit bounds checking (i < MAX_MNT_ELEMENTS) while maintaining
the NULL check. This ensures that there will never be reading past
the array boundaries regardless of its content.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 weeks agoftests/run.py: terminate processes that exceed timeout
Kamalesh Babulal [Wed, 4 Jun 2025 14:58:31 +0000 (20:28 +0530)] 
ftests/run.py: terminate processes that exceed timeout

Some commands, like 'cgrulesengd' in non-daemon mode, continue running
until explicitly terminated. Currently, we catch exceptions for timeouts
but do not terminate the lingering process. This patch ensures that such
processes are properly killed after the timeout.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 weeks agosrc/config: Fix segfault while using templates
Teodor Milkov [Thu, 12 Jun 2025 09:47:41 +0000 (15:17 +0530)] 
src/config: Fix segfault while using templates

An intermittent segmentation fault occurs when classifying tasks using
cgrulesengd in combination with a template defined in cgconfig.conf.
Backtrace:

(gdb) bt
 #0  __strcmp_evex () at ../sysdeps/x86_64/multiarch/strcmp-evex.S:295
 #1  0x00007079d2e69645 in cgroup_config_create_template_group (cgroup=0x18844f834600,
     template_name=0x18844f710cd0 "system/hosting-users/%g/mail-delivery", flags=1) at config.c:1950
 #2  0x00007079d2e61458 in cgroup_create_template_group (orig_group_name=0x79905b6ebb70 "system/hosting-users/ryleeisitt/mail-delivery",
     tmp=0x18844f69cce0, flags=1) at api.c:4609
 #3  0x00007079d2e61bcd in cgroup_change_cgroup_flags (uid=0, gid=674, procname=0x18844f79c310 "/var/qmail/bin/qmail-queue-wrapper", pid=1048, flags=1)
     at api.c:4811
 #4  0x000018844cc0f29d in cgre_process_event (ev=0x79905b6ecc74, type=4) at cgrulesengd.c:485
 #5  0x000018844cc0f441 in cgre_handle_msg (cn_hdr=0x79905b6ecc60) at cgrulesengd.c:531
 #6  0x000018844cc0f678 in cgre_receive_netlink_msg (sk_nl=0) at cgrulesengd.c:596
 #7  0x000018844cc0ffe1 in cgre_create_netlink_socket_process_msg () at cgrulesengd.c:786
 #8  0x000018844cc10e4e in main (argc=3, argv=0x79905b6eda58) at cgrulesengd.c:1282

Fix the issue using cgroup->index that holds the count of controllers,
populated for the cgroup instead of checking for
cgroup->controller[index] is NULL.

Fixes: https://github.com/libcgroup/libcgroup/issues/483
Signed-off-by: Teodor Milkov <zimage@icdsoft.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 weeks agoftests/utils: add get_distro() to detect Linux distribution
Kamalesh Babulal [Thu, 5 Jun 2025 15:36:26 +0000 (21:06 +0530)] 
ftests/utils: add get_distro() to detect Linux distribution

Introduce helper function get_distro() to identify the current Linux
distribution. Currently checks for 'Ubuntu' and 'Oracle Linux', which
are the only distros used for testing. Can be extended to support others
in the future.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 weeks agosrc: Bump MAX_MNT_ELEMENTS for new 'dmem' controller
Kamalesh Babulal [Fri, 13 Jun 2025 12:38:36 +0000 (18:08 +0530)] 
src: Bump MAX_MNT_ELEMENTS for new 'dmem' controller

Upstream commit b168ed458ddec ("kernel/cgroup: Add 'dmem' memory
accounting cgroup") adds a new controller. Update MAX_MNT_ELEMENTS
to match the increased number of cgroup controllers.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
6 weeks agotests: fix checking wrong result in 017-API_fuzz_test
Sam James [Thu, 22 May 2025 23:51:01 +0000 (00:51 +0100)] 
tests: fix checking wrong result in 017-API_fuzz_test

There seem to be various calls to cgroup_add_controller where the result
isn't validated, instead checking the cgrp pointer.

We could add two asserts in each place being changed here if the concern
was testing for if cgroup_add_controller mangled cgrp, but it looks
more likely that it's a copy/paste error instead and we're just testing
the wrong thing.

Signed-off-by: Sam James <sam@gentoo.org>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
6 weeks agosrc: handle NULL options in cgroup_parse_rules_options
Sam James [Fri, 23 May 2025 00:13:51 +0000 (01:13 +0100)] 
src: handle NULL options in cgroup_parse_rules_options

We don't want to pass NULL to strtok:
```
[ RUN      ] ParseRulesOptionsTest.RulesOptions_NullOptions
==2006496== Conditional jump or move depends on uninitialised value(s)
==2006496==    at 0x520D156: strtok_r (strtok_r.c:49)
==2006496==    by 0x403FB7E: cgroup_parse_rules_options (api.c:529)
==2006496==    by 0x4005F41: ParseRulesOptionsTest_RulesOptions_NullOptions_Test::TestBody() (002-cgroup_parse_rules_options.cpp:89)
==2006496==    by 0x4ABA45D: ??? (in /usr/lib64/libgtest.so.1.15.2)
==2006496==    by 0x4ABE5AB: ??? (in /usr/lib64/libgtest.so.1.15.2)
==2006496==    by 0x4A9D949: testing::TestInfo::Run() (in /usr/lib64/libgtest.so.1.15.2)
==2006496==    by 0x4ABF18A: ??? (in /usr/lib64/libgtest.so.1.15.2)
==2006496==    by 0x4AB7467: testing::internal::UnitTestImpl::RunAllTests() (in /usr/lib64/libgtest.so.1.15.2)
==2006496==    by 0x4AACC46: testing::UnitTest::Run() (in /usr/lib64/libgtest.so.1.15.2)
==2006496==    by 0x4002345: UnknownInlinedFun (gtest.h:2334)
==2006496==    by 0x4002345: main (gtest.cpp:15)
==2006496==
Error: failed to parse options: (null)
```

Signed-off-by: Sam James <sam@gentoo.org>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
2 months agoftests: Add a test for the memory abstraction layer
Tom Hromatka [Mon, 14 Apr 2025 20:54:50 +0000 (14:54 -0600)] 
ftests: Add a test for the memory abstraction layer

Add a test for the memory abstraction layer abstractions.
Currently only supports:
            memory.max <-> memory.limit_in_bytes
            memory.high <-> memory.soft_limit_in_bytes

-----------------------------------------------------------------
Test Results:
        Run Date:                          Apr 14 14:52:47
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                              Time (sec)
        --------------------------------------------
        setup                                   0.00
        093-cgxget-memory_settings.py           3.34
        teardown                                0.00
        --------------------------------------------
        Total Run Time                          3.34

[Kamalesh removed the unused exceptions variable (lint warnings)]
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
2 months agoabstraction-map: Add memory controller abstractions
Tom Hromatka [Wed, 26 Feb 2025 19:48:13 +0000 (19:48 +0000)] 
abstraction-map: Add memory controller abstractions

Add abstraction logic for:
memory.max <-> memory.limit_in_bytes
memory.high <-> memory.soft_limit_in_bytes

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
2 months agodoc/release: add step to push to release branch
Kamalesh Babulal [Tue, 15 Apr 2025 16:24:45 +0000 (21:54 +0530)] 
doc/release: add step to push to release branch

Update the release process documentation to include the missing step for
pushing to the newly created release branch. Renumber subsequent steps
to reflect the correct order.

Suggested-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Added "If this is a new..." text

2 months agogithub: dist: Rework the unit tests v3.2.0
Tom Hromatka [Tue, 8 Apr 2025 23:19:40 +0000 (17:19 -0600)] 
github: dist: Rework the unit tests

Add a configure option to enable/disable the unit tests. Because of their
dependency upon googletest, they're very difficult to run for distros.
This allows them to packaged with libcgroup, but they are disabled by
default.  They can be enabled via the config option `--enable-unittests`.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
2 months agogithub: dist: Rework the automated functional tests
Tom Hromatka [Tue, 8 Apr 2025 22:42:23 +0000 (16:42 -0600)] 
github: dist: Rework the automated functional tests

Now that Github Actions don't support cgroup v1, we can make the github
runners run the tests in a more granular fashion.  Add a runner to
individually run the containerized tests, the non-containerized tests,
and the sudo tests.  This simplifies the testing logic, and should help
us better identify failures.

As part of this, no longer run ftests-wrapper.sh when `make check` is
invoked on the ftests directory.  This is an undue burden for distros
as it requires uncommon dependencies (lxc, etc.) and can adversely
affect the cgroup sysfs filesystem on the build system.  The onus is
on upstream libcgroup to provide a well-tested and vetted *.tar.gz for
the distros that they can then just package up and disseminate.  They
shouldn't have to deal with challenging tests and test configurations.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
2 months agogithub: Delete cgroup v1 workflows
Tom Hromatka [Tue, 8 Apr 2025 22:17:33 +0000 (16:17 -0600)] 
github: Delete cgroup v1 workflows

Github has deprecated Ubuntu 20.  Since this was the last runner still
running cgroup v1 by default, we no longer have a runner than can run
the automated tests in cgroup v1 mode.  Therefore, delete the cgroup v1
automated test runs.

Note that we'll continue to run them by hand periodically and before
releases, but upstream changes may end up breaking/affecting cgroup v1
support.  We strongly recommend migrating to cgroup v2.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
2 months agosrc/daemon/cgrulesengd: Correctly check for ENOBUFS when doing recvfrom()
Ivaylo Dimitrov [Tue, 8 Apr 2025 14:01:17 +0000 (17:01 +0300)] 
src/daemon/cgrulesengd: Correctly check for ENOBUFS when doing recvfrom()

Currently, code checks if recvfrom() returns ENOBUFS, however, it can never
return errno type error code, but -1 on error

Fix that by checking errno in case of an error instead

Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 months agogoogletest: Update to use version 1.2.0
Tom Hromatka [Tue, 1 Apr 2025 18:38:14 +0000 (18:38 +0000)] 
googletest: Update to use version 1.2.0

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 months agogunit: Promote namespaces in test 001 and 013 to heap variables
Tom Hromatka [Tue, 1 Apr 2025 18:35:15 +0000 (18:35 +0000)] 
gunit: Promote namespaces in test 001 and 013 to heap variables

On one of my ubuntu22 machines, the NAMESPACE5[] character array was
outputing garbage for the last test.  Looks like gtest was running it in
another thread, and the pointer was garbage.  Promote the NAMESPACE*
variables to be heap variables so that they're safely available for all
threads.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 months agoftests: Don't run test 089 in a container
Tom Hromatka [Tue, 1 Apr 2025 18:07:56 +0000 (18:07 +0000)] 
ftests: Don't run test 089 in a container

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 months agoftests: Retry getting pid of sleep process
Tom Hromatka [Tue, 1 Apr 2025 17:41:01 +0000 (17:41 +0000)] 
ftests: Retry getting pid of sleep process

The ftests framework uses sleeping processes to test various cgroup
features.  Sometimes ps throws an error when we try to enumerate
processes via `ps x` within an lxc container.

The error thrown by ps is as follows:
Signal 21 (TTIN) caught by ps (3.3.17).
ps:ps/display.c:70: please report this bug

Fix this by adding a retry loop for the ps command, as it usually works
in a subsequent pass.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 months agotools/cgsnapshot: Fix Coverity uninitialized variable warning
Kamalesh Babulal [Mon, 31 Mar 2025 14:11:12 +0000 (19:41 +0530)] 
tools/cgsnapshot: Fix Coverity uninitialized variable warning

Coverity reported the following uninitialized variable warning:

CID 465887: (#1 of 1): Uninitialized scalar variable (UNINIT)
32. uninit_use_in_call: Using uninitialized value *wl_file when calling load_list.

Fix the issue by initializing the char[] wl_file with '\0', and also
initialize dl_file similarly as a best practice.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 months agodoc: Add documentation for cgrules' options
Tom Hromatka [Thu, 27 Mar 2025 14:20:10 +0000 (08:20 -0600)] 
doc: Add documentation for cgrules' options

Add man page documentation for the options field in cgrules
configuration files.  Currently only "ignore" and "ignore_rt" are
supported.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 months agoftests: Fix test 005 on Cgroup v2 Ubuntu22
Tom Hromatka [Thu, 27 Mar 2025 15:28:28 +0000 (15:28 +0000)] 
ftests: Fix test 005 on Cgroup v2 Ubuntu22

Test 005-cgsnapshot-basic_snapshot_v2.py was failing on Ubuntu22
(non-sudo tests) because the cpuset.cpus.exclusive.effective field
is no longer being reported by the kernel in that case.

Remove that line from the expected output for the non-sudo tests but
leave it in for the sudo tests as it's still reported there.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
4 months agoREADME: Fix Github Actions Continuous Integration badge
Tom Hromatka [Wed, 19 Feb 2025 22:11:23 +0000 (15:11 -0700)] 
README: Fix Github Actions Continuous Integration badge

The Github Actions Continuous Integration badge has been showing "no
status" for quite a while.  Fix it by removing the "?branch=main" suffix

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 months agoall: Add THIRD_PARTY_LICENSES.txt
Tom Hromatka [Tue, 18 Feb 2025 22:37:08 +0000 (15:37 -0700)] 
all: Add THIRD_PARTY_LICENSES.txt

Add third-party licenses file

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
4 months agoman: cgrules.conf - update rule fields allowed characters
Kamalesh Babulal [Wed, 12 Feb 2025 07:46:42 +0000 (13:16 +0530)] 
man: cgrules.conf - update rule fields allowed characters

Now, the process name and destination cgroup are allowed to have spaces
within quotes. Update the man page to reflect the allowed characters
for both fields and add an example demonstrating rule usage.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: small formatting changes

4 months agogunit: Add unit tests for get_next_rule_field()
Tom Hromatka [Wed, 22 Jan 2025 12:12:59 +0000 (17:42 +0530)] 
gunit: Add unit tests for get_next_rule_field()

[----------] 10 tests from GetNextRuleField
[ RUN      ] GetNextRuleField.InvalidParameters
[       OK ] GetNextRuleField.InvalidParameters (0 ms)
[ RUN      ] GetNextRuleField.FieldLenTooSmall
[       OK ] GetNextRuleField.FieldLenTooSmall (0 ms)
[ RUN      ] GetNextRuleField.FieldLenTooSmallWithQuotes
[       OK ] GetNextRuleField.FieldLenTooSmallWithQuotes (0 ms)
[ RUN      ] GetNextRuleField.FieldLenTooSmallWithQuotes2
[       OK ] GetNextRuleField.FieldLenTooSmallWithQuotes2 (0 ms)
[ RUN      ] GetNextRuleField.UserAndProcess
[       OK ] GetNextRuleField.UserAndProcess (0 ms)
[ RUN      ] GetNextRuleField.UserOnly
[       OK ] GetNextRuleField.UserOnly (0 ms)
[ RUN      ] GetNextRuleField.KeyWithQuotesAndSpaces
[       OK ] GetNextRuleField.KeyWithQuotesAndSpaces (0 ms)
[ RUN      ] GetNextRuleField.DestinationWithQuotes
[       OK ] GetNextRuleField.DestinationWithQuotes (0 ms)
[ RUN      ] GetNextRuleField.TabsAsDelimiters
[       OK ] GetNextRuleField.TabsAsDelimiters (0 ms)
[ RUN      ] GetNextRuleField.RuleWithOptions
[       OK ] GetNextRuleField.RuleWithOptions (0 ms)
[----------] 10 tests from GetNextRuleField (0 ms total)

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
4 months agocgrules: add support for process/dest cgroups with spaces
Kamalesh Babulal [Tue, 21 Jan 2025 08:10:27 +0000 (13:40 +0530)] 
cgrules: add support for process/dest cgroups with spaces

In a cgrules rule, allow the process names and the destination
cgroups with spaces and other allowed special characters.

Reported-by: @LinuxOnTheDesktop (github username)
Fixes: https://github.com/libcgroup/libcgroup/issues/462
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: slight logic changes and add gunit support

5 months agotools-common.c: Fix resource leak in cgroup_string_list_add_directory()
Kamalesh Babulal [Wed, 29 Jan 2025 09:49:12 +0000 (15:19 +0530)] 
tools-common.c: Fix resource leak in cgroup_string_list_add_directory()

Fix a Coverity warning about resource leak:

CID 465889: (#4 of 4): Resource leak (RESOURCE_LEAK)
32. leaked_storage: Variable fullpath going out of scope leaks the
storage it points to.

Fix it by releasing the 'fullpath', when file name does not matches
'*.conf' code path(s).

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 months agoconfig: Fix data race reported in cgroup_config_insert_into_mount_table
Kamalesh Babulal [Sun, 26 Jan 2025 06:01:25 +0000 (11:31 +0530)] 
config: Fix data race reported in cgroup_config_insert_into_mount_table

Fix the following data race issue reported by Coverity:

CID 465888: (#1 of 1): Check of thread-shared field evades lock
acquisition (LOCK_EVASION):

"The data guarded by this critical section may be read while in an
inconsistent state or modified by multiple racing threads.

In cgroup_config_insert_into_mount_table: Checking the value of a
thread-shared field outside of a locked region to determine if a locked
operation involving that thread shared field has completed."

Fix it by moving the config_table_index value check too under the
config_table_lock.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 months agosrc/config: Fix data race reported by Coverity
Kamalesh Babulal [Sun, 19 Jan 2025 05:48:02 +0000 (11:18 +0530)] 
src/config: Fix data race reported by Coverity

Fix the following data race issue reported by Coverity:

CID 465888:Check of thread-shared field evades lock acquisition
(LOCK_EVASION):

"The data guarded by this critical section may be read while in an
inconsistent state or modified by multiple racing threads.

In cgroup_config_insert_into_namespace_table: Checking the value of a
thread-shared field outside of a locked region to determine if a locked
operation involving that thread shared field has completed."

Fix it by moving the namespace_table_index value check too under the
namespace_table_lock

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 months agoapi: Add extra debugging when matching rule to a group
Aaron Tomlin [Mon, 13 Jan 2025 18:18:05 +0000 (11:18 -0700)] 
api: Add extra debugging when matching rule to a group

In the context of a group rule (i.e. indicated by '@' used to prefix the
actual group name), getgrnam(3) is used to provide a pointer to a group
file entry that may contain a NULL-terminated array of pointers to group
members. A user can belong to multiple groups. With this information, we
then check the username that corresponds to the specified UID against
each group member for a match. This patch makes it possible to see this
information if debug level logging is enabled.

Use the new cgroup_get_loglevel() API to optimize the rule loop to
minimize performance impacts.

Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
5 months agoapi: log: Add cgroup_get_loglevel()
Tom Hromatka [Mon, 13 Jan 2025 18:17:13 +0000 (11:17 -0700)] 
api: log: Add cgroup_get_loglevel()

Add a publicly-exposed function to get the current libcgroup logging
level.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
5 months agocgconfig: update cgroup mount paths
Kamalesh Babulal [Thu, 19 Dec 2024 08:30:45 +0000 (14:00 +0530)] 
cgconfig: update cgroup mount paths

Update the cgroup mount paths across cgconfig.conf* file, by replacing
/mnt/cgroups with /sys/fs/cgroup/

Fixes: https://github.com/libcgroup/libcgroup/issues/443
Suggested-by: @shamefulCake1 (github username)
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 months agoftests/consts.py: Add more cpu controller output (v2)
Kamalesh Babulal [Tue, 17 Dec 2024 05:56:30 +0000 (11:26 +0530)] 
ftests/consts.py: Add more cpu controller output (v2)

Upstream v6.13 kernel commit aefa398d93d5 ("cgroup/rstat: Tracking
cgroup-level niced CPU time") added "nice_usec" to the cgroup base stats
cputime, add it to the list of cpu controller (v2) expected output.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 months agogithub: Ignore unused data errors in lcov
Tom Hromatka [Mon, 13 Jan 2025 17:31:41 +0000 (10:31 -0700)] 
github: Ignore unused data errors in lcov

The "Unit Tests" job was throwing the following lcov error:

Summary coverage rate:
  lines......: 20.5% (1073 of 5227 lines)
  functions..: 29.0% (73 of 252 functions)
  branches...: no data found
(use "lcov --ignore-errors unused ..." to bypass this error)

Add "--ignore errors unused" to the lcov command to work around this.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 months agogithub: Revert to Ubuntu 22.04 (from latest) for cgroup v2 testing
Tom Hromatka [Mon, 13 Jan 2025 17:19:34 +0000 (10:19 -0700)] 
github: Revert to Ubuntu 22.04 (from latest) for cgroup v2 testing

Cgroup v2 testing on Ubuntu 24.04 is throwing the following errors.
Revert to Ubuntu 22.04 until the issue is resolved in the distro.

/home/runner/work/libcgroup/libcgroup/src/.libs/libcgroup.so.0)
Test:
012-cgget-multiple_r_flags2.py - RunError:
command = ['sudo', 'lxc', 'exec', 'TestLibcg', '--',
'/home/runner/work/libcgroup/libcgroup/src/tools/cgcreate', '-g',
'memory:012cgget1']
ret = 1
stdout =
stderr =
/home/runner/work/libcgroup/libcgroup/src/tools/.libs/cgcreate:
/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found
(required by
/home/runner/work/libcgroup/libcgroup/src/tools/.libs/cgcreate)
/home/runner/work/libcgroup/libcgroup/src/tools/.libs/cgcreate:
/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found
(required by
/home/runner/work/libcgroup/libcgroup/src/.libs/libcgroup.so.0)

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
5 months agolibcgroup.map: include cgroup_get_cgroup_name
Kamalesh Babulal [Thu, 2 Jan 2025 12:58:56 +0000 (12:58 +0000)] 
libcgroup.map: include cgroup_get_cgroup_name

Using cgroup_get_cgroup_name() API, fails with:

gcc -o cgrp_get_cgrp_name cgrp_get_cgrp_name.c -lcgroup
/usr/bin/ld: /tmp/ccIyBv5c.o: in function `main':
cgrp_get_cgrp_name.c:(.text+0xaa): undefined reference to `cgroup_get_cgroup_name'
collect2: error: ld returned 1 exit status

The API was introduced by commit ca32d88ef56b1 ("wrappers: Add a
cgroup_get_cgroup_name API") but missed adding it to libcgroup.map file,
causing the linkage issue. Fix the issue by adding the API at the
libcgroup.map under version it was introduced.

Fixes: https://github.com/libcgroup/libcgroup/issues/459
Reported-by: Ron Nazarov <ron@noisytoot.org>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
7 months agocgconfig: Add support for multiple controllers on the same mount path
lipengyu [Fri, 6 Dec 2024 05:08:17 +0000 (10:38 +0530)] 
cgconfig: Add support for multiple controllers on the same mount path

Add support to cgconfigparser for mounting multiple controllers to the
same mount point.

Given the following config:

mount {
cpu = /cg_sys;
cpuacct = /cg_sys;
}

cgconfigparser should mount both the cpu and cpuacct controllers to
/cg_sys. The mount should look as follows:

cgroup on /cg_sys type cgroup (rw,relatime,seclabel,cpu,cpuacct)

Without this change, the mount->name gets overwritten and the mount
fails, which can be categorized into two cases:

1.if cpu and cpuacct are at the same hierarchy before being mounted:

Error: cannot mount cpu to /cg_sys: Device or resource busy

2.if cpu and cpuacct are not at the same hierarchy before being mounted:

cgroup on /cg_sys type cgroup (rw,relatime,seclabel,cpu)

[TJH suggested improvements to commit message]
[Kamalesh fixed a few checkpatch warnings]
Signed-off-by: lipengyu <lipengyu@kylinos.cn>
Acked-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
7 months agoftests-wrapper: remove the timeout logic
Kamalesh Babulal [Wed, 4 Dec 2024 07:09:33 +0000 (12:39 +0530)] 
ftests-wrapper: remove the timeout logic

With commit e475d7a545a2 ("github: Use default runners"), the dependency
on the self-hosted runners is removed. Also, remove the timeout logic to
synchronize jobs between self-hosted runners too.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
7 months agogithub: Use default runners
Tom Hromatka [Wed, 30 Oct 2024 16:40:07 +0000 (10:40 -0600)] 
github: Use default runners

Now that github actions have an image that defaults to cgroup v2, we can
utilize that image rather than hosting our own github actions runners.

Use ubuntu-latest as our cgroup v2 test runner, and delete the jobs that
use self-hosted runners.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
8 months agotests/.gitignore: remove file
Kamalesh Babulal [Mon, 21 Oct 2024 04:10:56 +0000 (09:40 +0530)] 
tests/.gitignore: remove file

The tests under .gitignore file, have been moved to samples/c directory
and have it's own .gitignore. Remove this file.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agotests/gunit: src: match naming with upstream Linux
Kamalesh Babulal [Tue, 15 Oct 2024 01:42:03 +0000 (07:12 +0530)] 
tests/gunit: src: match naming with upstream Linux

Rename local variable 'cgroup' -> 'cgrp' to match upstream Linux Kernel,
across the files under tests/gunit bringing it closer to the Linux
kernel cgroup code.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agosamples/c: match naming with upstream Linux
Kamalesh Babulal [Mon, 14 Oct 2024 01:17:03 +0000 (06:47 +0530)] 
samples/c: match naming with upstream Linux

Rename local variable 'cgroup' -> 'cgrp' to match upstream Linux Kernel,
across the files under samples/c/ bringing it closer to the Linux kernel
cgroup code.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agoinclude: match naming with upstream Linux
Kamalesh Babulal [Sun, 13 Oct 2024 01:08:40 +0000 (06:38 +0530)] 
include: match naming with upstream Linux

Rename local variable 'cgroup' -> 'cgrp' to match upstream Linux Kernel,
across the files under include/libcgroup/ bringing it closer to the
Linux kernel cgroup code.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agotools: match naming with upstream Linux
Kamalesh Babulal [Sat, 12 Oct 2024 01:06:50 +0000 (06:36 +0530)] 
tools: match naming with upstream Linux

Rename local variable 'cgroup' -> 'cgrp' to match upstream Linux Kernel,
across the files under src/tools/ bringing it closer to the Linux kernel
cgroup code.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agosrc/daemon/cgrulesengd: match naming with upstream Linux
Kamalesh Babulal [Fri, 11 Oct 2024 00:51:26 +0000 (06:21 +0530)] 
src/daemon/cgrulesengd: match naming with upstream Linux

Rename local variable 'cgroup' -> 'cgrp' to match upstream Linux Kernel,
bringing it closer to the Linux kernel cgroup code.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agosrc: match naming with upstream Linux
Kamalesh Babulal [Thu, 10 Oct 2024 05:34:16 +0000 (11:04 +0530)] 
src: match naming with upstream Linux

Rename local variable 'cgroup' -> 'cgrp' to match upstream Linux Kernel,
across the files under src/*.c bringing it closer to the Linux kernel

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agosrc/libcgroup-internal: match naming with upstream Linux
Kamalesh Babulal [Wed, 9 Oct 2024 07:08:42 +0000 (12:38 +0530)] 
src/libcgroup-internal: match naming with upstream Linux

Rename local variable 'cgroup' -> 'cgrp' to match upstream Linux Kernel,
bringing it closer to the Linux kernel cgroup code.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agoftests/cgroup: Fix typo in CgroupMount::__init__
Kamalesh Babulal [Wed, 16 Oct 2024 09:11:32 +0000 (14:41 +0530)] 
ftests/cgroup: Fix typo in CgroupMount::__init__

Fix the typo of '==' (comparison) to '=' assignment in
CgroupMount::__init__.

Fixes: 52b196c2f4f3c ("ftests/cgroup: Add support for favordynmods")
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agoftests/ftests-wrapper.sh: Improve timeout comments
Kamalesh Babulal [Sat, 19 Oct 2024 09:10:12 +0000 (14:40 +0530)] 
ftests/ftests-wrapper.sh: Improve timeout comments

Fix the timeout minutes '5' -> '50' and improve the comment stating, we
would abort after timeout minutes.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agoapi.c: fix memory leak on non-writable settings
Felix Moessbauer [Wed, 16 Oct 2024 13:30:29 +0000 (15:30 +0200)] 
api.c: fix memory leak on non-writable settings

When hitting the path st_mode check, we might already have allocated a
path. In this case, the continue re-enters the loop without freeing the
path:

 653 bytes in 8 blocks are definitely lost in loss record
    at 0x484582F: realloc (vg_replace_malloc.c:1437)
    by 0x49023E1: __vasprintf_internal (vasprintf.c:79)
    by 0x48D5BD5: asprintf (asprintf.c:31)
    by 0x4B41722: cgroup_set_values_recursive (api.c:2414)
    by 0x4B4688A: _cgroup_create_cgroup (api.c:2999)
    by 0x4B47067: cgroup_create_cgroup (api.c:3062)
    by 0x4B47067: cgroup_create_cgroup (api.c:3028)

Fixes: 0e50142a1fe0 ("api.c: Don't fail a recursive write if value isn't dirty")
Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
8 months agocgrules: Add ignore_rt option
Kamalesh Babulal [Tue, 8 Oct 2024 13:25:00 +0000 (13:25 +0000)] 
cgrules: Add ignore_rt option

Introduce new ignore_rt option for cgrules, that would ignore rules
matching user:process, controller(s), destination cgroup with SCHED_RR
and SCHED_FF policies.

Suggested-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agoapi.c: constify cgroup_get_threads() arguments
Kamalesh Babulal [Wed, 2 Oct 2024 07:08:42 +0000 (12:38 +0530)] 
api.c: constify cgroup_get_threads() arguments

Constify the char* functional arguments of cgroup_get_threads(), these
parameters are not supposed to changed.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agoapi.c: constify cgroup_get_procs() arguments
Kamalesh Babulal [Tue, 1 Oct 2024 06:47:12 +0000 (12:17 +0530)] 
api.c: constify cgroup_get_procs() arguments

Constify the char* functional arguments of cgroup_get_procs(), these
parameters are not supposed to changed.

Fixes: https://github.com/libcgroup/libcgroup/issues/445
Reported-by: Dan Dedrick <dan.dedrick@gmail.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agotools/cgset: Fix -R switch indentation in help menu
Kamalesh Babulal [Fri, 4 Oct 2024 07:08:51 +0000 (12:38 +0530)] 
tools/cgset: Fix -R switch indentation in help menu

Fix the indentation of '-R' switch description of cgset help menu.

Before:
-------
$ cgset --help
Usage: cgset [-r <name=value>] <cgroup_path> ...
   or: cgset --copy-from <source_cgroup_path> <cgroup_path> ...
Set the parameters of given cgroup(s)
  -r, --variable <name>                 Define parameter to set
  --copy-from <source_cgroup_path>      Control group whose parameters will be copied
  -b                                    Ignore default systemd delegate hierarchy
  -R                                      Recursively set variable(s) for cgroups under <cgroup_path>

After:
------
$ cgset --help
Usage: cgset [-r <name=value>] <cgroup_path> ...
   or: cgset --copy-from <source_cgroup_path> <cgroup_path> ...
Set the parameters of given cgroup(s)
  -r, --variable <name>                 Define parameter to set
  --copy-from <source_cgroup_path>      Control group whose parameters will be copied
  -b                                    Ignore default systemd delegate hierarchy
  -R                                    Recursively set variable(s) for cgroups under <cgroup_path>

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agoapi.c: add support to build procs path for cgroup.thread
Kamalesh Babulal [Fri, 27 Sep 2024 06:45:09 +0000 (12:15 +0530)] 
api.c: add support to build procs path for cgroup.thread

In cgroup_build_tid_path(), add support for building path to write
tid into cgroup.thread instead of cgroup.procs, if the calling function
is cgroup_attach_thread_tid() or else build path to write into
cgroup.procs.

Fixes: https://github.com/libcgroup/libcgroup/issues/441
Reported-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agoapi: Add is_tid parameter to cgroup_get_cg_type()
Kamalesh Babulal [Thu, 26 Sep 2024 10:45:09 +0000 (16:15 +0530)] 
api: Add is_tid parameter to cgroup_get_cg_type()

Add new parameter bool is_tid to cgroup_get_cg_type(), this parameter
gets set, when called from cgroup_attach_thread_tid() path. When set and
cgroup.type is 'domain threaded', it returns 'cgroup.threads' instead of
'cgroup.procs'.

Fixes: https://github.com/libcgroup/libcgroup/issues/441
Reported-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
8 months agoapi.c: Rename cgroup_v1_build_procs_path()
Kamalesh Babulal [Wed, 25 Sep 2024 07:08:42 +0000 (12:38 +0530)] 
api.c: Rename cgroup_v1_build_procs_path()

Rename cgroup_v1_build_procs_path() to cgroup_build_tid_path(), this
function will be used to build a procs path on both cgroup v1/v2 to
which the tid/pid will be written based on the cgroup type. Change
the name to reflect the new functionality.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
9 months agoftests/030: teach parsing v6.12 memory isolation
Kamalesh Babulal [Sun, 29 Sep 2024 09:18:03 +0000 (14:48 +0530)] 
ftests/030: teach parsing v6.12 memory isolation

Starting v6.12 memory code is split into v1 and v2 code, where v1 code
is only compiled when CONFIG_MEMCG_V1 is set. Which defaults to
disabled, teach the test case to ignore such failure.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
9 months agoftests/030: teach parsing v6.12 cpuset isolation
Kamalesh Babulal [Sat, 28 Sep 2024 09:14:58 +0000 (14:44 +0530)] 
ftests/030: teach parsing v6.12 cpuset isolation

Starting v6.12 cpuset code is split into v1 and v2 code, where v1 code
is only compiled when CONFIG_CPUSET_V1 is set. Which defaults to
disabled, teach the test case to ignore such failure.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoworkflow/ci: Install flake8-quote under pylint job
Kamalesh Babulal [Wed, 14 Aug 2024 05:35:59 +0000 (11:05 +0530)] 
workflow/ci: Install flake8-quote under pylint job

In the Github workflow continuous integration::flake8-lint job, add
new checks for standardizing Python quotes usage. This will help
maintain the recommended quotes style in all new PR's.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agosamples/python/create_systemd_scope: Fix quote warnings
Kamalesh Babulal [Tue, 13 Aug 2024 06:31:14 +0000 (12:01 +0530)] 
samples/python/create_systemd_scope: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/cgroup: Fix quote warnings
Kamalesh Babulal [Mon, 12 Aug 2024 06:29:04 +0000 (11:59 +0530)] 
ftests/cgroup: Fix quote warnings

Fix "Q003 Change outer quotes to avoid escaping inner quotes" and
"Q000 Double quotes found but single quotes preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/consts: Fix quote warnings
Kamalesh Babulal [Sun, 11 Aug 2024 06:26:23 +0000 (11:56 +0530)] 
ftests/consts: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/092: Fix quote warning
Kamalesh Babulal [Sat, 10 Aug 2024 06:23:31 +0000 (11:53 +0530)] 
ftests/092: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/ftests: Fix quote warnings
Kamalesh Babulal [Fri, 9 Aug 2024 11:11:00 +0000 (16:41 +0530)] 
ftests/ftests: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
and "Q000 Double quotes found but single quotes preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/process: Fix quote warnings
Kamalesh Babulal [Thu, 8 Aug 2024 11:05:55 +0000 (16:35 +0530)] 
ftests/process: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/run: Fix quote warning
Kamalesh Babulal [Wed, 7 Aug 2024 11:03:24 +0000 (16:33 +0530)] 
ftests/run: Fix quote warning

Fix "Q003 Change outer quotes to avoid escaping inner quotes" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/systemd: Fix quote warnings
Kamalesh Babulal [Tue, 6 Aug 2024 11:01:04 +0000 (16:31 +0530)] 
ftests/systemd: Fix quote warnings

Fix "Q001 Single quote multiline found but double quotes preferred" and
multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/009: Fix quote warning
Kamalesh Babulal [Mon, 5 Aug 2024 05:59:05 +0000 (11:29 +0530)] 
ftests/009: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/010: Fix quote warning
Kamalesh Babulal [Sun, 4 Aug 2024 05:57:21 +0000 (11:27 +0530)] 
ftests/010: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/011: Fix quote warnings
Kamalesh Babulal [Sat, 3 Aug 2024 10:56:37 +0000 (16:26 +0530)] 
ftests/011: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/012: Fix quote warning
Kamalesh Babulal [Fri, 2 Aug 2024 05:54:50 +0000 (11:24 +0530)] 
ftests/012: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/012: Fix quote warnings
Kamalesh Babulal [Thu, 1 Aug 2024 10:55:53 +0000 (16:25 +0530)] 
ftests/012: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/016: Fix quote warnings
Kamalesh Babulal [Wed, 31 Jul 2024 10:54:45 +0000 (16:24 +0530)] 
ftests/016: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings by adjusting two lines into single line.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/017: Fix quote warnings
Kamalesh Babulal [Tue, 30 Jul 2024 10:51:04 +0000 (16:21 +0530)] 
ftests/017: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/018: Fix quote warnings
Kamalesh Babulal [Mon, 29 Jul 2024 10:50:19 +0000 (16:20 +0530)] 
ftests/018: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/019: Fix quote warnings
Kamalesh Babulal [Sun, 28 Jul 2024 10:49:21 +0000 (16:19 +0530)] 
ftests/019: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/020: Fix quote warnings
Kamalesh Babulal [Sat, 27 Jul 2024 10:48:09 +0000 (16:18 +0530)] 
ftests/020: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/021: Fix quote warnings
Kamalesh Babulal [Fri, 26 Jul 2024 10:46:46 +0000 (16:16 +0530)] 
ftests/021: Fix quote warnings

Fix multiple "Q001 Single quote multiline found but double quotes
preferred" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/031: Fix couple of quite warnings
Kamalesh Babulal [Thu, 25 Jul 2024 10:45:49 +0000 (16:15 +0530)] 
ftests/031: Fix couple of quite warnings

Fix "Q001 Single quote multiline found but double quotes preferred" and
multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/032: Fix couple of quite warnings
Kamalesh Babulal [Wed, 24 Jul 2024 10:43:50 +0000 (16:13 +0530)] 
ftests/032: Fix couple of quite warnings

Fix "Q001 Single quote multiline found but double quotes preferred" and
multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/038: Fix quote warning
Kamalesh Babulal [Tue, 23 Jul 2024 10:42:13 +0000 (16:12 +0530)] 
ftests/038: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/039: Fix quote warnings
Kamalesh Babulal [Mon, 22 Jul 2024 10:39:42 +0000 (16:09 +0530)] 
ftests/039: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/045: Fix quote warning
Kamalesh Babulal [Sun, 21 Jul 2024 10:35:36 +0000 (16:05 +0530)] 
ftests/045: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/054: Fix quote warnings
Kamalesh Babulal [Sat, 20 Jul 2024 10:34:38 +0000 (16:04 +0530)] 
ftests/054: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/055: Fix quote warnings
Kamalesh Babulal [Fri, 19 Jul 2024 10:33:03 +0000 (16:03 +0530)] 
ftests/055: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/056: Fix quote warnings
Kamalesh Babulal [Mon, 15 Jul 2024 10:30:35 +0000 (16:00 +0530)] 
ftests/056: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/057: Fix quote warnings
Kamalesh Babulal [Sun, 14 Jul 2024 10:28:56 +0000 (15:58 +0530)] 
ftests/057: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/058: Fix quote warnings
Kamalesh Babulal [Sat, 13 Jul 2024 10:27:20 +0000 (15:57 +0530)] 
ftests/058: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/059: Fix quote warnings
Kamalesh Babulal [Fri, 12 Jul 2024 10:25:38 +0000 (15:55 +0530)] 
ftests/059: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/071: Fix quote warnings
Kamalesh Babulal [Thu, 11 Jul 2024 10:23:31 +0000 (15:53 +0530)] 
ftests/071: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/078: Fix quote warning
Kamalesh Babulal [Wed, 10 Jul 2024 10:20:16 +0000 (15:50 +0530)] 
ftests/078: Fix quote warning

Fix "Q003 Change outer quotes to avoid escaping inner quotes" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/079: Fix quote warning
Kamalesh Babulal [Tue, 9 Jul 2024 10:19:25 +0000 (15:49 +0530)] 
ftests/079: Fix quote warning

Fix "Q003 Change outer quotes to avoid escaping inner quotes" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/084: Fix quote warnings
Kamalesh Babulal [Fri, 28 Jun 2024 08:04:14 +0000 (13:34 +0530)] 
ftests/084: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/076: Fix quote warning
Kamalesh Babulal [Mon, 24 Jun 2024 07:54:37 +0000 (13:24 +0530)] 
ftests/076: Fix quote warning

Fix "Q001 Single quote multiline found but double quotes preferred"
warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/081: Fix quote warnings
Kamalesh Babulal [Sun, 23 Jun 2024 07:50:45 +0000 (13:20 +0530)] 
ftests/081: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/082: Fix quote warnings
Kamalesh Babulal [Sat, 22 Jun 2024 07:48:29 +0000 (13:18 +0530)] 
ftests/082: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
10 months agoftests/088: Fix quote warnings
Kamalesh Babulal [Fri, 21 Jun 2024 07:41:55 +0000 (13:11 +0530)] 
ftests/088: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agotools/cgsnapshot: Fix ret value in load_list()
Kamalesh Babulal [Tue, 16 Jul 2024 07:13:32 +0000 (12:43 +0530)] 
tools/cgsnapshot: Fix ret value in load_list()

The CodeQL reported a warning:
"Incorrect return-value check for a 'scanf'-like function"

More information about the warning:
https://github.com/libcgroup/libcgroup/security/code-scanning/18

Fix the warning by adding an additional "EOF" check for the ret value
from sscanf() in the load_list().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>