From c6a3f50783f7b3633442cbcb2e2faee4eb567e9b Mon Sep 17 00:00:00 2001 From: Zhao Hang Date: Wed, 28 Aug 2024 13:34:05 +0800 Subject: [PATCH 01/17] update to systemd-239-82.1.src.rpm Signed-off-by: Zhao Hang --- 0980-ci-Extend-source-git-automation.patch | 196 ++++++ ...sing-configuration-for-commit-linter.patch | 32 + ...nterprise-Linux-8-to-the-list-of-sup.patch | 25 + ...-git-automation-to-validate-reviews-.patch | 95 +++ ...y-config-replaced-by-Pull-Request-Va.patch | 52 ++ 0985-ci-enable-auto-merge-GH-Action.patch | 84 +++ ...allow-overriding-etc-fstab-with-SYST.patch | 179 +++++ ...allow-overriding-path-to-sysroot-etc.patch | 37 ++ ...ST-81-GENERATORS-fstab-generator-onl.patch | 611 ++++++++++++++++++ ...y-check-authenticated-flag-of-SOA-tr.patch | 16 +- ...how-we-determine-highest-possible-fd.patch | 70 ++ ...efuse-infinite-loop-in-close_all_fds.patch | 70 ++ ...t-inner-fallback-loop-of-close_all_f.patch | 110 ++++ ...ose_all_fds_without_malloc-from-free.patch | 29 + ...urce-git-automation-composite-Action.patch | 185 ++++++ ...ease-the-cron-interval-to-45-minutes.patch | 29 + ...eam-versions-to-array-of-allowed-ver.patch | 31 + ...s-declare-bitflag-enums-the-same-way.patch | 215 ++++++ 0998-login-Add-KEY_RESTART-handling.patch | 343 ++++++++++ ...-fix-recursive-call-of-syscall_names.patch | 62 ++ ...-do-not-assign-badness-to-filtered-o.patch | 28 + ...ull-reference-case-in-load_from_path.patch | 34 - ...-t-pass-null-directive-argument-to-s.patch | 25 - ...roduce-EXIT_EXCEPTION-mapping-to-255.patch | 52 -- ...e-PID-1-in-containers-exit-with-non-.patch | 52 -- ...t-go-into-freeze-when-systemd-crashd.patch | 103 --- ...ge-the-system-mount-propagation-to-s.patch | 62 -- ...-definition-of-CGROUP_CONTROLLER_TO_.patch | 26 - ...only-siblings-that-got-realized-once.patch | 46 -- ...g-item-to-support-setting-the-value-.patch | 120 ---- ...9-systemd-anolis-support-loongarch64.patch | 56 -- ...-include-an-actual-syscall-name-in-t.patch | 105 +++ ...x-coredump-when-compiled-under-GCC10.patch | 56 -- 10011-hwdb-add-Iluvatar-CoreX.patch | 44 -- 10012-seccomp-add-loongarch-support.patch | 101 --- ...ding-a-full-file-into-memory-refuse-.patch | 120 ---- ...explicit_bzero_safe-for-explicit-mem.patch | 61 -- ...util-introduce-erase_and_free-helper.patch | 48 -- ...READ_FULL_FILE_SECURE-flag-for-readi.patch | 207 ------ ...roduce-warn_file_is_world_accessible.patch | 67 -- ...l_file_full-also-warns-when-file-is-.patch | 64 -- ...x-memory-leak-if-READ_FULL_FILE_SECU.patch | 30 - ...ntroduce-naming-scheme-for-RHEL-8.10.patch | 50 ++ ...icit-flag-for-generating-world-execu.patch | 44 -- ..._fd-parameter-to-read_full_file_full.patch | 142 ---- ...ort-for-read_full_file-on-AF_UNIX-st.patch | 271 -------- ...READ_FULL_FILE_CONNECT_SOCKET-to-all.patch | 181 ------ ...ad_full_file_full-to-read-from-offse.patch | 246 ------- ...-cryptsetup-s-main-key-file-logic-ov.patch | 95 --- ...FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch | 69 -- 10027-fix-compilation-without-utmp.patch | 24 - ...ly-simplify-caching-of-cgroups-membe.patch | 228 ------- ...listitem-to-systemd.net-naming-schem.patch | 79 +++ ...-cleanup-of-PID-hashmaps-when-we-now.patch | 34 + ...an-update-link-to-RHEL-documentation.patch | 24 + ...figuration-for-regression-sniffer-GA.patch | 20 + ...lly-store-parsed-unit-in-the-context.patch | 35 + ...he-number-of-signature-validations-i.patch | 184 ++++++ ...-the-maximum-nsec3-iterations-to-100.patch | 34 + ...make-user-units-inherit-their-umask-.patch | 117 ++++ 1011-pam-add-call-to-pam_umask.patch | 28 + ...i-deploy-systemd-man-to-GitHub-Pages.patch | 81 +++ ...it-update-list-of-supported-products.patch | 24 + 20001-hwdb-parse_hwdb_dot_py.patch | 299 --------- ...fresh-cgroup-devices-config-when-dae.patch | 26 - ...group-full-delegation-for-compabilit.patch | 125 ---- ...Update-vendor-ids-for-ieisystem-0750.patch | 27 - ...ble-full-delegation-on-device-cgroup.patch | 98 --- 20006-systemd-Add-sw64.patch | 94 --- 20007-add-seccomp-support-for-sw_64.patch | 96 --- ...t-test-test-seccomp-support-on-sw_64.patch | 43 -- ...group-FullDelegation-FullDelegationD.patch | 163 ----- ...ormation-from-hostnamed-in-plot-even.patch | 101 --- ...nd-a-requirement-of-user-runtime-dir.patch | 44 -- ...pendency-of-libcryptsetup-if-HAVE_LI.patch | 40 -- ...group-path-which-not-created-by-syst.patch | 31 - README.md | 13 - dist | 2 +- systemd-user | 1 + systemd.spec | 348 +++------- 80 files changed, 3411 insertions(+), 4128 deletions(-) create mode 100644 0980-ci-Extend-source-git-automation.patch create mode 100644 0981-ci-add-missing-configuration-for-commit-linter.patch create mode 100644 0982-ci-add-Red-Hat-Enterprise-Linux-8-to-the-list-of-sup.patch create mode 100644 0983-ci-enable-source-git-automation-to-validate-reviews-.patch create mode 100644 0984-ci-remove-Mergify-config-replaced-by-Pull-Request-Va.patch create mode 100644 0985-ci-enable-auto-merge-GH-Action.patch create mode 100644 0986-fstab-generator-allow-overriding-etc-fstab-with-SYST.patch create mode 100644 0987-fstab-generator-allow-overriding-path-to-sysroot-etc.patch create mode 100644 0988-test-backport-TEST-81-GENERATORS-fstab-generator-onl.patch rename Fix-CVE-2023-7008.patch => 0989-resolved-actually-check-authenticated-flag-of-SOA-tr.patch (76%) create mode 100644 0990-fd-util-rework-how-we-determine-highest-possible-fd.patch create mode 100644 0991-basic-fd-util-refuse-infinite-loop-in-close_all_fds.patch create mode 100644 0992-fd-util-split-out-inner-fallback-loop-of-close_all_f.patch create mode 100644 0993-exec-util-use-close_all_fds_without_malloc-from-free.patch create mode 100644 0994-ci-use-source-git-automation-composite-Action.patch create mode 100644 0995-ci-increase-the-cron-interval-to-45-minutes.patch create mode 100644 0996-ci-add-all-Z-Stream-versions-to-array-of-allowed-ver.patch create mode 100644 0997-tree-wide-always-declare-bitflag-enums-the-same-way.patch create mode 100644 0998-login-Add-KEY_RESTART-handling.patch create mode 100644 0999-analyze-security-fix-recursive-call-of-syscall_names.patch create mode 100644 1000-analyze-security-do-not-assign-badness-to-filtered-o.patch delete mode 100644 10000-core-fix-a-null-reference-case-in-load_from_path.patch delete mode 100644 10001-sysctl-Don-t-pass-null-directive-argument-to-s.patch delete mode 100644 10002-exit-status-introduce-EXIT_EXCEPTION-mapping-to-255.patch delete mode 100644 10003-main-don-t-freeze-PID-1-in-containers-exit-with-non-.patch delete mode 100644 10004-Do-not-go-into-freeze-when-systemd-crashd.patch delete mode 100644 10005-mount-setup-change-the-system-mount-propagation-to-s.patch delete mode 100644 10006-cgroup-util-make-definition-of-CGROUP_CONTROLLER_TO_.patch delete mode 100644 10007-cgroup-update-only-siblings-that-got-realized-once.patch delete mode 100644 10008-core-add-a-config-item-to-support-setting-the-value-.patch delete mode 100644 10009-systemd-anolis-support-loongarch64.patch create mode 100644 1001-analyze-security-include-an-actual-syscall-name-in-t.patch delete mode 100644 10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch delete mode 100644 10011-hwdb-add-Iluvatar-CoreX.patch delete mode 100644 10012-seccomp-add-loongarch-support.patch delete mode 100644 10013-fileio-when-reading-a-full-file-into-memory-refuse-.patch delete mode 100644 10014-util-introduce-explicit_bzero_safe-for-explicit-mem.patch delete mode 100644 10015-util-introduce-erase_and_free-helper.patch delete mode 100644 10016-util-introduce-READ_FULL_FILE_SECURE-flag-for-readi.patch delete mode 100644 10017-fileio-introduce-warn_file_is_world_accessible.patch delete mode 100644 10018-fileio-read_full_file_full-also-warns-when-file-is-.patch delete mode 100644 10019-basic-fileio-Fix-memory-leak-if-READ_FULL_FILE_SECU.patch create mode 100644 1002-udev-net_id-introduce-naming-scheme-for-RHEL-8.10.patch delete mode 100644 10020-fileio-add-explicit-flag-for-generating-world-execu.patch delete mode 100644 10021-fileio-add-dir_fd-parameter-to-read_full_file_full.patch delete mode 100644 10022-fileio-add-support-for-read_full_file-on-AF_UNIX-st.patch delete mode 100644 10023-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch delete mode 100644 10024-fileio-teach-read_full_file_full-to-read-from-offse.patch delete mode 100644 10025-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch delete mode 100644 10026-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch delete mode 100644 10027-fix-compilation-without-utmp.patch delete mode 100644 10029-cgroup-drastically-simplify-caching-of-cgroups-membe.patch create mode 100644 1003-doc-add-missing-listitem-to-systemd.net-naming-schem.patch create mode 100644 1004-service-schedule-cleanup-of-PID-hashmaps-when-we-now.patch create mode 100644 1005-man-update-link-to-RHEL-documentation.patch create mode 100644 1006-ci-add-configuration-for-regression-sniffer-GA.patch create mode 100644 1007-coredump-actually-store-parsed-unit-in-the-context.patch create mode 100644 1008-resolved-limit-the-number-of-signature-validations-i.patch create mode 100644 1009-resolved-reduce-the-maximum-nsec3-iterations-to-100.patch create mode 100644 1010-pid1-by-default-make-user-units-inherit-their-umask-.patch create mode 100644 1011-pam-add-call-to-pam_umask.patch create mode 100644 1012-ci-deploy-systemd-man-to-GitHub-Pages.patch create mode 100644 1013-ci-src-git-update-list-of-supported-products.patch delete mode 100644 20001-hwdb-parse_hwdb_dot_py.patch delete mode 100644 20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch delete mode 100644 20003-core-introduce-cgroup-full-delegation-for-compabilit.patch delete mode 100644 20004-Update-vendor-ids-for-ieisystem-0750.patch delete mode 100644 20005-default-enable-full-delegation-on-device-cgroup.patch delete mode 100644 20006-systemd-Add-sw64.patch delete mode 100644 20007-add-seccomp-support-for-sw_64.patch delete mode 100644 20008-Fix-unit-test-test-seccomp-support-on-sw_64.patch delete mode 100644 20009-core-introduce-cgroup-FullDelegation-FullDelegationD.patch delete mode 100644 91000-analyze-show-information-from-hostnamed-in-plot-even.patch delete mode 100644 92000-meson-Make-logind-a-requirement-of-user-runtime-dir.patch delete mode 100644 92001-shared-Remove-dependency-of-libcryptsetup-if-HAVE_LI.patch delete mode 100644 92002-Do-not-remove-cgroup-path-which-not-created-by-syst.patch delete mode 100644 README.md diff --git a/0980-ci-Extend-source-git-automation.patch b/0980-ci-Extend-source-git-automation.patch new file mode 100644 index 0000000..6c969e7 --- /dev/null +++ b/0980-ci-Extend-source-git-automation.patch @@ -0,0 +1,196 @@ +From 1628f48a0ecd13db92b79b7689e74b0ed4cb31a0 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Thu, 14 Sep 2023 13:54:12 +0200 +Subject: [PATCH] ci: Extend source-git-automation + +* on schedule and on demand workflows +* Added Tracker validation for Bugzilla and Jira + +rhel-only + +Resolves: RHEL-1087 +--- + .github/tracker-validator.yml | 13 +++ + .../source-git-automation-on-demand.yml | 99 +++++++++++++++++++ + .github/workflows/source-git-automation.yml | 29 +++++- + 3 files changed, 139 insertions(+), 2 deletions(-) + create mode 100644 .github/tracker-validator.yml + create mode 100644 .github/workflows/source-git-automation-on-demand.yml + +diff --git a/.github/tracker-validator.yml b/.github/tracker-validator.yml +new file mode 100644 +index 0000000000..10ead63eaa +--- /dev/null ++++ b/.github/tracker-validator.yml +@@ -0,0 +1,13 @@ ++labels: ++ missing-tracker: tracker/missing ++ invalid-product: tracker/invalid-product ++ invalid-component: tracker/invalid-component ++ unapproved: tracker/unapproved ++products: ++ - CentOS Stream 8 ++ - rhel-8.2.0 ++ - rhel-8.4.0 ++ - rhel-8.6.0 ++ - rhel-8.8.0 ++ - rhel-8.9.0 ++ - rhel-8.10.0 +diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml +new file mode 100644 +index 0000000000..92a65c8cc7 +--- /dev/null ++++ b/.github/workflows/source-git-automation-on-demand.yml +@@ -0,0 +1,99 @@ ++--- ++ ++name: Source git Automation Scheduled/On Demand ++on: ++ schedule: ++ # Workflow runs every 15 minutes ++ - cron: '*/15 * * * *' ++ workflow_dispatch: ++ inputs: ++ pr-number: ++ description: 'Pull Request number/s ; when not provided, the workflow will run for all open PRs' ++ required: true ++ default: '0' ++ ++permissions: ++ contents: read ++ ++jobs: ++ # Get all open PRs ++ gather-pull-requests: ++ if: github.repository == 'redhat-plumbers/systemd-rhel8' ++ runs-on: ubuntu-latest ++ ++ outputs: ++ pr-numbers: ${{ steps.get-pr-numbers.outputs.result }} ++ pr-numbers-manual: ${{ steps.parse-manual-input.outputs.result }} ++ ++ steps: ++ - id: get-pr-numbers ++ if: inputs.pr-number == '0' ++ name: Get all open PRs ++ uses: actions/github-script@v6 ++ with: ++ # !FIXME: this is not working if there is more than 100 PRs opened ++ script: | ++ const { data: pullRequests } = await github.rest.pulls.list({ ++ owner: context.repo.owner, ++ repo: context.repo.repo, ++ state: 'open', ++ per_page: 100 ++ }); ++ return pullRequests.map(pr => pr.number); ++ ++ - id: parse-manual-input ++ if: inputs.pr-number != '0' ++ name: Parse manual input ++ run: | ++ echo "result="[ ${{ inputs.pr-number }} ]"" >> $GITHUB_OUTPUT ++ shell: bash ++ ++ validate-pr: ++ name: 'Validation of Pull Request #${{ matrix.pr-number }}' ++ needs: [ gather-pull-requests ] ++ runs-on: ubuntu-latest ++ ++ strategy: ++ fail-fast: false ++ matrix: ++ pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }} ++ ++ permissions: ++ statuses: write ++ checks: write ++ pull-requests: write ++ ++ steps: ++ - name: Repository checkout ++ uses: actions/checkout@v3 ++ ++ - id: metadata ++ name: Gather Pull Request Metadata ++ uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1 ++ with: ++ pr-number: ${{ matrix.pr-number }} ++ ++ - id: commit-linter ++ name: Lint Commits ++ uses: redhat-plumbers-in-action/advanced-commit-linter@v2 ++ with: ++ pr-metadata: ${{ steps.metadata.outputs.metadata }} ++ token: ${{ secrets.GITHUB_TOKEN }} ++ ++ # Validates tracker, changes tracker status, updates PR title ++ - id: tracker-validator ++ name: Validate Tracker ++ uses: redhat-plumbers-in-action/tracker-validator@v1 ++ with: ++ pr-metadata: ${{ steps.metadata.outputs.metadata }} ++ component: systemd ++ tracker: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }} ++ tracker-type: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }} ++ bugzilla-instance: https://bugzilla.redhat.com ++ bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }} ++ jira-instance: https://issues.redhat.com ++ jira-api-token: ${{ secrets.JIRA_API_TOKEN }} ++ token: ${{ secrets.GITHUB_TOKEN }} ++ ++ # TODO: merge PR if all checks passed ++ # TODO: add comment to Tracker that PR was merged ... +diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml +index e653e28a7f..16c6f83d77 100644 +--- a/.github/workflows/source-git-automation.yml ++++ b/.github/workflows/source-git-automation.yml +@@ -12,7 +12,8 @@ jobs: + download-metadata: + if: > + github.event.workflow_run.event == 'pull_request' && +- github.event.workflow_run.conclusion == 'success' ++ github.event.workflow_run.conclusion == 'success' && ++ github.repository == 'redhat-plumbers/systemd-rhel8' + runs-on: ubuntu-latest + + outputs: +@@ -33,13 +34,37 @@ jobs: + validated-pr-metadata: ${{ steps.commit-linter.outputs.validated-pr-metadata }} + + permissions: ++ statuses: write + checks: write + pull-requests: write + + steps: + - id: commit-linter + name: Lint Commits +- uses: redhat-plumbers-in-action/advanced-commit-linter@v1 ++ uses: redhat-plumbers-in-action/advanced-commit-linter@v2 + with: + pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }} + token: ${{ secrets.GITHUB_TOKEN }} ++ ++ # Validates tracker, changes tracker status, updates PR title ++ tracker-validation: ++ needs: [ download-metadata, commit-linter ] ++ runs-on: ubuntu-latest ++ ++ permissions: ++ checks: write ++ pull-requests: write ++ ++ steps: ++ - name: Validate Tracker ++ uses: redhat-plumbers-in-action/tracker-validator@v1 ++ with: ++ pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }} ++ component: systemd ++ tracker: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }} ++ tracker-type: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }} ++ bugzilla-instance: https://bugzilla.redhat.com ++ bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }} ++ jira-instance: https://issues.redhat.com ++ jira-api-token: ${{ secrets.JIRA_API_TOKEN }} ++ token: ${{ secrets.GITHUB_TOKEN }} diff --git a/0981-ci-add-missing-configuration-for-commit-linter.patch b/0981-ci-add-missing-configuration-for-commit-linter.patch new file mode 100644 index 0000000..6a30f07 --- /dev/null +++ b/0981-ci-add-missing-configuration-for-commit-linter.patch @@ -0,0 +1,32 @@ +From 21200fc506b1d15be6ed6d5b9ac70f1ec865f9bc Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Tue, 19 Sep 2023 09:53:35 +0200 +Subject: [PATCH] ci: add missing configuration for commit linter + +rhel-only + +Related: RHEL-1087 +--- + .github/advanced-commit-linter.yml | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/.github/advanced-commit-linter.yml b/.github/advanced-commit-linter.yml +index 0fb74a9dc8..86f0e911f2 100644 +--- a/.github/advanced-commit-linter.yml ++++ b/.github/advanced-commit-linter.yml +@@ -11,6 +11,7 @@ policy: + - 'Resolves: #?' + - 'Related: #?' + - 'Reverts: #?' ++ type: bugzilla + issue-format: + - '\d+$' + url: 'https://bugzilla.redhat.com/show_bug.cgi?id=' +@@ -18,6 +19,7 @@ policy: + - 'Resolves: ' + - 'Related: ' + - 'Reverts: ' ++ type: jira + issue-format: + - 'RHEL-\d+$' + url: 'https://issues.redhat.com/browse/' diff --git a/0982-ci-add-Red-Hat-Enterprise-Linux-8-to-the-list-of-sup.patch b/0982-ci-add-Red-Hat-Enterprise-Linux-8-to-the-list-of-sup.patch new file mode 100644 index 0000000..8a3d248 --- /dev/null +++ b/0982-ci-add-Red-Hat-Enterprise-Linux-8-to-the-list-of-sup.patch @@ -0,0 +1,25 @@ +From ffd775b4b96ce0d772bcbb2fe2fbc62ed06bb4a4 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Tue, 19 Sep 2023 15:17:48 +0200 +Subject: [PATCH] ci: add `Red Hat Enterprise Linux 8` to the list of supported + products + +rhel-only + +Related: RHEL-1087 +--- + .github/tracker-validator.yml | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/.github/tracker-validator.yml b/.github/tracker-validator.yml +index 10ead63eaa..500dce3d92 100644 +--- a/.github/tracker-validator.yml ++++ b/.github/tracker-validator.yml +@@ -4,6 +4,7 @@ labels: + invalid-component: tracker/invalid-component + unapproved: tracker/unapproved + products: ++ - Red Hat Enterprise Linux 8 + - CentOS Stream 8 + - rhel-8.2.0 + - rhel-8.4.0 diff --git a/0983-ci-enable-source-git-automation-to-validate-reviews-.patch b/0983-ci-enable-source-git-automation-to-validate-reviews-.patch new file mode 100644 index 0000000..336a464 --- /dev/null +++ b/0983-ci-enable-source-git-automation-to-validate-reviews-.patch @@ -0,0 +1,95 @@ +From bf728def0c6eebdf8d2b8912232ba7806e109293 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Fri, 20 Oct 2023 13:32:22 +0200 +Subject: [PATCH] ci: enable source-git automation to validate reviews and ci + results + +rhel-only + +Related: RHEL-1087 +--- + .github/pull-request-validator.yml | 4 ++++ + .../source-git-automation-on-demand.yml | 14 ++++++++++---- + .github/workflows/source-git-automation.yml | 18 +++++++++++++++++- + 3 files changed, 31 insertions(+), 5 deletions(-) + create mode 100644 .github/pull-request-validator.yml + +diff --git a/.github/pull-request-validator.yml b/.github/pull-request-validator.yml +new file mode 100644 +index 0000000000..4bb5bbec12 +--- /dev/null ++++ b/.github/pull-request-validator.yml +@@ -0,0 +1,4 @@ ++labels: ++ missing-review: pr/needs-review ++ changes-requested: pr/changes-requested ++ missing-failing-ci: pr/needs-ci +diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml +index 92a65c8cc7..e70ba4857a 100644 +--- a/.github/workflows/source-git-automation-on-demand.yml ++++ b/.github/workflows/source-git-automation-on-demand.yml +@@ -73,7 +73,8 @@ jobs: + with: + pr-number: ${{ matrix.pr-number }} + +- - id: commit-linter ++ - if: ${{ !cancelled() }} ++ id: commit-linter + name: Lint Commits + uses: redhat-plumbers-in-action/advanced-commit-linter@v2 + with: +@@ -81,7 +82,8 @@ jobs: + token: ${{ secrets.GITHUB_TOKEN }} + + # Validates tracker, changes tracker status, updates PR title +- - id: tracker-validator ++ - if: ${{ !cancelled() }} ++ id: tracker-validator + name: Validate Tracker + uses: redhat-plumbers-in-action/tracker-validator@v1 + with: +@@ -95,5 +97,9 @@ jobs: + jira-api-token: ${{ secrets.JIRA_API_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} + +- # TODO: merge PR if all checks passed +- # TODO: add comment to Tracker that PR was merged ... ++ - if: ${{ !cancelled() }} ++ name: Pull Request Validator ++ uses: redhat-plumbers-in-action/pull-request-validator@v1 ++ with: ++ pr-metadata: ${{ steps.metadata.outputs.metadata }} ++ token: ${{ secrets.GITHUB_TOKEN }} +diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml +index 16c6f83d77..9faaaca099 100644 +--- a/.github/workflows/source-git-automation.yml ++++ b/.github/workflows/source-git-automation.yml +@@ -47,7 +47,8 @@ jobs: + token: ${{ secrets.GITHUB_TOKEN }} + + # Validates tracker, changes tracker status, updates PR title +- tracker-validation: ++ tracker-validator: ++ if: ${{ !cancelled() }} + needs: [ download-metadata, commit-linter ] + runs-on: ubuntu-latest + +@@ -68,3 +69,18 @@ jobs: + jira-instance: https://issues.redhat.com + jira-api-token: ${{ secrets.JIRA_API_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} ++ ++ pull-request-validator: ++ needs: [ download-metadata ] ++ runs-on: ubuntu-latest ++ ++ permissions: ++ checks: write ++ pull-requests: write ++ ++ steps: ++ - name: Pull Request Validator ++ uses: redhat-plumbers-in-action/pull-request-validator@v1 ++ with: ++ pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }} ++ token: ${{ secrets.GITHUB_TOKEN }} diff --git a/0984-ci-remove-Mergify-config-replaced-by-Pull-Request-Va.patch b/0984-ci-remove-Mergify-config-replaced-by-Pull-Request-Va.patch new file mode 100644 index 0000000..6b8fbd0 --- /dev/null +++ b/0984-ci-remove-Mergify-config-replaced-by-Pull-Request-Va.patch @@ -0,0 +1,52 @@ +From 36266d377ee5e57e24cd3c45f6db2a29919798f3 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Fri, 20 Oct 2023 13:33:38 +0200 +Subject: [PATCH] ci: remove Mergify config - replaced by Pull Request + Validator + +rhel-only + +Related: RHEL-1087 +--- + .mergify.yml | 32 -------------------------------- + 1 file changed, 32 deletions(-) + delete mode 100644 .mergify.yml + +diff --git a/.mergify.yml b/.mergify.yml +deleted file mode 100644 +index 624eb7291d..0000000000 +--- a/.mergify.yml ++++ /dev/null +@@ -1,32 +0,0 @@ +-# doc: https://docs.mergify.com +---- +- +-pull_request_rules: +- - name: Add `needs-ci` label on CI fail +- conditions: +- - label!=ci-waived +- - or: +- # Unit tests +- - -check-success=build (stream8, GCC) +- - -check-success=build (stream8, GCC_ASAN) +- # CentOS Stream CI +- - -check-success=CentOS CI (CentOS Stream 8) +- actions: +- label: +- add: +- - needs-ci +- +- - name: Remove `needs-ci` label on CI success +- conditions: +- - or: +- - label=ci-waived +- - and: +- # Unit tests +- - check-success=build (stream8, GCC) +- - check-success=build (stream8, GCC_ASAN) +- # CentOS Stream CI +- - check-success=CentOS CI (CentOS Stream 8) +- actions: +- label: +- remove: +- - needs-ci diff --git a/0985-ci-enable-auto-merge-GH-Action.patch b/0985-ci-enable-auto-merge-GH-Action.patch new file mode 100644 index 0000000..6828fca --- /dev/null +++ b/0985-ci-enable-auto-merge-GH-Action.patch @@ -0,0 +1,84 @@ +From 73b327eeeb3e2f17cbc1abd19aa5b87c28fcf509 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Fri, 3 Nov 2023 14:07:04 +0100 +Subject: [PATCH] ci: enable auto-merge GH Action + +rhel-only + +Related: RHEL-1087 +--- + .github/auto-merge.yml | 4 ++++ + .../source-git-automation-on-demand.yml | 14 ++++++++++++ + .github/workflows/source-git-automation.yml | 22 +++++++++++++++++++ + 3 files changed, 40 insertions(+) + create mode 100644 .github/auto-merge.yml + +diff --git a/.github/auto-merge.yml b/.github/auto-merge.yml +new file mode 100644 +index 0000000000..35c2539295 +--- /dev/null ++++ b/.github/auto-merge.yml +@@ -0,0 +1,4 @@ ++labels: ++ dont-merge: dont-merge ++ manual-merge: pr/needs-manual-merge ++target-branch': ['main'] +diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml +index e70ba4857a..948708916d 100644 +--- a/.github/workflows/source-git-automation-on-demand.yml ++++ b/.github/workflows/source-git-automation-on-demand.yml +@@ -59,6 +59,7 @@ jobs: + pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }} + + permissions: ++ contents: write + statuses: write + checks: write + pull-requests: write +@@ -103,3 +104,16 @@ jobs: + with: + pr-metadata: ${{ steps.metadata.outputs.metadata }} + token: ${{ secrets.GITHUB_TOKEN }} ++ ++ - id: auto-merge ++ name: Auto Merge ++ uses: redhat-plumbers-in-action/auto-merge@v1 ++ with: ++ pr-metadata: ${{ steps.metadata.outputs.metadata }} ++ tracker: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }} ++ tracker-type: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }} ++ bugzilla-instance: https://bugzilla.redhat.com ++ bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }} ++ jira-instance: https://issues.redhat.com ++ jira-api-token: ${{ secrets.JIRA_API_TOKEN }} ++ token: ${{ secrets.GITHUB_TOKEN }} +diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml +index 9faaaca099..95819baa8b 100644 +--- a/.github/workflows/source-git-automation.yml ++++ b/.github/workflows/source-git-automation.yml +@@ -84,3 +84,25 @@ jobs: + with: + pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }} + token: ${{ secrets.GITHUB_TOKEN }} ++ ++ auto-merge: ++ needs: [ download-metadata, commit-linter, tracker-validator, pull-request-validator ] ++ runs-on: ubuntu-latest ++ ++ permissions: ++ contents: write ++ checks: write ++ pull-requests: write ++ ++ steps: ++ - name: Auto Merge ++ uses: redhat-plumbers-in-action/auto-merge@v1 ++ with: ++ pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }} ++ tracker: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }} ++ tracker-type: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }} ++ bugzilla-instance: https://bugzilla.redhat.com ++ bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }} ++ jira-instance: https://issues.redhat.com ++ jira-api-token: ${{ secrets.JIRA_API_TOKEN }} ++ token: ${{ secrets.GITHUB_TOKEN }} diff --git a/0986-fstab-generator-allow-overriding-etc-fstab-with-SYST.patch b/0986-fstab-generator-allow-overriding-etc-fstab-with-SYST.patch new file mode 100644 index 0000000..4123a1d --- /dev/null +++ b/0986-fstab-generator-allow-overriding-etc-fstab-with-SYST.patch @@ -0,0 +1,179 @@ +From d0f59d4190a9f1e0e6db4b22b5e87bec2db4f7fb Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Mon, 27 Nov 2023 15:20:47 +0100 +Subject: [PATCH] fstab-generator: allow overriding /etc/fstab with + $SYSTEMD_FSTAB + +Based on: ed4ad4889723a9acdf75ed86f10cee0024bbbcbc +Related: RHEL-1087 + +rhel-only +--- + src/cryptsetup/cryptsetup.c | 3 ++- + src/fstab-generator/fstab-generator.c | 28 ++++++++++++++------------- + src/remount-fs/remount-fs.c | 5 +++-- + src/shared/fstab-util.c | 4 ++-- + src/shared/fstab-util.h | 4 ++++ + 5 files changed, 26 insertions(+), 18 deletions(-) + +diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c +index 11162eb722..de4bc9579c 100644 +--- a/src/cryptsetup/cryptsetup.c ++++ b/src/cryptsetup/cryptsetup.c +@@ -13,6 +13,7 @@ + #include "device-util.h" + #include "escape.h" + #include "fileio.h" ++#include "fstab-util.h" + #include "log.h" + #include "mount-util.h" + #include "parse-util.h" +@@ -318,7 +319,7 @@ static char *disk_mount_point(const char *label) { + if (asprintf(&device, "/dev/mapper/%s", label) < 0) + return NULL; + +- f = setmntent("/etc/fstab", "re"); ++ f = setmntent(fstab_path(), "re"); + if (!f) + return NULL; + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index f24c1d29da..105ddd2fd0 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -105,15 +105,17 @@ static int add_swap( + if (r < 0) + return log_error_errno(r, "Failed to generate unit name: %m"); + +- r = generator_open_unit_file(arg_dest, "/etc/fstab", name, &f); ++ r = generator_open_unit_file(arg_dest, fstab_path(), name, &f); + if (r < 0) + return r; + +- fputs("# Automatically generated by systemd-fstab-generator\n\n" +- "[Unit]\n" +- "SourcePath=/etc/fstab\n" +- "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n\n" +- "[Swap]\n", f); ++ fprintf(f, ++ "# Automatically generated by systemd-fstab-generator\n\n" ++ "[Unit]\n" ++ "SourcePath=%s\n" ++ "Documentation=man:fstab(5) man:systemd-fstab-generator(8)\n\n" ++ "[Swap]\n", ++ fstab_path()); + + r = write_what(f, what); + if (r < 0) +@@ -334,7 +336,7 @@ static int add_mount( + if (r < 0) + return log_error_errno(r, "Failed to generate unit name: %m"); + +- r = generator_open_unit_file(dest, "/etc/fstab", name, &f); ++ r = generator_open_unit_file(dest, fstab_path(), name, &f); + if (r < 0) + return r; + +@@ -451,7 +453,7 @@ static int add_mount( + + fclose(f); + +- r = generator_open_unit_file(dest, "/etc/fstab", automount_name, &f); ++ r = generator_open_unit_file(dest, fstab_path(), automount_name, &f); + if (r < 0) + return r; + +@@ -503,17 +505,17 @@ static int add_mount( + + static int parse_fstab(bool initrd) { + _cleanup_endmntent_ FILE *f = NULL; +- const char *fstab_path; ++ const char *fstab; + struct mntent *me; + int r = 0; + +- fstab_path = initrd ? "/sysroot/etc/fstab" : "/etc/fstab"; +- f = setmntent(fstab_path, "re"); ++ fstab = initrd ? "/sysroot/etc/fstab" : fstab_path(); ++ f = setmntent(fstab, "re"); + if (!f) { + if (errno == ENOENT) + return 0; + +- return log_error_errno(errno, "Failed to open %s: %m", fstab_path); ++ return log_error_errno(errno, "Failed to open %s: %m", fstab); + } + + while ((me = getmntent(f))) { +@@ -592,7 +594,7 @@ static int parse_fstab(bool initrd) { + me->mnt_passno, + makefs*MAKEFS | growfs*GROWFS | noauto*NOAUTO | nofail*NOFAIL | automount*AUTOMOUNT, + post, +- fstab_path); ++ fstab); + } + + if (r >= 0 && k < 0) +diff --git a/src/remount-fs/remount-fs.c b/src/remount-fs/remount-fs.c +index 9220a00215..5bcee999cc 100644 +--- a/src/remount-fs/remount-fs.c ++++ b/src/remount-fs/remount-fs.c +@@ -9,6 +9,7 @@ + #include + + #include "exit-status.h" ++#include "fstab-util.h" + #include "log.h" + #include "mount-setup.h" + #include "mount-util.h" +@@ -39,14 +40,14 @@ int main(int argc, char *argv[]) { + + umask(0022); + +- f = setmntent("/etc/fstab", "re"); ++ f = setmntent(fstab_path(), "re"); + if (!f) { + if (errno == ENOENT) { + r = 0; + goto finish; + } + +- r = log_error_errno(errno, "Failed to open /etc/fstab: %m"); ++ r = log_error_errno(errno, "Failed to open %s: %m", fstab_path()); + goto finish; + } + +diff --git a/src/shared/fstab-util.c b/src/shared/fstab-util.c +index 6fd9866c00..bc0c047509 100644 +--- a/src/shared/fstab-util.c ++++ b/src/shared/fstab-util.c +@@ -21,7 +21,7 @@ int fstab_has_fstype(const char *fstype) { + _cleanup_endmntent_ FILE *f = NULL; + struct mntent *m; + +- f = setmntent("/etc/fstab", "re"); ++ f = setmntent(fstab_path(), "re"); + if (!f) + return errno == ENOENT ? false : -errno; + +@@ -41,7 +41,7 @@ int fstab_is_mount_point(const char *mount) { + _cleanup_endmntent_ FILE *f = NULL; + struct mntent *m; + +- f = setmntent("/etc/fstab", "re"); ++ f = setmntent(fstab_path(), "re"); + if (!f) + return errno == ENOENT ? false : -errno; + +diff --git a/src/shared/fstab-util.h b/src/shared/fstab-util.h +index 9820f78ca8..9ec6db068c 100644 +--- a/src/shared/fstab-util.h ++++ b/src/shared/fstab-util.h +@@ -33,3 +33,7 @@ static inline bool fstab_test_yes_no_option(const char *opts, const char *yes_no + } + + char *fstab_node_to_udev_node(const char *p); ++ ++static inline const char *fstab_path(void) { ++ return secure_getenv("SYSTEMD_FSTAB") ?: "/etc/fstab"; ++} diff --git a/0987-fstab-generator-allow-overriding-path-to-sysroot-etc.patch b/0987-fstab-generator-allow-overriding-path-to-sysroot-etc.patch new file mode 100644 index 0000000..6693c2d --- /dev/null +++ b/0987-fstab-generator-allow-overriding-path-to-sysroot-etc.patch @@ -0,0 +1,37 @@ +From f4a9bdf74c23a55ea96de696155ce9a5dfa43850 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Mon, 27 Nov 2023 16:16:40 +0100 +Subject: [PATCH] fstab-generator: allow overriding path to /sysroot/etc/fstab + too + +Based on: 99e3d4767932bce5febb45e8543162d729d17425 +Related: RHEL-1087 + +rhel-only +--- + src/fstab-generator/fstab-generator.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c +index 105ddd2fd0..02f0bccd2f 100644 +--- a/src/fstab-generator/fstab-generator.c ++++ b/src/fstab-generator/fstab-generator.c +@@ -503,13 +503,17 @@ static int add_mount( + return 0; + } + ++static const char *sysroot_fstab_path(void) { ++ return getenv("SYSTEMD_SYSROOT_FSTAB") ?: "/sysroot/etc/fstab"; ++} ++ + static int parse_fstab(bool initrd) { + _cleanup_endmntent_ FILE *f = NULL; + const char *fstab; + struct mntent *me; + int r = 0; + +- fstab = initrd ? "/sysroot/etc/fstab" : fstab_path(); ++ fstab = initrd ? sysroot_fstab_path() : fstab_path(); + f = setmntent(fstab, "re"); + if (!f) { + if (errno == ENOENT) diff --git a/0988-test-backport-TEST-81-GENERATORS-fstab-generator-onl.patch b/0988-test-backport-TEST-81-GENERATORS-fstab-generator-onl.patch new file mode 100644 index 0000000..cf9269d --- /dev/null +++ b/0988-test-backport-TEST-81-GENERATORS-fstab-generator-onl.patch @@ -0,0 +1,611 @@ +From 52026032996f021963f5af8d625a5b9653d3f815 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Mon, 27 Nov 2023 14:54:15 +0100 +Subject: [PATCH] test: backport TEST-81-GENERATORS (fstab-generator only) + +Some fstab-generator features are not present on RHEL 8 or they behave +differently - in such case there's an inline comment explaining what's +different with a reference to an upstream commit that introduced the +changed behavior. + +Related: RHEL-1087 + +rhel-only +--- + test/TEST-81-GENERATORS/Makefile | 1 + + test/TEST-81-GENERATORS/generator-utils.sh | 78 ++++ + test/TEST-81-GENERATORS/test.sh | 50 +++ + .../testsuite.fstab-generator.sh | 397 ++++++++++++++++++ + test/TEST-81-GENERATORS/testsuite.sh | 14 + + test/test-functions | 2 +- + 6 files changed, 541 insertions(+), 1 deletion(-) + create mode 120000 test/TEST-81-GENERATORS/Makefile + create mode 100755 test/TEST-81-GENERATORS/generator-utils.sh + create mode 100755 test/TEST-81-GENERATORS/test.sh + create mode 100755 test/TEST-81-GENERATORS/testsuite.fstab-generator.sh + create mode 100755 test/TEST-81-GENERATORS/testsuite.sh + +diff --git a/test/TEST-81-GENERATORS/Makefile b/test/TEST-81-GENERATORS/Makefile +new file mode 120000 +index 0000000000..e9f93b1104 +--- /dev/null ++++ b/test/TEST-81-GENERATORS/Makefile +@@ -0,0 +1 @@ ++../TEST-01-BASIC/Makefile +\ No newline at end of file +diff --git a/test/TEST-81-GENERATORS/generator-utils.sh b/test/TEST-81-GENERATORS/generator-utils.sh +new file mode 100755 +index 0000000000..fb62747fa1 +--- /dev/null ++++ b/test/TEST-81-GENERATORS/generator-utils.sh +@@ -0,0 +1,78 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++ ++link_endswith() { ++ [[ -h "${1:?}" && "$(readlink "${1:?}")" =~ ${2:?}$ ]] ++} ++ ++link_eq() { ++ [[ -h "${1:?}" && "$(readlink "${1:?}")" == "${2:?}" ]] ++} ++ ++# Get the value from a 'key=value' assignment ++opt_get_arg() { ++ local arg ++ ++ IFS="=" read -r _ arg <<< "${1:?}" ++ test -n "$arg" ++ echo "$arg" ++} ++ ++in_initrd() { ++ [[ "${SYSTEMD_IN_INITRD:-0}" -ne 0 ]] ++} ++ ++# Check if we're parsing host's fstab in initrd ++in_initrd_host() { ++ in_initrd && [[ "${SYSTEMD_SYSROOT_FSTAB:-/dev/null}" != /dev/null ]] ++} ++ ++in_container() { ++ systemd-detect-virt -qc ++} ++ ++opt_filter() ( ++ set +x ++ local opt split_options filtered_options ++ ++ IFS="," read -ra split_options <<< "${1:?}" ++ for opt in "${split_options[@]}"; do ++ if [[ "$opt" =~ ${2:?} ]]; then ++ continue ++ fi ++ ++ filtered_options+=("$opt") ++ done ++ ++ IFS=","; printf "%s" "${filtered_options[*]}" ++) ++ ++# Run the given generator $1 with target directory $2 - clean the target ++# directory beforehand ++run_and_list() { ++ local generator="${1:?}" ++ local out_dir="${2:?}" ++ local environ ++ ++ # If $PID1_ENVIRON is set temporarily overmount /proc/1/environ with ++ # a temporary file that contains contents of $PID1_ENVIRON. This is ++ # necessary in cases where the generator reads the environment through ++ # getenv_for_pid(1, ...) or similar like getty-generator does. ++ # ++ # Note: $PID1_ENVIRON should be a NUL separated list of env assignments ++ if [[ -n "${PID1_ENVIRON:-}" ]]; then ++ environ="$(mktemp)" ++ echo -ne "${PID1_ENVIRON}\0" >"${environ:?}" ++ mount -v --bind "$environ" /proc/1/environ ++ fi ++ ++ rm -fr "${out_dir:?}"/* ++ mkdir -p "$out_dir"/{normal,early,late} ++ SYSTEMD_LOG_LEVEL="${SYSTEMD_LOG_LEVEL:-debug}" "$generator" "$out_dir/normal" "$out_dir/early" "$out_dir/late" ++ ls -lR "$out_dir" ++ ++ if [[ -n "${environ:-}" ]]; then ++ umount /proc/1/environ ++ rm -f "$environ" ++ fi ++} +diff --git a/test/TEST-81-GENERATORS/test.sh b/test/TEST-81-GENERATORS/test.sh +new file mode 100755 +index 0000000000..ec9c608c60 +--- /dev/null ++++ b/test/TEST-81-GENERATORS/test.sh +@@ -0,0 +1,50 @@ ++#!/usr/bin/env bash ++set -e ++TEST_DESCRIPTION="Test systemd generators" ++ ++# shellcheck source=test/test-functions ++. "$TEST_BASE_DIR/test-functions" ++ ++test_setup() { ++ create_empty_image ++ mkdir -p "${TESTDIR:?}/root" ++ mount "${LOOPDEV:?}p1" "$TESTDIR/root" ++ ++ ( ++ LOG_LEVEL=5 ++ # shellcheck disable=SC2046 ++ eval $(udevadm info --export --query=env --name="${LOOPDEV}p2") ++ ++ setup_basic_environment ++ ++ # mask some services that we do not want to run in these tests ++ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-hwdb-update.service" ++ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-journal-catalog-update.service" ++ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-networkd.service" ++ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-networkd.socket" ++ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-resolved.service" ++ ln -fs /dev/null "$initdir/etc/systemd/system/systemd-machined.service" ++ ++ # setup the testsuite service ++ cat >"$initdir/etc/systemd/system/testsuite.service" <&2 "Unhandled mount option: $opt" ++ exit 1 ++ fi ++ done ++ done ++} ++ ++: "fstab-generator: regular" ++printf "%s\n" "${FSTAB_GENERAL_ROOT[@]}" >"$FSTAB" ++cat "$FSTAB" ++SYSTEMD_FSTAB="$FSTAB" run_and_list "$GENERATOR_BIN" "$OUT_DIR" ++check_fstab_mount_units FSTAB_GENERAL_ROOT "$OUT_DIR" ++ ++# Skip the rest when running in a container, as it makes little sense to check ++# initrd-related stuff there and fstab-generator might have a bit strange ++# behavior during certain tests, like https://github.com/systemd/systemd/issues/27156 ++if in_container; then ++ echo "Running in a container, skipping the rest of the fstab-generator tests..." ++ exit 0 ++fi ++ ++# In this mode we treat the entries as "regular" ones ++: "fstab-generator: initrd - initrd fstab" ++printf "%s\n" "${FSTAB_GENERAL[@]}" >"$FSTAB" ++cat "$FSTAB" ++SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" SYSTEMD_SYSROOT_FSTAB=/dev/null run_and_list "$GENERATOR_BIN" "$OUT_DIR" ++SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" SYSTEMD_SYSROOT_FSTAB=/dev/null check_fstab_mount_units FSTAB_GENERAL "$OUT_DIR" ++ ++# In this mode we prefix the mount target with /sysroot and ignore all mounts ++# that don't have the x-initrd.mount flag ++: "fstab-generator: initrd - host fstab" ++printf "%s\n" "${FSTAB_GENERAL_ROOT[@]}" >"$FSTAB" ++cat "$FSTAB" ++SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB="$FSTAB" run_and_list "$GENERATOR_BIN" "$OUT_DIR" ++SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_GENERAL_ROOT "$OUT_DIR" ++ ++# Check the default stuff that we (almost) always create in initrd ++: "fstab-generator: initrd default" ++SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB=/dev/null run_and_list "$GENERATOR_BIN" "$OUT_DIR" ++test -e "$OUT_DIR/normal/sysroot.mount" ++test -e "$OUT_DIR/normal/systemd-fsck-root.service" ++link_eq "$OUT_DIR/normal/initrd-root-fs.target.requires/sysroot.mount" "../sysroot.mount" ++link_eq "$OUT_DIR/normal/initrd-root-fs.target.requires/sysroot.mount" "../sysroot.mount" ++ ++# systemd-sysroot-fstab-check is not in RHEL 8 ++ ++: "fstab-generator: duplicate" ++printf "%s\n" "${FSTAB_DUPLICATE[@]}" >"$FSTAB" ++cat "$FSTAB" ++(! SYSTEMD_FSTAB="$FSTAB" run_and_list "$GENERATOR_BIN" "$OUT_DIR") ++ ++: "fstab-generator: invalid" ++printf "%s\n" "${FSTAB_INVALID[@]}" >"$FSTAB" ++cat "$FSTAB" ++# Don't care about the exit code here ++SYSTEMD_FSTAB="$FSTAB" run_and_list "$GENERATOR_BIN" "$OUT_DIR" || : ++# No mounts should get created here ++[[ "$(find "$OUT_DIR" -name "*.mount" | wc -l)" -eq 0 ]] ++ ++: "fstab-generator: kernel args - fstab=0" ++printf "%s\n" "${FSTAB_MINIMAL[@]}" >"$FSTAB" ++SYSTEMD_FSTAB="$FSTAB" SYSTEMD_PROC_CMDLINE="fstab=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR" ++(! SYSTEMD_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_MINIMAL "$OUT_DIR") ++SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" SYSTEMD_PROC_CMDLINE="fstab=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR" ++(! SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_MINIMAL "$OUT_DIR") ++ ++: "fstab-generator: kernel args - rd.fstab=0" ++printf "%s\n" "${FSTAB_MINIMAL[@]}" >"$FSTAB" ++SYSTEMD_FSTAB="$FSTAB" SYSTEMD_PROC_CMDLINE="rd.fstab=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR" ++SYSTEMD_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_MINIMAL "$OUT_DIR" ++SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" SYSTEMD_PROC_CMDLINE="rd.fstab=0" run_and_list "$GENERATOR_BIN" "$OUT_DIR" ++(! SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB="$FSTAB" check_fstab_mount_units FSTAB_MINIMAL "$OUT_DIR") ++ ++# systemd.swap kernel cmdline arguments is not supported on RHEL 8, see ++# 567a5307601728c618546c584f63307283fa8def ++ ++# Possible TODO ++# - combine the rootfs & usrfs arguments and mix them with fstab entries ++# - systemd.volatile= ++: "fstab-generator: kernel args - root= + rootfstype= + rootflags=" ++# shellcheck disable=SC2034 ++EXPECTED_FSTAB=( ++ "/dev/disk/by-label/rootfs / ext4 noexec,ro 0 1" ++) ++CMDLINE="root=LABEL=rootfs rootfstype=ext4 rootflags=noexec" ++SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB=/dev/null SYSTEMD_PROC_CMDLINE="$CMDLINE" run_and_list "$GENERATOR_BIN" "$OUT_DIR" ++# The /proc/cmdline here is a dummy value to tell the in_initrd_host() function ++# we're parsing host's fstab, but it's all on the kernel cmdline instead ++SYSTEMD_IN_INITRD=1 SYSTEMD_SYSROOT_FSTAB=/proc/cmdline check_fstab_mount_units EXPECTED_FSTAB "$OUT_DIR" ++ ++# This is a very basic sanity test that involves manual checks, since adding it ++# to the check_fstab_mount_units() function would make it way too complex ++# (yet another possible TODO) ++: "fstab-generator: kernel args - mount.usr= + mount.usrfstype= + mount.usrflags=" ++CMDLINE="mount.usr=UUID=be780f43-8803-4a76-9732-02ceda6e9808 mount.usrfstype=ext4 mount.usrflags=noexec,nodev" ++SYSTEMD_IN_INITRD=1 SYSTEMD_FSTAB=/dev/null SYSTEMD_SYSROOT_FSTAB=/dev/null SYSTEMD_PROC_CMDLINE="$CMDLINE" run_and_list "$GENERATOR_BIN" "$OUT_DIR" ++cat "$OUT_DIR/normal/sysroot-usr.mount" ++# We don't do the /sysusr/usr/ -> /sysroot/usr/ dance on RHEL 8, see ++# 29a24ab28e9790680348b1ffab653a321fa49a67 ++grep -qE "^What=/dev/disk/by-uuid/be780f43-8803-4a76-9732-02ceda6e9808$" "$OUT_DIR/normal/sysroot-usr.mount" ++grep -qE "^Where=/sysroot/usr$" "$OUT_DIR/normal/sysroot-usr.mount" ++grep -qE "^Type=ext4$" "$OUT_DIR/normal/sysroot-usr.mount" ++grep -qE "^Options=noexec,nodev,ro$" "$OUT_DIR/normal/sysroot-usr.mount" ++link_eq "$OUT_DIR/normal/initrd-fs.target.requires/sysroot-usr.mount" "../sysroot-usr.mount" +diff --git a/test/TEST-81-GENERATORS/testsuite.sh b/test/TEST-81-GENERATORS/testsuite.sh +new file mode 100755 +index 0000000000..13c767e490 +--- /dev/null ++++ b/test/TEST-81-GENERATORS/testsuite.sh +@@ -0,0 +1,14 @@ ++#!/usr/bin/env bash ++# SPDX-License-Identifier: LGPL-2.1-or-later ++set -eux ++set -o pipefail ++ ++: >/failed ++ ++for script in "${0%.sh}".*.sh; do ++ echo "Running $script" ++ "./$script" ++done ++ ++touch /testok ++rm /failed +diff --git a/test/test-functions b/test/test-functions +index f0cf6f8575..2345ab6e8a 100644 +--- a/test/test-functions ++++ b/test/test-functions +@@ -23,7 +23,7 @@ fi + + PATH_TO_INIT=$ROOTLIBDIR/systemd + +-BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs env mktemp mountpoint useradd userdel timeout jq wc awk diff" ++BASICTOOLS="test sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm true false chmod chown ln xargs env mktemp mountpoint useradd userdel timeout jq wc awk diff dirname readlink" + DEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find" + + STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))" diff --git a/Fix-CVE-2023-7008.patch b/0989-resolved-actually-check-authenticated-flag-of-SOA-tr.patch similarity index 76% rename from Fix-CVE-2023-7008.patch rename to 0989-resolved-actually-check-authenticated-flag-of-SOA-tr.patch index ffe3aae..6a702d4 100644 --- a/Fix-CVE-2023-7008.patch +++ b/0989-resolved-actually-check-authenticated-flag-of-SOA-tr.patch @@ -1,4 +1,4 @@ -From 3b4cc1437b51fcc0b08da8cc3f5d1175eed25eb1 Mon Sep 17 00:00:00 2001 +From c3a86a3ab06713e865db694a80c0c5034ab902af Mon Sep 17 00:00:00 2001 From: Michal Sekletar Date: Wed, 20 Dec 2023 16:44:14 +0100 Subject: [PATCH] resolved: actually check authenticated flag of SOA @@ -6,17 +6,18 @@ Subject: [PATCH] resolved: actually check authenticated flag of SOA Fixes #25676 -Conflict:code context adaptation -Reference:https://github.com/systemd/systemd/commit/3b4cc1437b51fcc0b08da8cc3f5d1175eed25eb1 +(cherry picked from commit 3b4cc1437b51fcc0b08da8cc3f5d1175eed25eb1) + +Resolves: RHEL-6213 --- src/resolve/resolved-dns-transaction.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c -index 262f63c..3a3c078 100644 +index c975215468..6f614d7493 100644 --- a/src/resolve/resolved-dns-transaction.c +++ b/src/resolve/resolved-dns-transaction.c -@@ -2459,7 +2459,7 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord * +@@ -2520,7 +2520,7 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord * if (r == 0) continue; @@ -25,7 +26,7 @@ index 262f63c..3a3c078 100644 } return true; -@@ -2489,7 +2489,7 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord * +@@ -2550,7 +2550,7 @@ static int dns_transaction_requires_rrsig(DnsTransaction *t, DnsResourceRecord * * RR for us. This means we are not at a zone cut. In * this case, we require authentication if the SOA * lookup was authenticated too. */ @@ -34,6 +35,3 @@ index 262f63c..3a3c078 100644 } return true; --- -2.33.0 - diff --git a/0990-fd-util-rework-how-we-determine-highest-possible-fd.patch b/0990-fd-util-rework-how-we-determine-highest-possible-fd.patch new file mode 100644 index 0000000..f976e78 --- /dev/null +++ b/0990-fd-util-rework-how-we-determine-highest-possible-fd.patch @@ -0,0 +1,70 @@ +From 1b547e500207a469a533d819db5b7c6c22516ec3 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Thu, 17 Jan 2019 12:23:21 +0100 +Subject: [PATCH] fd-util: rework how we determine highest possible fd + +(cherry picked from commit 498e265df1c63212ec1a0991c135877a23f1ba4f) + +Related: RHEL-18302 +--- + src/basic/fd-util.c | 37 ++++++++++++++++++++++++++----------- + 1 file changed, 26 insertions(+), 11 deletions(-) + +diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c +index e085dc23b4..fea93d2039 100644 +--- a/src/basic/fd-util.c ++++ b/src/basic/fd-util.c +@@ -188,6 +188,27 @@ _pure_ static bool fd_in_set(int fd, const int fdset[], size_t n_fdset) { + return false; + } + ++static int get_max_fd(void) { ++ struct rlimit rl; ++ rlim_t m; ++ ++ /* Return the highest possible fd, based RLIMIT_NOFILE, but enforcing FD_SETSIZE-1 as lower boundary ++ * and INT_MAX as upper boundary. */ ++ ++ if (getrlimit(RLIMIT_NOFILE, &rl) < 0) ++ return -errno; ++ ++ m = MAX(rl.rlim_cur, rl.rlim_max); ++ if (m < FD_SETSIZE) /* Let's always cover at least 1024 fds */ ++ return FD_SETSIZE-1; ++ ++ if (m == RLIM_INFINITY || m > INT_MAX) /* Saturate on overflow. After all fds are "int", hence can ++ * never be above INT_MAX */ ++ return INT_MAX; ++ ++ return (int) (m - 1); ++} ++ + int close_all_fds(const int except[], size_t n_except) { + _cleanup_closedir_ DIR *d = NULL; + struct dirent *de; +@@ -197,20 +218,14 @@ int close_all_fds(const int except[], size_t n_except) { + + d = opendir("/proc/self/fd"); + if (!d) { +- struct rlimit rl; + int fd, max_fd; + +- /* When /proc isn't available (for example in chroots) the fallback is brute forcing through the fd +- * table */ +- +- assert_se(getrlimit(RLIMIT_NOFILE, &rl) >= 0); +- +- if (rl.rlim_max == 0) +- return -EINVAL; ++ /* When /proc isn't available (for example in chroots) the fallback is brute forcing through ++ * the fd table */ + +- /* Let's take special care if the resource limit is set to unlimited, or actually larger than the range +- * of 'int'. Let's avoid implicit overflows. */ +- max_fd = (rl.rlim_max == RLIM_INFINITY || rl.rlim_max > INT_MAX) ? INT_MAX : (int) (rl.rlim_max - 1); ++ max_fd = get_max_fd(); ++ if (max_fd < 0) ++ return max_fd; + + for (fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -1) { + int q; diff --git a/0991-basic-fd-util-refuse-infinite-loop-in-close_all_fds.patch b/0991-basic-fd-util-refuse-infinite-loop-in-close_all_fds.patch new file mode 100644 index 0000000..e7d679e --- /dev/null +++ b/0991-basic-fd-util-refuse-infinite-loop-in-close_all_fds.patch @@ -0,0 +1,70 @@ +From 957edb063f3e9751bbdc05bd973bb2190ab0e917 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Fri, 15 Mar 2019 15:13:25 +0100 +Subject: [PATCH] basic/fd-util: refuse "infinite" loop in close_all_fds() + +I had a test machine with ulimit -n set to 1073741816 through pam +("session required pam_limits.so set_all", which copies the limits from PID 1, +left over from testing of #10921). + +test-execute would "hang" and then fail with a timeout when running +exec-inaccessiblepaths-proc.service. It turns out that the problem was in +close_all_fds(), which would go to the fallback path of doing close() +1073741813 times. Let's just fail if we hit this case. This only matters +for cases where both /proc is inaccessible, and the *soft* limit has been +raised. + + (gdb) bt + #0 0x00007f7e2e73fdc8 in close () from target:/lib64/libc.so.6 + #1 0x00007f7e2e42cdfd in close_nointr () + from target:/home/zbyszek/src/systemd-work3/build-rawhide/src/shared/libsystemd-shared-241.so + #2 0x00007f7e2e42d525 in close_all_fds () + from target:/home/zbyszek/src/systemd-work3/build-rawhide/src/shared/libsystemd-shared-241.so + #3 0x0000000000426e53 in exec_child () + #4 0x0000000000429578 in exec_spawn () + #5 0x00000000004ce1ab in service_spawn () + #6 0x00000000004cff77 in service_enter_start () + #7 0x00000000004d028f in service_enter_start_pre () + #8 0x00000000004d16f2 in service_start () + #9 0x00000000004568f4 in unit_start () + #10 0x0000000000416987 in test () + #11 0x0000000000417632 in test_exec_inaccessiblepaths () + #12 0x0000000000419362 in run_tests () + #13 0x0000000000419632 in main () + +(cherry picked from commit 6a461d1f59850ff27bd254a3b71fe9ade0523e76) + +Related: RHEL-18302 +--- + src/basic/fd-util.c | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c +index fea93d2039..5d0df11d7e 100644 +--- a/src/basic/fd-util.c ++++ b/src/basic/fd-util.c +@@ -24,6 +24,10 @@ + #include "stdio-util.h" + #include "util.h" + ++/* The maximum number of iterations in the loop to close descriptors in the fallback case ++ * when /proc/self/fd/ is inaccessible. */ ++#define MAX_FD_LOOP_LIMIT (1024*1024) ++ + int close_nointr(int fd) { + assert(fd >= 0); + +@@ -227,6 +231,13 @@ int close_all_fds(const int except[], size_t n_except) { + if (max_fd < 0) + return max_fd; + ++ /* Refuse to do the loop over more too many elements. It's better to fail immediately than to ++ * spin the CPU for a long time. */ ++ if (max_fd > MAX_FD_LOOP_LIMIT) ++ return log_debug_errno(EPERM, ++ "/proc/self/fd is inaccessible. Refusing to loop over %d potential fds.", ++ max_fd); ++ + for (fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -1) { + int q; + diff --git a/0992-fd-util-split-out-inner-fallback-loop-of-close_all_f.patch b/0992-fd-util-split-out-inner-fallback-loop-of-close_all_f.patch new file mode 100644 index 0000000..faa1977 --- /dev/null +++ b/0992-fd-util-split-out-inner-fallback-loop-of-close_all_f.patch @@ -0,0 +1,110 @@ +From c2665abd4cae74f262d9a522b94528841ad141d2 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 12 Oct 2021 15:53:27 +0200 +Subject: [PATCH] fd-util: split out inner fallback loop of close_all_fds() as + close_all_fds_without_malloc() + +(cherry picked from commit 11966552a88039869972ca4b450f622664bd1c5e) + +Related: RHEL-18302 +--- + src/basic/fd-util.c | 63 +++++++++++++++++++++++++-------------------- + src/basic/fd-util.h | 1 + + 2 files changed, 36 insertions(+), 28 deletions(-) + +diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c +index 5d0df11d7e..7e4611dfda 100644 +--- a/src/basic/fd-util.c ++++ b/src/basic/fd-util.c +@@ -213,44 +213,51 @@ static int get_max_fd(void) { + return (int) (m - 1); + } + +-int close_all_fds(const int except[], size_t n_except) { +- _cleanup_closedir_ DIR *d = NULL; +- struct dirent *de; +- int r = 0; ++int close_all_fds_without_malloc(const int except[], size_t n_except) { ++ int max_fd, r = 0; + + assert(n_except == 0 || except); + +- d = opendir("/proc/self/fd"); +- if (!d) { +- int fd, max_fd; ++ /* This is the inner fallback core of close_all_fds(). This never calls malloc() or opendir() or so ++ * and hence is safe to be called in signal handler context. Most users should call close_all_fds(), ++ * but when we assume we are called from signal handler context, then use this simpler call ++ * instead. */ + +- /* When /proc isn't available (for example in chroots) the fallback is brute forcing through +- * the fd table */ ++ max_fd = get_max_fd(); ++ if (max_fd < 0) ++ return max_fd; + +- max_fd = get_max_fd(); +- if (max_fd < 0) +- return max_fd; ++ /* Refuse to do the loop over more too many elements. It's better to fail immediately than to ++ * spin the CPU for a long time. */ ++ if (max_fd > MAX_FD_LOOP_LIMIT) ++ return log_debug_errno(EPERM, ++ "Refusing to loop over %d potential fds.", ++ max_fd); + +- /* Refuse to do the loop over more too many elements. It's better to fail immediately than to +- * spin the CPU for a long time. */ +- if (max_fd > MAX_FD_LOOP_LIMIT) +- return log_debug_errno(EPERM, +- "/proc/self/fd is inaccessible. Refusing to loop over %d potential fds.", +- max_fd); ++ for (int fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -1) { ++ int q; + +- for (fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -1) { +- int q; ++ if (fd_in_set(fd, except, n_except)) ++ continue; + +- if (fd_in_set(fd, except, n_except)) +- continue; ++ q = close_nointr(fd); ++ if (q < 0 && q != -EBADF && r >= 0) ++ r = q; ++ } + +- q = close_nointr(fd); +- if (q < 0 && q != -EBADF && r >= 0) +- r = q; +- } ++ return r; ++} + +- return r; +- } ++int close_all_fds(const int except[], size_t n_except) { ++ _cleanup_closedir_ DIR *d = NULL; ++ struct dirent *de; ++ int r = 0; ++ ++ assert(n_except == 0 || except); ++ ++ d = opendir("/proc/self/fd"); ++ if (!d) ++ return close_all_fds_without_malloc(except, n_except); /* ultimate fallback if /proc/ is not available */ + + FOREACH_DIRENT(de, d, return -errno) { + int fd = -1, q; +diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h +index 8adc959da8..b2837d3588 100644 +--- a/src/basic/fd-util.h ++++ b/src/basic/fd-util.h +@@ -54,6 +54,7 @@ int fd_nonblock(int fd, bool nonblock); + int fd_cloexec(int fd, bool cloexec); + + int close_all_fds(const int except[], size_t n_except); ++int close_all_fds_without_malloc(const int except[], size_t n_except); + + int same_fd(int a, int b); + diff --git a/0993-exec-util-use-close_all_fds_without_malloc-from-free.patch b/0993-exec-util-use-close_all_fds_without_malloc-from-free.patch new file mode 100644 index 0000000..f82bbdb --- /dev/null +++ b/0993-exec-util-use-close_all_fds_without_malloc-from-free.patch @@ -0,0 +1,29 @@ +From 140e598dcf6b86007b1daba42c31253521964b2e Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Thu, 29 Jul 2021 16:50:44 +0200 +Subject: [PATCH] exec-util: use close_all_fds_without_malloc() from freeze() + +(cherry picked from commit ab27b2fe56c6c4bd0295b248448adb1c698e9284) + +Resolves: RHEL-18302 +--- + src/basic/process-util.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/basic/process-util.c b/src/basic/process-util.c +index 6016d83d41..9e2237375d 100644 +--- a/src/basic/process-util.c ++++ b/src/basic/process-util.c +@@ -991,8 +991,10 @@ _noreturn_ void freeze(void) { + + log_close(); + +- /* Make sure nobody waits for us on a socket anymore */ +- close_all_fds(NULL, 0); ++ /* Make sure nobody waits for us (i.e. on one of our sockets) anymore. Note that we use ++ * close_all_fds_without_malloc() instead of plain close_all_fds() here, since we want this function ++ * to be compatible with being called from signal handlers. */ ++ (void) close_all_fds_without_malloc(NULL, 0); + + sync(); + diff --git a/0994-ci-use-source-git-automation-composite-Action.patch b/0994-ci-use-source-git-automation-composite-Action.patch new file mode 100644 index 0000000..1ca70f2 --- /dev/null +++ b/0994-ci-use-source-git-automation-composite-Action.patch @@ -0,0 +1,185 @@ +From 5d0fc67965b48e05c28d0993368a3982efd03b4b Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Fri, 12 Jan 2024 16:01:43 +0100 +Subject: [PATCH] ci: use source-git-automation composite Action + +This will allow us maintain the source-git automation in separate repo +and reduce the duplication of the code and noise in the systemd repo. + +rhel-only + +Related: RHEL-1087 +--- + .../source-git-automation-on-demand.yml | 55 ++------------ + .github/workflows/source-git-automation.yml | 72 ++----------------- + 2 files changed, 9 insertions(+), 118 deletions(-) + +diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml +index 948708916d..0c72f9f210 100644 +--- a/.github/workflows/source-git-automation-on-demand.yml ++++ b/.github/workflows/source-git-automation-on-demand.yml +@@ -1,5 +1,3 @@ +---- +- + name: Source git Automation Scheduled/On Demand + on: + schedule: +@@ -59,61 +57,16 @@ jobs: + pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }} + + permissions: ++ # required for merging PRs + contents: write +- statuses: write +- checks: write ++ # required for PR comments and setting labels + pull-requests: write + + steps: +- - name: Repository checkout +- uses: actions/checkout@v3 +- +- - id: metadata +- name: Gather Pull Request Metadata +- uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1 ++ - name: Source-git Automation ++ uses: redhat-plumbers-in-action/source-git-automation@v1 + with: + pr-number: ${{ matrix.pr-number }} +- +- - if: ${{ !cancelled() }} +- id: commit-linter +- name: Lint Commits +- uses: redhat-plumbers-in-action/advanced-commit-linter@v2 +- with: +- pr-metadata: ${{ steps.metadata.outputs.metadata }} +- token: ${{ secrets.GITHUB_TOKEN }} +- +- # Validates tracker, changes tracker status, updates PR title +- - if: ${{ !cancelled() }} +- id: tracker-validator +- name: Validate Tracker +- uses: redhat-plumbers-in-action/tracker-validator@v1 +- with: +- pr-metadata: ${{ steps.metadata.outputs.metadata }} +- component: systemd +- tracker: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }} +- tracker-type: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }} +- bugzilla-instance: https://bugzilla.redhat.com +- bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }} +- jira-instance: https://issues.redhat.com +- jira-api-token: ${{ secrets.JIRA_API_TOKEN }} +- token: ${{ secrets.GITHUB_TOKEN }} +- +- - if: ${{ !cancelled() }} +- name: Pull Request Validator +- uses: redhat-plumbers-in-action/pull-request-validator@v1 +- with: +- pr-metadata: ${{ steps.metadata.outputs.metadata }} +- token: ${{ secrets.GITHUB_TOKEN }} +- +- - id: auto-merge +- name: Auto Merge +- uses: redhat-plumbers-in-action/auto-merge@v1 +- with: +- pr-metadata: ${{ steps.metadata.outputs.metadata }} +- tracker: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }} +- tracker-type: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }} +- bugzilla-instance: https://bugzilla.redhat.com + bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }} +- jira-instance: https://issues.redhat.com + jira-api-token: ${{ secrets.JIRA_API_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} +diff --git a/.github/workflows/source-git-automation.yml b/.github/workflows/source-git-automation.yml +index 95819baa8b..b6cefa67b1 100644 +--- a/.github/workflows/source-git-automation.yml ++++ b/.github/workflows/source-git-automation.yml +@@ -26,83 +26,21 @@ jobs: + with: + name: pr-metadata + +- commit-linter: ++ source-git-automation: + needs: [ download-metadata ] + runs-on: ubuntu-latest + +- outputs: +- validated-pr-metadata: ${{ steps.commit-linter.outputs.validated-pr-metadata }} +- +- permissions: +- statuses: write +- checks: write +- pull-requests: write +- +- steps: +- - id: commit-linter +- name: Lint Commits +- uses: redhat-plumbers-in-action/advanced-commit-linter@v2 +- with: +- pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }} +- token: ${{ secrets.GITHUB_TOKEN }} +- +- # Validates tracker, changes tracker status, updates PR title +- tracker-validator: +- if: ${{ !cancelled() }} +- needs: [ download-metadata, commit-linter ] +- runs-on: ubuntu-latest +- +- permissions: +- checks: write +- pull-requests: write +- +- steps: +- - name: Validate Tracker +- uses: redhat-plumbers-in-action/tracker-validator@v1 +- with: +- pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }} +- component: systemd +- tracker: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }} +- tracker-type: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }} +- bugzilla-instance: https://bugzilla.redhat.com +- bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }} +- jira-instance: https://issues.redhat.com +- jira-api-token: ${{ secrets.JIRA_API_TOKEN }} +- token: ${{ secrets.GITHUB_TOKEN }} +- +- pull-request-validator: +- needs: [ download-metadata ] +- runs-on: ubuntu-latest +- +- permissions: +- checks: write +- pull-requests: write +- +- steps: +- - name: Pull Request Validator +- uses: redhat-plumbers-in-action/pull-request-validator@v1 +- with: +- pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }} +- token: ${{ secrets.GITHUB_TOKEN }} +- +- auto-merge: +- needs: [ download-metadata, commit-linter, tracker-validator, pull-request-validator ] +- runs-on: ubuntu-latest +- + permissions: ++ # required for merging PRs + contents: write +- checks: write ++ # required for PR comments and setting labels + pull-requests: write + + steps: +- - name: Auto Merge +- uses: redhat-plumbers-in-action/auto-merge@v1 ++ - name: Source-git Automation ++ uses: redhat-plumbers-in-action/source-git-automation@v1 + with: + pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }} +- tracker: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }} +- tracker-type: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }} +- bugzilla-instance: https://bugzilla.redhat.com + bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }} +- jira-instance: https://issues.redhat.com + jira-api-token: ${{ secrets.JIRA_API_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} diff --git a/0995-ci-increase-the-cron-interval-to-45-minutes.patch b/0995-ci-increase-the-cron-interval-to-45-minutes.patch new file mode 100644 index 0000000..439ff3e --- /dev/null +++ b/0995-ci-increase-the-cron-interval-to-45-minutes.patch @@ -0,0 +1,29 @@ +From fd21fb2e2e3bbbd937d120197b11c740d608fb19 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Fri, 12 Jan 2024 16:03:09 +0100 +Subject: [PATCH] ci: increase the cron interval to 45 minutes + +This should help us to avoid hitting the rate limit on the GitHub API. + +rhel-only + +Related: RHEL-1087 +--- + .github/workflows/source-git-automation-on-demand.yml | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/.github/workflows/source-git-automation-on-demand.yml b/.github/workflows/source-git-automation-on-demand.yml +index 0c72f9f210..6aeee51e6d 100644 +--- a/.github/workflows/source-git-automation-on-demand.yml ++++ b/.github/workflows/source-git-automation-on-demand.yml +@@ -1,8 +1,8 @@ + name: Source git Automation Scheduled/On Demand + on: + schedule: +- # Workflow runs every 15 minutes +- - cron: '*/15 * * * *' ++ # Workflow runs every 45 minutes ++ - cron: '*/45 * * * *' + workflow_dispatch: + inputs: + pr-number: diff --git a/0996-ci-add-all-Z-Stream-versions-to-array-of-allowed-ver.patch b/0996-ci-add-all-Z-Stream-versions-to-array-of-allowed-ver.patch new file mode 100644 index 0000000..673fc84 --- /dev/null +++ b/0996-ci-add-all-Z-Stream-versions-to-array-of-allowed-ver.patch @@ -0,0 +1,31 @@ +From 42e3739198e41c65b986f69a53bc6c93f7e112be Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Fri, 12 Jan 2024 16:04:22 +0100 +Subject: [PATCH] ci: add all Z-Stream versions to array of allowed versions + +rhel-only + +Related: RHEL-1087 +--- + .github/tracker-validator.yml | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/.github/tracker-validator.yml b/.github/tracker-validator.yml +index 500dce3d92..b09f702dd9 100644 +--- a/.github/tracker-validator.yml ++++ b/.github/tracker-validator.yml +@@ -7,8 +7,14 @@ products: + - Red Hat Enterprise Linux 8 + - CentOS Stream 8 + - rhel-8.2.0 ++ - rhel-8.2.0.z + - rhel-8.4.0 ++ - rhel-8.4.0.z + - rhel-8.6.0 ++ - rhel-8.6.0.z + - rhel-8.8.0 ++ - rhel-8.8.0.z + - rhel-8.9.0 ++ - rhel-8.9.0.z + - rhel-8.10.0 ++ - rhel-8.10.0.z diff --git a/0997-tree-wide-always-declare-bitflag-enums-the-same-way.patch b/0997-tree-wide-always-declare-bitflag-enums-the-same-way.patch new file mode 100644 index 0000000..774b0fe --- /dev/null +++ b/0997-tree-wide-always-declare-bitflag-enums-the-same-way.patch @@ -0,0 +1,215 @@ +From dd3c13f364e03e843d838bf925a5fc85513343ed Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 7 Jan 2019 17:48:28 +0100 +Subject: [PATCH] tree-wide: always declare bitflag enums the same way + +let's always use the 1 << x syntax. No change of behaviour or even of +the compiled binary. + +(cherry picked from commit be0b7a1a66fd269b644124c4633088ab2224d1fb) + +Resolves: RHEL-2857 +--- + src/basic/btrfs-util.h | 16 ++++++++-------- + src/basic/cgroup-util.h | 6 +++--- + src/basic/extract-word.h | 12 ++++++------ + src/basic/unit-name.h | 10 +++++----- + src/libsystemd/sd-bus/bus-dump.h | 4 ++-- + src/libsystemd/sd-bus/bus-protocol.h | 12 ++++++------ + src/login/logind-inhibit.h | 18 +++++++++--------- + src/resolve/resolved-dns-answer.h | 10 +++++----- + 8 files changed, 44 insertions(+), 44 deletions(-) + +diff --git a/src/basic/btrfs-util.h b/src/basic/btrfs-util.h +index a594387b5a..967627991f 100644 +--- a/src/basic/btrfs-util.h ++++ b/src/basic/btrfs-util.h +@@ -27,17 +27,17 @@ typedef struct BtrfsQuotaInfo { + } BtrfsQuotaInfo; + + typedef enum BtrfsSnapshotFlags { +- BTRFS_SNAPSHOT_FALLBACK_COPY = 1, /* If the source isn't a subvolume, reflink everything */ +- BTRFS_SNAPSHOT_READ_ONLY = 2, +- BTRFS_SNAPSHOT_RECURSIVE = 4, +- BTRFS_SNAPSHOT_QUOTA = 8, +- BTRFS_SNAPSHOT_FALLBACK_DIRECTORY = 16, /* If the destination doesn't support subvolumes, reflink/copy instead */ +- BTRFS_SNAPSHOT_FALLBACK_IMMUTABLE = 32, /* When we can't create a subvolume, use the FS_IMMUTABLE attribute for indicating read-only */ ++ BTRFS_SNAPSHOT_FALLBACK_COPY = 1 << 0, /* If the source isn't a subvolume, reflink everything */ ++ BTRFS_SNAPSHOT_READ_ONLY = 1 << 1, ++ BTRFS_SNAPSHOT_RECURSIVE = 1 << 2, ++ BTRFS_SNAPSHOT_QUOTA = 1 << 3, ++ BTRFS_SNAPSHOT_FALLBACK_DIRECTORY = 1 << 4, /* If the destination doesn't support subvolumes, reflink/copy instead */ ++ BTRFS_SNAPSHOT_FALLBACK_IMMUTABLE = 1 << 5, /* When we can't create a subvolume, use the FS_IMMUTABLE attribute for indicating read-only */ + } BtrfsSnapshotFlags; + + typedef enum BtrfsRemoveFlags { +- BTRFS_REMOVE_RECURSIVE = 1, +- BTRFS_REMOVE_QUOTA = 2, ++ BTRFS_REMOVE_RECURSIVE = 1 << 0, ++ BTRFS_REMOVE_QUOTA = 1 << 1, + } BtrfsRemoveFlags; + + int btrfs_is_filesystem(int fd); +diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h +index 1210b38a83..65d2dbd4b6 100644 +--- a/src/basic/cgroup-util.h ++++ b/src/basic/cgroup-util.h +@@ -136,9 +136,9 @@ int cg_enumerate_subgroups(const char *controller, const char *path, DIR **_d); + int cg_read_subgroup(DIR *d, char **fn); + + typedef enum CGroupFlags { +- CGROUP_SIGCONT = 1, +- CGROUP_IGNORE_SELF = 2, +- CGROUP_REMOVE = 4, ++ CGROUP_SIGCONT = 1 << 0, ++ CGROUP_IGNORE_SELF = 1 << 1, ++ CGROUP_REMOVE = 1 << 2, + } CGroupFlags; + + typedef void (*cg_kill_log_func_t)(pid_t pid, int sig, void *userdata); +diff --git a/src/basic/extract-word.h b/src/basic/extract-word.h +index 8c63b7c306..705ebbe95b 100644 +--- a/src/basic/extract-word.h ++++ b/src/basic/extract-word.h +@@ -4,12 +4,12 @@ + #include "macro.h" + + typedef enum ExtractFlags { +- EXTRACT_RELAX = 1, +- EXTRACT_CUNESCAPE = 2, +- EXTRACT_CUNESCAPE_RELAX = 4, +- EXTRACT_QUOTES = 8, +- EXTRACT_DONT_COALESCE_SEPARATORS = 16, +- EXTRACT_RETAIN_ESCAPE = 32, ++ EXTRACT_RELAX = 1 << 0, ++ EXTRACT_CUNESCAPE = 1 << 1, ++ EXTRACT_CUNESCAPE_RELAX = 1 << 2, ++ EXTRACT_QUOTES = 1 << 3, ++ EXTRACT_DONT_COALESCE_SEPARATORS = 1 << 4, ++ EXTRACT_RETAIN_ESCAPE = 1 << 5, + } ExtractFlags; + + int extract_first_word(const char **p, char **ret, const char *separators, ExtractFlags flags); +diff --git a/src/basic/unit-name.h b/src/basic/unit-name.h +index 602295af8f..7df532bbc8 100644 +--- a/src/basic/unit-name.h ++++ b/src/basic/unit-name.h +@@ -9,9 +9,9 @@ + #define UNIT_NAME_MAX 256 + + typedef enum UnitNameFlags { +- UNIT_NAME_PLAIN = 1, /* Allow foo.service */ +- UNIT_NAME_INSTANCE = 2, /* Allow foo@bar.service */ +- UNIT_NAME_TEMPLATE = 4, /* Allow foo@.service */ ++ UNIT_NAME_PLAIN = 1 << 0, /* Allow foo.service */ ++ UNIT_NAME_INSTANCE = 1 << 1, /* Allow foo@bar.service */ ++ UNIT_NAME_TEMPLATE = 1 << 2, /* Allow foo@.service */ + UNIT_NAME_ANY = UNIT_NAME_PLAIN|UNIT_NAME_INSTANCE|UNIT_NAME_TEMPLATE, + } UnitNameFlags; + +@@ -53,8 +53,8 @@ int unit_name_from_path_instance(const char *prefix, const char *path, const cha + int unit_name_to_path(const char *name, char **ret); + + typedef enum UnitNameMangle { +- UNIT_NAME_MANGLE_GLOB = 1, +- UNIT_NAME_MANGLE_WARN = 2, ++ UNIT_NAME_MANGLE_GLOB = 1 << 0, ++ UNIT_NAME_MANGLE_WARN = 1 << 1, + } UnitNameMangle; + + int unit_name_mangle_with_suffix(const char *name, UnitNameMangle flags, const char *suffix, char **ret); +diff --git a/src/libsystemd/sd-bus/bus-dump.h b/src/libsystemd/sd-bus/bus-dump.h +index 8e47411a45..7c1f81edec 100644 +--- a/src/libsystemd/sd-bus/bus-dump.h ++++ b/src/libsystemd/sd-bus/bus-dump.h +@@ -10,8 +10,8 @@ + #include "sd-bus.h" + + enum { +- BUS_MESSAGE_DUMP_WITH_HEADER = 1, +- BUS_MESSAGE_DUMP_SUBTREE_ONLY = 2, ++ BUS_MESSAGE_DUMP_WITH_HEADER = 1 << 0, ++ BUS_MESSAGE_DUMP_SUBTREE_ONLY = 1 << 1, + }; + + int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags); +diff --git a/src/libsystemd/sd-bus/bus-protocol.h b/src/libsystemd/sd-bus/bus-protocol.h +index 20d19d4022..f96d4b39aa 100644 +--- a/src/libsystemd/sd-bus/bus-protocol.h ++++ b/src/libsystemd/sd-bus/bus-protocol.h +@@ -57,9 +57,9 @@ enum { + /* Flags */ + + enum { +- BUS_MESSAGE_NO_REPLY_EXPECTED = 1, +- BUS_MESSAGE_NO_AUTO_START = 2, +- BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION = 4, ++ BUS_MESSAGE_NO_REPLY_EXPECTED = 1 << 0, ++ BUS_MESSAGE_NO_AUTO_START = 1 << 1, ++ BUS_MESSAGE_ALLOW_INTERACTIVE_AUTHORIZATION = 1 << 2, + }; + + /* Header fields */ +@@ -81,9 +81,9 @@ enum { + /* RequestName parameters */ + + enum { +- BUS_NAME_ALLOW_REPLACEMENT = 1, +- BUS_NAME_REPLACE_EXISTING = 2, +- BUS_NAME_DO_NOT_QUEUE = 4 ++ BUS_NAME_ALLOW_REPLACEMENT = 1 << 0, ++ BUS_NAME_REPLACE_EXISTING = 1 << 1, ++ BUS_NAME_DO_NOT_QUEUE = 1 << 2, + }; + + /* RequestName returns */ +diff --git a/src/login/logind-inhibit.h b/src/login/logind-inhibit.h +index d358a48559..650587106d 100644 +--- a/src/login/logind-inhibit.h ++++ b/src/login/logind-inhibit.h +@@ -4,15 +4,15 @@ + typedef struct Inhibitor Inhibitor; + + typedef enum InhibitWhat { +- INHIBIT_SHUTDOWN = 1, +- INHIBIT_SLEEP = 2, +- INHIBIT_IDLE = 4, +- INHIBIT_HANDLE_POWER_KEY = 8, +- INHIBIT_HANDLE_SUSPEND_KEY = 16, +- INHIBIT_HANDLE_HIBERNATE_KEY = 32, +- INHIBIT_HANDLE_LID_SWITCH = 64, +- _INHIBIT_WHAT_MAX = 128, +- _INHIBIT_WHAT_INVALID = -1 ++ INHIBIT_SHUTDOWN = 1 << 0, ++ INHIBIT_SLEEP = 1 << 1, ++ INHIBIT_IDLE = 1 << 2, ++ INHIBIT_HANDLE_POWER_KEY = 1 << 3, ++ INHIBIT_HANDLE_SUSPEND_KEY = 1 << 4, ++ INHIBIT_HANDLE_HIBERNATE_KEY = 1 << 5, ++ INHIBIT_HANDLE_LID_SWITCH = 1 << 6, ++ _INHIBIT_WHAT_MAX = 1 << 7, ++ _INHIBIT_WHAT_INVALID = -1 + } InhibitWhat; + + typedef enum InhibitMode { +diff --git a/src/resolve/resolved-dns-answer.h b/src/resolve/resolved-dns-answer.h +index aff594a00e..cc90a82529 100644 +--- a/src/resolve/resolved-dns-answer.h ++++ b/src/resolve/resolved-dns-answer.h +@@ -15,11 +15,11 @@ typedef struct DnsAnswerItem DnsAnswerItem; + * Note that we usually encode the empty DnsAnswer object as a simple NULL. */ + + typedef enum DnsAnswerFlags { +- DNS_ANSWER_AUTHENTICATED = 1, /* Item has been authenticated */ +- DNS_ANSWER_CACHEABLE = 2, /* Item is subject to caching */ +- DNS_ANSWER_SHARED_OWNER = 4, /* For mDNS: RRset may be owner by multiple peers */ +- DNS_ANSWER_CACHE_FLUSH = 8, /* For mDNS: sets cache-flush bit in the rrclass of response records */ +- DNS_ANSWER_GOODBYE = 16, /* For mDNS: item is subject to disappear */ ++ DNS_ANSWER_AUTHENTICATED = 1 << 0, /* Item has been authenticated */ ++ DNS_ANSWER_CACHEABLE = 1 << 1, /* Item is subject to caching */ ++ DNS_ANSWER_SHARED_OWNER = 1 << 2, /* For mDNS: RRset may be owner by multiple peers */ ++ DNS_ANSWER_CACHE_FLUSH = 1 << 3, /* For mDNS: sets cache-flush bit in the rrclass of response records */ ++ DNS_ANSWER_GOODBYE = 1 << 4, /* For mDNS: item is subject to disappear */ + } DnsAnswerFlags; + + struct DnsAnswerItem { diff --git a/0998-login-Add-KEY_RESTART-handling.patch b/0998-login-Add-KEY_RESTART-handling.patch new file mode 100644 index 0000000..46ac8b3 --- /dev/null +++ b/0998-login-Add-KEY_RESTART-handling.patch @@ -0,0 +1,343 @@ +From d3072cec8cec84c6cb6e5771a5084e64f78c7e80 Mon Sep 17 00:00:00 2001 +From: Robert Marko +Date: Fri, 14 Aug 2020 13:10:18 +0200 +Subject: [PATCH] login: Add KEY_RESTART handling + +KEY_RESTART is widely used in Linux to indicate device reboot. +So lets handle it in the same fashion as KEY_POWER. + +Signed-off-by: Robert Marko +(cherry picked from commit adbb2b6afed7858f64f5b940579f6efe79eee997) + +Resolves: RHEL-2857 +--- + man/logind.conf.xml | 26 +++++++++++++++---------- + src/login/logind-button.c | 25 +++++++++++++++++++----- + src/login/logind-core.c | 4 ++++ + src/login/logind-dbus.c | 1 + + src/login/logind-gperf.gperf | 2 ++ + src/login/logind-inhibit.c | 14 ++++++++++++- + src/login/logind-inhibit.h | 3 ++- + src/login/logind.conf.in | 2 ++ + src/login/logind.h | 2 ++ + src/login/org.freedesktop.login1.policy | 11 +++++++++++ + src/systemd/sd-messages.h | 2 ++ + 11 files changed, 75 insertions(+), 17 deletions(-) + +diff --git a/man/logind.conf.xml b/man/logind.conf.xml +index 00b5b1f2e8..56981c1837 100644 +--- a/man/logind.conf.xml ++++ b/man/logind.conf.xml +@@ -202,10 +202,11 @@ + HandleLidSwitch= + HandleLidSwitchExternalPower= + HandleLidSwitchDocked= ++ HandleRebootKey= + + Controls how logind shall handle the +- system power and sleep keys and the lid switch to trigger +- actions such as system power-off or suspend. Can be one of ++ system power, reboot and sleep keys and the lid switch to trigger ++ actions such as system power-off, reboot or suspend. Can be one of + ignore, + poweroff, + reboot, +@@ -222,7 +223,8 @@ + in the respective event. Only input devices with the + power-switch udev tag will be watched for + key/lid switch events. HandlePowerKey= +- defaults to poweroff. ++ defaults to poweroff, HandleRebootKey= ++ defaults to reboot. + HandleSuspendKey= and + HandleLidSwitch= default to + suspend. +@@ -243,7 +245,8 @@ + A different application may disable logind's handling of system power and + sleep keys and the lid switch by taking a low-level inhibitor lock + (handle-power-key, handle-suspend-key, +- handle-hibernate-key, handle-lid-switch). ++ handle-hibernate-key, handle-lid-switch, ++ handle-reboot-switch). + This is most commonly used by graphical desktop environments + to take over suspend and hibernation handling, and to use their own configuration + mechanisms. If a low-level inhibitor lock is taken, logind will not take any +@@ -256,20 +259,23 @@ + SuspendKeyIgnoreInhibited= + HibernateKeyIgnoreInhibited= + LidSwitchIgnoreInhibited= ++ RebootKeyIgnoreInhibited= + + Controls whether actions that systemd-logind +- takes when the power and sleep keys and the lid switch are triggered are subject +- to high-level inhibitor locks ("shutdown", "sleep", "idle"). Low level inhibitor ++ takes when the power, reboot and sleep keys and the lid switch are triggered are subject ++ to high-level inhibitor locks ("shutdown", "reboot", "sleep", "idle"). Low level inhibitor + locks (handle-power-key, handle-suspend-key, +- handle-hibernate-key, handle-lid-switch), ++ handle-hibernate-key, handle-lid-switch, ++ handle-reboot-key), + are always honored, irrespective of this setting. + + These settings take boolean arguments. If no, the + inhibitor locks taken by applications are respected. If yes, +- "shutdown", "sleep", and "idle" inhibitor locks are ignored. ++ "shutdown", "reboot" "sleep", and "idle" inhibitor locks are ignored. + PowerKeyIgnoreInhibited=, +- SuspendKeyIgnoreInhibited=, and +- HibernateKeyIgnoreInhibited= default to no. ++ SuspendKeyIgnoreInhibited=, ++ HibernateKeyIgnoreInhibited= and ++ RebootKeyIgnoreInhibited= default to no. + LidSwitchIgnoreInhibited= defaults to yes. + This means that when systemd-logind is handling events by + itself (no low level inhibitor locks are taken by another application), the lid +diff --git a/src/login/logind-button.c b/src/login/logind-button.c +index 9944eb2316..48fc004198 100644 +--- a/src/login/logind-button.c ++++ b/src/login/logind-button.c +@@ -15,7 +15,7 @@ + #include "string-util.h" + #include "util.h" + +-#define CONST_MAX4(a, b, c, d) CONST_MAX(CONST_MAX(a, b), CONST_MAX(c, d)) ++#define CONST_MAX5(a, b, c, d, e) CONST_MAX(CONST_MAX(a, b), CONST_MAX(CONST_MAX(c, d), e)) + + #define ULONG_BITS (sizeof(unsigned long)*8) + +@@ -159,7 +159,20 @@ static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *u + manager_handle_action(b->manager, INHIBIT_HANDLE_POWER_KEY, b->manager->handle_power_key, b->manager->power_key_ignore_inhibited, true); + break; + +- /* The kernel is a bit confused here: ++ /* The kernel naming is a bit confusing here: ++ KEY_RESTART was probably introduced for media playback purposes, but ++ is now being predominantly used to indicate device reboot. ++ */ ++ ++ case KEY_RESTART: ++ log_struct(LOG_INFO, ++ LOG_MESSAGE("Reboot key pressed."), ++ "MESSAGE_ID=" SD_MESSAGE_REBOOT_KEY_STR); ++ ++ manager_handle_action(b->manager, INHIBIT_HANDLE_REBOOT_KEY, b->manager->handle_reboot_key, b->manager->reboot_key_ignore_inhibited, true); ++ break; ++ ++ /* The kernel naming is a bit confusing here: + + KEY_SLEEP = suspend-to-ram, which everybody else calls "suspend" + KEY_SUSPEND = suspend-to-disk, which everybody else calls "hibernate" +@@ -233,7 +246,7 @@ static int button_suitable(Button *b) { + return -errno; + + if (bitset_get(types, EV_KEY)) { +- unsigned long keys[CONST_MAX4(KEY_POWER, KEY_POWER2, KEY_SLEEP, KEY_SUSPEND)/ULONG_BITS+1]; ++ unsigned long keys[CONST_MAX5(KEY_POWER, KEY_POWER2, KEY_SLEEP, KEY_SUSPEND, KEY_RESTART)/ULONG_BITS+1]; + + if (ioctl(b->fd, EVIOCGBIT(EV_KEY, sizeof(keys)), keys) < 0) + return -errno; +@@ -241,7 +254,8 @@ static int button_suitable(Button *b) { + if (bitset_get(keys, KEY_POWER) || + bitset_get(keys, KEY_POWER2) || + bitset_get(keys, KEY_SLEEP) || +- bitset_get(keys, KEY_SUSPEND)) ++ bitset_get(keys, KEY_SUSPEND) || ++ bitset_get(keys, KEY_RESTART)) + return true; + } + +@@ -262,7 +276,7 @@ static int button_suitable(Button *b) { + static int button_set_mask(Button *b) { + unsigned long + types[CONST_MAX(EV_KEY, EV_SW)/ULONG_BITS+1] = {}, +- keys[CONST_MAX4(KEY_POWER, KEY_POWER2, KEY_SLEEP, KEY_SUSPEND)/ULONG_BITS+1] = {}, ++ keys[CONST_MAX5(KEY_POWER, KEY_POWER2, KEY_SLEEP, KEY_SUSPEND, KEY_RESTART)/ULONG_BITS+1] = {}, + switches[CONST_MAX(SW_LID, SW_DOCK)/ULONG_BITS+1] = {}; + struct input_mask mask; + +@@ -287,6 +301,7 @@ static int button_set_mask(Button *b) { + bitset_put(keys, KEY_POWER2); + bitset_put(keys, KEY_SLEEP); + bitset_put(keys, KEY_SUSPEND); ++ bitset_put(keys, KEY_RESTART); + + mask = (struct input_mask) { + .type = EV_KEY, +diff --git a/src/login/logind-core.c b/src/login/logind-core.c +index abe6eecffb..81ec4f2653 100644 +--- a/src/login/logind-core.c ++++ b/src/login/logind-core.c +@@ -39,10 +39,12 @@ void manager_reset_config(Manager *m) { + m->handle_lid_switch = HANDLE_SUSPEND; + m->handle_lid_switch_ep = _HANDLE_ACTION_INVALID; + m->handle_lid_switch_docked = HANDLE_IGNORE; ++ m->handle_reboot_key = HANDLE_REBOOT; + m->power_key_ignore_inhibited = false; + m->suspend_key_ignore_inhibited = false; + m->hibernate_key_ignore_inhibited = false; + m->lid_switch_ignore_inhibited = true; ++ m->reboot_key_ignore_inhibited = false; + + m->holdoff_timeout_usec = 30 * USEC_PER_SEC; + +@@ -698,6 +700,8 @@ bool manager_all_buttons_ignored(Manager *m) { + return false; + if (m->handle_lid_switch_docked != HANDLE_IGNORE) + return false; ++ if (m->handle_reboot_key != HANDLE_IGNORE) ++ return false; + + return true; + } +diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c +index dbac406035..61fd47999d 100644 +--- a/src/login/logind-dbus.c ++++ b/src/login/logind-dbus.c +@@ -2616,6 +2616,7 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error + w == INHIBIT_IDLE ? "org.freedesktop.login1.inhibit-block-idle" : + w == INHIBIT_HANDLE_POWER_KEY ? "org.freedesktop.login1.inhibit-handle-power-key" : + w == INHIBIT_HANDLE_SUSPEND_KEY ? "org.freedesktop.login1.inhibit-handle-suspend-key" : ++ w == INHIBIT_HANDLE_REBOOT_KEY ? "org.freedesktop.login1.inhibit-handle-reboot-key" : + w == INHIBIT_HANDLE_HIBERNATE_KEY ? "org.freedesktop.login1.inhibit-handle-hibernate-key" : + "org.freedesktop.login1.inhibit-handle-lid-switch", + NULL, +diff --git a/src/login/logind-gperf.gperf b/src/login/logind-gperf.gperf +index 214ac5c4a3..c49703698a 100644 +--- a/src/login/logind-gperf.gperf ++++ b/src/login/logind-gperf.gperf +@@ -30,10 +30,12 @@ Login.HandleHibernateKey, config_parse_handle_action, 0, offse + Login.HandleLidSwitch, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch) + Login.HandleLidSwitchExternalPower, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch_ep) + Login.HandleLidSwitchDocked, config_parse_handle_action, 0, offsetof(Manager, handle_lid_switch_docked) ++Login.HandleRebootKey, config_parse_handle_action, 0, offsetof(Manager, handle_reboot_key) + Login.PowerKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, power_key_ignore_inhibited) + Login.SuspendKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, suspend_key_ignore_inhibited) + Login.HibernateKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, hibernate_key_ignore_inhibited) + Login.LidSwitchIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, lid_switch_ignore_inhibited) ++Login.RebootKeyIgnoreInhibited, config_parse_bool, 0, offsetof(Manager, reboot_key_ignore_inhibited) + Login.HoldoffTimeoutSec, config_parse_sec, 0, offsetof(Manager, holdoff_timeout_usec) + Login.IdleAction, config_parse_handle_action, 0, offsetof(Manager, idle_action) + Login.IdleActionSec, config_parse_sec, 0, offsetof(Manager, idle_action_usec) +diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c +index b1f45baaca..27b862e7c4 100644 +--- a/src/login/logind-inhibit.c ++++ b/src/login/logind-inhibit.c +@@ -405,7 +405,15 @@ bool manager_is_inhibited( + } + + const char *inhibit_what_to_string(InhibitWhat w) { +- static thread_local char buffer[97]; ++ static thread_local char buffer[STRLEN( ++ "shutdown:" ++ "sleep:" ++ "idle:" ++ "handle-power-key:" ++ "handle-suspend-key:" ++ "handle-hibernate-key:" ++ "handle-lid-switch:" ++ "handle-reboot-key")+1]; + char *p; + + if (w < 0 || w >= _INHIBIT_WHAT_MAX) +@@ -426,6 +434,8 @@ const char *inhibit_what_to_string(InhibitWhat w) { + p = stpcpy(p, "handle-hibernate-key:"); + if (w & INHIBIT_HANDLE_LID_SWITCH) + p = stpcpy(p, "handle-lid-switch:"); ++ if (w & INHIBIT_HANDLE_REBOOT_KEY) ++ p = stpcpy(p, "handle-reboot-key:"); + + if (p > buffer) + *(p-1) = 0; +@@ -455,6 +465,8 @@ InhibitWhat inhibit_what_from_string(const char *s) { + what |= INHIBIT_HANDLE_HIBERNATE_KEY; + else if (l == 17 && strneq(word, "handle-lid-switch", l)) + what |= INHIBIT_HANDLE_LID_SWITCH; ++ else if (l == 17 && strneq(word, "handle-reboot-key", l)) ++ what |= INHIBIT_HANDLE_REBOOT_KEY; + else + return _INHIBIT_WHAT_INVALID; + } +diff --git a/src/login/logind-inhibit.h b/src/login/logind-inhibit.h +index 650587106d..51095a0bde 100644 +--- a/src/login/logind-inhibit.h ++++ b/src/login/logind-inhibit.h +@@ -11,7 +11,8 @@ typedef enum InhibitWhat { + INHIBIT_HANDLE_SUSPEND_KEY = 1 << 4, + INHIBIT_HANDLE_HIBERNATE_KEY = 1 << 5, + INHIBIT_HANDLE_LID_SWITCH = 1 << 6, +- _INHIBIT_WHAT_MAX = 1 << 7, ++ INHIBIT_HANDLE_REBOOT_KEY = 1 << 7, ++ _INHIBIT_WHAT_MAX = 1 << 8, + _INHIBIT_WHAT_INVALID = -1 + } InhibitWhat; + +diff --git a/src/login/logind.conf.in b/src/login/logind.conf.in +index a62c2b0b57..95f2d48d02 100644 +--- a/src/login/logind.conf.in ++++ b/src/login/logind.conf.in +@@ -24,10 +24,12 @@ + #HandleLidSwitch=suspend + #HandleLidSwitchExternalPower=suspend + #HandleLidSwitchDocked=ignore ++#HandleRebootKey=reboot + #PowerKeyIgnoreInhibited=no + #SuspendKeyIgnoreInhibited=no + #HibernateKeyIgnoreInhibited=no + #LidSwitchIgnoreInhibited=yes ++#RebootKeyIgnoreInhibited=no + #HoldoffTimeoutSec=30s + #IdleAction=ignore + #IdleActionSec=30min +diff --git a/src/login/logind.h b/src/login/logind.h +index b9b4a5113f..395306ced3 100644 +--- a/src/login/logind.h ++++ b/src/login/logind.h +@@ -111,11 +111,13 @@ struct Manager { + HandleAction handle_lid_switch; + HandleAction handle_lid_switch_ep; + HandleAction handle_lid_switch_docked; ++ HandleAction handle_reboot_key; + + bool power_key_ignore_inhibited; + bool suspend_key_ignore_inhibited; + bool hibernate_key_ignore_inhibited; + bool lid_switch_ignore_inhibited; ++ bool reboot_key_ignore_inhibited; + + bool remove_ipc; + +diff --git a/src/login/org.freedesktop.login1.policy b/src/login/org.freedesktop.login1.policy +index 83760e1580..882975849e 100644 +--- a/src/login/org.freedesktop.login1.policy ++++ b/src/login/org.freedesktop.login1.policy +@@ -113,6 +113,17 @@ + + + ++ ++ Allow applications to inhibit system handling of the reboot key ++ Authentication is required for an application to inhibit system handling of the reboot key. ++ ++ no ++ yes ++ yes ++ ++ org.freedesktop.login1.inhibit-handle-suspend-key org.freedesktop.login1.inhibit-handle-hibernate-key org.freedesktop.login1.inhibit-handle-lid-switch ++ ++ + + Allow non-logged-in user to run programs + Explicit request is required to run programs as a non-logged-in user. +diff --git a/src/systemd/sd-messages.h b/src/systemd/sd-messages.h +index 847b698ba4..3e9584c0b2 100644 +--- a/src/systemd/sd-messages.h ++++ b/src/systemd/sd-messages.h +@@ -134,6 +134,8 @@ _SD_BEGIN_DECLARATIONS; + #define SD_MESSAGE_SYSTEM_UNDOCKED_STR SD_ID128_MAKE_STR(51,e1,71,bd,58,52,48,56,81,10,14,4c,51,7c,ca,53) + #define SD_MESSAGE_POWER_KEY SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,71) + #define SD_MESSAGE_POWER_KEY_STR SD_ID128_MAKE_STR(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,71) ++#define SD_MESSAGE_REBOOT_KEY SD_ID128_MAKE(9f,a9,d2,c0,12,13,4e,c3,85,45,1f,fe,31,6f,97,d0) ++#define SD_MESSAGE_REBOOT_KEY_STR SD_ID128_MAKE_STR(9f,a9,d2,c0,12,13,4e,c3,85,45,1f,fe,31,6f,97,d0) + #define SD_MESSAGE_SUSPEND_KEY SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,72) + #define SD_MESSAGE_SUSPEND_KEY_STR SD_ID128_MAKE_STR(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,72) + #define SD_MESSAGE_HIBERNATE_KEY SD_ID128_MAKE(b7,2e,a4,a2,88,15,45,a0,b5,0e,20,0e,55,b9,b0,73) diff --git a/0999-analyze-security-fix-recursive-call-of-syscall_names.patch b/0999-analyze-security-fix-recursive-call-of-syscall_names.patch new file mode 100644 index 0000000..21a1e74 --- /dev/null +++ b/0999-analyze-security-fix-recursive-call-of-syscall_names.patch @@ -0,0 +1,62 @@ +From dd7a5f4144bde111334582eafbc0f358e63854ea Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Fri, 1 Feb 2019 11:49:24 +0100 +Subject: [PATCH] analyze security: fix recursive call of + syscall_names_in_filter() + +When `syscall_names_in_filter()` is called in itself, it is already +examined with `whitelist`. Or, in other words, `syscall_names_in_filter()` +returns bad or good in boolean. So, the returned value should not be +compared with `whitelist` again. + +This replaces #11302. + +(cherry picked from commit 95832a0f8c2941df83e72dfc9d37eab20da8b1fa) + +Related: RHEL-5991 +--- + src/analyze/analyze-security.c | 24 +++++++++++------------- + 1 file changed, 11 insertions(+), 13 deletions(-) + +diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c +index 969101c57b..5ef5d52e75 100644 +--- a/src/analyze/analyze-security.c ++++ b/src/analyze/analyze-security.c +@@ -480,26 +480,24 @@ static bool syscall_names_in_filter(Set *s, bool whitelist, const SyscallFilterS + const char *syscall; + + NULSTR_FOREACH(syscall, f->value) { +- bool b; ++ int id; + + if (syscall[0] == '@') { + const SyscallFilterSet *g; +- assert_se(g = syscall_filter_set_find(syscall)); +- b = syscall_names_in_filter(s, whitelist, g); +- } else { +-#if HAVE_SECCOMP +- int id; + +- /* Let's see if the system call actually exists on this platform, before complaining */ +- id = seccomp_syscall_resolve_name(syscall); +- if (id < 0) +- continue; +-#endif ++ assert_se(g = syscall_filter_set_find(syscall)); ++ if (syscall_names_in_filter(s, whitelist, g)) ++ return true; /* bad! */ + +- b = set_contains(s, syscall); ++ continue; + } + +- if (whitelist == b) { ++ /* Let's see if the system call actually exists on this platform, before complaining */ ++ id = seccomp_syscall_resolve_name(syscall); ++ if (id < 0) ++ continue; ++ ++ if (set_contains(s, syscall) == whitelist) { + log_debug("Offending syscall filter item: %s", syscall); + return true; /* bad! */ + } diff --git a/1000-analyze-security-do-not-assign-badness-to-filtered-o.patch b/1000-analyze-security-do-not-assign-badness-to-filtered-o.patch new file mode 100644 index 0000000..ba06451 --- /dev/null +++ b/1000-analyze-security-do-not-assign-badness-to-filtered-o.patch @@ -0,0 +1,28 @@ +From c8fe27ea2c560a213c3e3968fa76b5dd84e181f5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Sat, 1 Aug 2020 11:28:09 +0200 +Subject: [PATCH] analyze-security: do not assign badness to filtered-out + syscalls + +Fixes #16451, https://bugzilla.redhat.com/show_bug.cgi?id=1856273. + +(cherry picked from commit 01ecb3674ad3650bcbb14155b2dcbd4b9f4ed57e) + +Resolves: RHEL-5991 +--- + src/analyze/analyze-security.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c +index 5ef5d52e75..7c937e3587 100644 +--- a/src/analyze/analyze-security.c ++++ b/src/analyze/analyze-security.c +@@ -549,7 +549,7 @@ static int assess_system_call_filter( + b = 10; + } else { + (void) asprintf(&d, "System call blacklist defined for service, and %s is included", f->name); +- b = 5; ++ b = 0; + } + } + } diff --git a/10000-core-fix-a-null-reference-case-in-load_from_path.patch b/10000-core-fix-a-null-reference-case-in-load_from_path.patch deleted file mode 100644 index e15690c..0000000 --- a/10000-core-fix-a-null-reference-case-in-load_from_path.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 11e4aae398f9d26c7c4e54bfa6621f80a3ed2100 Mon Sep 17 00:00:00 2001 -From: Wen Yang -Date: Tue, 19 Apr 2022 11:04:47 +0800 -Subject: [PATCH] fix a null reference case in load_from_path() - ---- - src/core/load-fragment.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c -index c0b1fd4..f59a040 100644 ---- a/src/core/load-fragment.c -+++ b/src/core/load-fragment.c -@@ -4477,7 +4477,6 @@ static int load_from_path(Unit *u, const char *path) { - r = open_follow(&filename, &f, symlink_names, &id); - if (r >= 0) - break; -- filename = mfree(filename); - - /* ENOENT means that the file is missing or is a dangling symlink. - * ENOTDIR means that one of paths we expect to be is a directory -@@ -4486,7 +4485,8 @@ static int load_from_path(Unit *u, const char *path) { - */ - if (r == -EACCES) - log_debug_errno(r, "Cannot access \"%s\": %m", filename); -- else if (!IN_SET(r, -ENOENT, -ENOTDIR)) -+ filename = mfree(filename); -+ if (!IN_SET(r, -ENOENT, -ENOTDIR)) - return r; - - /* Empty the symlink names for the next run */ --- -2.27.0 - diff --git a/10001-sysctl-Don-t-pass-null-directive-argument-to-s.patch b/10001-sysctl-Don-t-pass-null-directive-argument-to-s.patch deleted file mode 100644 index ec09ee4..0000000 --- a/10001-sysctl-Don-t-pass-null-directive-argument-to-s.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 1b3f7805ed7c193e17cb5bad4f4f19c2f72f3d08 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Tue, 19 Apr 2022 11:16:42 +0800 -Subject: [PATCH] sysctl: Don't pass null directive argument to '%s' - ---- - src/sysctl/sysctl.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c -index 4c85d68..e756eff 100644 ---- a/src/sysctl/sysctl.c -+++ b/src/sysctl/sysctl.c -@@ -160,7 +160,7 @@ static int parse_file(OrderedHashmap *sysctl_options, const char *path, bool ign - - value = strchr(p, '='); - if (!value) { -- log_error("Line is not an assignment at '%s:%u': %s", path, c, value); -+ log_error("Line is not an assignment at '%s:%u': %s", path, c, p); - - if (r == 0) - r = -EINVAL; --- -2.27.0 - diff --git a/10002-exit-status-introduce-EXIT_EXCEPTION-mapping-to-255.patch b/10002-exit-status-introduce-EXIT_EXCEPTION-mapping-to-255.patch deleted file mode 100644 index 66539a0..0000000 --- a/10002-exit-status-introduce-EXIT_EXCEPTION-mapping-to-255.patch +++ /dev/null @@ -1,52 +0,0 @@ -From f7940c9cdf872d7504aca9637e9fd14328b2b726 Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Tue, 19 Apr 2022 11:26:10 +0800 -Subject: [PATCH] exit-status: introduce EXIT_EXCEPTION mapping to 255 - ---- - src/basic/exit-status.c | 9 ++++++--- - src/basic/exit-status.h | 1 + - 2 files changed, 7 insertions(+), 3 deletions(-) - -diff --git a/src/basic/exit-status.c b/src/basic/exit-status.c -index 0a7a53b..8b67d44 100644 ---- a/src/basic/exit-status.c -+++ b/src/basic/exit-status.c -@@ -19,9 +19,9 @@ const char* exit_status_to_string(int status, ExitStatusLevel level) { - * 79…199 │ (Currently unmapped) - * 200…241 │ systemd's private error codes (might be extended to 254 in future development) - * 242…254 │ (Currently unmapped, but see above) -- * 255 │ (We should probably stay away from that one, it's frequently used by applications to indicate an -- * │ exit reason that cannot really be expressed in a single exit status value — such as a propagated -- * │ signal or such) -+ * 255 │ EXIT_EXCEPTION (We use this to propagate exit-by-signal events. It's frequently used by others apps (like bash) -+ * │ to indicate exit reason that cannot really be expressed in a single exit status value — such as a propagated -+ * │ signal or such, and we follow that logic here.) - */ - - switch (status) { /* We always cover the ISO C ones */ -@@ -158,6 +158,9 @@ const char* exit_status_to_string(int status, ExitStatusLevel level) { - - case EXIT_NUMA_POLICY: - return "NUMA_POLICY"; -+ -+ case EXIT_EXCEPTION: -+ return "EXCEPTION"; - } - } - -diff --git a/src/basic/exit-status.h b/src/basic/exit-status.h -index dc284aa..e923247 100644 ---- a/src/basic/exit-status.h -+++ b/src/basic/exit-status.h -@@ -70,6 +70,7 @@ enum { - EXIT_LOGS_DIRECTORY, /* 240 */ - EXIT_CONFIGURATION_DIRECTORY, - EXIT_NUMA_POLICY, -+ EXIT_EXCEPTION = 255, /* Whenever we want to propagate an abnormal/signal exit, in line with bash */ - }; - - typedef enum ExitStatusLevel { --- -2.27.0 - diff --git a/10003-main-don-t-freeze-PID-1-in-containers-exit-with-non-.patch b/10003-main-don-t-freeze-PID-1-in-containers-exit-with-non-.patch deleted file mode 100644 index 026fc66..0000000 --- a/10003-main-don-t-freeze-PID-1-in-containers-exit-with-non-.patch +++ /dev/null @@ -1,52 +0,0 @@ -From dffb92b5520a4b539f0466d4161fcaacc6ba5ba8 Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Tue, 19 Apr 2022 11:34:27 +0800 -Subject: [PATCH] main: don't freeze PID 1 in containers, exit with - ---- - src/core/main.c | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) - -diff --git a/src/core/main.c b/src/core/main.c -index d897155..0aec5d1 100644 ---- a/src/core/main.c -+++ b/src/core/main.c -@@ -139,7 +139,13 @@ static NUMAPolicy arg_numa_policy; - static int parse_configuration(const struct rlimit *saved_rlimit_nofile, - const struct rlimit *saved_rlimit_memlock); - --_noreturn_ static void freeze_or_reboot(void) { -+_noreturn_ static void freeze_or_exit_or_reboot(void) { -+ /* If we are running in a contianer, let's prefer exiting, after all we can propagate an exit code to the -+ * container manager, and thus inform it that something went wrong. */ -+ if (detect_container() > 0) { -+ log_emergency("Exiting PID 1..."); -+ exit(EXIT_EXCEPTION); -+ } - - if (arg_crash_reboot) { - log_notice("Rebooting in 10s..."); -@@ -247,7 +253,7 @@ _noreturn_ static void crash(int sig) { - } - } - -- freeze_or_reboot(); -+ freeze_or_exit_or_reboot(); - } - - static void install_crash_handler(void) { -@@ -2664,9 +2670,9 @@ finish: - if (error_message) - manager_status_printf(NULL, STATUS_TYPE_EMERGENCY, - ANSI_HIGHLIGHT_RED "!!!!!!" ANSI_NORMAL, -- "%s, freezing.", error_message); -- freeze_or_reboot(); -+ "%s.", error_message); -+ freeze_or_exit_or_reboot(); - } - - reset_arguments(); - return retval; --- -2.27.0 - diff --git a/10004-Do-not-go-into-freeze-when-systemd-crashd.patch b/10004-Do-not-go-into-freeze-when-systemd-crashd.patch deleted file mode 100644 index 1cb12cc..0000000 --- a/10004-Do-not-go-into-freeze-when-systemd-crashd.patch +++ /dev/null @@ -1,103 +0,0 @@ -From 64072aab92ff6489a2e460a9bdd1cfefa587264b Mon Sep 17 00:00:00 2001 -From: Yuanhong Peng -Date: Tue, 19 Apr 2022 13:36:09 +0800 -Subject: [PATCH] Do not go into freeze when systemd crashd - ---- - src/core/main.c | 41 ++++++++++++++++++++++++++++++++++++++++- - 1 file changed, 40 insertions(+), 1 deletion(-) - -diff --git a/src/core/main.c b/src/core/main.c -index 0aec5d1..db91151 100644 ---- a/src/core/main.c -+++ b/src/core/main.c -@@ -3,6 +3,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -10,6 +11,7 @@ - #include - #include - #include -+#include - #include - #if HAVE_SECCOMP - #include -@@ -135,10 +137,41 @@ static sd_id128_t arg_machine_id; - static EmergencyAction arg_cad_burst_action; - static CPUSet arg_cpu_affinity; - static NUMAPolicy arg_numa_policy; -+static bool reexec_jmp_can = false; -+static bool reexec_jmp_inited = false; -+static sigjmp_buf reexec_jmp_buf; - - static int parse_configuration(const struct rlimit *saved_rlimit_nofile, - const struct rlimit *saved_rlimit_memlock); - -+static void reexec_handler(int sig) { -+ reexec_jmp_can = true; -+} -+ -+_noreturn_ static void freeze_wait_upgrade(void) { -+ struct sigaction sa; -+ sigset_t ss; -+ -+ sigemptyset(&ss); -+ sigaddset(&ss, SIGTERM); -+ sigprocmask(SIG_UNBLOCK, &ss, NULL); -+ -+ sa.sa_handler = reexec_handler; -+ sa.sa_flags = SA_RESTART; -+ sigaction(SIGTERM, &sa, NULL); -+ -+ log_error("freeze_wait_upgrade: %d\n", reexec_jmp_inited); -+ reexec_jmp_can = false; -+ while(1) { -+ usleep(10000); -+ if (reexec_jmp_inited && reexec_jmp_can) { -+ log_error("goto manager_reexecute.\n"); -+ siglongjmp(reexec_jmp_buf, 1); -+ } -+ waitpid(-1, NULL, WNOHANG); -+ } -+} -+ - _noreturn_ static void freeze_or_exit_or_reboot(void) { - /* If we are running in a contianer, let's prefer exiting, after all we can propagate an exit code to the - * container manager, and thus inform it that something went wrong. */ -@@ -157,7 +190,8 @@ _noreturn_ static void freeze_or_exit_or_reboot(void) { - } - - log_emergency("Freezing execution."); -- freeze(); -+ freeze_wait_upgrade(); -+ - } - - _noreturn_ static void crash(int sig) { -@@ -1667,6 +1701,10 @@ static int invoke_main_loop( - assert(ret_switch_root_init); - assert(ret_error_message); - -+ reexec_jmp_inited = true; -+ if (sigsetjmp(reexec_jmp_buf, 1)) -+ goto manager_reexecute; -+ - for (;;) { - r = manager_loop(m); - if (r < 0) { -@@ -1709,6 +1747,7 @@ static int invoke_main_loop( - - case MANAGER_REEXECUTE: - -+manager_reexecute: - r = prepare_reexecute(m, &arg_serialization, ret_fds, false); - if (r < 0) { - *ret_error_message = "Failed to prepare for reexecution"; --- -2.27.0 - diff --git a/10005-mount-setup-change-the-system-mount-propagation-to-s.patch b/10005-mount-setup-change-the-system-mount-propagation-to-s.patch deleted file mode 100644 index fa95141..0000000 --- a/10005-mount-setup-change-the-system-mount-propagation-to-s.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 0c7f29561634f9374c0d9042304f4d4caa4242f0 Mon Sep 17 00:00:00 2001 -From: Wen Yang -Date: Tue, 19 Apr 2022 13:50:04 +0800 -Subject: [PATCH] mount-setup: change the system mount propagation to - ---- - src/core/main.c | 2 +- - src/core/mount-setup.c | 4 ++-- - src/core/mount-setup.h | 2 +- - 3 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/src/core/main.c b/src/core/main.c -index db91151..81dae1c 100644 ---- a/src/core/main.c -+++ b/src/core/main.c -@@ -2519,7 +2519,7 @@ int main(int argc, char *argv[]) { - if (!skip_setup) - kmod_setup(); - -- r = mount_setup(loaded_policy); -+ r = mount_setup(loaded_policy, skip_setup); - if (r < 0) { - error_message = "Failed to mount API filesystems"; - goto finish; -diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c -index a659458..9f9f953 100644 ---- a/src/core/mount-setup.c -+++ b/src/core/mount-setup.c -@@ -400,7 +400,7 @@ static int relabel_cgroup_filesystems(void) { - } - #endif - --int mount_setup(bool loaded_policy) { -+int mount_setup(bool loaded_policy, bool leave_propagation) { - int r = 0; - - r = mount_points_setup(ELEMENTSOF(mount_table), loaded_policy); -@@ -444,7 +444,7 @@ int mount_setup(bool loaded_policy) { - * needed. Note that we set this only when we are invoked directly by the kernel. If we are invoked by a - * container manager we assume the container manager knows what it is doing (for example, because it set up - * some directories with different propagation modes). */ -- if (detect_container() <= 0) -+ if (detect_container() <= 0 && !leave_propagation) - if (mount(NULL, "/", NULL, MS_REC|MS_SHARED, NULL) < 0) - log_warning_errno(errno, "Failed to set up the root directory for shared mount propagation: %m"); - -diff --git a/src/core/mount-setup.h b/src/core/mount-setup.h -index 43cd890..7a011b2 100644 ---- a/src/core/mount-setup.h -+++ b/src/core/mount-setup.h -@@ -4,7 +4,7 @@ - #include - - int mount_setup_early(void); --int mount_setup(bool loaded_policy); -+int mount_setup(bool loaded_policy, bool leave_propagation); - - int mount_cgroup_controllers(char ***join_controllers); - --- -2.27.0 - diff --git a/10006-cgroup-util-make-definition-of-CGROUP_CONTROLLER_TO_.patch b/10006-cgroup-util-make-definition-of-CGROUP_CONTROLLER_TO_.patch deleted file mode 100644 index 9a5fa6e..0000000 --- a/10006-cgroup-util-make-definition-of-CGROUP_CONTROLLER_TO_.patch +++ /dev/null @@ -1,26 +0,0 @@ -From d449667a6a545a46647911838731e8e46a5a39ed Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Tue, 19 Apr 2022 13:56:39 +0800 -Subject: [PATCH] cgroup-util: make definition of CGROUP_CONTROLLER_TO_MASK() - unsigned - ---- - src/basic/cgroup-util.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h -index 1210b38..76659c3 100644 ---- a/src/basic/cgroup-util.h -+++ b/src/basic/cgroup-util.h -@@ -31,7 +31,7 @@ typedef enum CGroupController { - _CGROUP_CONTROLLER_INVALID = -1, - } CGroupController; - --#define CGROUP_CONTROLLER_TO_MASK(c) (1 << (c)) -+#define CGROUP_CONTROLLER_TO_MASK(c) (1U << (c)) - - /* A bit mask of well known cgroup controllers */ - typedef enum CGroupMask { --- -2.27.0 - diff --git a/10007-cgroup-update-only-siblings-that-got-realized-once.patch b/10007-cgroup-update-only-siblings-that-got-realized-once.patch deleted file mode 100644 index 068f21c..0000000 --- a/10007-cgroup-update-only-siblings-that-got-realized-once.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 841539281bed5187d2f773097eefb0bb3c5057ec Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Tue, 19 Apr 2022 14:03:12 +0800 -Subject: [PATCH] cgroup: update only siblings that got realized once - ---- - src/core/cgroup.c | 16 +++++++++++++++- - 1 file changed, 15 insertions(+), 1 deletion(-) - -diff --git a/src/core/cgroup.c b/src/core/cgroup.c -index f02cc31..e0e0a98 100644 ---- a/src/core/cgroup.c -+++ b/src/core/cgroup.c -@@ -1980,7 +1980,16 @@ static void unit_add_siblings_to_cgroup_realize_queue(Unit *u) { - Unit *slice; - - /* This adds the siblings of the specified unit and the siblings of all parent units to the cgroup -- * queue. (But neither the specified unit itself nor the parents.) */ -+ * queue. (But neither the specified unit itself nor the parents.) -+ * -+ * Propagation of realization "side-ways" (i.e. towards siblings) is in relevant on cgroup-v1 where -+ * scheduling become very weird if two units that own processes reside in the same slice, but one is -+ * realized in the "cpu" hierarchy and once is not (for example because one has CPUWeight= set and -+ * the other does not), because that means processes need to be scheduled against groups. Let's avoid -+ * this asymmetry by always ensuring that units below a slice that are realized at all are hence -+ * always realized in *all* their hierarchies, and it is sufficient for a unit's sibling to be -+ * realized for a unit to be realized too. */ -+ - - while ((slice = UNIT_DEREF(u->slice))) { - Iterator i; -@@ -1996,6 +2005,11 @@ static void unit_add_siblings_to_cgroup_realize_queue(Unit *u) { - if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(m))) - continue; - -+ /* We only enqueue siblings if they were realized once at least, in the main -+ * hierarchy. */ -+ if (!m->cgroup_realized) -+ continue; -+ - /* If the unit doesn't need any new controllers and has current ones realized, it - * doesn't need any changes. */ - if (unit_has_mask_realized(m, --- -2.27.0 - diff --git a/10008-core-add-a-config-item-to-support-setting-the-value-.patch b/10008-core-add-a-config-item-to-support-setting-the-value-.patch deleted file mode 100644 index 272d61b..0000000 --- a/10008-core-add-a-config-item-to-support-setting-the-value-.patch +++ /dev/null @@ -1,120 +0,0 @@ -From f21d63650318791f29f56dc26f23acb5b53620a6 Mon Sep 17 00:00:00 2001 -From:Yuanhong Peng -Date: Tue, 19 Apr 2022 14:13:49 +0800 -Subject: [PATCH] core: add a config item to support setting the value - ---- - src/core/main.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 69 insertions(+) - -diff --git a/src/core/main.c b/src/core/main.c -index 81dae1c..0712423 100644 ---- a/src/core/main.c -+++ b/src/core/main.c -@@ -140,6 +140,7 @@ static NUMAPolicy arg_numa_policy; - static bool reexec_jmp_can = false; - static bool reexec_jmp_inited = false; - static sigjmp_buf reexec_jmp_buf; -+static bool arg_default_cpuset_clone_children = false; - - static int parse_configuration(const struct rlimit *saved_rlimit_nofile, - const struct rlimit *saved_rlimit_memlock); -@@ -527,6 +528,14 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat - return 0; - - parse_path_argument_and_warn(value, false, &arg_watchdog_device); -+ -+ } else if (proc_cmdline_key_streq(key, "systemd.cpuset_clone_children") && value) { -+ -+ r = parse_boolean(value); -+ if (r < 0) -+ log_warning("Failed to parse cpuset_clone_children switch %s. Ignoring.", value); -+ else -+ arg_default_cpuset_clone_children = r; - - } else if (streq(key, "quiet") && !value) { - -@@ -756,6 +765,7 @@ static int parse_config_file(void) { - { "Manager", "DefaultTasksAccounting", config_parse_bool, 0, &arg_default_tasks_accounting }, - { "Manager", "DefaultTasksMax", config_parse_tasks_max, 0, &arg_default_tasks_max }, - { "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, 0, &arg_cad_burst_action }, -+ { "Manager", "DefaultCPUSetCloneChildren",config_parse_bool, 0, &arg_default_cpuset_clone_children }, - {} - }; - -@@ -1872,6 +1882,64 @@ static void log_execution_mode(bool *ret_first_boot) { - } - } - -+static bool is_use_triple_cgroup(void) { -+ const char * path ="/sys/fs/cgroup/cpuset"; -+ _cleanup_strv_free_ char **l = NULL; -+ char buf[128] = {0}; -+ int r; -+ -+ r = is_symlink(path); -+ if (r <= 0) -+ return false; -+ -+ r = readlink(path, buf, sizeof(buf)); -+ if (r < 0 || (unsigned int)r >= sizeof(buf)) -+ return false; -+ -+ buf[r] = '\0'; -+ l = strv_split(buf, ","); -+ if (!l) -+ return false; -+ -+ strv_sort(l); -+ if (strv_length(l) != 3) -+ return false; -+ -+ if (streq(l[0],"cpu") && streq(l[1], "cpuacct") && -+ streq(l[2], "cpuset")) { -+ log_debug(PACKAGE_STRING " use_triple_cgroup: %s", buf); -+ return true; -+ } -+ return false; -+} -+ -+static int ali_handle_cpuset_clone_children(void) -+{ -+ const char *file = "/sys/fs/cgroup/cpuset/cgroup.clone_children"; -+ _cleanup_free_ char *buf = NULL; -+ int r; -+ -+ r = read_one_line_file(file, &buf); -+ if (r < 0) { -+ log_warning_errno(r, "Cannot read %s: %m", file); -+ return r; -+ } -+ -+ if (streq(buf, "1") && arg_default_cpuset_clone_children) -+ return 0; -+ -+ if (streq(buf, "0") && (!arg_default_cpuset_clone_children)) -+ return 0; -+ -+ if (!is_use_triple_cgroup()) -+ return 0; -+ -+ r = write_string_file(file, one_zero(arg_default_cpuset_clone_children), 0); -+ log_info(PACKAGE_STRING " set %s to %s, ret=%d", file, one_zero(arg_default_cpuset_clone_children), r); -+ return r; -+} -+ -+ - static int initialize_runtime( - bool skip_setup, - struct rlimit *saved_rlimit_nofile, -@@ -1906,6 +1974,7 @@ static int initialize_runtime( - return r; - } - -+ ali_handle_cpuset_clone_children(); - status_welcome(); - hostname_setup(); - machine_id_setup(NULL, arg_machine_id, NULL); --- -2.27.0 - diff --git a/10009-systemd-anolis-support-loongarch64.patch b/10009-systemd-anolis-support-loongarch64.patch deleted file mode 100644 index b76c8e0..0000000 --- a/10009-systemd-anolis-support-loongarch64.patch +++ /dev/null @@ -1,56 +0,0 @@ -From c8b7c2b34bd451cd9d5904fc215ad14893008a03 Mon Sep 17 00:00:00 2001 -From: rpm-build -Date: Tue, 19 Apr 2022 14:25:05 +0800 -Subject: [PATCH] support loongarch64 for systemd - ---- - src/basic/architecture.c | 3 +++ - src/basic/architecture.h | 4 ++++ - 2 files changed, 7 insertions(+) - -diff --git a/src/basic/architecture.c b/src/basic/architecture.c -index 85837b5..96bbf97 100644 ---- a/src/basic/architecture.c -+++ b/src/basic/architecture.c -@@ -118,6 +118,8 @@ int uname_architecture(void) { - #elif defined(__arc__) - { "arc", ARCHITECTURE_ARC }, - { "arceb", ARCHITECTURE_ARC_BE }, -+#elif defined(__loongarch64) -+ { "loongarch64", ARCHITECTURE_LOONGARCH64 }, - #else - #error "Please register your architecture here!" - #endif -@@ -173,6 +175,7 @@ static const char *const architecture_table[_ARCHITECTURE_MAX] = { - [ARCHITECTURE_RISCV64] = "riscv64", - [ARCHITECTURE_ARC] = "arc", - [ARCHITECTURE_ARC_BE] = "arc-be", -+ [ARCHITECTURE_LOONGARCH64] = "loongarch64", - }; - - DEFINE_STRING_TABLE_LOOKUP(architecture, int); -diff --git a/src/basic/architecture.h b/src/basic/architecture.h -index 443e890..22e9108 100644 ---- a/src/basic/architecture.h -+++ b/src/basic/architecture.h -@@ -44,6 +44,7 @@ enum { - ARCHITECTURE_RISCV64, - ARCHITECTURE_ARC, - ARCHITECTURE_ARC_BE, -+ ARCHITECTURE_LOONGARCH64, - _ARCHITECTURE_MAX, - _ARCHITECTURE_INVALID = -1 - }; -@@ -229,6 +230,9 @@ int uname_architecture(void); - # define native_architecture() ARCHITECTURE_ARC - # define LIB_ARCH_TUPLE "arc-linux" - # endif -+#elif defined(__loongarch64) -+# define native_architecture() ARCHITECTURE_LOONGARCH64 -+# define LIB_ARCH_TUPLE "loongarch64-linux-gnu" - #else - # error "Please register your architecture here!" - #endif --- -2.27.0 - diff --git a/1001-analyze-security-include-an-actual-syscall-name-in-t.patch b/1001-analyze-security-include-an-actual-syscall-name-in-t.patch new file mode 100644 index 0000000..edc5dea --- /dev/null +++ b/1001-analyze-security-include-an-actual-syscall-name-in-t.patch @@ -0,0 +1,105 @@ +From 7aa12839166b5ae2c67d51946008543d016a7733 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Sat, 1 Aug 2020 11:41:57 +0200 +Subject: [PATCH] analyze-security: include an actual syscall name in the + message + +This information was already available in the debug output, but I think it +is good to include it in the message in the table. This makes it easier to wrap +one's head around the allowlist/denylist filtering. + +(cherry picked from commit a9134af2e3ab22eba96228ea6ba440e89213cef2) + +Related: RHEL-5991 +--- + src/analyze/analyze-security.c | 27 +++++++++++++++++---------- + 1 file changed, 17 insertions(+), 10 deletions(-) + +diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c +index 7c937e3587..d156aa607a 100644 +--- a/src/analyze/analyze-security.c ++++ b/src/analyze/analyze-security.c +@@ -476,7 +476,7 @@ static int assess_system_call_architectures( + return 0; + } + +-static bool syscall_names_in_filter(Set *s, bool whitelist, const SyscallFilterSet *f) { ++static bool syscall_names_in_filter(Set *s, bool whitelist, const SyscallFilterSet *f, const char **ret_offending_syscall) { + const char *syscall; + + NULSTR_FOREACH(syscall, f->value) { +@@ -486,7 +486,7 @@ static bool syscall_names_in_filter(Set *s, bool whitelist, const SyscallFilterS + const SyscallFilterSet *g; + + assert_se(g = syscall_filter_set_find(syscall)); +- if (syscall_names_in_filter(s, whitelist, g)) ++ if (syscall_names_in_filter(s, whitelist, g, ret_offending_syscall)) + return true; /* bad! */ + + continue; +@@ -499,10 +499,13 @@ static bool syscall_names_in_filter(Set *s, bool whitelist, const SyscallFilterS + + if (set_contains(s, syscall) == whitelist) { + log_debug("Offending syscall filter item: %s", syscall); ++ if (ret_offending_syscall) ++ *ret_offending_syscall = syscall; + return true; /* bad! */ + } + } + ++ *ret_offending_syscall = NULL; + return false; + } + +@@ -513,31 +516,33 @@ static int assess_system_call_filter( + uint64_t *ret_badness, + char **ret_description) { + +- const SyscallFilterSet *f; +- char *d = NULL; +- uint64_t b; +- + assert(a); + assert(info); + assert(ret_badness); + assert(ret_description); + + assert(a->parameter < _SYSCALL_FILTER_SET_MAX); +- f = syscall_filter_sets + a->parameter; ++ const SyscallFilterSet *f = syscall_filter_sets + a->parameter; ++ ++ char *d = NULL; ++ uint64_t b; + + if (!info->system_call_filter_whitelist && set_isempty(info->system_call_filter)) { + d = strdup("Service does not filter system calls"); + b = 10; + } else { + bool bad; ++ const char *offender = NULL; + + log_debug("Analyzing system call filter, checking against: %s", f->name); +- bad = syscall_names_in_filter(info->system_call_filter, info->system_call_filter_whitelist, f); ++ bad = syscall_names_in_filter(info->system_call_filter, info->system_call_filter_whitelist, f, &offender); + log_debug("Result: %s", bad ? "bad" : "good"); + + if (info->system_call_filter_whitelist) { + if (bad) { +- (void) asprintf(&d, "System call whitelist defined for service, and %s is included", f->name); ++ (void) asprintf(&d, "System call whitelist defined for service, and %s is included " ++ "(e.g. %s is allowed)", ++ f->name, offender); + b = 9; + } else { + (void) asprintf(&d, "System call whitelist defined for service, and %s is not included", f->name); +@@ -545,7 +550,9 @@ static int assess_system_call_filter( + } + } else { + if (bad) { +- (void) asprintf(&d, "System call blacklist defined for service, and %s is not included", f->name); ++ (void) asprintf(&d, "System call blacklist defined for service, and %s is not included " ++ "(e.g. %s is allowed)", ++ f->name, offender); + b = 10; + } else { + (void) asprintf(&d, "System call blacklist defined for service, and %s is included", f->name); diff --git a/10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch b/10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch deleted file mode 100644 index d4054b4..0000000 --- a/10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch +++ /dev/null @@ -1,56 +0,0 @@ -From 5209a26aa917aa54b09ee18394ad46ee601e77be Mon Sep 17 00:00:00 2001 -From: Yuanhong Peng -Date: Tue, 17 May 2022 21:34:34 +0800 -Subject: [PATCH] test-catalog: Fix coredump when compiled under GCC10 - -According to the documentation: -https://gcc.gnu.org/gcc-9/porting_to.html#complit: - -The `catalog_dirs` produced by STRV_MAKE(..) marco relies on -the extended lifetime feature which is fixed by GCC9. - -Signed-off-by: Yuanhong Peng ---- - src/journal/test-catalog.c | 12 ++++++++---- - 1 file changed, 8 insertions(+), 4 deletions(-) - -diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c -index 0c4da29..2ce92af 100644 ---- a/src/journal/test-catalog.c -+++ b/src/journal/test-catalog.c -@@ -201,7 +201,8 @@ static void test_catalog_file_lang(void) { - - int main(int argc, char *argv[]) { - _cleanup_(unlink_tempfilep) char database[] = "/tmp/test-catalog.XXXXXX"; -- _cleanup_free_ char *text = NULL, *catalog_dir = NULL; -+ _cleanup_free_ char *text = NULL; -+ char *catalog_dir = CATALOG_DIR; - int r; - - setlocale(LC_ALL, "de_DE.UTF-8"); -@@ -214,10 +215,9 @@ int main(int argc, char *argv[]) { - * If it is not, e.g. installed by systemd-tests package, then use installed catalogs. */ - if (test_is_running_from_builddir(NULL)) { - assert_se(catalog_dir = path_join(NULL, ABS_BUILD_DIR, "catalog")); -- catalog_dirs = STRV_MAKE(catalog_dir); -- } else -- catalog_dirs = STRV_MAKE(CATALOG_DIR); -+ } - -+ catalog_dirs = STRV_MAKE(catalog_dir); - assert_se(access(catalog_dirs[0], F_OK) >= 0); - log_notice("Using catalog directory '%s'", catalog_dirs[0]); - -@@ -242,5 +242,9 @@ int main(int argc, char *argv[]) { - assert_se(catalog_get(database, SD_MESSAGE_COREDUMP, &text) >= 0); - printf(">>>%s<<<\n", text); - -+ /* Only in this case, catalog_dir is malloced */ -+ if (test_is_running_from_builddir(NULL)) -+ free(catalog_dir); -+ - return 0; - } --- -2.27.0 - diff --git a/10011-hwdb-add-Iluvatar-CoreX.patch b/10011-hwdb-add-Iluvatar-CoreX.patch deleted file mode 100644 index e08657c..0000000 --- a/10011-hwdb-add-Iluvatar-CoreX.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 28e47526dce925e6f32cf79825d38fd10e1f442a Mon Sep 17 00:00:00 2001 -From: rpm-build -Date: Tue, 26 Jul 2022 22:01:58 +0800 -Subject: [PATCH] hwdb: add Iluvatar CoreX - -Signed-off-by: rpm-build ---- - hwdb/20-pci-vendor-model.hwdb | 6 ++++++ - hwdb/pci.ids | 2 ++ - 2 files changed, 8 insertions(+) - -diff --git a/hwdb/20-pci-vendor-model.hwdb b/hwdb/20-pci-vendor-model.hwdb -index 0020046..78926f8 100644 ---- a/hwdb/20-pci-vendor-model.hwdb -+++ b/hwdb/20-pci-vendor-model.hwdb -@@ -71141,6 +71141,12 @@ pci:v00001EEC* - pci:v00001EFB* - ID_VENDOR_FROM_DATABASE=Flexxon Pte Ltd - -+pci:v00001E3E* -+ ID_VENDOR_FROM_DATABASE=Iluvatar CoreX -+ -+pci:v00001E3Ed00000001* -+ ID_MODEL_FROM_DATABASE=Iluvatar BI-V100 -+ - pci:v00001FC0* - ID_VENDOR_FROM_DATABASE=Ascom (Finland) Oy - -diff --git a/hwdb/pci.ids b/hwdb/pci.ids -index 40ee143..d6661c7 100644 ---- a/hwdb/pci.ids -+++ b/hwdb/pci.ids -@@ -21543,6 +21543,8 @@ - 0003 alst4x - 1dfc JSC NT-COM - 1181 TDM 8 Port E1/T1/J1 Adapter -+1e3e Iluvatar CoreX -+ 0001 Iluvatar BI-V100 - # nee Tumsan Oy - 1fc0 Ascom (Finland) Oy - 0300 E2200 Dual E1/Rawpipe Card --- -2.27.0 - diff --git a/10012-seccomp-add-loongarch-support.patch b/10012-seccomp-add-loongarch-support.patch deleted file mode 100644 index 6aba34f..0000000 --- a/10012-seccomp-add-loongarch-support.patch +++ /dev/null @@ -1,101 +0,0 @@ -From 4c7025f5198be3d055c0e5ad68d364a57e8a7dcc Mon Sep 17 00:00:00 2001 -From: rpm-build -Date: Thu, 22 Sep 2022 10:33:54 +0800 -Subject: [PATCH] seccomp: add loongarch support - ---- - src/shared/seccomp-util.c | 18 +++++++++++++----- - 1 file changed, 13 insertions(+), 5 deletions(-) - -diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c -index c57c409..1eec0be 100644 ---- a/src/shared/seccomp-util.c -+++ b/src/shared/seccomp-util.c -@@ -42,6 +42,8 @@ const uint32_t seccomp_local_archs[] = { - SCMP_ARCH_AARCH64, /* native */ - #elif defined(__arm__) - SCMP_ARCH_ARM, -+#elif defined(__loongarch__) -+ SCMP_ARCH_LOONGARCH64, - #elif defined(__mips__) && __BYTE_ORDER == __BIG_ENDIAN && _MIPS_SIM == _MIPS_SIM_ABI32 - SCMP_ARCH_MIPSEL, - SCMP_ARCH_MIPS, /* native */ -@@ -114,6 +116,8 @@ const char* seccomp_arch_to_string(uint32_t c) { - return "arm"; - case SCMP_ARCH_AARCH64: - return "arm64"; -+ case SCMP_ARCH_LOONGARCH64: -+ return "loongarch64"; - case SCMP_ARCH_MIPS: - return "mips"; - case SCMP_ARCH_MIPS64: -@@ -159,6 +163,8 @@ int seccomp_arch_from_string(const char *n, uint32_t *ret) { - *ret = SCMP_ARCH_ARM; - else if (streq(n, "arm64")) - *ret = SCMP_ARCH_AARCH64; -+ else if (streq(n, "loongarch64")) -+ *ret = SCMP_ARCH_LOONGARCH64; - else if (streq(n, "mips")) - *ret = SCMP_ARCH_MIPS; - else if (streq(n, "mips64")) -@@ -1206,7 +1212,7 @@ int seccomp_protect_sysctl(void) { - - log_debug("Operating on architecture: %s", seccomp_arch_to_string(arch)); - -- if (IN_SET(arch, SCMP_ARCH_X32, SCMP_ARCH_AARCH64)) -+ if (IN_SET(arch, SCMP_ARCH_X32, SCMP_ARCH_AARCH64, SCMP_ARCH_LOONGARCH64)) - /* No _sysctl syscall */ - continue; - -@@ -1251,6 +1257,7 @@ int seccomp_restrict_address_families(Set *address_families, bool whitelist) { - case SCMP_ARCH_X32: - case SCMP_ARCH_ARM: - case SCMP_ARCH_AARCH64: -+ case SCMP_ARCH_LOONGARCH64: - case SCMP_ARCH_MIPSEL64N32: - case SCMP_ARCH_MIPS64N32: - case SCMP_ARCH_MIPSEL64: -@@ -1496,7 +1503,7 @@ static int add_seccomp_syscall_filter(scmp_filter_ctx seccomp, - } - - /* For known architectures, check that syscalls are indeed defined or not. */ --#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) -+#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__loongarch__) - assert_cc(SCMP_SYS(shmget) > 0); - assert_cc(SCMP_SYS(shmat) > 0); - assert_cc(SCMP_SYS(shmdt) > 0); -@@ -1543,13 +1550,14 @@ int seccomp_memory_deny_write_execute(void) { - case SCMP_ARCH_X86_64: - case SCMP_ARCH_X32: - case SCMP_ARCH_AARCH64: -+ case SCMP_ARCH_LOONGARCH64: - filter_syscall = SCMP_SYS(mmap); /* amd64, x32, and arm64 have only mmap */ - shmat_syscall = SCMP_SYS(shmat); - break; - - /* Please add more definitions here, if you port systemd to other architectures! */ - --#if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__) && !defined(__powerpc64__) && !defined(__arm__) && !defined(__aarch64__) -+#if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__) && !defined(__powerpc64__) && !defined(__arm__) && !defined(__aarch64__) && !defined(__loongarch__) - #warning "Consider adding the right mmap() syscall definitions here!" - #endif - } -@@ -1573,13 +1581,13 @@ int seccomp_memory_deny_write_execute(void) { - if (r < 0) - continue; - } -- -+ if (!IN_SET(arch, SCMP_ARCH_LOONGARCH64)){ - r = add_seccomp_syscall_filter(seccomp, arch, SCMP_SYS(mprotect), - 1, - SCMP_A2(SCMP_CMP_MASKED_EQ, PROT_EXEC, PROT_EXEC)); - if (r < 0) - continue; -- -+ } - #ifdef __NR_pkey_mprotect - r = add_seccomp_syscall_filter(seccomp, arch, SCMP_SYS(pkey_mprotect), - 1, --- -2.27.0 - diff --git a/10013-fileio-when-reading-a-full-file-into-memory-refuse-.patch b/10013-fileio-when-reading-a-full-file-into-memory-refuse-.patch deleted file mode 100644 index f2eeed5..0000000 --- a/10013-fileio-when-reading-a-full-file-into-memory-refuse-.patch +++ /dev/null @@ -1,120 +0,0 @@ -From 9f181efdd59bd3e9134cf94007953562ca8b57fa Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Sat, 15 Dec 2018 12:25:32 +0100 -Subject: [PATCH] fileio: when reading a full file into memory, refuse inner - NUL bytes - -Just some extra care to avoid any ambiguities in what we read. - -(cherry picked from commit beb90929913354eec50c3524086fe70d14f97e2f) - -Signed-off-by: Guorui Yu ---- - src/basic/fileio.c | 25 +++++++++++++++++++------ - src/test/test-unit-file.c | 10 +++++----- - 2 files changed, 24 insertions(+), 11 deletions(-) - -diff --git a/src/basic/fileio.c b/src/basic/fileio.c -index 733fb42463..9fef97ff0c 100644 ---- a/src/basic/fileio.c -+++ b/src/basic/fileio.c -@@ -383,16 +383,20 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re - return 0; - } - --int read_full_stream(FILE *f, char **contents, size_t *size) { -+int read_full_stream( -+ FILE *f, -+ char **ret_contents, -+ size_t *ret_size) { -+ - _cleanup_free_ char *buf = NULL; - struct stat st; - size_t n, l; - int fd; - - assert(f); -- assert(contents); -+ assert(ret_contents); - -- n = LINE_MAX; -+ n = LINE_MAX; /* Start size */ - - fd = fileno(f); - if (fd >= 0) { /* If the FILE* object is backed by an fd (as opposed to memory or such, see fmemopen(), let's -@@ -448,11 +452,20 @@ int read_full_stream(FILE *f, char **contents, size_t *size) { - n = MIN(n * 2, READ_FULL_BYTES_MAX); - } - -+ if (!ret_size) { -+ /* Safety check: if the caller doesn't want to know the size of what we just read it will rely on the -+ * trailing NUL byte. But if there's an embedded NUL byte, then we should refuse operation as otherwise -+ * there'd be ambiguity about what we just read. */ -+ -+ if (memchr(buf, 0, l)) -+ return -EBADMSG; -+ } -+ - buf[l] = 0; -- *contents = TAKE_PTR(buf); -+ *ret_contents = TAKE_PTR(buf); - -- if (size) -- *size = l; -+ if (ret_size) -+ *ret_size = l; - - return 0; - } -diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c -index 09b0179fa1..e64a27dd39 100644 ---- a/src/test/test-unit-file.c -+++ b/src/test/test-unit-file.c -@@ -532,7 +532,7 @@ static void test_load_env_file_1(void) { - - fd = mkostemp_safe(name); - assert_se(fd >= 0); -- assert_se(write(fd, env_file_1, sizeof(env_file_1)) == sizeof(env_file_1)); -+ assert_se(write(fd, env_file_1, strlen(env_file_1)) == strlen(env_file_1)); - - r = load_env_file(NULL, name, NULL, &data); - assert_se(r == 0); -@@ -554,7 +554,7 @@ static void test_load_env_file_2(void) { - - fd = mkostemp_safe(name); - assert_se(fd >= 0); -- assert_se(write(fd, env_file_2, sizeof(env_file_2)) == sizeof(env_file_2)); -+ assert_se(write(fd, env_file_2, strlen(env_file_2)) == strlen(env_file_2)); - - r = load_env_file(NULL, name, NULL, &data); - assert_se(r == 0); -@@ -571,7 +571,7 @@ static void test_load_env_file_3(void) { - - fd = mkostemp_safe(name); - assert_se(fd >= 0); -- assert_se(write(fd, env_file_3, sizeof(env_file_3)) == sizeof(env_file_3)); -+ assert_se(write(fd, env_file_3, strlen(env_file_3)) == strlen(env_file_3)); - - r = load_env_file(NULL, name, NULL, &data); - assert_se(r == 0); -@@ -586,7 +586,7 @@ static void test_load_env_file_4(void) { - - fd = mkostemp_safe(name); - assert_se(fd >= 0); -- assert_se(write(fd, env_file_4, sizeof(env_file_4)) == sizeof(env_file_4)); -+ assert_se(write(fd, env_file_4, strlen(env_file_4)) == strlen(env_file_4)); - - r = load_env_file(NULL, name, NULL, &data); - assert_se(r == 0); -@@ -605,7 +605,7 @@ static void test_load_env_file_5(void) { - - fd = mkostemp_safe(name); - assert_se(fd >= 0); -- assert_se(write(fd, env_file_5, sizeof(env_file_5)) == sizeof(env_file_5)); -+ assert_se(write(fd, env_file_5, strlen(env_file_5)) == strlen(env_file_5)); - - r = load_env_file(NULL, name, NULL, &data); - assert_se(r == 0); --- -2.39.1 - diff --git a/10014-util-introduce-explicit_bzero_safe-for-explicit-mem.patch b/10014-util-introduce-explicit_bzero_safe-for-explicit-mem.patch deleted file mode 100644 index c0ec4be..0000000 --- a/10014-util-introduce-explicit_bzero_safe-for-explicit-mem.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 17037ec625fca9e9a473a33954d011065f0088e3 Mon Sep 17 00:00:00 2001 -From: Guorui Yu -Date: Fri, 23 Jun 2023 13:01:24 +0800 -Subject: [PATCH] util: introduce explicit_bzero_safe for explicit memset - -(cherry picked from commit f441ae81ef70e9bdfddbb9e0a276bbb8ca2151d4) - -Signed-off-by: Guorui Yu ---- - src/basic/util.c | 18 ++++++++++++++++++ - src/basic/util.h | 11 +++++++++++ - 2 files changed, 29 insertions(+) - -diff --git a/src/basic/util.c b/src/basic/util.c -index 548e3652cc..bdfaca4aed 100644 ---- a/src/basic/util.c -+++ b/src/basic/util.c -@@ -684,3 +684,21 @@ void disable_coredumps(void) { - if (r < 0) - log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m"); - } -+ -+#if !HAVE_EXPLICIT_BZERO -+/* -+ * The pointer to memset() is volatile so that compiler must de-reference the pointer and can't assume that -+ * it points to any function in particular (such as memset(), which it then might further "optimize"). This -+ * approach is inspired by openssl's crypto/mem_clr.c. -+ */ -+typedef void *(*memset_t)(void *,int,size_t); -+ -+static volatile memset_t memset_func = memset; -+ -+void* explicit_bzero_safe(void *p, size_t l) { -+ if (l > 0) -+ memset_func(p, '\0', l); -+ -+ return p; -+} -+#endif -diff --git a/src/basic/util.h b/src/basic/util.h -index 195f02cf5f..ab3314f82e 100644 ---- a/src/basic/util.h -+++ b/src/basic/util.h -@@ -240,3 +240,14 @@ int version(void); - int str_verscmp(const char *s1, const char *s2); - - void disable_coredumps(void); -+ -+#if HAVE_EXPLICIT_BZERO -+static inline void* explicit_bzero_safe(void *p, size_t l) { -+ if (l > 0) -+ explicit_bzero(p, l); -+ -+ return p; -+} -+#else -+void *explicit_bzero_safe(void *p, size_t l); -+#endif --- -2.39.1 - diff --git a/10015-util-introduce-erase_and_free-helper.patch b/10015-util-introduce-erase_and_free-helper.patch deleted file mode 100644 index 43c42fc..0000000 --- a/10015-util-introduce-erase_and_free-helper.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 7c48fe64e3f1cdc61d9191d5e004d56d5244aa2c Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Thu, 8 Aug 2019 19:53:17 +0200 -Subject: [PATCH] util: introduce erase_and_free() helper - -(cherry picked from commit a20dda788d5a0f3b300e0d8bb34e45be335e2915) - -Signed-off-by: Guorui Yu ---- - src/basic/util.h | 18 ++++++++++++++++++ - 1 file changed, 18 insertions(+) - -diff --git a/src/basic/util.h b/src/basic/util.h -index ab3314f82e..4f4877b6b0 100644 ---- a/src/basic/util.h -+++ b/src/basic/util.h -@@ -5,6 +5,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -251,3 +252,20 @@ static inline void* explicit_bzero_safe(void *p, size_t l) { - #else - void *explicit_bzero_safe(void *p, size_t l); - #endif -+ -+static inline void* erase_and_free(void *p) { -+ size_t l; -+ -+ if (!p) -+ return NULL; -+ -+ l = malloc_usable_size(p); -+ explicit_bzero_safe(p, l); -+ free(p); -+ -+ return NULL; -+} -+ -+static inline void erase_and_freep(void *p) { -+ erase_and_free(*(void**) p); -+} --- -2.39.1 - diff --git a/10016-util-introduce-READ_FULL_FILE_SECURE-flag-for-readi.patch b/10016-util-introduce-READ_FULL_FILE_SECURE-flag-for-readi.patch deleted file mode 100644 index a37d579..0000000 --- a/10016-util-introduce-READ_FULL_FILE_SECURE-flag-for-readi.patch +++ /dev/null @@ -1,207 +0,0 @@ -From bc781489901fc6447cbd27b8d33f4f4439d6a5db Mon Sep 17 00:00:00 2001 -From: Yu Watanabe -Date: Mon, 8 Apr 2019 02:22:40 +0900 -Subject: [PATCH] util: introduce READ_FULL_FILE_SECURE flag for reading secure - data - -(cherry picked from commit e0721f97b05c0a5f782233711ea95c1e02ccba44) - -[Guorui Yu: include util.h for explicit_bzero_safe] -Signed-off-by: Guorui Yu ---- - src/basic/fileio.c | 68 ++++++++++++++++++++++++++++++++-------------- - src/basic/fileio.h | 16 +++++++++-- - 2 files changed, 60 insertions(+), 24 deletions(-) - -diff --git a/src/basic/fileio.c b/src/basic/fileio.c -index 9fef97ff0c..cf7c92ebc7 100644 ---- a/src/basic/fileio.c -+++ b/src/basic/fileio.c -@@ -35,6 +35,7 @@ - #include "time-util.h" - #include "umask-util.h" - #include "utf8.h" -+#include "util.h" - - #define READ_FULL_BYTES_MAX (4U*1024U*1024U) - -@@ -383,26 +384,27 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re - return 0; - } - --int read_full_stream( -+int read_full_stream_full( - FILE *f, -+ ReadFullFileFlags flags, - char **ret_contents, - size_t *ret_size) { - - _cleanup_free_ char *buf = NULL; - struct stat st; -- size_t n, l; -- int fd; -+ size_t n, n_next, l; -+ int fd, r; - - assert(f); - assert(ret_contents); - -- n = LINE_MAX; /* Start size */ -+ n_next = LINE_MAX; /* Start size */ - - fd = fileno(f); - if (fd >= 0) { /* If the FILE* object is backed by an fd (as opposed to memory or such, see fmemopen(), let's - * optimize our buffering) */ - -- if (fstat(fileno(f), &st) < 0) -+ if (fstat(fd, &st) < 0) - return -errno; - - if (S_ISREG(st.st_mode)) { -@@ -415,27 +417,41 @@ int read_full_stream( - * to read here by one, so that the first read attempt already - * makes us notice the EOF. */ - if (st.st_size > 0) -- n = st.st_size + 1; -+ n_next = st.st_size + 1; - } - } - -- l = 0; -+ n = l = 0; - for (;;) { - char *t; - size_t k; - -- t = realloc(buf, n + 1); -- if (!t) -- return -ENOMEM; -+ if (flags & READ_FULL_FILE_SECURE) { -+ t = malloc(n_next + 1); -+ if (!t) { -+ r = -ENOMEM; -+ goto finalize; -+ } -+ memcpy_safe(t, buf, n); -+ explicit_bzero_safe(buf, n); -+ } else { -+ t = realloc(buf, n_next + 1); -+ if (!t) -+ return -ENOMEM; -+ } - - buf = t; -+ n = n_next; -+ - errno = 0; - k = fread(buf + l, 1, n - l, f); - if (k > 0) - l += k; - -- if (ferror(f)) -- return errno > 0 ? -errno : -EIO; -+ if (ferror(f)) { -+ r = errno > 0 ? -errno : -EIO; -+ goto finalize; -+ } - - if (feof(f)) - break; -@@ -446,10 +462,12 @@ int read_full_stream( - assert(l == n); - - /* Safety check */ -- if (n >= READ_FULL_BYTES_MAX) -- return -E2BIG; -+ if (n >= READ_FULL_BYTES_MAX) { -+ r = -E2BIG; -+ goto finalize; -+ } - -- n = MIN(n * 2, READ_FULL_BYTES_MAX); -+ n_next = MIN(n * 2, READ_FULL_BYTES_MAX); - } - - if (!ret_size) { -@@ -457,8 +475,10 @@ int read_full_stream( - * trailing NUL byte. But if there's an embedded NUL byte, then we should refuse operation as otherwise - * there'd be ambiguity about what we just read. */ - -- if (memchr(buf, 0, l)) -- return -EBADMSG; -+ if (memchr(buf, 0, l)) { -+ r = -EBADMSG; -+ goto finalize; -+ } - } - - buf[l] = 0; -@@ -468,21 +488,27 @@ int read_full_stream( - *ret_size = l; - - return 0; -+ -+finalize: -+ if (flags & READ_FULL_FILE_SECURE) -+ explicit_bzero_safe(buf, n); -+ -+ return r; - } - --int read_full_file(const char *fn, char **contents, size_t *size) { -+int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **contents, size_t *size) { - _cleanup_fclose_ FILE *f = NULL; - -- assert(fn); -+ assert(filename); - assert(contents); - -- f = fopen(fn, "re"); -+ f = fopen(filename, "re"); - if (!f) - return -errno; - - (void) __fsetlocking(f, FSETLOCKING_BYCALLER); - -- return read_full_stream(f, contents, size); -+ return read_full_stream_full(f, flags, contents, size); - } - - static int parse_env_file_internal( -diff --git a/src/basic/fileio.h b/src/basic/fileio.h -index c6ad375b8d..06649ef7e6 100644 ---- a/src/basic/fileio.h -+++ b/src/basic/fileio.h -@@ -24,6 +24,10 @@ typedef enum { - - } WriteStringFileFlags; - -+typedef enum { -+ READ_FULL_FILE_SECURE = 1 << 0, -+} ReadFullFileFlags; -+ - int write_string_stream_ts(FILE *f, const char *line, WriteStringFileFlags flags, struct timespec *ts); - static inline int write_string_stream(FILE *f, const char *line, WriteStringFileFlags flags) { - return write_string_stream_ts(f, line, flags, NULL); -@@ -35,9 +39,15 @@ static inline int write_string_file(const char *fn, const char *line, WriteStrin - - int write_string_filef(const char *fn, WriteStringFileFlags flags, const char *format, ...) _printf_(3, 4); - --int read_one_line_file(const char *fn, char **line); --int read_full_file(const char *fn, char **contents, size_t *size); --int read_full_stream(FILE *f, char **contents, size_t *size); -+int read_one_line_file(const char *filename, char **line); -+int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); -+static inline int read_full_file(const char *filename, char **contents, size_t *size) { -+ return read_full_file_full(filename, 0, contents, size); -+} -+int read_full_stream_full(FILE *f, ReadFullFileFlags flags, char **contents, size_t *size); -+static inline int read_full_stream(FILE *f, char **contents, size_t *size) { -+ return read_full_stream_full(f, 0, contents, size); -+} - int read_full_virtual_file(const char *filename, char **ret_contents, size_t *ret_size); - - int verify_file(const char *fn, const char *blob, bool accept_extra_nl); --- -2.39.1 - diff --git a/10017-fileio-introduce-warn_file_is_world_accessible.patch b/10017-fileio-introduce-warn_file_is_world_accessible.patch deleted file mode 100644 index 02f9518..0000000 --- a/10017-fileio-introduce-warn_file_is_world_accessible.patch +++ /dev/null @@ -1,67 +0,0 @@ -From e4c4f0bc712e43776c4f58712f47260711607098 Mon Sep 17 00:00:00 2001 -From: Yu Watanabe -Date: Mon, 8 Apr 2019 03:48:30 +0900 -Subject: [PATCH] fileio: introduce warn_file_is_world_accessible() - -(cherry picked from commit fc0895034d4811e8c6b263c0d902b31535613d76) - -Signed-off-by: Guorui Yu ---- - src/basic/fileio.c | 25 +++++++++++++++++++++++++ - src/basic/fileio.h | 3 +++ - 2 files changed, 28 insertions(+) - -diff --git a/src/basic/fileio.c b/src/basic/fileio.c -index cf7c92ebc7..2e74aac554 100644 ---- a/src/basic/fileio.c -+++ b/src/basic/fileio.c -@@ -1797,3 +1797,28 @@ int read_line(FILE *f, size_t limit, char **ret) { - - return (int) count; - } -+ -+int warn_file_is_world_accessible(const char *filename, struct stat *st, const char *unit, unsigned line) { -+ struct stat _st; -+ -+ if (!filename) -+ return 0; -+ -+ if (!st) { -+ if (stat(filename, &_st) < 0) -+ return -errno; -+ st = &_st; -+ } -+ -+ if ((st->st_mode & S_IRWXO) == 0) -+ return 0; -+ -+ if (unit) -+ log_syntax(unit, LOG_WARNING, filename, line, 0, -+ "%s has %04o mode that is too permissive, please adjust the access mode.", -+ filename, st->st_mode & 07777); -+ else -+ log_warning("%s has %04o mode that is too permissive, please adjust the access mode.", -+ filename, st->st_mode & 07777); -+ return 0; -+} -diff --git a/src/basic/fileio.h b/src/basic/fileio.h -index 06649ef7e6..2c9ce4355b 100644 ---- a/src/basic/fileio.h -+++ b/src/basic/fileio.h -@@ -5,6 +5,7 @@ - #include - #include - #include -+#include - #include - - #include "macro.h" -@@ -105,3 +106,5 @@ int read_nul_string(FILE *f, char **ret); - int mkdtemp_malloc(const char *template, char **ret); - - int read_line(FILE *f, size_t limit, char **ret); -+ -+int warn_file_is_world_accessible(const char *filename, struct stat *st, const char *unit, unsigned line); --- -2.39.1 - diff --git a/10018-fileio-read_full_file_full-also-warns-when-file-is-.patch b/10018-fileio-read_full_file_full-also-warns-when-file-is-.patch deleted file mode 100644 index af813a5..0000000 --- a/10018-fileio-read_full_file_full-also-warns-when-file-is-.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 0dbf69ccdfa7b1f99935c3932445fbfa16dbbe75 Mon Sep 17 00:00:00 2001 -From: Yu Watanabe -Date: Mon, 8 Apr 2019 14:15:10 +0900 -Subject: [PATCH] fileio: read_full_file_full() also warns when file is world - readable and secure flag is set - -(cherry picked from commit 65dcd394d8223bc6bc194f3fe5bd70fed9d9a4fe) - -Signed-off-by: Guorui Yu ---- - src/basic/fileio.c | 6 +++++- - src/basic/fileio.h | 4 ++-- - 2 files changed, 7 insertions(+), 3 deletions(-) - -diff --git a/src/basic/fileio.c b/src/basic/fileio.c -index 2e74aac554..3abeb0d7f4 100644 ---- a/src/basic/fileio.c -+++ b/src/basic/fileio.c -@@ -386,6 +386,7 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re - - int read_full_stream_full( - FILE *f, -+ const char *filename, - ReadFullFileFlags flags, - char **ret_contents, - size_t *ret_size) { -@@ -418,6 +419,9 @@ int read_full_stream_full( - * makes us notice the EOF. */ - if (st.st_size > 0) - n_next = st.st_size + 1; -+ -+ if (flags & READ_FULL_FILE_SECURE) -+ (void) warn_file_is_world_accessible(filename, &st, NULL, 0); - } - } - -@@ -508,7 +512,7 @@ int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **co - - (void) __fsetlocking(f, FSETLOCKING_BYCALLER); - -- return read_full_stream_full(f, flags, contents, size); -+ return read_full_stream_full(f, filename, flags, contents, size); - } - - static int parse_env_file_internal( -diff --git a/src/basic/fileio.h b/src/basic/fileio.h -index 2c9ce4355b..3e572dc0de 100644 ---- a/src/basic/fileio.h -+++ b/src/basic/fileio.h -@@ -45,9 +45,9 @@ int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **co - static inline int read_full_file(const char *filename, char **contents, size_t *size) { - return read_full_file_full(filename, 0, contents, size); - } --int read_full_stream_full(FILE *f, ReadFullFileFlags flags, char **contents, size_t *size); -+int read_full_stream_full(FILE *f, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); - static inline int read_full_stream(FILE *f, char **contents, size_t *size) { -- return read_full_stream_full(f, 0, contents, size); -+ return read_full_stream_full(f, NULL, 0, contents, size); - } - int read_full_virtual_file(const char *filename, char **ret_contents, size_t *ret_size); - --- -2.39.1 - diff --git a/10019-basic-fileio-Fix-memory-leak-if-READ_FULL_FILE_SECU.patch b/10019-basic-fileio-Fix-memory-leak-if-READ_FULL_FILE_SECU.patch deleted file mode 100644 index e434089..0000000 --- a/10019-basic-fileio-Fix-memory-leak-if-READ_FULL_FILE_SECU.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 14e0760c251fd5fc51731f7b58079c73f5055d64 Mon Sep 17 00:00:00 2001 -From: Benjamin Robin -Date: Sun, 14 Apr 2019 17:21:27 +0200 -Subject: [PATCH] basic/fileio: Fix memory leak if READ_FULL_FILE_SECURE flag - is used - -The memory leak introduced in #12223 (15f8f02) - -(cherry picked from commit 315a51982af2d480de9f7539346f30425e37a01e) - -Signed-off-by: Guorui Yu ---- - src/basic/fileio.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/basic/fileio.c b/src/basic/fileio.c -index 3abeb0d7f4..bb804e3afa 100644 ---- a/src/basic/fileio.c -+++ b/src/basic/fileio.c -@@ -438,6 +438,7 @@ int read_full_stream_full( - } - memcpy_safe(t, buf, n); - explicit_bzero_safe(buf, n); -+ buf = mfree(buf); - } else { - t = realloc(buf, n_next + 1); - if (!t) --- -2.39.1 - diff --git a/1002-udev-net_id-introduce-naming-scheme-for-RHEL-8.10.patch b/1002-udev-net_id-introduce-naming-scheme-for-RHEL-8.10.patch new file mode 100644 index 0000000..5da176e --- /dev/null +++ b/1002-udev-net_id-introduce-naming-scheme-for-RHEL-8.10.patch @@ -0,0 +1,50 @@ +From 9d9c3d38451befec0494aea4fdb12c65289b0b46 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Tue, 23 Jan 2024 15:15:00 +0100 +Subject: [PATCH] udev/net_id: introduce naming scheme for RHEL-8.10 + +rhel-only + +Resolves: RHEL-22426 +--- + man/systemd.net-naming-scheme.xml | 6 ++++++ + src/udev/udev-builtin-net_id.c | 2 ++ + 2 files changed, 8 insertions(+) + +diff --git a/man/systemd.net-naming-scheme.xml b/man/systemd.net-naming-scheme.xml +index ddd41646ae..25e8bd9aea 100644 +--- a/man/systemd.net-naming-scheme.xml ++++ b/man/systemd.net-naming-scheme.xml +@@ -340,6 +340,12 @@ + Same as naming scheme rhel-8.7. + + ++ ++ rhel-8.10 ++ ++ Same as naming scheme rhel-8.7. ++ ++ + Note that latest may be used to denote the latest scheme known to this + particular version of systemd. + +diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c +index 0f42c1c007..ece5d29205 100644 +--- a/src/udev/udev-builtin-net_id.c ++++ b/src/udev/udev-builtin-net_id.c +@@ -143,6 +143,7 @@ typedef enum NamingSchemeFlags { + NAMING_RHEL_8_7 = NAMING_RHEL_8_4|NAMING_SLOT_FUNCTION_ID|NAMING_16BIT_INDEX, + NAMING_RHEL_8_8 = NAMING_RHEL_8_7, + NAMING_RHEL_8_9 = NAMING_RHEL_8_7, ++ NAMING_RHEL_8_10 = NAMING_RHEL_8_7, + + _NAMING_SCHEME_FLAGS_INVALID = -1, + } NamingSchemeFlags; +@@ -165,6 +166,7 @@ static const NamingScheme naming_schemes[] = { + { "rhel-8.7", NAMING_RHEL_8_7 }, + { "rhel-8.8", NAMING_RHEL_8_8 }, + { "rhel-8.9", NAMING_RHEL_8_9 }, ++ { "rhel-8.10", NAMING_RHEL_8_10 }, + /* … add more schemes here, as the logic to name devices is updated … */ + }; + diff --git a/10020-fileio-add-explicit-flag-for-generating-world-execu.patch b/10020-fileio-add-explicit-flag-for-generating-world-execu.patch deleted file mode 100644 index 1a93b5a..0000000 --- a/10020-fileio-add-explicit-flag-for-generating-world-execu.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 1e0dcd6fa1abea9c561f46556f7f7561b2a46e62 Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Fri, 17 Jul 2020 11:53:22 +0200 -Subject: [PATCH] fileio: add explicit flag for generating world executable - warning when reading file - -(cherry picked from commit 684aa979f1c4ce5f75ccdc131f32fc0434999918) - -Signed-off-by: Guorui Yu ---- - src/basic/fileio.c | 2 +- - src/basic/fileio.h | 3 ++- - 2 files changed, 3 insertions(+), 2 deletions(-) - -diff --git a/src/basic/fileio.c b/src/basic/fileio.c -index bb804e3afa..833c55b030 100644 ---- a/src/basic/fileio.c -+++ b/src/basic/fileio.c -@@ -420,7 +420,7 @@ int read_full_stream_full( - if (st.st_size > 0) - n_next = st.st_size + 1; - -- if (flags & READ_FULL_FILE_SECURE) -+ if (flags & READ_FULL_FILE_WARN_WORLD_READABLE) - (void) warn_file_is_world_accessible(filename, &st, NULL, 0); - } - } -diff --git a/src/basic/fileio.h b/src/basic/fileio.h -index 3e572dc0de..be10ac77b6 100644 ---- a/src/basic/fileio.h -+++ b/src/basic/fileio.h -@@ -26,7 +26,8 @@ typedef enum { - } WriteStringFileFlags; - - typedef enum { -- READ_FULL_FILE_SECURE = 1 << 0, -+ READ_FULL_FILE_SECURE = 1 << 0, -+ READ_FULL_FILE_WARN_WORLD_READABLE = 1 << 3, - } ReadFullFileFlags; - - int write_string_stream_ts(FILE *f, const char *line, WriteStringFileFlags flags, struct timespec *ts); --- -2.39.1 - diff --git a/10021-fileio-add-dir_fd-parameter-to-read_full_file_full.patch b/10021-fileio-add-dir_fd-parameter-to-read_full_file_full.patch deleted file mode 100644 index f6dc153..0000000 --- a/10021-fileio-add-dir_fd-parameter-to-read_full_file_full.patch +++ /dev/null @@ -1,142 +0,0 @@ -From 3f4ca11498028756ebde239ae469c0f88e5d3ecc Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Tue, 8 Jan 2019 18:29:36 +0100 -Subject: [PATCH] fileio: add 'dir_fd' parameter to read_full_file_full() - -Let's introduce an "at" version of read_full_file(). - -(cherry picked from commit f6be4db4530b7cfea191227c141343a4fb10d4c6) - -Signed-off-by: Guorui Yu ---- - src/basic/fileio.c | 84 +++++++++++++++++++++++++++++++++++++++++++--- - src/basic/fileio.h | 5 +-- - 2 files changed, 83 insertions(+), 6 deletions(-) - -diff --git a/src/basic/fileio.c b/src/basic/fileio.c -index 833c55b030..d7da834a74 100644 ---- a/src/basic/fileio.c -+++ b/src/basic/fileio.c -@@ -501,15 +501,91 @@ finalize: - return r; - } - --int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **contents, size_t *size) { -+static int mode_to_flags(const char *mode) { -+ const char *p; -+ int flags; -+ -+ if ((p = startswith(mode, "r+"))) -+ flags = O_RDWR; -+ else if ((p = startswith(mode, "r"))) -+ flags = O_RDONLY; -+ else if ((p = startswith(mode, "w+"))) -+ flags = O_RDWR|O_CREAT|O_TRUNC; -+ else if ((p = startswith(mode, "w"))) -+ flags = O_WRONLY|O_CREAT|O_TRUNC; -+ else if ((p = startswith(mode, "a+"))) -+ flags = O_RDWR|O_CREAT|O_APPEND; -+ else if ((p = startswith(mode, "a"))) -+ flags = O_WRONLY|O_CREAT|O_APPEND; -+ else -+ return -EINVAL; -+ -+ for (; *p != 0; p++) { -+ -+ switch (*p) { -+ -+ case 'e': -+ flags |= O_CLOEXEC; -+ break; -+ -+ case 'x': -+ flags |= O_EXCL; -+ break; -+ -+ case 'm': -+ /* ignore this here, fdopen() might care later though */ -+ break; -+ -+ case 'c': /* not sure what to do about this one */ -+ default: -+ return -EINVAL; -+ } -+ } -+ -+ return flags; -+} -+ -+static int xfopenat(int dir_fd, const char *path, const char *mode, int flags, FILE **ret) { -+ FILE *f; -+ -+ /* A combination of fopen() with openat() */ -+ -+ if (dir_fd == AT_FDCWD && flags == 0) { -+ f = fopen(path, mode); -+ if (!f) -+ return -errno; -+ } else { -+ int fd, mode_flags; -+ -+ mode_flags = mode_to_flags(mode); -+ if (mode_flags < 0) -+ return mode_flags; -+ -+ fd = openat(dir_fd, path, mode_flags | flags); -+ if (fd < 0) -+ return -errno; -+ -+ f = fdopen(fd, mode); -+ if (!f) { -+ safe_close(fd); -+ return -errno; -+ } -+ } -+ -+ *ret = f; -+ return 0; -+} -+ -+int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size) { - _cleanup_fclose_ FILE *f = NULL; -+ int r; - - assert(filename); - assert(contents); - -- f = fopen(filename, "re"); -- if (!f) -- return -errno; -+ r = xfopenat(dir_fd, filename, "re", 0, &f); -+ if (r < 0) -+ return r; - - (void) __fsetlocking(f, FSETLOCKING_BYCALLER); - -diff --git a/src/basic/fileio.h b/src/basic/fileio.h -index be10ac77b6..916ddc5e47 100644 ---- a/src/basic/fileio.h -+++ b/src/basic/fileio.h -@@ -6,6 +6,7 @@ - #include - #include - #include -+#include - #include - - #include "macro.h" -@@ -42,9 +43,9 @@ static inline int write_string_file(const char *fn, const char *line, WriteStrin - int write_string_filef(const char *fn, WriteStringFileFlags flags, const char *format, ...) _printf_(3, 4); - - int read_one_line_file(const char *filename, char **line); --int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); -+int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); - static inline int read_full_file(const char *filename, char **contents, size_t *size) { -- return read_full_file_full(filename, 0, contents, size); -+ return read_full_file_full(AT_FDCWD, filename, 0, contents, size); - } - int read_full_stream_full(FILE *f, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); - static inline int read_full_stream(FILE *f, char **contents, size_t *size) { --- -2.39.1 - diff --git a/10022-fileio-add-support-for-read_full_file-on-AF_UNIX-st.patch b/10022-fileio-add-support-for-read_full_file-on-AF_UNIX-st.patch deleted file mode 100644 index bb392bc..0000000 --- a/10022-fileio-add-support-for-read_full_file-on-AF_UNIX-st.patch +++ /dev/null @@ -1,271 +0,0 @@ -From 054669a4cc4897792b6c209fd55ab1fc1d7b9bd5 Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Fri, 17 Jul 2020 12:26:01 +0200 -Subject: [PATCH] fileio: add support for read_full_file() on AF_UNIX stream - sockets - -Optionally, teach read_full_file() the ability to connect to an AF_UNIX -socket if the specified path points to one. - -(cherry picked from commit 412b888ec803cdf96fb1d005bb245d20abdb8f2e) - -[Guorui Yu: Adds sockaddr_un_set_path function to socket-util.{c,h}] -Signed-off-by: Guorui Yu ---- - src/basic/fileio.c | 62 +++++++++++++++++++++++++++++++++++------ - src/basic/fileio.h | 1 + - src/basic/socket-util.c | 42 ++++++++++++++++++++++++++++ - src/basic/socket-util.h | 1 + - src/test/test-fileio.c | 50 +++++++++++++++++++++++++++++++++ - 5 files changed, 147 insertions(+), 9 deletions(-) - -diff --git a/src/basic/fileio.c b/src/basic/fileio.c -index d7da834a74..9cb0a2bd28 100644 ---- a/src/basic/fileio.c -+++ b/src/basic/fileio.c -@@ -27,6 +27,7 @@ - #include "missing.h" - #include "parse-util.h" - #include "path-util.h" -+#include "socket-util.h" - #include "process-util.h" - #include "random-util.h" - #include "stdio-util.h" -@@ -450,21 +451,18 @@ int read_full_stream_full( - - errno = 0; - k = fread(buf + l, 1, n - l, f); -- if (k > 0) -- l += k; -+ -+ assert(k <= n - l); -+ l += k; - - if (ferror(f)) { - r = errno > 0 ? -errno : -EIO; - goto finalize; - } -- - if (feof(f)) - break; - -- /* We aren't expecting fread() to return a short read outside -- * of (error && eof), assert buffer is full and enlarge buffer. -- */ -- assert(l == n); -+ assert(k > 0); /* we can't have read zero bytes because that would have been EOF */ - - /* Safety check */ - if (n >= READ_FULL_BYTES_MAX) { -@@ -584,8 +582,54 @@ int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flag - assert(contents); - - r = xfopenat(dir_fd, filename, "re", 0, &f); -- if (r < 0) -- return r; -+ if (r < 0) { -+ _cleanup_close_ int dfd = -1, sk = -1; -+ union sockaddr_union sa; -+ -+ /* ENXIO is what Linux returns if we open a node that is an AF_UNIX socket */ -+ if (r != -ENXIO) -+ return r; -+ -+ /* If this is enabled, let's try to connect to it */ -+ if (!FLAGS_SET(flags, READ_FULL_FILE_CONNECT_SOCKET)) -+ return -ENXIO; -+ -+ if (dir_fd == AT_FDCWD) -+ r = sockaddr_un_set_path(&sa.un, filename); -+ else { -+ char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; -+ -+ /* If we shall operate relative to some directory, then let's use O_PATH first to -+ * open the socket inode, and then connect to it via /proc/self/fd/. We have to do -+ * this since there's not connectat() that takes a directory fd as first arg. */ -+ -+ dfd = openat(dir_fd, filename, O_PATH|O_CLOEXEC); -+ if (dfd < 0) -+ return -errno; -+ -+ xsprintf(procfs_path, "/proc/self/fd/%i", dfd); -+ r = sockaddr_un_set_path(&sa.un, procfs_path); -+ } -+ if (r < 0) -+ return r; -+ -+ sk = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0); -+ if (sk < 0) -+ return -errno; -+ -+ if (connect(sk, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0) -+ return errno == ENOTSOCK ? -ENXIO : -errno; /* propagate original error if this is -+ * not a socket after all */ -+ -+ if (shutdown(sk, SHUT_WR) < 0) -+ return -errno; -+ -+ f = fdopen(sk, "r"); -+ if (!f) -+ return -errno; -+ -+ TAKE_FD(sk); -+ } - - (void) __fsetlocking(f, FSETLOCKING_BYCALLER); - -diff --git a/src/basic/fileio.h b/src/basic/fileio.h -index 916ddc5e47..1a16e0fd13 100644 ---- a/src/basic/fileio.h -+++ b/src/basic/fileio.h -@@ -29,6 +29,7 @@ typedef enum { - typedef enum { - READ_FULL_FILE_SECURE = 1 << 0, - READ_FULL_FILE_WARN_WORLD_READABLE = 1 << 3, -+ READ_FULL_FILE_CONNECT_SOCKET = 1 << 4, - } ReadFullFileFlags; - - int write_string_stream_ts(FILE *f, const char *line, WriteStringFileFlags flags, struct timespec *ts); -diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c -index 7f8066123b..427c8b89bb 100644 ---- a/src/basic/socket-util.c -+++ b/src/basic/socket-util.c -@@ -1253,6 +1253,48 @@ int socket_ioctl_fd(void) { - return fd; - } - -+int sockaddr_un_set_path(struct sockaddr_un *ret, const char *path) { -+ size_t l; -+ -+ assert(ret); -+ assert(path); -+ -+ /* Initialize ret->sun_path from the specified argument. This will interpret paths starting with '@' as -+ * abstract namespace sockets, and those starting with '/' as regular filesystem sockets. It won't accept -+ * anything else (i.e. no relative paths), to avoid ambiguities. Note that this function cannot be used to -+ * reference paths in the abstract namespace that include NUL bytes in the name. */ -+ -+ l = strlen(path); -+ if (l < 2) -+ return -EINVAL; -+ if (!IN_SET(path[0], '/', '@')) -+ return -EINVAL; -+ -+ /* Don't allow paths larger than the space in sockaddr_un. Note that we are a tiny bit more restrictive than -+ * the kernel is: we insist on NUL termination (both for abstract namespace and regular file system socket -+ * addresses!), which the kernel doesn't. We do this to reduce chance of incompatibility with other apps that -+ * do not expect non-NUL terminated file system path*/ -+ if (l+1 > sizeof(ret->sun_path)) -+ return -EINVAL; -+ -+ *ret = (struct sockaddr_un) { -+ .sun_family = AF_UNIX, -+ }; -+ -+ if (path[0] == '@') { -+ /* Abstract namespace socket */ -+ memcpy(ret->sun_path + 1, path + 1, l); /* copy *with* trailing NUL byte */ -+ return (int) (offsetof(struct sockaddr_un, sun_path) + l); /* 🔥 *don't* 🔥 include trailing NUL in size */ -+ -+ } else { -+ assert(path[0] == '/'); -+ -+ /* File system socket */ -+ memcpy(ret->sun_path, path, l + 1); /* copy *with* trailing NUL byte */ -+ return (int) (offsetof(struct sockaddr_un, sun_path) + l + 1); /* include trailing NUL in size */ -+ } -+} -+ - int socket_pass_pktinfo(int fd, bool b) { - int af; - socklen_t sl = sizeof(af); -diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h -index 30baba6c03..36edc58caf 100644 ---- a/src/basic/socket-util.h -+++ b/src/basic/socket-util.h -@@ -186,6 +186,7 @@ struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t leng - }) - - int socket_ioctl_fd(void); -+int sockaddr_un_set_path(struct sockaddr_un *ret, const char *path); - - static inline int setsockopt_int(int fd, int level, int optname, int value) { - if (setsockopt(fd, level, optname, &value, sizeof(value)) < 0) -diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c -index 14ba075144..82b7cb1242 100644 ---- a/src/test/test-fileio.c -+++ b/src/test/test-fileio.c -@@ -14,6 +14,8 @@ - #include "io-util.h" - #include "parse-util.h" - #include "process-util.h" -+#include "rm-rf.h" -+#include "socket-util.h" - #include "string-util.h" - #include "strv.h" - #include "util.h" -@@ -709,6 +711,53 @@ static void test_read_line3(void) { - assert_se(read_line(f, LINE_MAX, NULL) == 0); - } - -+static void test_read_full_file_socket(void) { -+ _cleanup_(rm_rf_physical_and_freep) char *z = NULL; -+ _cleanup_close_ int listener = -1; -+ _cleanup_free_ char *data = NULL; -+ union sockaddr_union sa; -+ const char *j; -+ size_t size; -+ pid_t pid; -+ int r; -+ -+ log_info("/* %s */", __func__); -+ -+ listener = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0); -+ assert_se(listener >= 0); -+ -+ assert_se(mkdtemp_malloc(NULL, &z) >= 0); -+ j = strjoina(z, "/socket"); -+ -+ assert_se(sockaddr_un_set_path(&sa.un, j) >= 0); -+ -+ assert_se(bind(listener, &sa.sa, SOCKADDR_UN_LEN(sa.un)) >= 0); -+ assert_se(listen(listener, 1) >= 0); -+ -+ r = safe_fork("(server)", FORK_DEATHSIG|FORK_LOG, &pid); -+ assert_se(r >= 0); -+ if (r == 0) { -+ _cleanup_close_ int rfd = -1; -+ /* child */ -+ -+ rfd = accept4(listener, NULL, 0, SOCK_CLOEXEC); -+ assert_se(rfd >= 0); -+ -+#define TEST_STR "This is a test\nreally." -+ -+ assert_se(write(rfd, TEST_STR, strlen(TEST_STR)) == strlen(TEST_STR)); -+ _exit(EXIT_SUCCESS); -+ } -+ -+ assert_se(read_full_file_full(AT_FDCWD, j, 0, &data, &size) == -ENXIO); -+ assert_se(read_full_file_full(AT_FDCWD, j, READ_FULL_FILE_CONNECT_SOCKET, &data, &size) >= 0); -+ assert_se(size == strlen(TEST_STR)); -+ assert_se(streq(data, TEST_STR)); -+ -+ assert_se(wait_for_terminate_and_check("(server)", pid, WAIT_LOG) >= 0); -+#undef TEST_STR -+} -+ - int main(int argc, char *argv[]) { - log_set_max_level(LOG_DEBUG); - log_parse_environment(); -@@ -733,6 +782,7 @@ int main(int argc, char *argv[]) { - test_read_line(); - test_read_line2(); - test_read_line3(); -+ test_read_full_file_socket(); - - return 0; - } --- -2.39.1 - diff --git a/10023-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch b/10023-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch deleted file mode 100644 index 2edc538..0000000 --- a/10023-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch +++ /dev/null @@ -1,181 +0,0 @@ -From 0717de25e6508b10ea034fa1b96675f18100ac01 Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Mon, 2 Nov 2020 12:07:51 +0100 -Subject: [PATCH] fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow - setting sender socket name - -This beefs up the READ_FULL_FILE_CONNECT_SOCKET logic of -read_full_file_full() a bit: when used a sender socket name may be -specified. If specified as NULL behaviour is as before: the client -socket name is picked by the kernel. But if specified as non-NULL the -client can pick a socket name to use when connecting. This is useful to -communicate a minimal amount of metainformation from client to server, -outside of the transport payload. - -Specifically, these beefs up the service credential logic to pass an -abstract AF_UNIX socket name as client socket name when connecting via -READ_FULL_FILE_CONNECT_SOCKET, that includes the requesting unit name -and the eventual credential name. This allows servers implementing the -trivial credential socket logic to distinguish clients: via a simple -getpeername() it can be determined which unit is requesting a -credential, and which credential specifically. - -Example: with this patch in place, in a unit file "waldo.service" a -configuration line like the following: - - LoadCredential=foo:/run/quux/creds.sock - -will result in a connection to the AF_UNIX socket /run/quux/creds.sock, -originating from an abstract namespace AF_UNIX socket: - - @$RANDOM/unit/waldo.service/foo - -(The $RANDOM is replaced by some randomized string. This is included in -the socket name order to avoid namespace squatting issues: the abstract -socket namespace is open to unprivileged users after all, and care needs -to be taken not to use guessable names) - -The services listening on the /run/quux/creds.sock socket may thus -easily retrieve the name of the unit the credential is requested for -plus the credential name, via a simpler getpeername(), discarding the -random preifx and the /unit/ string. - -This logic uses "/" as separator between the fields, since both unit -names and credential names appear in the file system, and thus are -designed to use "/" as outer separators. Given that it's a good safe -choice to use as separators here, too avoid any conflicts. - -This is a minimal patch only: the new logic is used only for the unit -file credential logic. For other places where we use -READ_FULL_FILE_CONNECT_SOCKET it is probably a good idea to use this -scheme too, but this should be done carefully in later patches, since -the socket names become API that way, and we should determine the right -amount of info to pass over. - -(cherry picked from commit 142e9756c98c69cdd5d03df4028700acb5739f72) - -Signed-off-by: Guorui Yu ---- - src/basic/fileio.c | 22 +++++++++++++++++++++- - src/basic/fileio.h | 4 ++-- - src/test/test-fileio.c | 19 ++++++++++++++++--- - 3 files changed, 39 insertions(+), 6 deletions(-) - -diff --git a/src/basic/fileio.c b/src/basic/fileio.c -index 9cb0a2bd28..35eaa3c1c7 100644 ---- a/src/basic/fileio.c -+++ b/src/basic/fileio.c -@@ -574,7 +574,13 @@ static int xfopenat(int dir_fd, const char *path, const char *mode, int flags, F - return 0; - } - --int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size) { -+int read_full_file_full( -+ int dir_fd, -+ const char *filename, -+ ReadFullFileFlags flags, -+ const char *bind_name, -+ char **contents, size_t *size) { -+ - _cleanup_fclose_ FILE *f = NULL; - int r; - -@@ -617,6 +623,20 @@ int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flag - if (sk < 0) - return -errno; - -+ if (bind_name) { -+ /* If the caller specified a socket name to bind to, do so before connecting. This is -+ * useful to communicate some minor, short meta-information token from the client to -+ * the server. */ -+ union sockaddr_union bsa; -+ -+ r = sockaddr_un_set_path(&bsa.un, bind_name); -+ if (r < 0) -+ return r; -+ -+ if (bind(sk, &bsa.sa, r) < 0) -+ return r; -+ } -+ - if (connect(sk, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0) - return errno == ENOTSOCK ? -ENXIO : -errno; /* propagate original error if this is - * not a socket after all */ -diff --git a/src/basic/fileio.h b/src/basic/fileio.h -index 1a16e0fd13..82897e209c 100644 ---- a/src/basic/fileio.h -+++ b/src/basic/fileio.h -@@ -44,9 +44,9 @@ static inline int write_string_file(const char *fn, const char *line, WriteStrin - int write_string_filef(const char *fn, WriteStringFileFlags flags, const char *format, ...) _printf_(3, 4); - - int read_one_line_file(const char *filename, char **line); --int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); -+int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flags, const char *bind_name, char **contents, size_t *size); - static inline int read_full_file(const char *filename, char **contents, size_t *size) { -- return read_full_file_full(AT_FDCWD, filename, 0, contents, size); -+ return read_full_file_full(AT_FDCWD, filename, 0, NULL, contents, size); - } - int read_full_stream_full(FILE *f, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); - static inline int read_full_stream(FILE *f, char **contents, size_t *size) { -diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c -index 82b7cb1242..5ec70eec14 100644 ---- a/src/test/test-fileio.c -+++ b/src/test/test-fileio.c -@@ -14,6 +14,7 @@ - #include "io-util.h" - #include "parse-util.h" - #include "process-util.h" -+#include "random-util.h" - #include "rm-rf.h" - #include "socket-util.h" - #include "string-util.h" -@@ -714,7 +715,7 @@ static void test_read_line3(void) { - static void test_read_full_file_socket(void) { - _cleanup_(rm_rf_physical_and_freep) char *z = NULL; - _cleanup_close_ int listener = -1; -- _cleanup_free_ char *data = NULL; -+ _cleanup_free_ char *data = NULL, *clientname = NULL; - union sockaddr_union sa; - const char *j; - size_t size; -@@ -734,23 +735,35 @@ static void test_read_full_file_socket(void) { - assert_se(bind(listener, &sa.sa, SOCKADDR_UN_LEN(sa.un)) >= 0); - assert_se(listen(listener, 1) >= 0); - -+ /* Bind the *client* socket to some randomized name, to verify that this works correctly. */ -+ assert_se(asprintf(&clientname, "@%" PRIx64 "/test-bindname", random_u64()) >= 0); -+ - r = safe_fork("(server)", FORK_DEATHSIG|FORK_LOG, &pid); - assert_se(r >= 0); - if (r == 0) { -+ union sockaddr_union peer = {}; -+ socklen_t peerlen = sizeof(peer); - _cleanup_close_ int rfd = -1; - /* child */ - - rfd = accept4(listener, NULL, 0, SOCK_CLOEXEC); - assert_se(rfd >= 0); - -+ assert_se(getpeername(rfd, &peer.sa, &peerlen) >= 0); -+ -+ assert_se(peer.un.sun_family == AF_UNIX); -+ assert_se(peerlen > offsetof(struct sockaddr_un, sun_path)); -+ assert_se(peer.un.sun_path[0] == 0); -+ assert_se(streq(peer.un.sun_path + 1, clientname + 1)); -+ - #define TEST_STR "This is a test\nreally." - - assert_se(write(rfd, TEST_STR, strlen(TEST_STR)) == strlen(TEST_STR)); - _exit(EXIT_SUCCESS); - } - -- assert_se(read_full_file_full(AT_FDCWD, j, 0, &data, &size) == -ENXIO); -- assert_se(read_full_file_full(AT_FDCWD, j, READ_FULL_FILE_CONNECT_SOCKET, &data, &size) >= 0); -+ assert_se(read_full_file_full(AT_FDCWD, j, 0, NULL, &data, &size) == -ENXIO); -+ assert_se(read_full_file_full(AT_FDCWD, j, READ_FULL_FILE_CONNECT_SOCKET, clientname, &data, &size) >= 0); - assert_se(size == strlen(TEST_STR)); - assert_se(streq(data, TEST_STR)); - --- -2.39.1 - diff --git a/10024-fileio-teach-read_full_file_full-to-read-from-offse.patch b/10024-fileio-teach-read_full_file_full-to-read-from-offse.patch deleted file mode 100644 index 08e8f40..0000000 --- a/10024-fileio-teach-read_full_file_full-to-read-from-offse.patch +++ /dev/null @@ -1,246 +0,0 @@ -From 5be0e8a2c3e683c195fd872979d6e5741c80d13f Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Wed, 4 Nov 2020 20:25:06 +0100 -Subject: [PATCH] fileio: teach read_full_file_full() to read from offset/with - maximum size - -(cherry picked from commit 7399b3f8083b65db4cb9acb17e4b5c897ba7946d) - -Signed-off-by: Guorui Yu ---- - src/basic/fileio.c | 60 ++++++++++++++++++++++++++++++------------ - src/basic/fileio.h | 12 ++++----- - src/test/test-fileio.c | 49 ++++++++++++++++++++++++++++++++-- - 3 files changed, 96 insertions(+), 25 deletions(-) - -diff --git a/src/basic/fileio.c b/src/basic/fileio.c -index 35eaa3c1c7..c14f9797bd 100644 ---- a/src/basic/fileio.c -+++ b/src/basic/fileio.c -@@ -388,44 +388,58 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re - int read_full_stream_full( - FILE *f, - const char *filename, -+ uint64_t offset, -+ size_t size, - ReadFullFileFlags flags, - char **ret_contents, - size_t *ret_size) { - - _cleanup_free_ char *buf = NULL; -- struct stat st; - size_t n, n_next, l; - int fd, r; - - assert(f); - assert(ret_contents); - -- n_next = LINE_MAX; /* Start size */ -+ if (offset != UINT64_MAX && offset > LONG_MAX) -+ return -ERANGE; -+ -+ n_next = size != SIZE_MAX ? size : LINE_MAX; /* Start size */ - - fd = fileno(f); -- if (fd >= 0) { /* If the FILE* object is backed by an fd (as opposed to memory or such, see fmemopen(), let's -- * optimize our buffering) */ -+ if (fd >= 0) { /* If the FILE* object is backed by an fd (as opposed to memory or such, see -+ * fmemopen()), let's optimize our buffering */ -+ struct stat st; - - if (fstat(fd, &st) < 0) - return -errno; - - if (S_ISREG(st.st_mode)) { -- -- /* Safety check */ -- if (st.st_size > READ_FULL_BYTES_MAX) -- return -E2BIG; -- -- /* Start with the right file size. Note that we increase the size -- * to read here by one, so that the first read attempt already -- * makes us notice the EOF. */ -- if (st.st_size > 0) -- n_next = st.st_size + 1; -+ if (size == SIZE_MAX) { -+ uint64_t rsize = -+ LESS_BY((uint64_t) st.st_size, offset == UINT64_MAX ? 0 : offset); -+ -+ /* Safety check */ -+ if (rsize > READ_FULL_BYTES_MAX) -+ return -E2BIG; -+ -+ /* Start with the right file size. Note that we increase the size to read -+ * here by one, so that the first read attempt already makes us notice the -+ * EOF. If the reported size of the file is zero, we avoid this logic -+ * however, since quite likely it might be a virtual file in procfs that all -+ * report a zero file size. */ -+ if (st.st_size > 0) -+ n_next = rsize + 1; -+ } - - if (flags & READ_FULL_FILE_WARN_WORLD_READABLE) - (void) warn_file_is_world_accessible(filename, &st, NULL, 0); - } - } - -+ if (offset != UINT64_MAX && fseek(f, offset, SEEK_SET) < 0) -+ return -errno; -+ - n = l = 0; - for (;;) { - char *t; -@@ -462,6 +476,11 @@ int read_full_stream_full( - if (feof(f)) - break; - -+ if (size != SIZE_MAX) { /* If we got asked to read some specific size, we already sized the buffer right, hence leave */ -+ assert(l == size); -+ break; -+ } -+ - assert(k > 0); /* we can't have read zero bytes because that would have been EOF */ - - /* Safety check */ -@@ -577,15 +596,18 @@ static int xfopenat(int dir_fd, const char *path, const char *mode, int flags, F - int read_full_file_full( - int dir_fd, - const char *filename, -+ uint64_t offset, -+ size_t size, - ReadFullFileFlags flags, - const char *bind_name, -- char **contents, size_t *size) { -+ char **ret_contents, -+ size_t *ret_size) { - - _cleanup_fclose_ FILE *f = NULL; - int r; - - assert(filename); -- assert(contents); -+ assert(ret_contents); - - r = xfopenat(dir_fd, filename, "re", 0, &f); - if (r < 0) { -@@ -600,6 +622,10 @@ int read_full_file_full( - if (!FLAGS_SET(flags, READ_FULL_FILE_CONNECT_SOCKET)) - return -ENXIO; - -+ /* Seeking is not supported on AF_UNIX sockets */ -+ if (offset != UINT64_MAX) -+ return -ESPIPE; -+ - if (dir_fd == AT_FDCWD) - r = sockaddr_un_set_path(&sa.un, filename); - else { -@@ -653,7 +679,7 @@ int read_full_file_full( - - (void) __fsetlocking(f, FSETLOCKING_BYCALLER); - -- return read_full_stream_full(f, filename, flags, contents, size); -+ return read_full_stream_full(f, filename, offset, size, flags, ret_contents, ret_size); - } - - static int parse_env_file_internal( -diff --git a/src/basic/fileio.h b/src/basic/fileio.h -index 82897e209c..03150ce776 100644 ---- a/src/basic/fileio.h -+++ b/src/basic/fileio.h -@@ -44,13 +44,13 @@ static inline int write_string_file(const char *fn, const char *line, WriteStrin - int write_string_filef(const char *fn, WriteStringFileFlags flags, const char *format, ...) _printf_(3, 4); - - int read_one_line_file(const char *filename, char **line); --int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flags, const char *bind_name, char **contents, size_t *size); --static inline int read_full_file(const char *filename, char **contents, size_t *size) { -- return read_full_file_full(AT_FDCWD, filename, 0, NULL, contents, size); -+int read_full_file_full(int dir_fd, const char *filename, uint64_t offset, size_t size, ReadFullFileFlags flags, const char *bind_name, char **ret_contents, size_t *ret_size); -+static inline int read_full_file(const char *filename, char **ret_contents, size_t *ret_size) { -+ return read_full_file_full(AT_FDCWD, filename, UINT64_MAX, SIZE_MAX, 0, NULL, ret_contents, ret_size); - } --int read_full_stream_full(FILE *f, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); --static inline int read_full_stream(FILE *f, char **contents, size_t *size) { -- return read_full_stream_full(f, NULL, 0, contents, size); -+int read_full_stream_full(FILE *f, const char *filename, uint64_t offset, size_t size, ReadFullFileFlags flags, char **ret_contents, size_t *ret_size); -+static inline int read_full_stream(FILE *f, char **ret_contents, size_t *ret_size) { -+ return read_full_stream_full(f, NULL, UINT64_MAX, SIZE_MAX, 0, ret_contents, ret_size); - } - int read_full_virtual_file(const char *filename, char **ret_contents, size_t *ret_size); - -diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c -index 5ec70eec14..5d0006149b 100644 ---- a/src/test/test-fileio.c -+++ b/src/test/test-fileio.c -@@ -762,8 +762,8 @@ static void test_read_full_file_socket(void) { - _exit(EXIT_SUCCESS); - } - -- assert_se(read_full_file_full(AT_FDCWD, j, 0, NULL, &data, &size) == -ENXIO); -- assert_se(read_full_file_full(AT_FDCWD, j, READ_FULL_FILE_CONNECT_SOCKET, clientname, &data, &size) >= 0); -+ assert_se(read_full_file_full(AT_FDCWD, j, UINT64_MAX, SIZE_MAX, 0, NULL, &data, &size) == -ENXIO); -+ assert_se(read_full_file_full(AT_FDCWD, j, UINT64_MAX, SIZE_MAX, READ_FULL_FILE_CONNECT_SOCKET, clientname, &data, &size) >= 0); - assert_se(size == strlen(TEST_STR)); - assert_se(streq(data, TEST_STR)); - -@@ -771,6 +771,50 @@ static void test_read_full_file_socket(void) { - #undef TEST_STR - } - -+static void test_read_full_file_offset_size(void) { -+ _cleanup_fclose_ FILE *f = NULL; -+ _cleanup_(unlink_and_freep) char *fn = NULL; -+ _cleanup_free_ char *rbuf = NULL; -+ size_t rbuf_size; -+ uint8_t buf[4711]; -+ -+ random_bytes(buf, sizeof(buf)); -+ -+ assert_se(tempfn_random_child(NULL, NULL, &fn) >= 0); -+ assert_se(f = fopen(fn, "we")); -+ assert_se(fwrite(buf, 1, sizeof(buf), f) == sizeof(buf)); -+ assert_se(fflush_and_check(f) >= 0); -+ -+ assert_se(read_full_file_full(AT_FDCWD, fn, UINT64_MAX, SIZE_MAX, 0, NULL, &rbuf, &rbuf_size) >= 0); -+ assert_se(rbuf_size == sizeof(buf)); -+ assert_se(memcmp(buf, rbuf, rbuf_size) == 0); -+ rbuf = mfree(rbuf); -+ -+ assert_se(read_full_file_full(AT_FDCWD, fn, UINT64_MAX, 128, 0, NULL, &rbuf, &rbuf_size) >= 0); -+ assert_se(rbuf_size == 128); -+ assert_se(memcmp(buf, rbuf, rbuf_size) == 0); -+ rbuf = mfree(rbuf); -+ -+ assert_se(read_full_file_full(AT_FDCWD, fn, 1234, SIZE_MAX, 0, NULL, &rbuf, &rbuf_size) >= 0); -+ assert_se(rbuf_size == sizeof(buf) - 1234); -+ assert_se(memcmp(buf + 1234, rbuf, rbuf_size) == 0); -+ rbuf = mfree(rbuf); -+ -+ assert_se(read_full_file_full(AT_FDCWD, fn, 2345, 777, 0, NULL, &rbuf, &rbuf_size) >= 0); -+ assert_se(rbuf_size == 777); -+ assert_se(memcmp(buf + 2345, rbuf, rbuf_size) == 0); -+ rbuf = mfree(rbuf); -+ -+ assert_se(read_full_file_full(AT_FDCWD, fn, 4700, 20, 0, NULL, &rbuf, &rbuf_size) >= 0); -+ assert_se(rbuf_size == 11); -+ assert_se(memcmp(buf + 4700, rbuf, rbuf_size) == 0); -+ rbuf = mfree(rbuf); -+ -+ assert_se(read_full_file_full(AT_FDCWD, fn, 10000, 99, 0, NULL, &rbuf, &rbuf_size) >= 0); -+ assert_se(rbuf_size == 0); -+ rbuf = mfree(rbuf); -+} -+ - int main(int argc, char *argv[]) { - log_set_max_level(LOG_DEBUG); - log_parse_environment(); -@@ -796,6 +840,7 @@ int main(int argc, char *argv[]) { - test_read_line2(); - test_read_line3(); - test_read_full_file_socket(); -+ test_read_full_file_offset_size(); - - return 0; - } --- -2.39.1 - diff --git a/10025-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch b/10025-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch deleted file mode 100644 index bb66170..0000000 --- a/10025-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch +++ /dev/null @@ -1,95 +0,0 @@ -From 8ef03861b75cf0a70511760c395cb4bd228c37b9 Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Wed, 4 Nov 2020 17:24:53 +0100 -Subject: [PATCH] cryptsetup: port cryptsetup's main key file logic over to - read_full_file_full() -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Previously, we'd load the file with libcryptsetup's calls. Let's do that -in our own, so that we can make use of READ_FULL_FILE_CONNECT_SOCKET, -i.e. read in keys via AF_UNIX sockets, so that people can plug key -providers into our logic. - -This provides functionality similar to Debian's keyscript= crypttab -option (see → #3007), as it allows key scripts to be run as socket -activated services, that have stdout connected to the activated socket. -In contrast to traditional keyscript= support this logic runs stuff out -of process however, which is beneficial, since it allows sandboxing and -similar. - -(cherry picked from commit 165a476841ff1aa3aab3508771db9495ab073c7a) - -Signed-off-by: Guorui Yu ---- - src/cryptsetup/cryptsetup.c | 37 ++++++++++++++++++++++++++++++++----- - 1 file changed, 32 insertions(+), 5 deletions(-) - -diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c -index 11162eb722..9251e0eba8 100644 ---- a/src/cryptsetup/cryptsetup.c -+++ b/src/cryptsetup/cryptsetup.c -@@ -17,6 +17,7 @@ - #include "mount-util.h" - #include "parse-util.h" - #include "path-util.h" -+#include "random-util.h" - #include "string-util.h" - #include "strv.h" - #include "util.h" -@@ -480,6 +481,15 @@ static int attach_tcrypt( - return 0; - } - -+static char *make_bindname(const char *volume) { -+ char *s; -+ -+ if (asprintf(&s, "@%" PRIx64"/cryptsetup/%s", random_u64(), volume) < 0) -+ return NULL; -+ -+ return s; -+} -+ - static int attach_luks_or_plain(struct crypt_device *cd, - const char *name, - const char *key_file, -@@ -553,13 +563,30 @@ static int attach_luks_or_plain(struct crypt_device *cd, - crypt_get_device_name(cd)); - - if (key_file) { -- r = crypt_activate_by_keyfile_offset(cd, name, arg_key_slot, key_file, arg_keyfile_size, arg_keyfile_offset, flags); -- if (r == -EPERM) { -- log_error_errno(r, "Failed to activate with key file '%s'. (Key data incorrect?)", key_file); -+ _cleanup_(erase_and_freep) char *kfdata = NULL; -+ _cleanup_free_ char *bindname = NULL; -+ size_t kfsize; -+ -+ /* If we read the key via AF_UNIX, make this client recognizable */ -+ bindname = make_bindname(name); -+ if (!bindname) -+ return log_oom(); -+ -+ r = read_full_file_full( -+ AT_FDCWD, key_file, -+ arg_keyfile_offset == 0 ? UINT64_MAX : arg_keyfile_offset, -+ arg_keyfile_size == 0 ? SIZE_MAX : arg_keyfile_size, -+ READ_FULL_FILE_SECURE|READ_FULL_FILE_WARN_WORLD_READABLE|READ_FULL_FILE_CONNECT_SOCKET, -+ bindname, -+ &kfdata, &kfsize); -+ if (r == -ENOENT) { -+ log_error_errno(r, "Failed to activate, key file '%s' missing.", key_file); - return -EAGAIN; /* Log actual error, but return EAGAIN */ - } -- if (r == -EINVAL) { -- log_error_errno(r, "Failed to activate with key file '%s'. (Key file missing?)", key_file); -+ -+ r = crypt_activate_by_passphrase(cd, name, arg_key_slot, kfdata, kfsize, flags); -+ if (r == -EPERM) { -+ log_error_errno(r, "Failed to activate with key file '%s'. (Key data incorrect?)", key_file); - return -EAGAIN; /* Log actual error, but return EAGAIN */ - } - if (r < 0) --- -2.39.1 - diff --git a/10026-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch b/10026-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch deleted file mode 100644 index fbc76ac..0000000 --- a/10026-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch +++ /dev/null @@ -1,69 +0,0 @@ -From b877c3b06f15a025748b9f09621ddf1bd00cacce Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Fri, 20 Dec 2019 17:58:03 +0100 -Subject: [PATCH] umount: check LO_FLAGS_AUTOCLEAR after LOOP_CLR_FD claimed - success - -Fixes: #14410 -Replaces: #14386 - -For Lifsea-ng, this patch fixes the problem that the system occasionally -fail to shutdown caused by /sysroot unable to umount. - ---- - systemd-239/src/core/umount.c | 29 ++++++++++++++++++++++------- - 1 file changed, 22 insertions(+), 7 deletions(-) - -diff --git a/src/core/umount.c b/src/core/umount.c -index 241fe6f..4400b3c 100644 ---- a/src/core/umount.c -+++ b/src/core/umount.c -@@ -334,23 +334,38 @@ static int dm_list_get(MountPoint **head) { - - static int delete_loopback(const char *device) { - _cleanup_close_ int fd = -1; -- int r; -+ struct loop_info64 info; - - assert(device); - - fd = open(device, O_RDONLY|O_CLOEXEC); - if (fd < 0) - return errno == ENOENT ? 0 : -errno; -+ -+ if (ioctl(fd, LOOP_CLR_FD, 0) < 0) { -+ if (errno == ENXIO) /* Nothing bound, didn't do anything */ -+ return 0; -+ -+ return -errno; -+ } - -- r = ioctl(fd, LOOP_CLR_FD, 0); -- if (r >= 0) -+ if (ioctl(fd, LOOP_GET_STATUS64, &info) < 0) { -+ /* If the LOOP_CLR_FD above succeeded we'll see ENXIO here. */ -+ if (errno == ENXIO) -+ log_debug("Successfully detached loopback device %s.", device); -+ else -+ log_debug_errno(errno, "Failed to invoke LOOP_GET_STATUS64 on loopback device %s, ignoring: %m", device); /* the LOOP_CLR_FD at least worked, let's hope for the best */ - return 1; -+ } - -- /* ENXIO: not bound, so no error */ -- if (errno == ENXIO) -- return 0; -+ /* Linux makes LOOP_CLR_FD succeed whenever LO_FLAGS_AUTOCLEAR is set without actually doing -+ * anything. Very confusing. Let's hence not claim we did anything in this case. */ -+ if (FLAGS_SET(info.lo_flags, LO_FLAGS_AUTOCLEAR)) -+ log_debug("Successfully called LOOP_CLR_FD on a loopback device %s with autoclear set, which is a NOP.", device); -+ else -+ log_debug("Weird, LOOP_CLR_FD succeeded but the device is still attached on %s.", device); - -- return -errno; -+ return -EBUSY; /* Nothing changed, the device is still attached, hence it apparently is still busy */; - } - - static int delete_dm(dev_t devnum) { --- -2.31.1 - diff --git a/10027-fix-compilation-without-utmp.patch b/10027-fix-compilation-without-utmp.patch deleted file mode 100644 index 4526be3..0000000 --- a/10027-fix-compilation-without-utmp.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 813c9418ca8f6eabd179feace3f115b874e6a1a6 Mon Sep 17 00:00:00 2001 -From: Steven Allen -Date: Wed, 7 Nov 2018 07:44:36 -0800 -Subject: [PATCH] fix compilation without utmp - ---- - src/login/logind-core.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/login/logind-core.c b/src/login/logind-core.c -index abe6eec..519abf5 100644 ---- a/src/login/logind-core.c -+++ b/src/login/logind-core.c -@@ -779,7 +779,7 @@ int manager_read_utmp(Manager *m) { - endutxent(); - return r; - #else -- return 0 -+ return 0; - #endif - } - --- -2.39.3 diff --git a/10029-cgroup-drastically-simplify-caching-of-cgroups-membe.patch b/10029-cgroup-drastically-simplify-caching-of-cgroups-membe.patch deleted file mode 100644 index d69f0ba..0000000 --- a/10029-cgroup-drastically-simplify-caching-of-cgroups-membe.patch +++ /dev/null @@ -1,228 +0,0 @@ -From 5af8805872809e6de4cc4d9495cb1a904772ab4e Mon Sep 17 00:00:00 2001 -From: Lennart Poettering -Date: Fri, 23 Nov 2018 01:07:34 +0100 -Subject: [PATCH] cgroup: drastically simplify caching of cgroups members mask - -Previously we tried to be smart: when a new unit appeared and it only -added controllers to the cgroup mask we'd update the cached members mask -in all parents by ORing in the controller flags in their cached values. -Unfortunately this was quite broken, as we missed some conditions when -this cache had to be reset (for example, when a unit got unloaded), -moreover the optimization doesn't work when a controller is removed -anyway (as in that case there's no other way for the parent to iterate -though all children if any other, remaining child unit still needs it). -Hence, let's simplify the logic substantially: instead of updating the -cache on the right events (which we didn't get right), let's simply -invalidate the cache, and generate it lazily when we encounter it later. -This should actually result in better behaviour as we don't have to -calculate the new members mask for a whole subtree whever we have the -suspicion something changed, but can delay it to the point where we -actually need the members mask. - -This allows us to simplify things quite a bit, which is good, since -validating this cache for correctness is hard enough. - -Fixes: #9512 ---- - src/core/cgroup.c | 49 +++++------------------------------------ - src/core/cgroup.h | 2 +- - src/core/dbus-mount.c | 2 +- - src/core/dbus-scope.c | 2 +- - src/core/dbus-service.c | 2 +- - src/core/dbus-slice.c | 2 +- - src/core/dbus-socket.c | 2 +- - src/core/dbus-swap.c | 2 +- - src/core/unit.c | 3 ++- - src/core/unit.h | 2 -- - 10 files changed, 14 insertions(+), 54 deletions(-) - -diff --git a/src/core/cgroup.c b/src/core/cgroup.c -index 6a5606f..d569077 100644 ---- a/src/core/cgroup.c -+++ b/src/core/cgroup.c -@@ -1450,53 +1450,12 @@ bool unit_get_needs_bpf(Unit *u) { - return false; - } - --/* Recurse from a unit up through its containing slices, propagating -- * mask bits upward. A unit is also member of itself. */ --void unit_update_cgroup_members_masks(Unit *u) { -- CGroupMask m; -- bool more; -- -+void unit_invalidate_cgroup_members_masks(Unit *u) { - assert(u); -- -- /* Calculate subtree mask */ -- m = unit_get_subtree_mask(u); -- -- /* See if anything changed from the previous invocation. If -- * not, we're done. */ -- if (u->cgroup_subtree_mask_valid && m == u->cgroup_subtree_mask) -- return; -- -- more = -- u->cgroup_subtree_mask_valid && -- ((m & ~u->cgroup_subtree_mask) != 0) && -- ((~m & u->cgroup_subtree_mask) == 0); -- -- u->cgroup_subtree_mask = m; -- u->cgroup_subtree_mask_valid = true; -- -- if (UNIT_ISSET(u->slice)) { -- Unit *s = UNIT_DEREF(u->slice); -- -- if (more) -- /* There's more set now than before. We -- * propagate the new mask to the parent's mask -- * (not caring if it actually was valid or -- * not). */ -- -- s->cgroup_members_mask |= m; -- -- else -- /* There's less set now than before (or we -- * don't know), we need to recalculate -- * everything, so let's invalidate the -- * parent's members mask */ -- -- s->cgroup_members_mask_valid = false; -- -- /* And now make sure that this change also hits our -- * grandparents */ -- unit_update_cgroup_members_masks(s); -- } -+ /* Recurse invalidate the member masks cache all the way up the tree */ -+ u->cgroup_members_mask_valid = false; -+ if (UNIT_ISSET(u->slice)) -+ unit_invalidate_cgroup_members_masks(UNIT_DEREF(u->slice)); - } - - const char *unit_get_realized_cgroup_path(Unit *u, CGroupMask mask) { -diff --git a/src/core/cgroup.h b/src/core/cgroup.h -index 36ea77f..a2e1644 100644 ---- a/src/core/cgroup.h -+++ b/src/core/cgroup.h -@@ -181,7 +181,7 @@ CGroupMask unit_get_enable_mask(Unit *u); - - bool unit_get_needs_bpf(Unit *u); - --void unit_update_cgroup_members_masks(Unit *u); -+void unit_invalidate_cgroup_members_masks(Unit *u); - - const char *unit_get_realized_cgroup_path(Unit *u, CGroupMask mask); - char *unit_default_cgroup_path(Unit *u); - -diff --git a/src/core/dbus-mount.c b/src/core/dbus-mount.c -index 3f98d3ecf0..b6d61627eb 100644 ---- a/src/core/dbus-mount.c -+++ b/src/core/dbus-mount.c -@@ -145,7 +145,7 @@ int bus_mount_set_property( - int bus_mount_commit_properties(Unit *u) { - assert(u); - -- unit_update_cgroup_members_masks(u); -+ unit_invalidate_cgroup_members_masks(u); - unit_realize_cgroup(u); - - return 0; -diff --git a/src/core/dbus-scope.c b/src/core/dbus-scope.c -index 5d9fe98857..bb807df2e9 100644 ---- a/src/core/dbus-scope.c -+++ b/src/core/dbus-scope.c -@@ -186,7 +186,7 @@ int bus_scope_set_property( - int bus_scope_commit_properties(Unit *u) { - assert(u); - -- unit_update_cgroup_members_masks(u); -+ unit_invalidate_cgroup_members_masks(u); - unit_realize_cgroup(u); - - return 0; -diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c -index fdf6120610..10f53ef401 100644 ---- a/src/core/dbus-service.c -+++ b/src/core/dbus-service.c -@@ -424,7 +424,7 @@ int bus_service_set_property( - int bus_service_commit_properties(Unit *u) { - assert(u); - -- unit_update_cgroup_members_masks(u); -+ unit_invalidate_cgroup_members_masks(u); - unit_realize_cgroup(u); - - return 0; -diff --git a/src/core/dbus-slice.c b/src/core/dbus-slice.c -index 722a5688a5..effd5fa5d7 100644 ---- a/src/core/dbus-slice.c -+++ b/src/core/dbus-slice.c -@@ -28,7 +28,7 @@ int bus_slice_set_property( - int bus_slice_commit_properties(Unit *u) { - assert(u); - -- unit_update_cgroup_members_masks(u); -+ unit_invalidate_cgroup_members_masks(u); - unit_realize_cgroup(u); - - return 0; -diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c -index 4ea5b6c6e5..3819653908 100644 ---- a/src/core/dbus-socket.c -+++ b/src/core/dbus-socket.c -@@ -461,7 +461,7 @@ int bus_socket_set_property( - int bus_socket_commit_properties(Unit *u) { - assert(u); - -- unit_update_cgroup_members_masks(u); -+ unit_invalidate_cgroup_members_masks(u); - unit_realize_cgroup(u); - - return 0; -diff --git a/src/core/dbus-swap.c b/src/core/dbus-swap.c -index b272d10113..353fa20132 100644 ---- a/src/core/dbus-swap.c -+++ b/src/core/dbus-swap.c -@@ -63,7 +63,7 @@ int bus_swap_set_property( - int bus_swap_commit_properties(Unit *u) { - assert(u); - -- unit_update_cgroup_members_masks(u); -+ unit_invalidate_cgroup_members_masks(u); - unit_realize_cgroup(u); - - return 0; -diff --git a/src/core/unit.c b/src/core/unit.c -index 392cc2d7c5..a8c0f08e95 100644 ---- a/src/core/unit.c -+++ b/src/core/unit.c -@@ -1547,7 +1547,8 @@ int unit_load(Unit *u) { - if (u->job_running_timeout != USEC_INFINITY && u->job_running_timeout > u->job_timeout) - log_unit_warning(u, "JobRunningTimeoutSec= is greater than JobTimeoutSec=, it has no effect."); - -- unit_update_cgroup_members_masks(u); -+ /* We finished loading, let's ensure our parents recalculate the members mask */ -+ unit_invalidate_cgroup_members_masks(u); - } - - assert((u->load_state != UNIT_MERGED) == !u->merged_into); -diff --git a/src/core/unit.h b/src/core/unit.h -index b8b9147..e2dd794 100644 ---- a/src/core/unit.h -+++ b/src/core/unit.h -@@ -265,7 +265,6 @@ typedef struct Unit { - char *cgroup_path; - CGroupMask cgroup_realized_mask; - CGroupMask cgroup_enabled_mask; -- CGroupMask cgroup_subtree_mask; - CGroupMask cgroup_members_mask; - int cgroup_inotify_wd; - -@@ -341,7 +340,6 @@ typedef struct Unit { - - bool cgroup_realized:1; - bool cgroup_members_mask_valid:1; -- bool cgroup_subtree_mask_valid:1; - - UnitCGroupBPFState cgroup_bpf_state:2; - - diff --git a/1003-doc-add-missing-listitem-to-systemd.net-naming-schem.patch b/1003-doc-add-missing-listitem-to-systemd.net-naming-schem.patch new file mode 100644 index 0000000..9f756e0 --- /dev/null +++ b/1003-doc-add-missing-listitem-to-systemd.net-naming-schem.patch @@ -0,0 +1,79 @@ +From 8ac0c00fa9699f1cd096a4775cf0cf7879b81f37 Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Fri, 9 Feb 2024 14:42:28 +0100 +Subject: [PATCH] doc: add missing `` to + `systemd.net-naming-scheme.xml` + +rhel-only + +Related: RHEL-22426 +--- + man/systemd.net-naming-scheme.xml | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/man/systemd.net-naming-scheme.xml b/man/systemd.net-naming-scheme.xml +index 25e8bd9aea..11ef2ea02f 100644 +--- a/man/systemd.net-naming-scheme.xml ++++ b/man/systemd.net-naming-scheme.xml +@@ -276,19 +276,19 @@ + + rhel-8.1 + +- Same as naming scheme rhel-8.0. ++ Same as naming scheme rhel-8.0. + + + + rhel-8.2 + +- Same as naming scheme rhel-8.0. ++ Same as naming scheme rhel-8.0. + + + + rhel-8.3 + +- Same as naming scheme rhel-8.0. ++ Same as naming scheme rhel-8.0. + + + +@@ -304,13 +304,13 @@ + + rhel-8.5 + +- Same as naming scheme rhel-8.4. ++ Same as naming scheme rhel-8.4. + + + + rhel-8.6 + +- Same as naming scheme rhel-8.4. ++ Same as naming scheme rhel-8.4. + + + +@@ -331,19 +331,19 @@ + + rhel-8.8 + +- Same as naming scheme rhel-8.7. ++ Same as naming scheme rhel-8.7. + + + + rhel-8.9 + +- Same as naming scheme rhel-8.7. ++ Same as naming scheme rhel-8.7. + + + + rhel-8.10 + +- Same as naming scheme rhel-8.7. ++ Same as naming scheme rhel-8.7. + + + Note that latest may be used to denote the latest scheme known to this diff --git a/1004-service-schedule-cleanup-of-PID-hashmaps-when-we-now.patch b/1004-service-schedule-cleanup-of-PID-hashmaps-when-we-now.patch new file mode 100644 index 0000000..973bd7f --- /dev/null +++ b/1004-service-schedule-cleanup-of-PID-hashmaps-when-we-now.patch @@ -0,0 +1,34 @@ +From 8bf7a6f42efba3ebe59872ba75233e75ffdf7c87 Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Mon, 11 Dec 2023 16:09:02 +0100 +Subject: [PATCH] service: schedule cleanup of PID hashmaps when we now longer + have main_pid and we are in container + +RHEL-only + +Resolves: RHEL-5863 +--- + src/core/service.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/core/service.c b/src/core/service.c +index 0423f2c73e..82c09d59f0 100644 +--- a/src/core/service.c ++++ b/src/core/service.c +@@ -34,6 +34,7 @@ + #include "string-table.h" + #include "string-util.h" + #include "strv.h" ++#include "virt.h" + #include "unit-name.h" + #include "unit.h" + #include "utf8.h" +@@ -3535,7 +3536,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) { + * detect when the cgroup becomes empty. Note that the control process is always + * our child so it's pointless to watch all other processes. */ + if (!control_pid_good(s)) +- if (!s->main_pid_known || s->main_pid_alien) ++ if (!s->main_pid_known || s->main_pid_alien || (s->main_pid == 0 && detect_container() > 0)) + (void) unit_enqueue_rewatch_pids(u); + } + diff --git a/1005-man-update-link-to-RHEL-documentation.patch b/1005-man-update-link-to-RHEL-documentation.patch new file mode 100644 index 0000000..395a03f --- /dev/null +++ b/1005-man-update-link-to-RHEL-documentation.patch @@ -0,0 +1,24 @@ +From 9cb89ed011a12a210dce977aaa65f6b90e0ed928 Mon Sep 17 00:00:00 2001 +From: Frantisek Sumsal +Date: Thu, 22 Feb 2024 14:28:09 +0100 +Subject: [PATCH] man: update link to RHEL documentation + +Resolves: RHEL-26355 +RHEL-only +--- + man/systemctl.xml | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/man/systemctl.xml b/man/systemctl.xml +index abc386e6fb..445d35fefd 100644 +--- a/man/systemctl.xml ++++ b/man/systemctl.xml +@@ -2018,7 +2018,7 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output err + + For examples how to use systemctl in comparsion + with old service and chkconfig command please see: +- ++ + Managing System Services + + diff --git a/1006-ci-add-configuration-for-regression-sniffer-GA.patch b/1006-ci-add-configuration-for-regression-sniffer-GA.patch new file mode 100644 index 0000000..d8f04c7 --- /dev/null +++ b/1006-ci-add-configuration-for-regression-sniffer-GA.patch @@ -0,0 +1,20 @@ +From ca150b92be2e0edf3bfafe88ee79a419e7e11aaa Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Mon, 4 Mar 2024 13:40:45 +0100 +Subject: [PATCH] ci: add configuration for regression sniffer GA + +rhel-only + +Related: RHEL-1087 +--- + .github/regression-sniffer.yml | 1 + + 1 file changed, 1 insertion(+) + create mode 100644 .github/regression-sniffer.yml + +diff --git a/.github/regression-sniffer.yml b/.github/regression-sniffer.yml +new file mode 100644 +index 0000000000..3824028e92 +--- /dev/null ++++ b/.github/regression-sniffer.yml +@@ -0,0 +1 @@ ++upstream: systemd/systemd diff --git a/1007-coredump-actually-store-parsed-unit-in-the-context.patch b/1007-coredump-actually-store-parsed-unit-in-the-context.patch new file mode 100644 index 0000000..88da82e --- /dev/null +++ b/1007-coredump-actually-store-parsed-unit-in-the-context.patch @@ -0,0 +1,35 @@ +From ccaa361e04719efc6bcf7f3201cc9e6a869677d8 Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Mon, 4 Mar 2024 14:40:32 +0100 +Subject: [PATCH] coredump: actually store parsed unit in the context + +RHEL-only + +Related: RHEL-18302 +--- + src/coredump/coredump.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c +index d8acd2d3a7..7af8e97877 100644 +--- a/src/coredump/coredump.c ++++ b/src/coredump/coredump.c +@@ -1262,6 +1262,8 @@ static int gather_pid_metadata( + context->meta[CONTEXT_EXE] = t; + + if (cg_pid_get_unit(pid, &t) >= 0) { ++ context->meta[CONTEXT_UNIT] = t; ++ + if (!is_journald_crash(context)) { + /* OK, now we know it's not the journal, hence we can make use of it now. */ + log_set_target(LOG_TARGET_JOURNAL_OR_KMSG); +@@ -1275,8 +1277,7 @@ static int gather_pid_metadata( + } + + set_iovec_string_field(iovec, n_iovec, "COREDUMP_UNIT=", context->meta[CONTEXT_UNIT]); +- } else +- context->meta[CONTEXT_UNIT] = t; ++ } + + if (cg_pid_get_user_unit(pid, &t) >= 0) + set_iovec_field_free(iovec, n_iovec, "COREDUMP_USER_UNIT=", t); diff --git a/1008-resolved-limit-the-number-of-signature-validations-i.patch b/1008-resolved-limit-the-number-of-signature-validations-i.patch new file mode 100644 index 0000000..e7868c1 --- /dev/null +++ b/1008-resolved-limit-the-number-of-signature-validations-i.patch @@ -0,0 +1,184 @@ +From 899e3c43d6ac9d97c3cb9340b778427391def4ac Mon Sep 17 00:00:00 2001 +From: Jacek Migacz +Date: Mon, 26 Feb 2024 13:47:24 +0100 +Subject: [PATCH] resolved: limit the number of signature validations in a + transaction + +It has been demonstrated that tolerating an unbounded number of dnssec +signature validations is a bad idea. It is easy for a maliciously +crafted DNS reply to contain as many keytag collisions as desired, +causing us to iterate every dnskey and signature combination in vain. + +The solution is to impose a maximum number of validations we will +tolerate. While collisions are not hard to craft, I still expect they +are unlikely in the wild so it should be safe to pick fairly small +values. + +Here two limits are imposed: one on the maximum number of invalid +signatures encountered per rrset, and another on the total number of +validations performed per transaction. + +(cherry picked from commit 67d0ce8843d612a2245d0966197d4f528b911b66) + +Resolves: RHEL-26644 +--- + src/resolve/resolved-dns-dnssec.c | 16 ++++++++++++++-- + src/resolve/resolved-dns-dnssec.h | 9 ++++++++- + src/resolve/resolved-dns-transaction.c | 19 ++++++++++++++++--- + 3 files changed, 38 insertions(+), 6 deletions(-) + +diff --git a/src/resolve/resolved-dns-dnssec.c b/src/resolve/resolved-dns-dnssec.c +index 0a6f482cc1..5dbfbc94c7 100644 +--- a/src/resolve/resolved-dns-dnssec.c ++++ b/src/resolve/resolved-dns-dnssec.c +@@ -996,6 +996,7 @@ int dnssec_verify_rrset_search( + DnsResourceRecord **ret_rrsig) { + + bool found_rrsig = false, found_invalid = false, found_expired_rrsig = false, found_unsupported_algorithm = false; ++ unsigned nvalidations = 0; + DnsResourceRecord *rrsig; + int r; + +@@ -1041,6 +1042,14 @@ int dnssec_verify_rrset_search( + if (realtime == USEC_INFINITY) + realtime = now(CLOCK_REALTIME); + ++ /* Have we seen an unreasonable number of invalid signaures? */ ++ if (nvalidations > DNSSEC_INVALID_MAX) { ++ if (ret_rrsig) ++ *ret_rrsig = NULL; ++ *result = DNSSEC_TOO_MANY_VALIDATIONS; ++ return (int) nvalidations; ++ } ++ + /* Yay, we found a matching RRSIG with a matching + * DNSKEY, awesome. Now let's verify all entries of + * the RRSet against the RRSIG and DNSKEY +@@ -1050,6 +1059,8 @@ int dnssec_verify_rrset_search( + if (r < 0) + return r; + ++ nvalidations++; ++ + switch (one_result) { + + case DNSSEC_VALIDATED: +@@ -1060,7 +1071,7 @@ int dnssec_verify_rrset_search( + *ret_rrsig = rrsig; + + *result = one_result; +- return 0; ++ return (int) nvalidations; + + case DNSSEC_INVALID: + /* If the signature is invalid, let's try another +@@ -1107,7 +1118,7 @@ int dnssec_verify_rrset_search( + if (ret_rrsig) + *ret_rrsig = NULL; + +- return 0; ++ return (int) nvalidations; + } + + int dnssec_has_rrsig(DnsAnswer *a, const DnsResourceKey *key) { +@@ -2301,6 +2312,7 @@ static const char* const dnssec_result_table[_DNSSEC_RESULT_MAX] = { + [DNSSEC_FAILED_AUXILIARY] = "failed-auxiliary", + [DNSSEC_NSEC_MISMATCH] = "nsec-mismatch", + [DNSSEC_INCOMPATIBLE_SERVER] = "incompatible-server", ++ [DNSSEC_TOO_MANY_VALIDATIONS] = "too-many-validations", + }; + DEFINE_STRING_TABLE_LOOKUP(dnssec_result, DnssecResult); + +diff --git a/src/resolve/resolved-dns-dnssec.h b/src/resolve/resolved-dns-dnssec.h +index dfee7232c0..4d6abee084 100644 +--- a/src/resolve/resolved-dns-dnssec.h ++++ b/src/resolve/resolved-dns-dnssec.h +@@ -9,12 +9,13 @@ typedef enum DnssecVerdict DnssecVerdict; + #include "resolved-dns-rr.h" + + enum DnssecResult { +- /* These five are returned by dnssec_verify_rrset() */ ++ /* These six are returned by dnssec_verify_rrset() */ + DNSSEC_VALIDATED, + DNSSEC_VALIDATED_WILDCARD, /* Validated via a wildcard RRSIG, further NSEC/NSEC3 checks necessary */ + DNSSEC_INVALID, + DNSSEC_SIGNATURE_EXPIRED, + DNSSEC_UNSUPPORTED_ALGORITHM, ++ DNSSEC_TOO_MANY_VALIDATIONS, + + /* These two are added by dnssec_verify_rrset_search() */ + DNSSEC_NO_SIGNATURE, +@@ -45,6 +46,12 @@ enum DnssecVerdict { + /* The longest digest we'll ever generate, of all digest algorithms we support */ + #define DNSSEC_HASH_SIZE_MAX (MAX(20, 32)) + ++/* The most invalid signatures we will tolerate for a single rrset */ ++#define DNSSEC_INVALID_MAX 5 ++ ++/* The total number of signature validations we will tolerate for a single transaction */ ++#define DNSSEC_VALIDATION_MAX 64 ++ + int dnssec_rrsig_match_dnskey(DnsResourceRecord *rrsig, DnsResourceRecord *dnskey, bool revoked_ok); + int dnssec_key_match_rrsig(const DnsResourceKey *key, DnsResourceRecord *rrsig); + +diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c +index 6f614d7493..1ca6c9abc8 100644 +--- a/src/resolve/resolved-dns-transaction.c ++++ b/src/resolve/resolved-dns-transaction.c +@@ -2870,11 +2870,14 @@ static int dnssec_validate_records( + DnsTransaction *t, + Phase phase, + bool *have_nsec, ++ unsigned *nvalidations, + DnsAnswer **validated) { + + DnsResourceRecord *rr; + int r; + ++ assert(nvalidations); ++ + /* Returns negative on error, 0 if validation failed, 1 to restart validation, 2 when finished. */ + + DNS_ANSWER_FOREACH(rr, t->answer) { +@@ -2909,6 +2912,7 @@ static int dnssec_validate_records( + r = dnssec_verify_rrset_search(t->answer, rr->key, t->validated_keys, USEC_INFINITY, &result, &rrsig); + if (r < 0) + return r; ++ *nvalidations += r; + + log_debug("Looking at %s: %s", strna(dns_resource_record_to_string(rr)), dnssec_result_to_string(result)); + +@@ -3086,7 +3090,8 @@ static int dnssec_validate_records( + DNSSEC_SIGNATURE_EXPIRED, + DNSSEC_NO_SIGNATURE)) + manager_dnssec_verdict(t->scope->manager, DNSSEC_BOGUS, rr->key); +- else /* DNSSEC_MISSING_KEY or DNSSEC_UNSUPPORTED_ALGORITHM */ ++ else /* DNSSEC_MISSING_KEY, DNSSEC_UNSUPPORTED_ALGORITHM, ++ or DNSSEC_TOO_MANY_VALIDATIONS */ + manager_dnssec_verdict(t->scope->manager, DNSSEC_INDETERMINATE, rr->key); + + /* This is a primary response to our question, and it failed validation. +@@ -3180,13 +3185,21 @@ int dns_transaction_validate_dnssec(DnsTransaction *t) { + return r; + + phase = DNSSEC_PHASE_DNSKEY; +- for (;;) { ++ for (unsigned nvalidations = 0;;) { + bool have_nsec = false; + +- r = dnssec_validate_records(t, phase, &have_nsec, &validated); ++ r = dnssec_validate_records(t, phase, &have_nsec, &nvalidations, &validated); + if (r <= 0) + return r; + ++ if (nvalidations > DNSSEC_VALIDATION_MAX) { ++ /* This reply requires an onerous number of signature validations to verify. Let's ++ * not waste our time trying, as this shouldn't happen for well-behaved domains ++ * anyway. */ ++ t->answer_dnssec_result = DNSSEC_TOO_MANY_VALIDATIONS; ++ return 0; ++ } ++ + /* Try again as long as we managed to achieve something */ + if (r == 1) + continue; diff --git a/1009-resolved-reduce-the-maximum-nsec3-iterations-to-100.patch b/1009-resolved-reduce-the-maximum-nsec3-iterations-to-100.patch new file mode 100644 index 0000000..6c2b224 --- /dev/null +++ b/1009-resolved-reduce-the-maximum-nsec3-iterations-to-100.patch @@ -0,0 +1,34 @@ +From 92124e84be68005be92cce046c7c679b98199d66 Mon Sep 17 00:00:00 2001 +From: Jacek Migacz +Date: Mon, 26 Feb 2024 13:56:36 +0100 +Subject: [PATCH] resolved: reduce the maximum nsec3 iterations to 100 + +According to RFC9267, the 2500 value is not helpful, and in fact it can +be harmful to permit a large number of iterations. Combined with limits +on the number of signature validations, I expect this will mitigate the +impact of maliciously crafted domains designed to cause excessive +cryptographic work. + +(cherry picked from commit eba291124bc11f03732d1fc468db3bfac069f9cb) + +Related: RHEL-26644 +--- + src/resolve/resolved-dns-dnssec.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/resolve/resolved-dns-dnssec.c b/src/resolve/resolved-dns-dnssec.c +index 5dbfbc94c7..5a0540568c 100644 +--- a/src/resolve/resolved-dns-dnssec.c ++++ b/src/resolve/resolved-dns-dnssec.c +@@ -22,8 +22,9 @@ + /* Permit a maximum clock skew of 1h 10min. This should be enough to deal with DST confusion */ + #define SKEW_MAX (1*USEC_PER_HOUR + 10*USEC_PER_MINUTE) + +-/* Maximum number of NSEC3 iterations we'll do. RFC5155 says 2500 shall be the maximum useful value */ +-#define NSEC3_ITERATIONS_MAX 2500 ++/* Maximum number of NSEC3 iterations we'll do. RFC5155 says 2500 shall be the maximum useful value, but ++ * RFC9276 § 3.2 says that we should reduce the acceptable iteration count */ ++#define NSEC3_ITERATIONS_MAX 100 + + /* + * The DNSSEC Chain of trust: diff --git a/1010-pid1-by-default-make-user-units-inherit-their-umask-.patch b/1010-pid1-by-default-make-user-units-inherit-their-umask-.patch new file mode 100644 index 0000000..d008ac8 --- /dev/null +++ b/1010-pid1-by-default-make-user-units-inherit-their-umask-.patch @@ -0,0 +1,117 @@ +From f896e672ec6101ccbb21108345946e834455a25f Mon Sep 17 00:00:00 2001 +From: Franck Bui +Date: Fri, 3 Apr 2020 10:00:25 +0200 +Subject: [PATCH] pid1: by default make user units inherit their umask from the + user manager + +This patch changes the way user managers set the default umask for the units it +manages. + +Indeed one can expect that if user manager's umask is redefined through PAM +(via /etc/login.defs or pam_umask), all its children including the units it +spawns have their umask set to the new value. + +Hence make user units inherit their umask value from their parent instead of +the hard coded value 0022 but allow them to override this value via their unit +file. + +Note that reexecuting managers with 'systemctl daemon-reexec' after changing +UMask= has no effect. To take effect managers need to be restarted with +'systemct restart' instead. This behavior was already present before this +patch. + +Fixes #6077. + +(cherry picked from commit 5e37d1930b41b24c077ce37c6db0e36c745106c7) + +Related: RHEL-28048 +--- + man/systemd.exec.xml | 9 +++++++-- + src/basic/process-util.c | 17 +++++++++++++++++ + src/basic/process-util.h | 1 + + src/core/unit.c | 12 ++++++++++-- + 4 files changed, 35 insertions(+), 4 deletions(-) + +diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml +index b04b4ba552..844c1ce94b 100644 +--- a/man/systemd.exec.xml ++++ b/man/systemd.exec.xml +@@ -590,8 +590,13 @@ CapabilityBoundingSet=~CAP_B CAP_C + UMask= + + Controls the file mode creation mask. Takes an access mode in octal notation. See +- umask2 for details. Defaults +- to 0022. ++ umask2 for ++ details. Defaults to 0022 for system units. For units of the user service manager the default value ++ is inherited from the user instance (whose default is inherited from the system service manager, and ++ thus also is 0022). Hence changing the default value of a user instance, either via ++ UMask= or via a PAM module, will affect the user instance itself and all user ++ units started by the user instance unless a user unit has specified its own ++ UMask=. + + + +diff --git a/src/basic/process-util.c b/src/basic/process-util.c +index 9e2237375d..af44bfab3e 100644 +--- a/src/basic/process-util.c ++++ b/src/basic/process-util.c +@@ -657,6 +657,23 @@ int get_process_ppid(pid_t pid, pid_t *ret) { + return 0; + } + ++int get_process_umask(pid_t pid, mode_t *umask) { ++ _cleanup_free_ char *m = NULL; ++ const char *p; ++ int r; ++ ++ assert(umask); ++ assert(pid >= 0); ++ ++ p = procfs_file_alloca(pid, "status"); ++ ++ r = get_proc_field(p, "Umask", WHITESPACE, &m); ++ if (r == -ENOENT) ++ return -ESRCH; ++ ++ return parse_mode(m, umask); ++} ++ + int wait_for_terminate(pid_t pid, siginfo_t *status) { + siginfo_t dummy; + +diff --git a/src/basic/process-util.h b/src/basic/process-util.h +index a3bd2851b4..9059aad4cc 100644 +--- a/src/basic/process-util.h ++++ b/src/basic/process-util.h +@@ -41,6 +41,7 @@ int get_process_cwd(pid_t pid, char **cwd); + int get_process_root(pid_t pid, char **root); + int get_process_environ(pid_t pid, char **environ); + int get_process_ppid(pid_t pid, pid_t *ppid); ++int get_process_umask(pid_t pid, mode_t *umask); + + int wait_for_terminate(pid_t pid, siginfo_t *status); + +diff --git a/src/core/unit.c b/src/core/unit.c +index 76fb9f8075..d3459dcdd0 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -167,8 +167,16 @@ static void unit_init(Unit *u) { + if (ec) { + exec_context_init(ec); + +- ec->keyring_mode = MANAGER_IS_SYSTEM(u->manager) ? +- EXEC_KEYRING_SHARED : EXEC_KEYRING_INHERIT; ++ if (MANAGER_IS_SYSTEM(u->manager)) ++ ec->keyring_mode = EXEC_KEYRING_SHARED; ++ else { ++ ec->keyring_mode = EXEC_KEYRING_INHERIT; ++ ++ /* User manager might have its umask redefined by PAM or UMask=. In this ++ * case let the units it manages inherit this value by default. They can ++ * still tune this value through their own unit file */ ++ (void) get_process_umask(getpid_cached(), &ec->umask); ++ } + } + + kc = unit_get_kill_context(u); diff --git a/1011-pam-add-call-to-pam_umask.patch b/1011-pam-add-call-to-pam_umask.patch new file mode 100644 index 0000000..d4ea11c --- /dev/null +++ b/1011-pam-add-call-to-pam_umask.patch @@ -0,0 +1,28 @@ +From 49dbe60d4b3c6f111911c8217bc5e7da5a4ba0d0 Mon Sep 17 00:00:00 2001 +From: Michal Sekletar +Date: Wed, 31 May 2023 18:50:12 +0200 +Subject: [PATCH] pam: add call to pam_umask + +Setting umask for user sessions via UMASK setting in /etc/login.defs is +a well-known feature. Let's make sure that user manager also runs with +this umask value. + +Follow-up for 5e37d1930b41b24c077ce37c6db0e36c745106c7. + +(cherry picked from commit 159f1b78576ce91c3932f4867f07361a530875d3) + +Resolves: RHEL-28048 +--- + src/login/systemd-user.m4 | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/login/systemd-user.m4 b/src/login/systemd-user.m4 +index eb291beaed..a194a636d6 100644 +--- a/src/login/systemd-user.m4 ++++ b/src/login/systemd-user.m4 +@@ -10,4 +10,5 @@ session required pam_selinux.so nottys open + session required pam_loginuid.so + session optional pam_keyinit.so force revoke + session required pam_namespace.so ++session optional pam_umask.so silent + session optional pam_systemd.so diff --git a/1012-ci-deploy-systemd-man-to-GitHub-Pages.patch b/1012-ci-deploy-systemd-man-to-GitHub-Pages.patch new file mode 100644 index 0000000..1808f97 --- /dev/null +++ b/1012-ci-deploy-systemd-man-to-GitHub-Pages.patch @@ -0,0 +1,81 @@ +From 045ba12c6337760f0a7f8b0ceb9f998b309e025f Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Fri, 9 Feb 2024 14:48:02 +0100 +Subject: [PATCH] ci: deploy systemd man to GitHub Pages + +rhel-only + +Related: RHEL-32494 + +Co-authored-by: Frantisek Sumsal +--- + .github/workflows/deploy-man-pages.yml | 60 ++++++++++++++++++++++++++ + 1 file changed, 60 insertions(+) + create mode 100644 .github/workflows/deploy-man-pages.yml + +diff --git a/.github/workflows/deploy-man-pages.yml b/.github/workflows/deploy-man-pages.yml +new file mode 100644 +index 0000000000..9da38a1687 +--- /dev/null ++++ b/.github/workflows/deploy-man-pages.yml +@@ -0,0 +1,60 @@ ++name: Deploy systemd man to Pages ++ ++on: ++ push: ++ branches: [ rhel-8.10.0 ] ++ paths: ++ - man/* ++ - .github/workflows/deploy-man-pages.yml ++ schedule: ++ # Run every Monday at 4:00 AM UTC ++ - cron: 0 4 * * 1 ++ workflow_dispatch: ++ ++permissions: ++ contents: read ++ ++# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. ++# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. ++concurrency: ++ group: pages ++ cancel-in-progress: false ++ ++jobs: ++ # Single deploy job since we're just deploying ++ deploy: ++ environment: ++ name: github-pages ++ url: ${{ steps.deployment.outputs.page_url }} ++ runs-on: ubuntu-latest ++ ++ permissions: ++ pages: write ++ id-token: write ++ ++ steps: ++ - uses: actions/checkout@v4 ++ ++ - name: Install dependencies ++ run: | ++ RELEASE="$(lsb_release -cs)" ++ sudo add-apt-repository -y --no-update --enable-source ++ sudo apt-get -y update ++ sudo apt-get -y build-dep systemd ++ ++ - name: Build HTML man pages ++ run: | ++ meson setup build ++ ninja -C build man/html ++ ++ - name: Setup Pages ++ uses: actions/configure-pages@v4 ++ ++ - name: Upload artifact ++ uses: actions/upload-pages-artifact@v3 ++ with: ++ path: ./build/man ++ ++ - name: Deploy to GitHub Pages ++ id: deployment ++ uses: actions/deploy-pages@v4 diff --git a/1013-ci-src-git-update-list-of-supported-products.patch b/1013-ci-src-git-update-list-of-supported-products.patch new file mode 100644 index 0000000..ecb2591 --- /dev/null +++ b/1013-ci-src-git-update-list-of-supported-products.patch @@ -0,0 +1,24 @@ +From 604d2f1c8b6ecb46be7f70c5be7ae6fc6be04cab Mon Sep 17 00:00:00 2001 +From: Jan Macku +Date: Thu, 11 Apr 2024 10:14:51 +0200 +Subject: [PATCH] ci(src-git): update list of supported products + +rhel-only + +Related: RHEL-32494 +--- + .github/tracker-validator.yml | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/.github/tracker-validator.yml b/.github/tracker-validator.yml +index b09f702dd9..1bb684e722 100644 +--- a/.github/tracker-validator.yml ++++ b/.github/tracker-validator.yml +@@ -16,5 +16,5 @@ products: + - rhel-8.8.0.z + - rhel-8.9.0 + - rhel-8.9.0.z +- - rhel-8.10.0 +- - rhel-8.10.0.z ++ - rhel-8.10 ++ - rhel-8.10.z diff --git a/20001-hwdb-parse_hwdb_dot_py.patch b/20001-hwdb-parse_hwdb_dot_py.patch deleted file mode 100644 index 71bf1c5..0000000 --- a/20001-hwdb-parse_hwdb_dot_py.patch +++ /dev/null @@ -1,299 +0,0 @@ -From: rpm-build -Date: Thu, 28 Apr 2022 01:49:39 +0000 -Subject: [PATCH] Update upstream parse_hwdb.py to fix parse-hwdb error - -This patch does not correspond to a specific commit from upstream. Instead, it -is directly taken from - -https://github.com/systemd/systemd/blob/f2c36c0e2445fa95ba109017d4b768b2fd825c43/hwdb.d/parse_hwdb.py. - -This patch allows systemd-udev to parse newer hwdb. Hwdb is updated mostly -because of new hardware. Therefore, this patch allows systemd-udev to recongnize -these new hardware. - ---- -diff -uNrp systemd-239.orig/hwdb/parse_hwdb.py systemd-239/hwdb/parse_hwdb.py ---- systemd-239.orig/hwdb/parse_hwdb.py 2022-04-28 11:32:08.740731756 +0800 -+++ systemd-239/hwdb/parse_hwdb.py 2022-04-28 11:32:08.741731786 +0800 -@@ -1,6 +1,5 @@ - #!/usr/bin/env python3 --# -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */ --# SPDX-License-Identifier: MIT -+# SPDX-License-Identifier: MIT - # - # This file is distributed under the MIT license, see below. - # -@@ -30,12 +29,11 @@ import sys - import os - - try: -- from pyparsing import (Word, White, Literal, ParserElement, Regex, -- LineStart, LineEnd, -+ from pyparsing import (Word, White, Literal, ParserElement, Regex, LineEnd, - OneOrMore, Combine, Or, Optional, Suppress, Group, - nums, alphanums, printables, -- stringEnd, pythonStyleComment, QuotedString, -- ParseBaseException) -+ stringEnd, pythonStyleComment, -+ ParseBaseException, __diag__) - except ImportError: - print('pyparsing is not available') - sys.exit(77) -@@ -52,33 +50,61 @@ except ImportError: - # don't do caching on old python - lru_cache = lambda: (lambda f: f) - -+__diag__.warn_multiple_tokens_in_named_alternation = True -+__diag__.warn_ungrouped_named_tokens_in_collection = True -+__diag__.warn_name_set_on_empty_Forward = True -+__diag__.warn_on_multiple_string_args_to_oneof = True -+__diag__.enable_debug_on_named_expressions = True -+ - EOL = LineEnd().suppress() - EMPTYLINE = LineEnd() - COMMENTLINE = pythonStyleComment + EOL - INTEGER = Word(nums) --STRING = QuotedString('"') - REAL = Combine((INTEGER + Optional('.' + Optional(INTEGER))) ^ ('.' + INTEGER)) - SIGNED_REAL = Combine(Optional(Word('-+')) + REAL) - UDEV_TAG = Word(string.ascii_uppercase, alphanums + '_') - -+# Those patterns are used in type-specific matches - TYPES = {'mouse': ('usb', 'bluetooth', 'ps2', '*'), - 'evdev': ('name', 'atkbd', 'input'), -+ 'fb': ('pci'), - 'id-input': ('modalias'), - 'touchpad': ('i8042', 'rmi', 'bluetooth', 'usb'), - 'joystick': ('i8042', 'rmi', 'bluetooth', 'usb'), - 'keyboard': ('name', ), - 'sensor': ('modalias', ), -+ 'ieee1394-unit-function' : ('node', ), -+ 'camera': ('usb'), - } - -+# Patterns that are used to set general properties on a device -+GENERAL_MATCHES = {'acpi', -+ 'bluetooth', -+ 'usb', -+ 'pci', -+ 'sdio', -+ 'vmbus', -+ 'OUI', -+ 'ieee1394', -+ } -+ -+def upperhex_word(length): -+ return Word(nums + 'ABCDEF', exact=length) -+ - @lru_cache() - def hwdb_grammar(): - ParserElement.setDefaultWhitespaceChars('') - - prefix = Or(category + ':' + Or(conn) + ':' - for category, conn in TYPES.items()) -- matchline = Combine(prefix + Word(printables + ' ' + '®')) + EOL -+ -+ matchline_typed = Combine(prefix + Word(printables + ' ' + '®')) -+ matchline_general = Combine(Or(GENERAL_MATCHES) + ':' + Word(printables + ' ' + '®')) -+ matchline = (matchline_typed | matchline_general) + EOL -+ - propertyline = (White(' ', exact=1).suppress() + -- Combine(UDEV_TAG - '=' - Word(alphanums + '_=:@*.!-;, "') - Optional(pythonStyleComment)) + -+ Combine(UDEV_TAG - '=' - Optional(Word(alphanums + '_=:@*.!-;, "/')) -+ - Optional(pythonStyleComment)) + - EOL) - propertycomment = White(' ', exact=1) + pythonStyleComment + EOL - -@@ -87,7 +113,7 @@ def hwdb_grammar(): - (EMPTYLINE ^ stringEnd()).suppress()) - commentgroup = OneOrMore(COMMENTLINE).suppress() - EMPTYLINE.suppress() - -- grammar = OneOrMore(group('GROUPS*') ^ commentgroup) + stringEnd() -+ grammar = OneOrMore(Group(group)('GROUPS*') ^ commentgroup) + stringEnd() - - return grammar - -@@ -95,39 +121,57 @@ def hwdb_grammar(): - def property_grammar(): - ParserElement.setDefaultWhitespaceChars(' ') - -- dpi_setting = (Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ'))('SETTINGS*') -+ dpi_setting = Group(Optional('*')('DEFAULT') + INTEGER('DPI') + Optional(Suppress('@') + INTEGER('HZ')))('SETTINGS*') - mount_matrix_row = SIGNED_REAL + ',' + SIGNED_REAL + ',' + SIGNED_REAL -- mount_matrix = (mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX') -+ mount_matrix = Group(mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX') -+ xkb_setting = Optional(Word(alphanums + '+-/@._')) -+ -+ # Although this set doesn't cover all of characters in database entries, it's enough for test targets. -+ name_literal = Word(printables + ' ') - - props = (('MOUSE_DPI', Group(OneOrMore(dpi_setting))), - ('MOUSE_WHEEL_CLICK_ANGLE', INTEGER), - ('MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL', INTEGER), - ('MOUSE_WHEEL_CLICK_COUNT', INTEGER), - ('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', INTEGER), -- ('ID_INPUT', Literal('1')), -- ('ID_INPUT_ACCELEROMETER', Literal('1')), -- ('ID_INPUT_JOYSTICK', Literal('1')), -- ('ID_INPUT_KEY', Literal('1')), -- ('ID_INPUT_KEYBOARD', Literal('1')), -- ('ID_INPUT_MOUSE', Literal('1')), -- ('ID_INPUT_POINTINGSTICK', Literal('1')), -- ('ID_INPUT_SWITCH', Literal('1')), -- ('ID_INPUT_TABLET', Literal('1')), -- ('ID_INPUT_TABLET_PAD', Literal('1')), -- ('ID_INPUT_TOUCHPAD', Literal('1')), -- ('ID_INPUT_TOUCHSCREEN', Literal('1')), -- ('ID_INPUT_TRACKBALL', Literal('1')), -- ('MOUSE_WHEEL_TILT_HORIZONTAL', Literal('1')), -- ('MOUSE_WHEEL_TILT_VERTICAL', Literal('1')), -+ ('ID_AUTOSUSPEND', Or((Literal('0'), Literal('1')))), -+ ('ID_AV_PRODUCTION_CONTROLLER', Or((Literal('0'), Literal('1')))), -+ ('ID_PERSIST', Or((Literal('0'), Literal('1')))), -+ ('ID_PDA', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT_ACCELEROMETER', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT_JOYSTICK', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT_KEY', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT_KEYBOARD', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT_MOUSE', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT_POINTINGSTICK', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT_SWITCH', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT_TABLET', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT_TABLET_PAD', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT_TOUCHPAD', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT_TOUCHSCREEN', Or((Literal('0'), Literal('1')))), -+ ('ID_INPUT_TRACKBALL', Or((Literal('0'), Literal('1')))), -+ ('ID_SIGNAL_ANALYZER', Or((Literal('0'), Literal('1')))), - ('POINTINGSTICK_SENSITIVITY', INTEGER), - ('POINTINGSTICK_CONST_ACCEL', REAL), - ('ID_INPUT_JOYSTICK_INTEGRATION', Or(('internal', 'external'))), - ('ID_INPUT_TOUCHPAD_INTEGRATION', Or(('internal', 'external'))), -- ('XKB_FIXED_LAYOUT', STRING), -- ('XKB_FIXED_VARIANT', STRING), -+ ('XKB_FIXED_LAYOUT', xkb_setting), -+ ('XKB_FIXED_VARIANT', xkb_setting), -+ ('XKB_FIXED_MODEL', xkb_setting), - ('KEYBOARD_LED_NUMLOCK', Literal('0')), - ('KEYBOARD_LED_CAPSLOCK', Literal('0')), - ('ACCEL_MOUNT_MATRIX', mount_matrix), -+ ('ACCEL_LOCATION', Or(('display', 'base'))), -+ ('PROXIMITY_NEAR_LEVEL', INTEGER), -+ ('IEEE1394_UNIT_FUNCTION_MIDI', Or((Literal('0'), Literal('1')))), -+ ('IEEE1394_UNIT_FUNCTION_AUDIO', Or((Literal('0'), Literal('1')))), -+ ('IEEE1394_UNIT_FUNCTION_VIDEO', Or((Literal('0'), Literal('1')))), -+ ('ID_VENDOR_FROM_DATABASE', name_literal), -+ ('ID_MODEL_FROM_DATABASE', name_literal), -+ ('ID_TAG_MASTER_OF_SEAT', Literal('1')), -+ ('ID_INFRARED_CAMERA', Or((Literal('0'), Literal('1')))), -+ ('ID_CAMERA_DIRECTION', Or(('front', 'rear'))), - ) - fixed_props = [Literal(name)('NAME') - Suppress('=') - val('VALUE') - for name, val in props] -@@ -165,8 +209,29 @@ def parse(fname): - return [] - return [convert_properties(g) for g in parsed.GROUPS] - --def check_match_uniqueness(groups): -+def check_matches(groups): - matches = sum((group[0] for group in groups), []) -+ -+ # This is a partial check. The other cases could be also done, but those -+ # two are most commonly wrong. -+ grammars = { 'usb' : 'v' + upperhex_word(4) + Optional('p' + upperhex_word(4) + Optional(':')) + '*', -+ 'pci' : 'v' + upperhex_word(8) + Optional('d' + upperhex_word(8) + Optional(':')) + '*', -+ } -+ -+ for match in matches: -+ prefix, rest = match.split(':', maxsplit=1) -+ gr = grammars.get(prefix) -+ if gr: -+ # we check this first to provide an easy error message -+ if rest[-1] not in '*:': -+ error('pattern {} does not end with "*" or ":"', match) -+ -+ try: -+ gr.parseString(rest) -+ except ParseBaseException as e: -+ error('Pattern {!r} is invalid: {}', rest, e) -+ continue -+ - matches.sort() - prev = None - for match in matches: -@@ -196,15 +261,25 @@ def check_one_mount_matrix(prop, value): - def check_one_keycode(prop, value): - if value != '!' and ecodes is not None: - key = 'KEY_' + value.upper() -- if key not in ecodes: -- key = value.upper() -- if key not in ecodes: -- error('Keycode {} unknown', key) -+ if not (key in ecodes or -+ value.upper() in ecodes or -+ # new keys added in kernel 5.5 -+ 'KBD_LCD_MENU' in key): -+ error('Keycode {} unknown', key) -+ -+def check_wheel_clicks(properties): -+ pairs = (('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', 'MOUSE_WHEEL_CLICK_COUNT'), -+ ('MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL', 'MOUSE_WHEEL_CLICK_ANGLE'), -+ ('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', 'MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL'), -+ ('MOUSE_WHEEL_CLICK_COUNT', 'MOUSE_WHEEL_CLICK_ANGLE')) -+ for pair in pairs: -+ if pair[0] in properties and pair[1] not in properties: -+ error('{} requires {} to be specified', *pair) - - def check_properties(groups): - grammar = property_grammar() - for matches, props in groups: -- prop_names = set() -+ seen_props = {} - for prop in props: - # print('--', prop) - prop = prop.partition('#')[0].rstrip() -@@ -214,30 +289,35 @@ def check_properties(groups): - error('Failed to parse: {!r}', prop) - continue - # print('{!r}'.format(parsed)) -- if parsed.NAME in prop_names: -+ if parsed.NAME in seen_props: - error('Property {} is duplicated', parsed.NAME) -- prop_names.add(parsed.NAME) -+ seen_props[parsed.NAME] = parsed.VALUE - if parsed.NAME == 'MOUSE_DPI': - check_one_default(prop, parsed.VALUE.SETTINGS) - elif parsed.NAME == 'ACCEL_MOUNT_MATRIX': - check_one_mount_matrix(prop, parsed.VALUE) - elif parsed.NAME.startswith('KEYBOARD_KEY_'): -- check_one_keycode(prop, parsed.VALUE) -+ val = parsed.VALUE if isinstance(parsed.VALUE, str) else parsed.VALUE[0] -+ check_one_keycode(prop, val) -+ -+ check_wheel_clicks(seen_props) - - def print_summary(fname, groups): -+ n_matches = sum(len(matches) for matches, props in groups) -+ n_props = sum(len(props) for matches, props in groups) - print('{}: {} match groups, {} matches, {} properties' -- .format(fname, -- len(groups), -- sum(len(matches) for matches, props in groups), -- sum(len(props) for matches, props in groups))) -+ .format(fname, len(groups), n_matches, n_props)) -+ -+ if n_matches == 0 or n_props == 0: -+ error('{}: no matches or props'.format(fname)) - - if __name__ == '__main__': -- args = sys.argv[1:] or glob.glob(os.path.dirname(sys.argv[0]) + '/[67]0-*.hwdb') -+ args = sys.argv[1:] or sorted(glob.glob(os.path.dirname(sys.argv[0]) + '/[678][0-9]-*.hwdb')) - - for fname in args: - groups = parse(fname) - print_summary(fname, groups) -- check_match_uniqueness(groups) -+ check_matches(groups) - check_properties(groups) - - sys.exit(ERROR) diff --git a/20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch b/20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch deleted file mode 100644 index 7d81489..0000000 --- a/20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 62f8dac80e5f908f83b6e7cd06629055184c25d7 Mon Sep 17 00:00:00 2001 -From: Forrestly -Date: Thu, 23 Mar 2023 10:08:33 +0800 -Subject: [PATCH] cgroup: do not refresh cgroup devices config when - daemon-reload(#42937798) - -Signed-off-by: Forrestly ---- - src/core/cgroup.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/core/cgroup.c b/src/core/cgroup.c -index 50d2738..ea92aa6 100644 ---- a/src/core/cgroup.c -+++ b/src/core/cgroup.c -@@ -1920,6 +1920,7 @@ static int unit_realize_cgroup_now(Unit *u, ManagerState state) { - enable_mask = unit_get_enable_mask(u); - needs_bpf = unit_get_needs_bpf(u); - -+ target_mask &= ~CGROUP_MASK_DEVICES; - if (unit_has_mask_realized(u, target_mask, enable_mask, needs_bpf)) - return 0; - --- -2.34.1 - diff --git a/20003-core-introduce-cgroup-full-delegation-for-compabilit.patch b/20003-core-introduce-cgroup-full-delegation-for-compabilit.patch deleted file mode 100644 index a09eaa2..0000000 --- a/20003-core-introduce-cgroup-full-delegation-for-compabilit.patch +++ /dev/null @@ -1,125 +0,0 @@ -From ce2e0936e03f6cef91a326186978643b93403052 Mon Sep 17 00:00:00 2001 -From: "zhongling.h" -Date: Fri, 4 Aug 2023 10:08:16 +0800 -Subject: [PATCH] core: introduce cgroup full delegation for compability - -While using systemd-219, users can set 'delegate=y' to claim the -possession of cgroup settings. By then, users are able to write raw -values under /sys/fs/cgroup to adjust cgroup settings and systemd -won't touch these values any longer. - -However, this is likely to be an undefined behaviour for systemd-219. -Upon releasing systemd-239, a documentation of cgroup delegation was -added, -https://github.com/systemd/systemd/commit/e30eaff3a32523b09d61af67fc999f1f62f4e0cb. -It states that: - -Only sub-trees can be delegated (though whoever decides to request a -sub-tree can delegate sub-sub-trees further to somebody else if they -like it).' - -Which is quite different from what people understand the delegation of -systemd-219. Currently, whether a unit is delegated or not, systemd always -possesses any cgroup it created, only ignoring the sub-tree ones -according to delegation settings. - -This behaviour change causes confusion if users switch from systemd-219 to -systemd-239. As a result, we introduce 'FullDelegation', a feature that -brings what users are already familiar with to systemd-239. If users set -'FullDelegation=yes' in /etc/systemd/system.conf, they can control raw -values under /sys/fs/cgroup without worrying systemd touching these -values, which is the same as what they expected with systemd-219. - -diff --git a/src/core/cgroup.c b/src/core/cgroup.c -index 8e474f6..461f9df 100644 ---- a/src/core/cgroup.c -+++ b/src/core/cgroup.c -@@ -1692,6 +1692,15 @@ static int unit_create_cgroup( - /* Keep track that this is now realized */ - u->cgroup_realized = true; - u->cgroup_realized_mask = target_mask; -+ -+ // While realizing cgroup, we don't realize delegated cgroup, therefore, target_mask -+ // doesn't contain delegated cgroup controller bit, and u->cgroup_realized_mask will -+ // not contain delegated cgroup controller bit as well. This unit will be in a state -+ // as if delegated cgroup is not set, which is not expected. -+ // If this is not present, delegated cgroup will be set every 2 systemctl daemon-reload -+ if (u->manager->full_delegation && unit_cgroup_delegate(u)) -+ u->cgroup_realized_mask |= unit_get_delegate_mask(u); -+ - u->cgroup_enabled_mask = enable_mask; - u->cgroup_bpf_state = needs_bpf ? UNIT_CGROUP_BPF_ON : UNIT_CGROUP_BPF_OFF; - -@@ -1920,6 +1929,9 @@ static int unit_realize_cgroup_now(Unit *u, ManagerState state) { - enable_mask = unit_get_enable_mask(u); - needs_bpf = unit_get_needs_bpf(u); - -+ if (u->manager->full_delegation && unit_cgroup_delegate(u)) -+ target_mask ^= u->cgroup_realized_mask; -+ - if (unit_has_mask_realized(u, target_mask, enable_mask, needs_bpf)) - return 0; - -@@ -2882,6 +2894,9 @@ int unit_reset_ip_accounting(Unit *u) { - void unit_invalidate_cgroup(Unit *u, CGroupMask m) { - assert(u); - -+ if (u->manager->full_delegation) -+ m ^= unit_get_delegate_mask(u); // don't invalidate delegated cgroup -+ - if (!UNIT_HAS_CGROUP_CONTEXT(u)) - return; - -diff --git a/src/core/main.c b/src/core/main.c -index 546bf0d..68daf07 100644 ---- a/src/core/main.c -+++ b/src/core/main.c -@@ -142,6 +142,7 @@ static bool reexec_jmp_can = false; - static bool reexec_jmp_inited = false; - static sigjmp_buf reexec_jmp_buf; - static bool arg_default_cpuset_clone_children = false; -+static bool arg_full_delegation = false; - - static int parse_configuration(const struct rlimit *saved_rlimit_nofile, - const struct rlimit *saved_rlimit_memlock); -@@ -768,6 +769,8 @@ static int parse_config_file(void) { - { "Manager", "DefaultTasksMax", config_parse_tasks_max, 0, &arg_default_tasks_max }, - { "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, 0, &arg_cad_burst_action }, - { "Manager", "DefaultCPUSetCloneChildren",config_parse_bool, 0, &arg_default_cpuset_clone_children }, -+ { "Manager", "FullDelegation", config_parse_bool, 0, &arg_full_delegation }, -+ - {} - }; - -@@ -817,6 +820,7 @@ static void set_manager_defaults(Manager *m) { - m->default_memory_accounting = arg_default_memory_accounting; - m->default_tasks_accounting = arg_default_tasks_accounting; - m->default_tasks_max = arg_default_tasks_max; -+ m->full_delegation = arg_full_delegation; - - manager_set_default_rlimits(m, arg_default_rlimit); - manager_environment_add(m, NULL, arg_default_environment); -diff --git a/src/core/manager.h b/src/core/manager.h -index 98d381b..91f2c05 100644 ---- a/src/core/manager.h -+++ b/src/core/manager.h -@@ -297,6 +297,7 @@ struct Manager { - bool default_blockio_accounting; - bool default_tasks_accounting; - bool default_ip_accounting; -+ bool full_delegation; - - uint64_t default_tasks_max; - usec_t default_timer_accuracy_usec; -diff --git a/src/core/system.conf.in b/src/core/system.conf.in -index 2f6852a..6c84a55 100644 ---- a/src/core/system.conf.in -+++ b/src/core/system.conf.in -@@ -67,3 +67,4 @@ DefaultLimitCORE=0:infinity - #DefaultLimitRTTIME= - #IPAddressAllow= - #IPAddressDeny= -+#FullDelegation=no --- -2.39.3 - diff --git a/20004-Update-vendor-ids-for-ieisystem-0750.patch b/20004-Update-vendor-ids-for-ieisystem-0750.patch deleted file mode 100644 index ca0b4c2..0000000 --- a/20004-Update-vendor-ids-for-ieisystem-0750.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 2afcc209fb4677581294421f20bb0d057238539e Mon Sep 17 00:00:00 2001 -From: wangkaiyuan -Date: Wed, 31 Jan 2024 19:30:33 +0800 -Subject: [PATCH] Update vendor ids for ieisystem 0750 - -Signed-off-by: wangkaiyuan ---- - hwdb/20-pci-vendor-model.hwdb | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/hwdb/20-pci-vendor-model.hwdb b/hwdb/20-pci-vendor-model.hwdb -index cdbd8ff..4b666e8 100644 ---- a/hwdb/20-pci-vendor-model.hwdb -+++ b/hwdb/20-pci-vendor-model.hwdb -@@ -69122,6 +69122,9 @@ pci:v00001BD0d00001203* - pci:v00001BD4* - ID_VENDOR_FROM_DATABASE=Inspur Electronic Information Industry Co., Ltd. - -+pci:v00001BD4d00000750* -+ ID_MODEL_FROM_DATABASE=YHGCH ZX1000 -+ - pci:v00001BD4d00000911* - ID_MODEL_FROM_DATABASE=Arria10_PCIe_F10A1150 - --- -2.31.1 - diff --git a/20005-default-enable-full-delegation-on-device-cgroup.patch b/20005-default-enable-full-delegation-on-device-cgroup.patch deleted file mode 100644 index bf11aa5..0000000 --- a/20005-default-enable-full-delegation-on-device-cgroup.patch +++ /dev/null @@ -1,98 +0,0 @@ -From 0c54a1eda08dc8a1c40274c1f90e5e809e054706 Mon Sep 17 00:00:00 2001 -From: rpm-build -Date: Tue, 19 Mar 2024 15:53:21 +0800 -Subject: [PATCH] default enable full delegation on device cgroup - ---- - src/core/cgroup.c | 9 +++++++++ - src/core/main.c | 3 +++ - src/core/manager.h | 1 + - src/core/system.conf.in | 1 + - 4 files changed, 14 insertions(+) - -diff --git a/src/core/cgroup.c b/src/core/cgroup.c -index 461f9df..bc677d8 100644 ---- a/src/core/cgroup.c -+++ b/src/core/cgroup.c -@@ -1701,6 +1701,9 @@ static int unit_create_cgroup( - if (u->manager->full_delegation && unit_cgroup_delegate(u)) - u->cgroup_realized_mask |= unit_get_delegate_mask(u); - -+ if (u->manager->full_delegation_devicecg && unit_cgroup_delegate(u)) -+ u->cgroup_realized_mask |= (unit_get_delegate_mask(u) & CGROUP_MASK_DEVICES); -+ - u->cgroup_enabled_mask = enable_mask; - u->cgroup_bpf_state = needs_bpf ? UNIT_CGROUP_BPF_ON : UNIT_CGROUP_BPF_OFF; - -@@ -1932,6 +1935,9 @@ static int unit_realize_cgroup_now(Unit *u, ManagerState state) { - if (u->manager->full_delegation && unit_cgroup_delegate(u)) - target_mask ^= u->cgroup_realized_mask; - -+ if (u->manager->full_delegation_devicecg && unit_cgroup_delegate(u)) -+ target_mask ^= (u->cgroup_realized_mask & CGROUP_MASK_DEVICES); -+ - if (unit_has_mask_realized(u, target_mask, enable_mask, needs_bpf)) - return 0; - -@@ -2897,6 +2903,9 @@ void unit_invalidate_cgroup(Unit *u, CGroupMask m) { - if (u->manager->full_delegation) - m ^= unit_get_delegate_mask(u); // don't invalidate delegated cgroup - -+ if (u->manager->full_delegation_devicecg) -+ m ^= (unit_get_delegate_mask(u) & CGROUP_MASK_DEVICES); // don't invalidate device cgroup if delegate=yes -+ - if (!UNIT_HAS_CGROUP_CONTEXT(u)) - return; - -diff --git a/src/core/main.c b/src/core/main.c -index 68daf07..e27f0a5 100644 ---- a/src/core/main.c -+++ b/src/core/main.c -@@ -143,6 +143,7 @@ static bool reexec_jmp_inited = false; - static sigjmp_buf reexec_jmp_buf; - static bool arg_default_cpuset_clone_children = false; - static bool arg_full_delegation = false; -+static bool arg_full_delegation_devicecg = true; - - static int parse_configuration(const struct rlimit *saved_rlimit_nofile, - const struct rlimit *saved_rlimit_memlock); -@@ -770,6 +771,7 @@ static int parse_config_file(void) { - { "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, 0, &arg_cad_burst_action }, - { "Manager", "DefaultCPUSetCloneChildren",config_parse_bool, 0, &arg_default_cpuset_clone_children }, - { "Manager", "FullDelegation", config_parse_bool, 0, &arg_full_delegation }, -+ { "Manager", "FullDelegationDeviceCGroup",config_parse_bool, 0, &arg_full_delegation_devicecg }, - - {} - }; -@@ -821,6 +823,7 @@ static void set_manager_defaults(Manager *m) { - m->default_tasks_accounting = arg_default_tasks_accounting; - m->default_tasks_max = arg_default_tasks_max; - m->full_delegation = arg_full_delegation; -+ m->full_delegation_devicecg = arg_full_delegation_devicecg; - - manager_set_default_rlimits(m, arg_default_rlimit); - manager_environment_add(m, NULL, arg_default_environment); -diff --git a/src/core/manager.h b/src/core/manager.h -index 91f2c05..8017d9a 100644 ---- a/src/core/manager.h -+++ b/src/core/manager.h -@@ -298,6 +298,7 @@ struct Manager { - bool default_tasks_accounting; - bool default_ip_accounting; - bool full_delegation; -+ bool full_delegation_devicecg; - - uint64_t default_tasks_max; - usec_t default_timer_accuracy_usec; -diff --git a/src/core/system.conf.in b/src/core/system.conf.in -index 6c84a55..3f9ef7f 100644 ---- a/src/core/system.conf.in -+++ b/src/core/system.conf.in -@@ -68,3 +68,4 @@ DefaultLimitCORE=0:infinity - #IPAddressAllow= - #IPAddressDeny= - #FullDelegation=no -+#FullDelegationDeviceCGroup=yes --- -2.39.3 - diff --git a/20006-systemd-Add-sw64.patch b/20006-systemd-Add-sw64.patch deleted file mode 100644 index f1e0e6a..0000000 --- a/20006-systemd-Add-sw64.patch +++ /dev/null @@ -1,94 +0,0 @@ -From 1d1259c0bada01ed92d991b44be1f53042837187 Mon Sep 17 00:00:00 2001 -From: rpm-build -Date: Fri, 12 May 2023 15:33:42 +0800 -Subject: [PATCH] Add sw64 architecture - -Signed-off-by: rpm-build ---- - src/basic/architecture.c | 3 +++ - src/basic/architecture.h | 4 ++++ - src/basic/missing.h | 2 +- - src/basic/missing_syscall.h | 4 +++- - 4 files changed, 11 insertions(+), 2 deletions(-) - -diff --git a/src/basic/architecture.c b/src/basic/architecture.c -index 96bbf97..72b98a3 100644 ---- a/src/basic/architecture.c -+++ b/src/basic/architecture.c -@@ -120,6 +120,8 @@ int uname_architecture(void) { - { "arceb", ARCHITECTURE_ARC_BE }, - #elif defined(__loongarch64) - { "loongarch64", ARCHITECTURE_LOONGARCH64 }, -+#elif defined(__sw_64__) -+ { "sw_64" , ARCHITECTURE_SW_64 }, - #else - #error "Please register your architecture here!" - #endif -@@ -176,6 +178,7 @@ static const char *const architecture_table[_ARCHITECTURE_MAX] = { - [ARCHITECTURE_ARC] = "arc", - [ARCHITECTURE_ARC_BE] = "arc-be", - [ARCHITECTURE_LOONGARCH64] = "loongarch64", -+ [ARCHITECTURE_SW_64] = "sw_64", - }; - - DEFINE_STRING_TABLE_LOOKUP(architecture, int); -diff --git a/src/basic/architecture.h b/src/basic/architecture.h -index 22e9108..c317c75 100644 ---- a/src/basic/architecture.h -+++ b/src/basic/architecture.h -@@ -45,6 +45,7 @@ enum { - ARCHITECTURE_ARC, - ARCHITECTURE_ARC_BE, - ARCHITECTURE_LOONGARCH64, -+ ARCHITECTURE_SW_64, - _ARCHITECTURE_MAX, - _ARCHITECTURE_INVALID = -1 - }; -@@ -233,6 +234,9 @@ int uname_architecture(void); - #elif defined(__loongarch64) - # define native_architecture() ARCHITECTURE_LOONGARCH64 - # define LIB_ARCH_TUPLE "loongarch64-linux-gnu" -+#elif defined(__sw_64__) -+# define native_architecture() ARCHITECTURE_SW_64 -+# define LIB_ARCH_TUPLE "sw_64-linux-gnu" - #else - # error "Please register your architecture here!" - #endif -diff --git a/src/basic/missing.h b/src/basic/missing.h -index b937661..c2913b5 100644 ---- a/src/basic/missing.h -+++ b/src/basic/missing.h -@@ -646,7 +646,7 @@ struct input_mask { - */ - - #ifndef __O_TMPFILE --#if defined(__alpha__) -+#if defined(__alpha__) || defined(__sw_64__) - #define __O_TMPFILE 0100000000 - #elif defined(__parisc__) || defined(__hppa__) - #define __O_TMPFILE 0400000000 -diff --git a/src/basic/missing_syscall.h b/src/basic/missing_syscall.h -index 014dd2b..3acf59f 100644 ---- a/src/basic/missing_syscall.h -+++ b/src/basic/missing_syscall.h -@@ -182,7 +182,7 @@ static inline int missing_setns(int fd, int nstype) { - /* ======================================================================= */ - - static inline pid_t raw_getpid(void) { --#if defined(__alpha__) -+#if defined(__alpha__) || defined(__sw_64__) - return (pid_t) syscall(__NR_getxpid); - #else - return (pid_t) syscall(__NR_getpid); -@@ -405,6 +405,8 @@ static inline int missing_bpf(int cmd, union bpf_attr *attr, size_t size) { - # define __NR_statx 360 - # elif defined __x86_64__ - # define __NR_statx 332 -+# elif defined __sw_64__ -+# define __NR_statx 518 - # else - # warning "__NR_statx not defined for your architecture" - # endif --- -2.31.1 - diff --git a/20007-add-seccomp-support-for-sw_64.patch b/20007-add-seccomp-support-for-sw_64.patch deleted file mode 100644 index f3cda33..0000000 --- a/20007-add-seccomp-support-for-sw_64.patch +++ /dev/null @@ -1,96 +0,0 @@ -From a8b1f7bfc0190af52e863ddc821701d32e6c3c97 Mon Sep 17 00:00:00 2001 -From: Weisson -Date: Sun, 7 Apr 2024 15:45:26 +0800 -Subject: [PATCH 1/1] add seccomp support for sw_64. - -Signed-off-by: Weisson ---- - src/shared/seccomp-util.c | 16 ++++++++++++---- - 1 file changed, 12 insertions(+), 4 deletions(-) - -diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c -index 8b0d366..2cedca5 100644 ---- a/src/shared/seccomp-util.c -+++ b/src/shared/seccomp-util.c -@@ -44,6 +44,8 @@ const uint32_t seccomp_local_archs[] = { - SCMP_ARCH_ARM, - #elif defined(__loongarch__) - SCMP_ARCH_LOONGARCH64, -+#elif defined(__sw_64__) -+ SCMP_ARCH_SW_64, - #elif defined(__mips__) && __BYTE_ORDER == __BIG_ENDIAN && _MIPS_SIM == _MIPS_SIM_ABI32 - SCMP_ARCH_MIPSEL, - SCMP_ARCH_MIPS, /* native */ -@@ -114,6 +116,8 @@ const char* seccomp_arch_to_string(uint32_t c) { - return "x32"; - case SCMP_ARCH_ARM: - return "arm"; -+ case SCMP_ARCH_SW_64: -+ return "sw_64"; - case SCMP_ARCH_AARCH64: - return "arm64"; - case SCMP_ARCH_LOONGARCH64: -@@ -163,6 +167,8 @@ int seccomp_arch_from_string(const char *n, uint32_t *ret) { - *ret = SCMP_ARCH_ARM; - else if (streq(n, "arm64")) - *ret = SCMP_ARCH_AARCH64; -+ else if (streq(n, "sw_64")) -+ *ret = SCMP_ARCH_SW_64; - else if (streq(n, "loongarch64")) - *ret = SCMP_ARCH_LOONGARCH64; - else if (streq(n, "mips")) -@@ -1246,7 +1252,7 @@ int seccomp_protect_sysctl(void) { - - log_debug("Operating on architecture: %s", seccomp_arch_to_string(arch)); - -- if (IN_SET(arch, SCMP_ARCH_X32, SCMP_ARCH_AARCH64, SCMP_ARCH_LOONGARCH64)) -+ if (IN_SET(arch, SCMP_ARCH_X32, SCMP_ARCH_AARCH64, SCMP_ARCH_LOONGARCH64, SCMP_ARCH_SW_64)) - /* No _sysctl syscall */ - continue; - -@@ -1291,6 +1297,7 @@ int seccomp_restrict_address_families(Set *address_families, bool whitelist) { - case SCMP_ARCH_X32: - case SCMP_ARCH_ARM: - case SCMP_ARCH_AARCH64: -+ case SCMP_ARCH_SW_64: - case SCMP_ARCH_LOONGARCH64: - case SCMP_ARCH_MIPSEL64N32: - case SCMP_ARCH_MIPS64N32: -@@ -1536,7 +1543,7 @@ static int add_seccomp_syscall_filter(scmp_filter_ctx seccomp, - } - - /* For known architectures, check that syscalls are indeed defined or not. */ --#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__loongarch__) -+#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__loongarch__) || defined(__sw_64__) - assert_cc(SCMP_SYS(shmget) > 0); - assert_cc(SCMP_SYS(shmat) > 0); - assert_cc(SCMP_SYS(shmdt) > 0); -@@ -1583,6 +1590,7 @@ int seccomp_memory_deny_write_execute(void) { - case SCMP_ARCH_X86_64: - case SCMP_ARCH_X32: - case SCMP_ARCH_AARCH64: -+ case SCMP_ARCH_SW_64: - case SCMP_ARCH_LOONGARCH64: - filter_syscall = SCMP_SYS(mmap); /* amd64, x32, and arm64 have only mmap */ - shmat_syscall = SCMP_SYS(shmat); -@@ -1590,7 +1598,7 @@ int seccomp_memory_deny_write_execute(void) { - - /* Please add more definitions here, if you port systemd to other architectures! */ - --#if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__) && !defined(__powerpc64__) && !defined(__arm__) && !defined(__aarch64__) && !defined(__loongarch__) -+#if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__) && !defined(__powerpc64__) && !defined(__arm__) && !defined(__aarch64__) && !defined(__loongarch__) && !defined(__sw_64__) - #warning "Consider adding the right mmap() syscall definitions here!" - #endif - } -@@ -1614,7 +1622,7 @@ int seccomp_memory_deny_write_execute(void) { - if (r < 0) - continue; - } -- if (!IN_SET(arch, SCMP_ARCH_LOONGARCH64)){ -+ if (!IN_SET(arch, SCMP_ARCH_LOONGARCH64, SCMP_ARCH_SW_64)){ - r = add_seccomp_syscall_filter(seccomp, arch, SCMP_SYS(mprotect), - 1, - SCMP_A2(SCMP_CMP_MASKED_EQ, PROT_EXEC, PROT_EXEC)); --- -2.31.1 - diff --git a/20008-Fix-unit-test-test-seccomp-support-on-sw_64.patch b/20008-Fix-unit-test-test-seccomp-support-on-sw_64.patch deleted file mode 100644 index ac70671..0000000 --- a/20008-Fix-unit-test-test-seccomp-support-on-sw_64.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 573700e701553081bd2bdb9081da0a1215f5ed97 Mon Sep 17 00:00:00 2001 -From: Weisson -Date: Sun, 7 Apr 2024 17:13:11 +0800 -Subject: [PATCH] Fix unit-test: test-seccomp support on sw_64. - -Signed-off-by: Weisson ---- - src/test/test-seccomp.c | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c -index 286f01b..c04eb66 100644 ---- a/src/test/test-seccomp.c -+++ b/src/test/test-seccomp.c -@@ -55,6 +55,7 @@ static void test_architecture_table(void) { - "x32\0" - "arm\0" - "arm64\0" -+ "sw_64\0" - "mips\0" - "mips64\0" - "mips64-n32\0" -@@ -403,7 +404,7 @@ static void test_memory_deny_write_execute_mmap(void) { - assert_se(seccomp_memory_deny_write_execute() >= 0); - - p = mmap(NULL, page_size(), PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1,0); --#if defined(__x86_64__) || defined(__i386__) || defined(__powerpc64__) || defined(__arm__) || defined(__aarch64__) -+#if defined(__x86_64__) || defined(__i386__) || defined(__powerpc64__) || defined(__arm__) || defined(__aarch64__) || defined(__sw_64__) - assert_se(p == MAP_FAILED); - assert_se(errno == EPERM); - #else /* unknown architectures */ -@@ -450,7 +451,7 @@ static void test_memory_deny_write_execute_shmat(void) { - assert_se(seccomp_memory_deny_write_execute() >= 0); - - p = shmat(shmid, NULL, SHM_EXEC); --#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) -+#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__sw_64__) - assert_se(p == MAP_FAILED); - assert_se(errno == EPERM); - #else /* __i386__, __powerpc64__, and "unknown" architectures */ --- -2.31.1 - diff --git a/20009-core-introduce-cgroup-FullDelegation-FullDelegationD.patch b/20009-core-introduce-cgroup-FullDelegation-FullDelegationD.patch deleted file mode 100644 index bcd28b5..0000000 --- a/20009-core-introduce-cgroup-FullDelegation-FullDelegationD.patch +++ /dev/null @@ -1,163 +0,0 @@ -From f4fc78bb9b250e7e8f5197aa15055239276ec3cd Mon Sep 17 00:00:00 2001 -From: rpm-build -Date: Wed, 10 Jul 2024 17:46:57 +0800 -Subject: [PATCH] core: introduce cgroup FullDelegation, - FullDelegationDeviceCGroup for compability - -Whille using systemd-219, users can set 'delegate=y' to claim the -possession of cgroup settings. By then, users are able to write raw -values under /sys/fs/cgroup to adjust cgroup settings and systemd -won't touch these values any longer. - -However, this is likely to be an undefined behaviour for systemd-219. -Upon releasing systemd-239, a documentation of cgroup delegation was -added, -https://github.com/systemd/systemd/commit/e30eaff3a32523b09d61af67fc999f1f62f4e0cb. -It states that: - -Only sub-trees can be delegated (though whoever decides to request a -sub-tree can delegate sub-sub-trees further to somebody else if they -like it).' - -Which is quite different from what people understand the delegation of -systemd-219. Currently, whether a unit is delegated or not, systemd always -possesses any cgroup it created, only ignoring the sub-tree ones -according to delegation settings. - -This behaviour change causes confusion if users switch from systemd-219 to -systemd-239. As a result, we introduce 'FullDelegation', a feature that -brings what users are already familiar with to systemd-239. If users set -'FullDelegation=yes' in /etc/systemd/system.conf, they can control raw -values under /sys/fs/cgroup without worrying systemd touching these -values, which is the same as what they expected with systemd-219. - -The 'FullDelegation' option should not be enabled by default, as it alters the -default behavior that users are accustomed to or will become familiar with. -However, without enabling this option, GPU containers will not function -correctly. To address this issue, we have introduced -'FullDelegationDeviceCGroup', which replicates the behavior of systemd-219 -specifically for device cgroups. This option is enabled by default. - -During the use of earlier versions of systemd, we encountered bug reports -indicating that when 'FullDelegation' is enabled, subcgroups are removed by -systemd. This issue arises due to a flaw in our modification of the -`unit_realize_cgroup_now` function. We overlooked the fact that, in addition to -creating cgroups, the unit_create_cgroup function also deletes subcgroups based -on unset bits in the `target_mask`. To resolve this, we have adjusted the -procedure by moving the reduction of the `target_mask` to occur after the -execution of `unit_create_cgroup`, thereby preventing the unintended deletion of -subcgroups. ---- - src/core/cgroup.c | 24 ++++++++++++++++++++++++ - src/core/main.c | 7 +++++++ - src/core/manager.h | 2 ++ - src/core/system.conf.in | 2 ++ - 4 files changed, 35 insertions(+) - -diff --git a/src/core/cgroup.c b/src/core/cgroup.c -index 8e474f6..6a5606f 100644 ---- a/src/core/cgroup.c -+++ b/src/core/cgroup.c -@@ -1692,6 +1692,18 @@ static int unit_create_cgroup( - /* Keep track that this is now realized */ - u->cgroup_realized = true; - u->cgroup_realized_mask = target_mask; -+ -+ // While realizing cgroup, we don't realize delegated cgroup, therefore, target_mask -+ // doesn't contain delegated cgroup controller bit, and u->cgroup_realized_mask will -+ // not contain delegated cgroup controller bit as well. This unit will be in a state -+ // as if delegated cgroup is not set, which is not expected. -+ // If this is not present, delegated cgroup will be set every 2 systemctl daemon-reload -+ if (u->manager->full_delegation && unit_cgroup_delegate(u)) -+ u->cgroup_realized_mask |= unit_get_delegate_mask(u); -+ -+ if (u->manager->full_delegation_devicecg && unit_cgroup_delegate(u)) -+ u->cgroup_realized_mask |= (unit_get_delegate_mask(u) & CGROUP_MASK_DEVICES); -+ - u->cgroup_enabled_mask = enable_mask; - u->cgroup_bpf_state = needs_bpf ? UNIT_CGROUP_BPF_ON : UNIT_CGROUP_BPF_OFF; - -@@ -1940,6 +1952,12 @@ static int unit_realize_cgroup_now(Unit *u, ManagerState state) { - if (r < 0) - return r; - -+ if (u->manager->full_delegation && unit_cgroup_delegate(u)) -+ target_mask ^= u->cgroup_realized_mask; -+ -+ if (u->manager->full_delegation_devicecg && unit_cgroup_delegate(u)) -+ target_mask ^= (u->cgroup_realized_mask & CGROUP_MASK_DEVICES); -+ - /* Finally, apply the necessary attributes. */ - cgroup_context_apply(u, target_mask, apply_bpf, state); - cgroup_xattr_apply(u); -@@ -2882,6 +2900,12 @@ int unit_reset_ip_accounting(Unit *u) { - void unit_invalidate_cgroup(Unit *u, CGroupMask m) { - assert(u); - -+ if (u->manager->full_delegation) -+ m ^= unit_get_delegate_mask(u); // don't invalidate delegated cgroup -+ -+ if (u->manager->full_delegation_devicecg) -+ m ^= (unit_get_delegate_mask(u) & CGROUP_MASK_DEVICES); // don't invalidate device cgroup if delegate=yes -+ - if (!UNIT_HAS_CGROUP_CONTEXT(u)) - return; - -diff --git a/src/core/main.c b/src/core/main.c -index 546bf0d..e27f0a5 100644 ---- a/src/core/main.c -+++ b/src/core/main.c -@@ -142,6 +142,8 @@ static bool reexec_jmp_can = false; - static bool reexec_jmp_inited = false; - static sigjmp_buf reexec_jmp_buf; - static bool arg_default_cpuset_clone_children = false; -+static bool arg_full_delegation = false; -+static bool arg_full_delegation_devicecg = true; - - static int parse_configuration(const struct rlimit *saved_rlimit_nofile, - const struct rlimit *saved_rlimit_memlock); -@@ -768,6 +770,9 @@ static int parse_config_file(void) { - { "Manager", "DefaultTasksMax", config_parse_tasks_max, 0, &arg_default_tasks_max }, - { "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, 0, &arg_cad_burst_action }, - { "Manager", "DefaultCPUSetCloneChildren",config_parse_bool, 0, &arg_default_cpuset_clone_children }, -+ { "Manager", "FullDelegation", config_parse_bool, 0, &arg_full_delegation }, -+ { "Manager", "FullDelegationDeviceCGroup",config_parse_bool, 0, &arg_full_delegation_devicecg }, -+ - {} - }; - -@@ -817,6 +822,8 @@ static void set_manager_defaults(Manager *m) { - m->default_memory_accounting = arg_default_memory_accounting; - m->default_tasks_accounting = arg_default_tasks_accounting; - m->default_tasks_max = arg_default_tasks_max; -+ m->full_delegation = arg_full_delegation; -+ m->full_delegation_devicecg = arg_full_delegation_devicecg; - - manager_set_default_rlimits(m, arg_default_rlimit); - manager_environment_add(m, NULL, arg_default_environment); -diff --git a/src/core/manager.h b/src/core/manager.h -index 98d381b..8017d9a 100644 ---- a/src/core/manager.h -+++ b/src/core/manager.h -@@ -297,6 +297,8 @@ struct Manager { - bool default_blockio_accounting; - bool default_tasks_accounting; - bool default_ip_accounting; -+ bool full_delegation; -+ bool full_delegation_devicecg; - - uint64_t default_tasks_max; - usec_t default_timer_accuracy_usec; -diff --git a/src/core/system.conf.in b/src/core/system.conf.in -index 2f6852a..3f9ef7f 100644 ---- a/src/core/system.conf.in -+++ b/src/core/system.conf.in -@@ -67,3 +67,5 @@ DefaultLimitCORE=0:infinity - #DefaultLimitRTTIME= - #IPAddressAllow= - #IPAddressDeny= -+#FullDelegation=no -+#FullDelegationDeviceCGroup=yes --- -2.39.3 - diff --git a/91000-analyze-show-information-from-hostnamed-in-plot-even.patch b/91000-analyze-show-information-from-hostnamed-in-plot-even.patch deleted file mode 100644 index 272abec..0000000 --- a/91000-analyze-show-information-from-hostnamed-in-plot-even.patch +++ /dev/null @@ -1,101 +0,0 @@ -From af0841e9fc99fbab958a53fc43424ada6b9a19ad Mon Sep 17 00:00:00 2001 -From: Yu Watanabe -Date: Sun, 22 Jul 2018 14:33:31 +0900 -Subject: [PATCH] analyze: show information from hostnamed in plot even when - user mode - -(cherry-picked from upstream 4f481d76fcbb72fc91789a464cd2b75f0bd47e20) - -This will resolve the following issue after systemd-hostnamed is -disabled: - -``` -[root@localhost ~]# systemd-analyze plot -Failed to get host information from systemd: The name org.freedesktop.hostname1 was not provided by any .service files -``` - -Signed-off-by: Yuanhong Peng ---- - src/analyze/analyze.c | 28 ++++++++++++++++++++-------- - 1 file changed, 20 insertions(+), 8 deletions(-) - -diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c -index c30a133..1ae096d 100644 ---- a/src/analyze/analyze.c -+++ b/src/analyze/analyze.c -@@ -448,6 +448,7 @@ static int acquire_host_info(sd_bus *bus, struct host_info **hi) { - }; - - _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; -+ _cleanup_(sd_bus_flush_close_unrefp) sd_bus *system_bus = NULL; - _cleanup_(free_host_infop) struct host_info *host; - int r; - -@@ -455,7 +456,15 @@ static int acquire_host_info(sd_bus *bus, struct host_info **hi) { - if (!host) - return log_oom(); - -- r = bus_map_all_properties(bus, -+ if (arg_scope != UNIT_FILE_SYSTEM) { -+ r = bus_connect_transport(arg_transport, arg_host, false, &system_bus); -+ if (r < 0) { -+ log_debug_errno(r, "Failed to connect to system bus, ignoring: %m"); -+ goto manager; -+ } -+ } -+ -+ r = bus_map_all_properties(system_bus ?: bus, - "org.freedesktop.hostname1", - "/org/freedesktop/hostname1", - hostname_map, -@@ -463,9 +472,12 @@ static int acquire_host_info(sd_bus *bus, struct host_info **hi) { - &error, - NULL, - host); -- if (r < 0) -- log_debug_errno(r, "Failed to get host information from systemd-hostnamed: %s", bus_error_message(&error, r)); -+ if (r < 0) { -+ log_debug_errno(r, "Failed to get host information from systemd-hostnamed, ignoring: %s", bus_error_message(&error, r)); -+ sd_bus_error_free(&error); -+ } - -+manager: - r = bus_map_all_properties(bus, - "org.freedesktop.systemd1", - "/org/freedesktop/systemd1", -@@ -584,12 +596,12 @@ static int analyze_plot(int argc, char *argv[], void *userdata) { - _cleanup_(free_host_infop) struct host_info *host = NULL; - _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; - _cleanup_(unit_times_freep) struct unit_times *times = NULL; -+ _cleanup_free_ char *pretty_times = NULL; -+ bool use_full_bus = arg_scope == UNIT_FILE_SYSTEM; - struct boot_times *boot; -+ struct unit_times *u; - int n, m = 1, y = 0, r; -- bool use_full_bus = true; - double width; -- _cleanup_free_ char *pretty_times = NULL; -- struct unit_times *u; - - r = acquire_bus(&bus, &use_full_bus); - if (r < 0) -@@ -603,7 +615,7 @@ static int analyze_plot(int argc, char *argv[], void *userdata) { - if (n < 0) - return n; - -- if (use_full_bus) { -+ if (use_full_bus || arg_scope != UNIT_FILE_SYSTEM) { - n = acquire_host_info(bus, &host); - if (n < 0) - return n; -@@ -705,7 +717,7 @@ static int analyze_plot(int argc, char *argv[], void *userdata) { - - svg("\n"); - svg("%s", pretty_times); -- if (use_full_bus) -+ if (host) - svg("%s %s (%s %s %s) %s %s", - isempty(host->os_pretty_name) ? "Linux" : host->os_pretty_name, - strempty(host->hostname), --- -2.18.1 \ No newline at end of file diff --git a/92000-meson-Make-logind-a-requirement-of-user-runtime-dir.patch b/92000-meson-Make-logind-a-requirement-of-user-runtime-dir.patch deleted file mode 100644 index 16bea35..0000000 --- a/92000-meson-Make-logind-a-requirement-of-user-runtime-dir.patch +++ /dev/null @@ -1,44 +0,0 @@ -From b7da107bc80d65ebf6a1e6838f780f756f2fb25c Mon Sep 17 00:00:00 2001 -From: Yuanhong Peng -Date: Fri, 26 Feb 2021 19:20:48 +0800 -Subject: [PATCH] meson: Make logind a requirement of user-runtime-dir - -Partly cherry-picked from upstream 07ee5adb. Since we don't -enable logind in LifseaOS, this is the simplest way to cut -off the user-runtime-dir binary and service file. - -Signed-off-by: Yuanhong Peng ---- - meson.build | 16 ++++++++-------- - 1 file changed, 8 insertions(+), 8 deletions(-) - -diff --git a/meson.build b/meson.build -index cf6990a..fd47e75 100644 ---- a/meson.build -+++ b/meson.build -@@ -1735,15 +1735,15 @@ if conf.get('ENABLE_LOGIND') == 1 - test_dlopen, - args : [pam_systemd.full_path()]) # path to dlopen must include a slash - endif --endif - --executable('systemd-user-runtime-dir', -- user_runtime_dir_sources, -- include_directories : includes, -- link_with : [libshared, liblogind_core], -- install_rpath : rootlibexecdir, -- install : true, -- install_dir : rootlibexecdir) -+ executable('systemd-user-runtime-dir', -+ user_runtime_dir_sources, -+ include_directories : includes, -+ link_with : [libshared, liblogind_core], -+ install_rpath : rootlibexecdir, -+ install : true, -+ install_dir : rootlibexecdir) -+endif - - if conf.get('HAVE_PAM') == 1 - executable('systemd-user-sessions', --- -2.18.1 \ No newline at end of file diff --git a/92001-shared-Remove-dependency-of-libcryptsetup-if-HAVE_LI.patch b/92001-shared-Remove-dependency-of-libcryptsetup-if-HAVE_LI.patch deleted file mode 100644 index 433c611..0000000 --- a/92001-shared-Remove-dependency-of-libcryptsetup-if-HAVE_LI.patch +++ /dev/null @@ -1,40 +0,0 @@ -From afaeb794b5ecf2772765f4a92e92f9be831ef1ea Mon Sep 17 00:00:00 2001 -From: Yuanhong Peng -Date: Fri, 26 Mar 2021 10:37:15 +0800 -Subject: [PATCH] shared: Remove dependency of libcryptsetup if - HAVE_LIBCRYPTSETUP is not defined - -We do not enable libcryptsetup in configuration, so this dependency is -fake. Remove dependency of libcryptsetup will reduce more than ten -dependencies of libsystemd-shared-239.so. - -Signed-off-by: Yuanhong Peng ---- - src/shared/meson.build | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/src/shared/meson.build b/src/shared/meson.build -index d0a1bba..e492ce9 100644 ---- a/src/shared/meson.build -+++ b/src/shared/meson.build -@@ -131,7 +131,6 @@ libshared_deps = [threads, - librt, - libcap, - libacl, -- libcryptsetup, - libgcrypt, - libiptc, - libseccomp, -@@ -141,6 +140,10 @@ libshared_deps = [threads, - liblz4, - libblkid] - -+if conf.get('HAVE_LIBCRYPTSETUP') == 1 -+ libshared_deps += [libcryptsetup] -+endif -+ - libshared_sym_path = '@0@/libshared.sym'.format(meson.current_source_dir()) - - libshared_static = static_library( --- -2.18.1 \ No newline at end of file diff --git a/92002-Do-not-remove-cgroup-path-which-not-created-by-syst.patch b/92002-Do-not-remove-cgroup-path-which-not-created-by-syst.patch deleted file mode 100644 index aec1813..0000000 --- a/92002-Do-not-remove-cgroup-path-which-not-created-by-syst.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 327dab8117c7b478a928387b4384ae7815ad4f06 Mon Sep 17 00:00:00 2001 -From: Yuanhong Peng -Date: Wed, 22 Nov 2023 17:03:33 +0800 -Subject: [PATCH] Do not remove cgroup path which not created by systemd - -It's a workaround for #52520469 - -Details in https://issues.redhat.com/browse/RHEL-16781 - -Signed-off-by: Yuanhong Peng ---- - src/basic/cgroup-util.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c -index 14abe6e..5c87a7a 100644 ---- a/src/basic/cgroup-util.c -+++ b/src/basic/cgroup-util.c -@@ -719,6 +719,10 @@ static int trim_cb(const char *path, const struct stat *sb, int typeflag, struct - if (ftwbuf->level < 1) - return 0; - -+ // workaround: do not remove cgroup path which not created by systemd -+ if (!strstr(path, ".slice/") && !strstr(path, ".service/")) -+ return 0; -+ - (void) rmdir(path); - return 0; - } --- -2.39.3 \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index b91be56..0000000 --- a/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# systemd-239 - -This is the repository of systemd-239 for Anolis OS 8. - -## Patch index convention - -Below is the patch index convention of this repository: - -- 0001 ... 0xxx : patches from upstream srpm -- 10001 ... 10xxx : patches cherry-picked from systemd github upstream -- 20001 ... 20xxx : original patch by OpenAnolis community -- 910001 ... 910xxx : LifseaOS patches that cherry-picked from systemd github upstream -- 920001 ... 920xxx : LifseaOS original patches diff --git a/dist b/dist index 9c0e36e..1fe92cf 100644 --- a/dist +++ b/dist @@ -1 +1 @@ -an8 +an8_10 diff --git a/systemd-user b/systemd-user index d1f64c1..6749b68 100644 --- a/systemd-user +++ b/systemd-user @@ -9,4 +9,5 @@ session required pam_selinux.so close session required pam_selinux.so nottys open session required pam_loginuid.so session required pam_namespace.so +session optional pam_umask.so silent session include system-auth diff --git a/systemd.spec b/systemd.spec index 7a1e822..e976746 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1,4 +1,3 @@ -%define anolis_release .0.8 #global gitcommit 10e465b5321bd53c1fc59ffab27e724535c6bc0f %{?gitcommit:%global gitcommitshort %(c=%{gitcommit}; echo ${c:0:7})} @@ -14,7 +13,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd Version: 239 -Release: 78%{anolis_release}%{?dist}%{?lifsea_dist} +Release: 82%{?dist}.1 # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: System and Service Manager @@ -41,9 +40,7 @@ Source8: systemd-journal-gatewayd.xml Source9: 20-yama-ptrace.conf Source10: systemd-udev-trigger-no-reload.conf Source11: 20-grubby.install -%if ! %{defined lifsea_dist} Source12: systemd-user -%endif Source13: rc.local %if 0 @@ -1032,55 +1029,40 @@ Patch0976: 0976-tmpfiles-don-t-complain-if-we-can-t-enable-pstore-in.patch Patch0977: 0977-pstore-don-t-enable-crash_kexec_post_notifiers-by-de.patch Patch0978: 0978-core-when-Delegate-yes-is-set-for-a-unit-run-ExecSta.patch Patch0979: 0979-man-link-Delegate-documentation-up-with-the-markdown.patch -Patch10000: 10000-core-fix-a-null-reference-case-in-load_from_path.patch -Patch10001: 10001-sysctl-Don-t-pass-null-directive-argument-to-s.patch -Patch10002: 10002-exit-status-introduce-EXIT_EXCEPTION-mapping-to-255.patch -Patch10003: 10003-main-don-t-freeze-PID-1-in-containers-exit-with-non-.patch -Patch10004: 10004-Do-not-go-into-freeze-when-systemd-crashd.patch -Patch10005: 10005-mount-setup-change-the-system-mount-propagation-to-s.patch -Patch10006: 10006-cgroup-util-make-definition-of-CGROUP_CONTROLLER_TO_.patch -Patch10007: 10007-cgroup-update-only-siblings-that-got-realized-once.patch -Patch10008: 10008-core-add-a-config-item-to-support-setting-the-value-.patch -Patch10009: 10009-systemd-anolis-support-loongarch64.patch -Patch10010: 10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch -Patch10011: 10011-hwdb-add-Iluvatar-CoreX.patch -Patch10012: 10012-seccomp-add-loongarch-support.patch -Patch10013: 10013-fileio-when-reading-a-full-file-into-memory-refuse-.patch -Patch10014: 10014-util-introduce-explicit_bzero_safe-for-explicit-mem.patch -Patch10015: 10015-util-introduce-erase_and_free-helper.patch -Patch10016: 10016-util-introduce-READ_FULL_FILE_SECURE-flag-for-readi.patch -Patch10017: 10017-fileio-introduce-warn_file_is_world_accessible.patch -Patch10018: 10018-fileio-read_full_file_full-also-warns-when-file-is-.patch -Patch10019: 10019-basic-fileio-Fix-memory-leak-if-READ_FULL_FILE_SECU.patch -Patch10020: 10020-fileio-add-explicit-flag-for-generating-world-execu.patch -Patch10021: 10021-fileio-add-dir_fd-parameter-to-read_full_file_full.patch -Patch10022: 10022-fileio-add-support-for-read_full_file-on-AF_UNIX-st.patch -Patch10023: 10023-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch -Patch10024: 10024-fileio-teach-read_full_file_full-to-read-from-offse.patch -Patch10025: 10025-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch -Patch10026: 10026-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch -Patch10027: 10027-fix-compilation-without-utmp.patch -# Fix-CVE-2023-7008 Upstream fix:https://github.com/systemd/systemd/commit/3b4cc1437b51fcc0b08da8cc3f5d1175eed25eb1 -Patch10028: Fix-CVE-2023-7008.patch -Patch10029: 10029-cgroup-drastically-simplify-caching-of-cgroups-membe.patch - -Patch20001: 20001-hwdb-parse_hwdb_dot_py.patch -# Patch20002: 20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch -# Patch20003: 20003-core-introduce-cgroup-full-delegation-for-compabilit.patch -Patch20004: 20004-Update-vendor-ids-for-ieisystem-0750.patch -# Patch20005: 20005-default-enable-full-delegation-on-device-cgroup.patch -Patch20006: 20006-systemd-Add-sw64.patch -Patch20007: 20007-add-seccomp-support-for-sw_64.patch -Patch20008: 20008-Fix-unit-test-test-seccomp-support-on-sw_64.patch -Patch20009: 20009-core-introduce-cgroup-FullDelegation-FullDelegationD.patch - -# lifsea only patch -%if %{defined lifsea_dist} -Patch91000: 91000-analyze-show-information-from-hostnamed-in-plot-even.patch -Patch92000: 92000-meson-Make-logind-a-requirement-of-user-runtime-dir.patch -Patch92001: 92001-shared-Remove-dependency-of-libcryptsetup-if-HAVE_LI.patch -Patch92002: 92002-Do-not-remove-cgroup-path-which-not-created-by-syst.patch -%endif +Patch0980: 0980-ci-Extend-source-git-automation.patch +Patch0981: 0981-ci-add-missing-configuration-for-commit-linter.patch +Patch0982: 0982-ci-add-Red-Hat-Enterprise-Linux-8-to-the-list-of-sup.patch +Patch0983: 0983-ci-enable-source-git-automation-to-validate-reviews-.patch +Patch0984: 0984-ci-remove-Mergify-config-replaced-by-Pull-Request-Va.patch +Patch0985: 0985-ci-enable-auto-merge-GH-Action.patch +Patch0986: 0986-fstab-generator-allow-overriding-etc-fstab-with-SYST.patch +Patch0987: 0987-fstab-generator-allow-overriding-path-to-sysroot-etc.patch +Patch0988: 0988-test-backport-TEST-81-GENERATORS-fstab-generator-onl.patch +Patch0989: 0989-resolved-actually-check-authenticated-flag-of-SOA-tr.patch +Patch0990: 0990-fd-util-rework-how-we-determine-highest-possible-fd.patch +Patch0991: 0991-basic-fd-util-refuse-infinite-loop-in-close_all_fds.patch +Patch0992: 0992-fd-util-split-out-inner-fallback-loop-of-close_all_f.patch +Patch0993: 0993-exec-util-use-close_all_fds_without_malloc-from-free.patch +Patch0994: 0994-ci-use-source-git-automation-composite-Action.patch +Patch0995: 0995-ci-increase-the-cron-interval-to-45-minutes.patch +Patch0996: 0996-ci-add-all-Z-Stream-versions-to-array-of-allowed-ver.patch +Patch0997: 0997-tree-wide-always-declare-bitflag-enums-the-same-way.patch +Patch0998: 0998-login-Add-KEY_RESTART-handling.patch +Patch0999: 0999-analyze-security-fix-recursive-call-of-syscall_names.patch +Patch1000: 1000-analyze-security-do-not-assign-badness-to-filtered-o.patch +Patch1001: 1001-analyze-security-include-an-actual-syscall-name-in-t.patch +Patch1002: 1002-udev-net_id-introduce-naming-scheme-for-RHEL-8.10.patch +Patch1003: 1003-doc-add-missing-listitem-to-systemd.net-naming-schem.patch +Patch1004: 1004-service-schedule-cleanup-of-PID-hashmaps-when-we-now.patch +Patch1005: 1005-man-update-link-to-RHEL-documentation.patch +Patch1006: 1006-ci-add-configuration-for-regression-sniffer-GA.patch +Patch1007: 1007-coredump-actually-store-parsed-unit-in-the-context.patch +Patch1008: 1008-resolved-limit-the-number-of-signature-validations-i.patch +Patch1009: 1009-resolved-reduce-the-maximum-nsec3-iterations-to-100.patch +Patch1010: 1010-pid1-by-default-make-user-units-inherit-their-umask-.patch +Patch1011: 1011-pam-add-call-to-pam_umask.patch +Patch1012: 1012-ci-deploy-systemd-man-to-GitHub-Pages.patch +Patch1013: 1013-ci-src-git-update-list-of-supported-products.patch %ifarch %{ix86} x86_64 aarch64 %global have_gnu_efi 1 @@ -1090,8 +1072,7 @@ BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: libcap-devel BuildRequires: libmount-devel -%{!?lifsea_dist:BuildRequires: pam-devel} -%{?lifsea_dist:BuildRequires: acl} +BuildRequires: pam-devel BuildRequires: libselinux-devel BuildRequires: audit-libs-devel BuildRequires: cryptsetup-devel @@ -1132,19 +1113,15 @@ BuildRequires: gettext Requires(post): coreutils Requires(post): sed -%{!?lifsea_dist:Requires(post): acl} +Requires(post): acl Requires(post): grep # systemd-machine-id-setup requires libssl Requires(post): openssl-libs Requires(pre): coreutils Requires(pre): /usr/bin/getent Requires(pre): /usr/sbin/groupadd -%if ! %{defined lifsea_dist} Requires: dbus >= 1.9.18 Requires: %{name}-pam = %{version}-%{release} -%else -Recommends: dbus >= 1.9.18 -%endif Requires: %{name}-libs = %{version}-%{release} Recommends: diffutils Requires: util-linux @@ -1188,11 +1165,9 @@ Obsoletes: libudev < 183 Obsoletes: systemd < 185-4 Conflicts: systemd < 185-4 Obsoletes: systemd-compat-libs < 230 -%if ! %{defined lifsea_dist} Obsoletes: nss-myhostname < 0.4 Provides: nss-myhostname = 0.4 Provides: nss-myhostname%{_isa} = 0.4 -%endif Requires(post): coreutils Requires(post): sed Requires(post): grep @@ -1201,14 +1176,12 @@ Requires(post): /usr/bin/getent %description libs Libraries for systemd and udev. -%if ! %{defined lifsea_dist} %package pam Summary: systemd PAM module Requires: %{name} = %{version}-%{release} %description pam Systemd PAM module registers the session with systemd-logind. -%endif %package devel Summary: Development headers for systemd @@ -1217,10 +1190,8 @@ Requires: %{name}-libs%{?_isa} = %{version}-%{release} Provides: libudev-devel = %{version} Provides: libudev-devel%{_isa} = %{version} Obsoletes: libudev-devel < 183 -%if ! %{defined lifsea_dist} # Fake dependency to make sure systemd-pam is pulled into multilib (#1414153) Requires: %{name}-pam = %{version}-%{release} -%endif %description devel Development headers and auxiliary files for developing applications linking @@ -1295,15 +1266,8 @@ License: LGPLv2+ "Installed tests" that are usually run as part of the build system. They can be useful to test systemd internals. -# To avoid users installing the LifseaOS package in other os -%define common_pre_scripts() \ -if ! grep -q 'ID="lifsea"' /etc/os-release; then \ - echo "This package is only for LifseaOS!" \ - exit 1 \ -fi - %prep -%autosetup %{?gitcommit:-n %{name}-%{gitcommit}}%{?lifsea_dist: -n %{name}-%{version}} -S git_am +%autosetup %{?gitcommit:-n %{name}-%{gitcommit}} -S git_am %build %define ntpvendor %(source /etc/os-release; echo ${ID}) @@ -1316,34 +1280,35 @@ CONFIGURE_OPTS=( -Ddns-servers='' -Ddev-kvm-mode=0666 -Dkmod=true - -Dxkbcommon=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dxkbcommon=true -Dblkid=true -Dseccomp=true -Dima=true -Dselinux=true -Dapparmor=false - -Dpolkit=%{!?lifsea_dist:true}%{?lifsea_dist:false} - -Dxz=%{!?lifsea_dist:true}%{?lifsea_dist:false} - -Dzlib=%{!?lifsea_dist:true}%{?lifsea_dist:false} - -Dbzip2=%{!?lifsea_dist:true}%{?lifsea_dist:false} - -Dlz4=%{!?lifsea_dist:true}%{?lifsea_dist:false} - -Dpam=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dpolkit=true + -Dxz=true + -Dzlib=true + -Dbzip2=true + -Dlz4=true + -Dpam=true -Dacl=true - -Dsmack=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dsmack=true -Dgcrypt=true - -Daudit=%{!?lifsea_dist:true}%{?lifsea_dist:false} - -Delfutils=%{!?lifsea_dist:true}%{?lifsea_dist:false} - -Dlibcryptsetup=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Daudit=true + -Delfutils=true + -Dlibcryptsetup=true + -Delfutils=true -Dqrencode=false - -Dgnutls=%{!?lifsea_dist:true}%{?lifsea_dist:false} - -Dmicrohttpd=%{!?lifsea_dist:true}%{?lifsea_dist:false} - -Dlibidn2=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dgnutls=true + -Dmicrohttpd=true + -Dlibidn2=true -Dlibiptc=false - -Dlibcurl=%{!?lifsea_dist:true}%{?lifsea_dist:false} - -Defi=%{!?lifsea_dist:true}%{?lifsea_dist:false} - %{!?lifsea_dist:-Dgnu-efi=%{?have_gnu_efi:true}%{?!have_gnu_efi:false}} - -Dtpm=%{!?lifsea_dist:true}%{?lifsea_dist:false} - -Dhwdb=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dlibcurl=true + -Defi=true + -Dgnu-efi=%{?have_gnu_efi:true}%{?!have_gnu_efi:false} + -Dtpm=true + -Dhwdb=true -Dsysusers=true -Ddefault-kill-user-processes=false -Dtests=unsafe @@ -1359,36 +1324,6 @@ CONFIGURE_OPTS=( -Dtimesyncd=false -Ddefault-hierarchy=legacy -Dversion-tag=%{version}-%{release} - %if %{defined lifsea_dist} - # remove many useless tools - -Dtimedated=true - -Dman=false - -Dhtml=false - -Dzshcompletiondir=no - -Dbashcompletiondir=no - -Dlogind=false - -Dcoredump=false - -Dbacklight=false - -Dbinfmt=false - -Dimportd=false - -Dhibernate=false - -Dportabled=false - -Dquotacheck=false - -Drfkill=false - -Dvconsole=false - -Dhostnamed=true - -Dlocaled=false - -Dfirstboot=false - -Denvironment-d=false - -Dutmp=false - -Didn=false - -Dlibidn=false - -Dpcre2=false - -Dgcrypt=false - -Dnss-myhostname=false - -Dnss-resolve=false - -Dnss-systemd=false - %endif ) # Don't ship /var/log/README. The relationship between journal and syslog should be documented @@ -1445,7 +1380,7 @@ mkdir -p %{buildroot}%{pkgdir}/user-generators # Create new-style configuration files so that we can ghost-own them touch %{buildroot}%{_sysconfdir}/hostname touch %{buildroot}%{_sysconfdir}/vconsole.conf -%{!?lifsea_dist:touch %{buildroot}%{_sysconfdir}/locale.conf} +touch %{buildroot}%{_sysconfdir}/locale.conf touch %{buildroot}%{_sysconfdir}/machine-id touch %{buildroot}%{_sysconfdir}/machine-info touch %{buildroot}%{_sysconfdir}/localtime @@ -1460,7 +1395,7 @@ mkdir -p %{buildroot}%{pkgdir}/system-sleep/ mkdir -p %{buildroot}%{_localstatedir}/lib/systemd/coredump mkdir -p %{buildroot}%{_localstatedir}/lib/systemd/catalog mkdir -p %{buildroot}%{_localstatedir}/lib/systemd/backlight -%{!?lifsea_dist:mkdir -p %{buildroot}%{_localstatedir}/lib/systemd/rfkill} +mkdir -p %{buildroot}%{_localstatedir}/lib/systemd/rfkill mkdir -p %{buildroot}%{_localstatedir}/lib/systemd/linger mkdir -p %{buildroot}%{_localstatedir}/lib/private mkdir -p %{buildroot}%{_localstatedir}/log/private @@ -1483,10 +1418,8 @@ install -Dm0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/dnf/protected.d/systemd.co install -Dm0644 -t %{buildroot}/usr/lib/firewalld/services/ %{SOURCE7} %{SOURCE8} -%if ! %{defined lifsea_dist} # Restore systemd-user pam config from before "removal of Fedora-specific bits" install -Dm0644 -t %{buildroot}/etc/pam.d/ %{SOURCE12} -%endif # Install additional docs # https://bugzilla.redhat.com/show_bug.cgi?id=1234951 @@ -1524,9 +1457,7 @@ python3 %{SOURCE2} %buildroot </dev/null || groupadd -r -g 11 cdrom &>/dev/null || : getent group utmp &>/dev/null || groupadd -r -g 22 utmp &>/dev/null || : getent group tape &>/dev/null || groupadd -r -g 33 tape &>/dev/null || : @@ -1589,10 +1497,8 @@ getent group kvm &>/dev/null || groupadd -r -g 36 kvm &>/dev/null || : getent group render &>/dev/null || groupadd -r render &>/dev/null || : getent group systemd-journal &>/dev/null || groupadd -r -g 190 systemd-journal 2>&1 || : -%if ! %{defined lifsea_dist} getent group systemd-coredump &>/dev/null || groupadd -r systemd-coredump 2>&1 || : getent passwd systemd-coredump &>/dev/null || useradd -r -l -g systemd-coredump -d / -s /sbin/nologin -c "systemd Core Dumper" systemd-coredump &>/dev/null || : -%endif getent group systemd-resolve &>/dev/null || groupadd -r -g 193 systemd-resolve 2>&1 || : getent passwd systemd-resolve &>/dev/null || useradd -r -u 193 -l -g systemd-resolve -d / -s /sbin/nologin -c "systemd Resolver" systemd-resolve &>/dev/null || : @@ -1607,10 +1513,8 @@ systemd-tmpfiles --create &>/dev/null || : chgrp systemd-journal /run/log/journal/ /run/log/journal/`cat /etc/machine-id 2>/dev/null` /var/log/journal/ /var/log/journal/`cat /etc/machine-id 2>/dev/null` &>/dev/null || : chmod g+s /run/log/journal/ /run/log/journal/`cat /etc/machine-id 2>/dev/null` /var/log/journal/ /var/log/journal/`cat /etc/machine-id 2>/dev/null` &>/dev/null || : -%if ! %{defined lifsea_dist} # Apply ACL to the journal directory setfacl -Rnm g:wheel:rx,d:g:wheel:rx,g:adm:rx,d:g:adm:rx /var/log/journal/ &>/dev/null || : -%endif # Stop-gap until rsyslog.rpm does this on its own. (This is supposed # to fail when the link already exists) @@ -1655,7 +1559,6 @@ fi %post libs %{?ldconfig} -%if ! %{defined lifsea_dist} function mod_nss() { if [ $1 -eq 1 ] && [ -f "$2" ]; then # sed-fu to add myhostname to hosts line (only once, on install) @@ -1684,7 +1587,6 @@ else # possible future authselect configuration mod_nss $1 "/etc/authselect/user-nsswitch.conf" fi -%endif # check if nobody or nfsnobody is defined export SYSTEMD_NSS_BYPASS_SYNTHETIC=1 @@ -1726,9 +1628,6 @@ grep -q -E '^KEYMAP="?fi-latin[19]"?' /etc/vconsole.conf 2>/dev/null && %systemd_postun_with_restart systemd-udevd.service %pre journal-remote -%if %{defined lifsea_dist} -%{common_pre_scripts} -%endif getent group systemd-journal-remote &>/dev/null || groupadd -r systemd-journal-remote 2>&1 || : getent passwd systemd-journal-remote &>/dev/null || useradd -r -l -g systemd-journal-remote -d %{_localstatedir}/log/journal/remote -s /sbin/nologin -c "Journal Remote" systemd-journal-remote &>/dev/null || : @@ -1777,17 +1676,11 @@ fi %ghost %dir %attr(0755,-,-) /etc/systemd/system/system-update.target.wants %ghost %dir %attr(0755,-,-) /etc/systemd/system/timers.target.wants %ghost %dir %attr(0755,-,-) /var/lib/rpm-state/systemd -%if %{defined lifsea_dist} -%exclude %{_prefix}/lib/tmpfiles.d/systemd-nologin.conf -%exclude %{_datarootdir}/polkit-1 -%endif %files libs -f .file-list-libs %license LICENSE.LGPL2.1 -%if ! %{defined lifsea_dist} %files pam -f .file-list-pam -%endif %files devel -f .file-list-devel @@ -1800,82 +1693,49 @@ fi %files tests -f .file-list-tests %changelog -* Mon Jun 24 2024 Zhongling He 239-78.0.8 -- core: Fix subcgroup deletion caused by full delegation -- core: Fix cgroups members mask cache propagation problem - -* Fri Jun 07 2024 Kai Song - 239-78.0.7 -- Fix CVE-2023-7008 - -* Thu Apr 18 2024 Weisson - 239-78.0.6 -- add seccomp support for sw_64. -- add test-seccomp support for sw_64. - -* Thu Apr 18 2024 wxiat - 239-78.0.5 -- cherry-pick `add sw patch #20ead624ed837d467ff4c9607d46c027bbc84ac3`. - -* Wed Apr 3 2024 zhongling.h - 239-78.0.4 -- Remove patch 20002 as it inhibits systemd device cgroup slice creation -- Add patch 20005 to enable device cgroup full delegation by default - -* Thu Feb 29 2024 yuanhui - 239-78.0.3 -- LifseaOS: Add back hostnamectl -- LifseaOS: Add back timedatectl -- LifseaOS: shared: Remove dependency of libcryptsetup if HAVE_LIBCRYPTSETUP is not defined -- LifseaOS: analyze: show information from hostnamed in plot even when user mode -- LifseaOS: configure: Disable smack -- LifseaOS: Remove nss module provided by systemd -- LifseaOS: configure: Remove multiple non-essential features -- LifseaOS: configure: Disable firstboot -- LifseaOS: Remove user-runtime-dir binary and service file -- LifseaOS: Remove the dependency of acl package -- LifseaOS: Remove locale and hostname related tools -- LifseaOS: Remove multiple unnecessary modules -- LifseaOS: Remove compression algorithm -- LifseaOS: Remove many tools of little use -- LifseaOS: Remove coredump tools -- LifseaOS: configure: Disable cryptsetup -- LifseaOS: configure: Disable polkit -- LifseaOS: configure: Disable logind -- LifseaOS: Remove systemd-pam module -- LifseaOS: configure: Remove manpage and bash/zsh completion -- LifseaOS: cgroup: Do not remove cgroup path which not created by systemd - -* Wed Jan 31 2024 wangkaiyuan - 239-78.0.2 -- Update vendor ids for ieisystem 0750 - -* Tue Dec 26 2023 Yuanhong Peng - 239-78.0.1 -- core: fix a null reference case in load_from_path() -- sysctl: Don't pass null directive argument to '%s' -- exit-status: introduce EXIT_EXCEPTION mapping to 255 -- main: don't freeze PID 1 in containers, exit with non-zero instead -- Do not go into freeze when systemd crashd -- mount-setup: change the system mount propagation to shared by default only at bootup -- cgroup-util: make definition of CGROUP_CONTROLLER_TO_MASK() unsigned -- cgroup: update only siblings that got realized once -- core: add a config item to support setting the value of cpuset.clone_children when systemd is starting -- support loongarch for systemd -- test-catalog: Fix coredump when compiled under GCC10 -- add Iluvatar CoreX pci id (Liwei Ge) -- seccomp: add loongarch64 support (Liwei Ge) -- seccomp: remove loongarch64 switch(Liwei Ge) -- umount: check LO_FLAGS_AUTOCLEAR after LOOP_CLR_FD claimed success(yuanhui) -- fileio: when reading a full file into memory, refuse inner NUL bytes (Guorui Yu) -- util: introduce explicit_bzero_safe for explicit memset (Guorui Yu) -- util: introduce erase_and_free() helper (Guorui Yu) -- util: introduce READ_FULL_FILE_SECURE flag for reading secure data (Guorui Yu) -- fileio: introduce warn_file_is_world_accessible() (Guorui Yu) -- fileio: read_full_file_full() also warns when file is world readable and secure flag is set (Guorui Yu) -- basic/fileio: Fix memory leak if READ_FULL_FILE_SECURE flag is used (Guorui Yu) -- fileio: add explicit flag for generating world executable warning when reading file (Guorui Yu) -- fileio: add 'dir_fd' parameter to read_full_file_full() (Guorui Yu) -- fileio: add support for read_full_file() on AF_UNIX stream sockets (Guorui Yu) -- fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name (Guorui Yu) -- fileio: teach read_full_file_full() to read from offset/with maximum size (Guorui Yu) -- cryptsetup: port cryptsetup's main key file logic over to read_full_file_full() (Guorui Yu) -- Update upstream parse_hwdb.py to fix parse-hwdb error (Zhongling He) -- cgroup: do not refresh cgroup devices config when daemon-reload (Zhongling He) -- core: introduce cgroup full delegation for compability (Zhongling He) +* Thu Apr 11 2024 systemd maintenance team - 239-82.1 +- pid1: by default make user units inherit their umask from the user manager (RHEL-28048) +- pam: add call to pam_umask (RHEL-28048) +- ci: deploy systemd man to GitHub Pages (RHEL-32494) +- ci(src-git): update list of supported products (RHEL-32494) + +* Thu Mar 07 2024 systemd maintenance team - 239-82 +- ci: add configuration for regression sniffer GA (RHEL-1087) +- coredump: actually store parsed unit in the context (RHEL-18302) +- resolved: limit the number of signature validations in a transaction (RHEL-26644) +- resolved: reduce the maximum nsec3 iterations to 100 (RHEL-26644) + +* Mon Feb 26 2024 systemd maintenance team - 239-81 +- man: update link to RHEL documentation (RHEL-26355) + +* Thu Feb 15 2024 systemd maintenance team - 239-80 +- fd-util: rework how we determine highest possible fd (RHEL-18302) +- basic/fd-util: refuse "infinite" loop in close_all_fds() (RHEL-18302) +- fd-util: split out inner fallback loop of close_all_fds() as close_all_fds_without_malloc() (RHEL-18302) +- exec-util: use close_all_fds_without_malloc() from freeze() (RHEL-18302) +- ci: use source-git-automation composite Action (RHEL-1087) +- ci: increase the cron interval to 45 minutes (RHEL-1087) +- ci: add all Z-Stream versions to array of allowed versions (RHEL-1087) +- tree-wide: always declare bitflag enums the same way (RHEL-2857) +- login: Add KEY_RESTART handling (RHEL-2857) +- analyze security: fix recursive call of syscall_names_in_filter() (RHEL-5991) +- analyze-security: do not assign badness to filtered-out syscalls (RHEL-5991) +- analyze-security: include an actual syscall name in the message (RHEL-5991) +- udev/net_id: introduce naming scheme for RHEL-8.10 (RHEL-22426) +- doc: add missing `` to `systemd.net-naming-scheme.xml` (RHEL-22426) +- service: schedule cleanup of PID hashmaps when we now longer have main_pid and we are in container (RHEL-5863) + +* Mon Jan 08 2024 systemd maintenance team - 239-79 +- ci: Extend source-git-automation (RHEL-1087) +- ci: add missing configuration for commit linter (RHEL-1087) +- ci: add `Red Hat Enterprise Linux 8` to the list of supported products (RHEL-1087) +- ci: enable source-git automation to validate reviews and ci results (RHEL-1087) +- ci: remove Mergify config - replaced by Pull Request Validator (RHEL-1087) +- ci: enable auto-merge GH Action (RHEL-1087) +- fstab-generator: allow overriding /etc/fstab with $SYSTEMD_FSTAB (RHEL-1087) +- fstab-generator: allow overriding path to /sysroot/etc/fstab too (RHEL-1087) +- test: backport TEST-81-GENERATORS (fstab-generator only) (RHEL-1087) +- resolved: actually check authenticated flag of SOA transaction (RHEL-6213) * Tue Aug 22 2023 systemd maintenance team - 239-78 - login: add a missing error check for session_set_leader() (#2158167) -- Gitee From 75b457ae3344651f451785fcc581702ca9a15aad Mon Sep 17 00:00:00 2001 From: pangqing Date: Tue, 19 Apr 2022 15:08:32 +0800 Subject: [PATCH 02/17] Add optimized patches Signed-off-by: Yuanhong Peng --- ...ull-reference-case-in-load_from_path.patch | 34 +++++ ...-t-pass-null-directive-argument-to-s.patch | 25 ++++ ...roduce-EXIT_EXCEPTION-mapping-to-255.patch | 52 ++++++++ ...e-PID-1-in-containers-exit-with-non-.patch | 52 ++++++++ ...t-go-into-freeze-when-systemd-crashd.patch | 103 +++++++++++++++ ...ge-the-system-mount-propagation-to-s.patch | 62 +++++++++ ...-definition-of-CGROUP_CONTROLLER_TO_.patch | 26 ++++ ...only-siblings-that-got-realized-once.patch | 46 +++++++ ...g-item-to-support-setting-the-value-.patch | 120 ++++++++++++++++++ ...9-systemd-anolis-support-loongarch64.patch | 56 ++++++++ systemd.spec | 25 +++- 11 files changed, 600 insertions(+), 1 deletion(-) create mode 100644 10000-core-fix-a-null-reference-case-in-load_from_path.patch create mode 100644 10001-sysctl-Don-t-pass-null-directive-argument-to-s.patch create mode 100644 10002-exit-status-introduce-EXIT_EXCEPTION-mapping-to-255.patch create mode 100644 10003-main-don-t-freeze-PID-1-in-containers-exit-with-non-.patch create mode 100644 10004-Do-not-go-into-freeze-when-systemd-crashd.patch create mode 100644 10005-mount-setup-change-the-system-mount-propagation-to-s.patch create mode 100644 10006-cgroup-util-make-definition-of-CGROUP_CONTROLLER_TO_.patch create mode 100644 10007-cgroup-update-only-siblings-that-got-realized-once.patch create mode 100644 10008-core-add-a-config-item-to-support-setting-the-value-.patch create mode 100644 10009-systemd-anolis-support-loongarch64.patch diff --git a/10000-core-fix-a-null-reference-case-in-load_from_path.patch b/10000-core-fix-a-null-reference-case-in-load_from_path.patch new file mode 100644 index 0000000..e15690c --- /dev/null +++ b/10000-core-fix-a-null-reference-case-in-load_from_path.patch @@ -0,0 +1,34 @@ +From 11e4aae398f9d26c7c4e54bfa6621f80a3ed2100 Mon Sep 17 00:00:00 2001 +From: Wen Yang +Date: Tue, 19 Apr 2022 11:04:47 +0800 +Subject: [PATCH] fix a null reference case in load_from_path() + +--- + src/core/load-fragment.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c +index c0b1fd4..f59a040 100644 +--- a/src/core/load-fragment.c ++++ b/src/core/load-fragment.c +@@ -4477,7 +4477,6 @@ static int load_from_path(Unit *u, const char *path) { + r = open_follow(&filename, &f, symlink_names, &id); + if (r >= 0) + break; +- filename = mfree(filename); + + /* ENOENT means that the file is missing or is a dangling symlink. + * ENOTDIR means that one of paths we expect to be is a directory +@@ -4486,7 +4485,8 @@ static int load_from_path(Unit *u, const char *path) { + */ + if (r == -EACCES) + log_debug_errno(r, "Cannot access \"%s\": %m", filename); +- else if (!IN_SET(r, -ENOENT, -ENOTDIR)) ++ filename = mfree(filename); ++ if (!IN_SET(r, -ENOENT, -ENOTDIR)) + return r; + + /* Empty the symlink names for the next run */ +-- +2.27.0 + diff --git a/10001-sysctl-Don-t-pass-null-directive-argument-to-s.patch b/10001-sysctl-Don-t-pass-null-directive-argument-to-s.patch new file mode 100644 index 0000000..ec09ee4 --- /dev/null +++ b/10001-sysctl-Don-t-pass-null-directive-argument-to-s.patch @@ -0,0 +1,25 @@ +From 1b3f7805ed7c193e17cb5bad4f4f19c2f72f3d08 Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Tue, 19 Apr 2022 11:16:42 +0800 +Subject: [PATCH] sysctl: Don't pass null directive argument to '%s' + +--- + src/sysctl/sysctl.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c +index 4c85d68..e756eff 100644 +--- a/src/sysctl/sysctl.c ++++ b/src/sysctl/sysctl.c +@@ -160,7 +160,7 @@ static int parse_file(OrderedHashmap *sysctl_options, const char *path, bool ign + + value = strchr(p, '='); + if (!value) { +- log_error("Line is not an assignment at '%s:%u': %s", path, c, value); ++ log_error("Line is not an assignment at '%s:%u': %s", path, c, p); + + if (r == 0) + r = -EINVAL; +-- +2.27.0 + diff --git a/10002-exit-status-introduce-EXIT_EXCEPTION-mapping-to-255.patch b/10002-exit-status-introduce-EXIT_EXCEPTION-mapping-to-255.patch new file mode 100644 index 0000000..66539a0 --- /dev/null +++ b/10002-exit-status-introduce-EXIT_EXCEPTION-mapping-to-255.patch @@ -0,0 +1,52 @@ +From f7940c9cdf872d7504aca9637e9fd14328b2b726 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 19 Apr 2022 11:26:10 +0800 +Subject: [PATCH] exit-status: introduce EXIT_EXCEPTION mapping to 255 + +--- + src/basic/exit-status.c | 9 ++++++--- + src/basic/exit-status.h | 1 + + 2 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/src/basic/exit-status.c b/src/basic/exit-status.c +index 0a7a53b..8b67d44 100644 +--- a/src/basic/exit-status.c ++++ b/src/basic/exit-status.c +@@ -19,9 +19,9 @@ const char* exit_status_to_string(int status, ExitStatusLevel level) { + * 79…199 │ (Currently unmapped) + * 200…241 │ systemd's private error codes (might be extended to 254 in future development) + * 242…254 │ (Currently unmapped, but see above) +- * 255 │ (We should probably stay away from that one, it's frequently used by applications to indicate an +- * │ exit reason that cannot really be expressed in a single exit status value — such as a propagated +- * │ signal or such) ++ * 255 │ EXIT_EXCEPTION (We use this to propagate exit-by-signal events. It's frequently used by others apps (like bash) ++ * │ to indicate exit reason that cannot really be expressed in a single exit status value — such as a propagated ++ * │ signal or such, and we follow that logic here.) + */ + + switch (status) { /* We always cover the ISO C ones */ +@@ -158,6 +158,9 @@ const char* exit_status_to_string(int status, ExitStatusLevel level) { + + case EXIT_NUMA_POLICY: + return "NUMA_POLICY"; ++ ++ case EXIT_EXCEPTION: ++ return "EXCEPTION"; + } + } + +diff --git a/src/basic/exit-status.h b/src/basic/exit-status.h +index dc284aa..e923247 100644 +--- a/src/basic/exit-status.h ++++ b/src/basic/exit-status.h +@@ -70,6 +70,7 @@ enum { + EXIT_LOGS_DIRECTORY, /* 240 */ + EXIT_CONFIGURATION_DIRECTORY, + EXIT_NUMA_POLICY, ++ EXIT_EXCEPTION = 255, /* Whenever we want to propagate an abnormal/signal exit, in line with bash */ + }; + + typedef enum ExitStatusLevel { +-- +2.27.0 + diff --git a/10003-main-don-t-freeze-PID-1-in-containers-exit-with-non-.patch b/10003-main-don-t-freeze-PID-1-in-containers-exit-with-non-.patch new file mode 100644 index 0000000..026fc66 --- /dev/null +++ b/10003-main-don-t-freeze-PID-1-in-containers-exit-with-non-.patch @@ -0,0 +1,52 @@ +From dffb92b5520a4b539f0466d4161fcaacc6ba5ba8 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 19 Apr 2022 11:34:27 +0800 +Subject: [PATCH] main: don't freeze PID 1 in containers, exit with + +--- + src/core/main.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/src/core/main.c b/src/core/main.c +index d897155..0aec5d1 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -139,7 +139,13 @@ static NUMAPolicy arg_numa_policy; + static int parse_configuration(const struct rlimit *saved_rlimit_nofile, + const struct rlimit *saved_rlimit_memlock); + +-_noreturn_ static void freeze_or_reboot(void) { ++_noreturn_ static void freeze_or_exit_or_reboot(void) { ++ /* If we are running in a contianer, let's prefer exiting, after all we can propagate an exit code to the ++ * container manager, and thus inform it that something went wrong. */ ++ if (detect_container() > 0) { ++ log_emergency("Exiting PID 1..."); ++ exit(EXIT_EXCEPTION); ++ } + + if (arg_crash_reboot) { + log_notice("Rebooting in 10s..."); +@@ -247,7 +253,7 @@ _noreturn_ static void crash(int sig) { + } + } + +- freeze_or_reboot(); ++ freeze_or_exit_or_reboot(); + } + + static void install_crash_handler(void) { +@@ -2664,9 +2670,9 @@ finish: + if (error_message) + manager_status_printf(NULL, STATUS_TYPE_EMERGENCY, + ANSI_HIGHLIGHT_RED "!!!!!!" ANSI_NORMAL, +- "%s, freezing.", error_message); +- freeze_or_reboot(); ++ "%s.", error_message); ++ freeze_or_exit_or_reboot(); + } + + reset_arguments(); + return retval; +-- +2.27.0 + diff --git a/10004-Do-not-go-into-freeze-when-systemd-crashd.patch b/10004-Do-not-go-into-freeze-when-systemd-crashd.patch new file mode 100644 index 0000000..1cb12cc --- /dev/null +++ b/10004-Do-not-go-into-freeze-when-systemd-crashd.patch @@ -0,0 +1,103 @@ +From 64072aab92ff6489a2e460a9bdd1cfefa587264b Mon Sep 17 00:00:00 2001 +From: Yuanhong Peng +Date: Tue, 19 Apr 2022 13:36:09 +0800 +Subject: [PATCH] Do not go into freeze when systemd crashd + +--- + src/core/main.c | 41 ++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 40 insertions(+), 1 deletion(-) + +diff --git a/src/core/main.c b/src/core/main.c +index 0aec5d1..db91151 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -3,6 +3,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -10,6 +11,7 @@ + #include + #include + #include ++#include + #include + #if HAVE_SECCOMP + #include +@@ -135,10 +137,41 @@ static sd_id128_t arg_machine_id; + static EmergencyAction arg_cad_burst_action; + static CPUSet arg_cpu_affinity; + static NUMAPolicy arg_numa_policy; ++static bool reexec_jmp_can = false; ++static bool reexec_jmp_inited = false; ++static sigjmp_buf reexec_jmp_buf; + + static int parse_configuration(const struct rlimit *saved_rlimit_nofile, + const struct rlimit *saved_rlimit_memlock); + ++static void reexec_handler(int sig) { ++ reexec_jmp_can = true; ++} ++ ++_noreturn_ static void freeze_wait_upgrade(void) { ++ struct sigaction sa; ++ sigset_t ss; ++ ++ sigemptyset(&ss); ++ sigaddset(&ss, SIGTERM); ++ sigprocmask(SIG_UNBLOCK, &ss, NULL); ++ ++ sa.sa_handler = reexec_handler; ++ sa.sa_flags = SA_RESTART; ++ sigaction(SIGTERM, &sa, NULL); ++ ++ log_error("freeze_wait_upgrade: %d\n", reexec_jmp_inited); ++ reexec_jmp_can = false; ++ while(1) { ++ usleep(10000); ++ if (reexec_jmp_inited && reexec_jmp_can) { ++ log_error("goto manager_reexecute.\n"); ++ siglongjmp(reexec_jmp_buf, 1); ++ } ++ waitpid(-1, NULL, WNOHANG); ++ } ++} ++ + _noreturn_ static void freeze_or_exit_or_reboot(void) { + /* If we are running in a contianer, let's prefer exiting, after all we can propagate an exit code to the + * container manager, and thus inform it that something went wrong. */ +@@ -157,7 +190,8 @@ _noreturn_ static void freeze_or_exit_or_reboot(void) { + } + + log_emergency("Freezing execution."); +- freeze(); ++ freeze_wait_upgrade(); ++ + } + + _noreturn_ static void crash(int sig) { +@@ -1667,6 +1701,10 @@ static int invoke_main_loop( + assert(ret_switch_root_init); + assert(ret_error_message); + ++ reexec_jmp_inited = true; ++ if (sigsetjmp(reexec_jmp_buf, 1)) ++ goto manager_reexecute; ++ + for (;;) { + r = manager_loop(m); + if (r < 0) { +@@ -1709,6 +1747,7 @@ static int invoke_main_loop( + + case MANAGER_REEXECUTE: + ++manager_reexecute: + r = prepare_reexecute(m, &arg_serialization, ret_fds, false); + if (r < 0) { + *ret_error_message = "Failed to prepare for reexecution"; +-- +2.27.0 + diff --git a/10005-mount-setup-change-the-system-mount-propagation-to-s.patch b/10005-mount-setup-change-the-system-mount-propagation-to-s.patch new file mode 100644 index 0000000..fa95141 --- /dev/null +++ b/10005-mount-setup-change-the-system-mount-propagation-to-s.patch @@ -0,0 +1,62 @@ +From 0c7f29561634f9374c0d9042304f4d4caa4242f0 Mon Sep 17 00:00:00 2001 +From: Wen Yang +Date: Tue, 19 Apr 2022 13:50:04 +0800 +Subject: [PATCH] mount-setup: change the system mount propagation to + +--- + src/core/main.c | 2 +- + src/core/mount-setup.c | 4 ++-- + src/core/mount-setup.h | 2 +- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/core/main.c b/src/core/main.c +index db91151..81dae1c 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -2519,7 +2519,7 @@ int main(int argc, char *argv[]) { + if (!skip_setup) + kmod_setup(); + +- r = mount_setup(loaded_policy); ++ r = mount_setup(loaded_policy, skip_setup); + if (r < 0) { + error_message = "Failed to mount API filesystems"; + goto finish; +diff --git a/src/core/mount-setup.c b/src/core/mount-setup.c +index a659458..9f9f953 100644 +--- a/src/core/mount-setup.c ++++ b/src/core/mount-setup.c +@@ -400,7 +400,7 @@ static int relabel_cgroup_filesystems(void) { + } + #endif + +-int mount_setup(bool loaded_policy) { ++int mount_setup(bool loaded_policy, bool leave_propagation) { + int r = 0; + + r = mount_points_setup(ELEMENTSOF(mount_table), loaded_policy); +@@ -444,7 +444,7 @@ int mount_setup(bool loaded_policy) { + * needed. Note that we set this only when we are invoked directly by the kernel. If we are invoked by a + * container manager we assume the container manager knows what it is doing (for example, because it set up + * some directories with different propagation modes). */ +- if (detect_container() <= 0) ++ if (detect_container() <= 0 && !leave_propagation) + if (mount(NULL, "/", NULL, MS_REC|MS_SHARED, NULL) < 0) + log_warning_errno(errno, "Failed to set up the root directory for shared mount propagation: %m"); + +diff --git a/src/core/mount-setup.h b/src/core/mount-setup.h +index 43cd890..7a011b2 100644 +--- a/src/core/mount-setup.h ++++ b/src/core/mount-setup.h +@@ -4,7 +4,7 @@ + #include + + int mount_setup_early(void); +-int mount_setup(bool loaded_policy); ++int mount_setup(bool loaded_policy, bool leave_propagation); + + int mount_cgroup_controllers(char ***join_controllers); + +-- +2.27.0 + diff --git a/10006-cgroup-util-make-definition-of-CGROUP_CONTROLLER_TO_.patch b/10006-cgroup-util-make-definition-of-CGROUP_CONTROLLER_TO_.patch new file mode 100644 index 0000000..9a5fa6e --- /dev/null +++ b/10006-cgroup-util-make-definition-of-CGROUP_CONTROLLER_TO_.patch @@ -0,0 +1,26 @@ +From d449667a6a545a46647911838731e8e46a5a39ed Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 19 Apr 2022 13:56:39 +0800 +Subject: [PATCH] cgroup-util: make definition of CGROUP_CONTROLLER_TO_MASK() + unsigned + +--- + src/basic/cgroup-util.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h +index 1210b38..76659c3 100644 +--- a/src/basic/cgroup-util.h ++++ b/src/basic/cgroup-util.h +@@ -31,7 +31,7 @@ typedef enum CGroupController { + _CGROUP_CONTROLLER_INVALID = -1, + } CGroupController; + +-#define CGROUP_CONTROLLER_TO_MASK(c) (1 << (c)) ++#define CGROUP_CONTROLLER_TO_MASK(c) (1U << (c)) + + /* A bit mask of well known cgroup controllers */ + typedef enum CGroupMask { +-- +2.27.0 + diff --git a/10007-cgroup-update-only-siblings-that-got-realized-once.patch b/10007-cgroup-update-only-siblings-that-got-realized-once.patch new file mode 100644 index 0000000..068f21c --- /dev/null +++ b/10007-cgroup-update-only-siblings-that-got-realized-once.patch @@ -0,0 +1,46 @@ +From 841539281bed5187d2f773097eefb0bb3c5057ec Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 19 Apr 2022 14:03:12 +0800 +Subject: [PATCH] cgroup: update only siblings that got realized once + +--- + src/core/cgroup.c | 16 +++++++++++++++- + 1 file changed, 15 insertions(+), 1 deletion(-) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index f02cc31..e0e0a98 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -1980,7 +1980,16 @@ static void unit_add_siblings_to_cgroup_realize_queue(Unit *u) { + Unit *slice; + + /* This adds the siblings of the specified unit and the siblings of all parent units to the cgroup +- * queue. (But neither the specified unit itself nor the parents.) */ ++ * queue. (But neither the specified unit itself nor the parents.) ++ * ++ * Propagation of realization "side-ways" (i.e. towards siblings) is in relevant on cgroup-v1 where ++ * scheduling become very weird if two units that own processes reside in the same slice, but one is ++ * realized in the "cpu" hierarchy and once is not (for example because one has CPUWeight= set and ++ * the other does not), because that means processes need to be scheduled against groups. Let's avoid ++ * this asymmetry by always ensuring that units below a slice that are realized at all are hence ++ * always realized in *all* their hierarchies, and it is sufficient for a unit's sibling to be ++ * realized for a unit to be realized too. */ ++ + + while ((slice = UNIT_DEREF(u->slice))) { + Iterator i; +@@ -1996,6 +2005,11 @@ static void unit_add_siblings_to_cgroup_realize_queue(Unit *u) { + if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(m))) + continue; + ++ /* We only enqueue siblings if they were realized once at least, in the main ++ * hierarchy. */ ++ if (!m->cgroup_realized) ++ continue; ++ + /* If the unit doesn't need any new controllers and has current ones realized, it + * doesn't need any changes. */ + if (unit_has_mask_realized(m, +-- +2.27.0 + diff --git a/10008-core-add-a-config-item-to-support-setting-the-value-.patch b/10008-core-add-a-config-item-to-support-setting-the-value-.patch new file mode 100644 index 0000000..272d61b --- /dev/null +++ b/10008-core-add-a-config-item-to-support-setting-the-value-.patch @@ -0,0 +1,120 @@ +From f21d63650318791f29f56dc26f23acb5b53620a6 Mon Sep 17 00:00:00 2001 +From:Yuanhong Peng +Date: Tue, 19 Apr 2022 14:13:49 +0800 +Subject: [PATCH] core: add a config item to support setting the value + +--- + src/core/main.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 69 insertions(+) + +diff --git a/src/core/main.c b/src/core/main.c +index 81dae1c..0712423 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -140,6 +140,7 @@ static NUMAPolicy arg_numa_policy; + static bool reexec_jmp_can = false; + static bool reexec_jmp_inited = false; + static sigjmp_buf reexec_jmp_buf; ++static bool arg_default_cpuset_clone_children = false; + + static int parse_configuration(const struct rlimit *saved_rlimit_nofile, + const struct rlimit *saved_rlimit_memlock); +@@ -527,6 +528,14 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat + return 0; + + parse_path_argument_and_warn(value, false, &arg_watchdog_device); ++ ++ } else if (proc_cmdline_key_streq(key, "systemd.cpuset_clone_children") && value) { ++ ++ r = parse_boolean(value); ++ if (r < 0) ++ log_warning("Failed to parse cpuset_clone_children switch %s. Ignoring.", value); ++ else ++ arg_default_cpuset_clone_children = r; + + } else if (streq(key, "quiet") && !value) { + +@@ -756,6 +765,7 @@ static int parse_config_file(void) { + { "Manager", "DefaultTasksAccounting", config_parse_bool, 0, &arg_default_tasks_accounting }, + { "Manager", "DefaultTasksMax", config_parse_tasks_max, 0, &arg_default_tasks_max }, + { "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, 0, &arg_cad_burst_action }, ++ { "Manager", "DefaultCPUSetCloneChildren",config_parse_bool, 0, &arg_default_cpuset_clone_children }, + {} + }; + +@@ -1872,6 +1882,64 @@ static void log_execution_mode(bool *ret_first_boot) { + } + } + ++static bool is_use_triple_cgroup(void) { ++ const char * path ="/sys/fs/cgroup/cpuset"; ++ _cleanup_strv_free_ char **l = NULL; ++ char buf[128] = {0}; ++ int r; ++ ++ r = is_symlink(path); ++ if (r <= 0) ++ return false; ++ ++ r = readlink(path, buf, sizeof(buf)); ++ if (r < 0 || (unsigned int)r >= sizeof(buf)) ++ return false; ++ ++ buf[r] = '\0'; ++ l = strv_split(buf, ","); ++ if (!l) ++ return false; ++ ++ strv_sort(l); ++ if (strv_length(l) != 3) ++ return false; ++ ++ if (streq(l[0],"cpu") && streq(l[1], "cpuacct") && ++ streq(l[2], "cpuset")) { ++ log_debug(PACKAGE_STRING " use_triple_cgroup: %s", buf); ++ return true; ++ } ++ return false; ++} ++ ++static int ali_handle_cpuset_clone_children(void) ++{ ++ const char *file = "/sys/fs/cgroup/cpuset/cgroup.clone_children"; ++ _cleanup_free_ char *buf = NULL; ++ int r; ++ ++ r = read_one_line_file(file, &buf); ++ if (r < 0) { ++ log_warning_errno(r, "Cannot read %s: %m", file); ++ return r; ++ } ++ ++ if (streq(buf, "1") && arg_default_cpuset_clone_children) ++ return 0; ++ ++ if (streq(buf, "0") && (!arg_default_cpuset_clone_children)) ++ return 0; ++ ++ if (!is_use_triple_cgroup()) ++ return 0; ++ ++ r = write_string_file(file, one_zero(arg_default_cpuset_clone_children), 0); ++ log_info(PACKAGE_STRING " set %s to %s, ret=%d", file, one_zero(arg_default_cpuset_clone_children), r); ++ return r; ++} ++ ++ + static int initialize_runtime( + bool skip_setup, + struct rlimit *saved_rlimit_nofile, +@@ -1906,6 +1974,7 @@ static int initialize_runtime( + return r; + } + ++ ali_handle_cpuset_clone_children(); + status_welcome(); + hostname_setup(); + machine_id_setup(NULL, arg_machine_id, NULL); +-- +2.27.0 + diff --git a/10009-systemd-anolis-support-loongarch64.patch b/10009-systemd-anolis-support-loongarch64.patch new file mode 100644 index 0000000..b76c8e0 --- /dev/null +++ b/10009-systemd-anolis-support-loongarch64.patch @@ -0,0 +1,56 @@ +From c8b7c2b34bd451cd9d5904fc215ad14893008a03 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Tue, 19 Apr 2022 14:25:05 +0800 +Subject: [PATCH] support loongarch64 for systemd + +--- + src/basic/architecture.c | 3 +++ + src/basic/architecture.h | 4 ++++ + 2 files changed, 7 insertions(+) + +diff --git a/src/basic/architecture.c b/src/basic/architecture.c +index 85837b5..96bbf97 100644 +--- a/src/basic/architecture.c ++++ b/src/basic/architecture.c +@@ -118,6 +118,8 @@ int uname_architecture(void) { + #elif defined(__arc__) + { "arc", ARCHITECTURE_ARC }, + { "arceb", ARCHITECTURE_ARC_BE }, ++#elif defined(__loongarch64) ++ { "loongarch64", ARCHITECTURE_LOONGARCH64 }, + #else + #error "Please register your architecture here!" + #endif +@@ -173,6 +175,7 @@ static const char *const architecture_table[_ARCHITECTURE_MAX] = { + [ARCHITECTURE_RISCV64] = "riscv64", + [ARCHITECTURE_ARC] = "arc", + [ARCHITECTURE_ARC_BE] = "arc-be", ++ [ARCHITECTURE_LOONGARCH64] = "loongarch64", + }; + + DEFINE_STRING_TABLE_LOOKUP(architecture, int); +diff --git a/src/basic/architecture.h b/src/basic/architecture.h +index 443e890..22e9108 100644 +--- a/src/basic/architecture.h ++++ b/src/basic/architecture.h +@@ -44,6 +44,7 @@ enum { + ARCHITECTURE_RISCV64, + ARCHITECTURE_ARC, + ARCHITECTURE_ARC_BE, ++ ARCHITECTURE_LOONGARCH64, + _ARCHITECTURE_MAX, + _ARCHITECTURE_INVALID = -1 + }; +@@ -229,6 +230,9 @@ int uname_architecture(void); + # define native_architecture() ARCHITECTURE_ARC + # define LIB_ARCH_TUPLE "arc-linux" + # endif ++#elif defined(__loongarch64) ++# define native_architecture() ARCHITECTURE_LOONGARCH64 ++# define LIB_ARCH_TUPLE "loongarch64-linux-gnu" + #else + # error "Please register your architecture here!" + #endif +-- +2.27.0 + diff --git a/systemd.spec b/systemd.spec index e976746..7d8278f 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1,3 +1,4 @@ +%define anolis_release .0.1 #global gitcommit 10e465b5321bd53c1fc59ffab27e724535c6bc0f %{?gitcommit:%global gitcommitshort %(c=%{gitcommit}; echo ${c:0:7})} @@ -13,7 +14,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd Version: 239 -Release: 82%{?dist}.1 +Release: 82%{anolis_release}%{?dist}.1 # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: System and Service Manager @@ -1063,6 +1064,16 @@ Patch1010: 1010-pid1-by-default-make-user-units-inherit-their-umask-.patch Patch1011: 1011-pam-add-call-to-pam_umask.patch Patch1012: 1012-ci-deploy-systemd-man-to-GitHub-Pages.patch Patch1013: 1013-ci-src-git-update-list-of-supported-products.patch +Patch10000: 10000-core-fix-a-null-reference-case-in-load_from_path.patch +Patch10001: 10001-sysctl-Don-t-pass-null-directive-argument-to-s.patch +Patch10002: 10002-exit-status-introduce-EXIT_EXCEPTION-mapping-to-255.patch +Patch10003: 10003-main-don-t-freeze-PID-1-in-containers-exit-with-non-.patch +Patch10004: 10004-Do-not-go-into-freeze-when-systemd-crashd.patch +Patch10005: 10005-mount-setup-change-the-system-mount-propagation-to-s.patch +Patch10006: 10006-cgroup-util-make-definition-of-CGROUP_CONTROLLER_TO_.patch +Patch10007: 10007-cgroup-update-only-siblings-that-got-realized-once.patch +Patch10008: 10008-core-add-a-config-item-to-support-setting-the-value-.patch +Patch10009: 10009-systemd-anolis-support-loongarch64.patch %ifarch %{ix86} x86_64 aarch64 %global have_gnu_efi 1 @@ -1693,6 +1704,18 @@ fi %files tests -f .file-list-tests %changelog +* Wed Aug 28 2024 Yuanhong Peng - 239-82.0.1 +- core: fix a null reference case in load_from_path() +- sysctl: Don't pass null directive argument to '%s' +- exit-status: introduce EXIT_EXCEPTION mapping to 255 +- main: don't freeze PID 1 in containers, exit with non-zero instead +- Do not go into freeze when systemd crashd +- mount-setup: change the system mount propagation to shared by default only at bootup +- cgroup-util: make definition of CGROUP_CONTROLLER_TO_MASK() unsigned +- cgroup: update only siblings that got realized once +- core: add a config item to support setting the value of cpuset.clone_children when systemd is starting +- support loongarch for systemd + * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) - pam: add call to pam_umask (RHEL-28048) -- Gitee From d1f6bd77b70d871fa9e64937a9daf8860010cfd2 Mon Sep 17 00:00:00 2001 From: Yuanhong Peng Date: Wed, 18 May 2022 10:24:07 +0800 Subject: [PATCH 03/17] test-catalog: Fix coredump when compiled under GCC10 Signed-off-by: Yuanhong Peng --- ...x-coredump-when-compiled-under-GCC10.patch | 56 +++++++++++++++++++ systemd.spec | 2 + 2 files changed, 58 insertions(+) create mode 100644 10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch diff --git a/10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch b/10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch new file mode 100644 index 0000000..d4054b4 --- /dev/null +++ b/10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch @@ -0,0 +1,56 @@ +From 5209a26aa917aa54b09ee18394ad46ee601e77be Mon Sep 17 00:00:00 2001 +From: Yuanhong Peng +Date: Tue, 17 May 2022 21:34:34 +0800 +Subject: [PATCH] test-catalog: Fix coredump when compiled under GCC10 + +According to the documentation: +https://gcc.gnu.org/gcc-9/porting_to.html#complit: + +The `catalog_dirs` produced by STRV_MAKE(..) marco relies on +the extended lifetime feature which is fixed by GCC9. + +Signed-off-by: Yuanhong Peng +--- + src/journal/test-catalog.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/src/journal/test-catalog.c b/src/journal/test-catalog.c +index 0c4da29..2ce92af 100644 +--- a/src/journal/test-catalog.c ++++ b/src/journal/test-catalog.c +@@ -201,7 +201,8 @@ static void test_catalog_file_lang(void) { + + int main(int argc, char *argv[]) { + _cleanup_(unlink_tempfilep) char database[] = "/tmp/test-catalog.XXXXXX"; +- _cleanup_free_ char *text = NULL, *catalog_dir = NULL; ++ _cleanup_free_ char *text = NULL; ++ char *catalog_dir = CATALOG_DIR; + int r; + + setlocale(LC_ALL, "de_DE.UTF-8"); +@@ -214,10 +215,9 @@ int main(int argc, char *argv[]) { + * If it is not, e.g. installed by systemd-tests package, then use installed catalogs. */ + if (test_is_running_from_builddir(NULL)) { + assert_se(catalog_dir = path_join(NULL, ABS_BUILD_DIR, "catalog")); +- catalog_dirs = STRV_MAKE(catalog_dir); +- } else +- catalog_dirs = STRV_MAKE(CATALOG_DIR); ++ } + ++ catalog_dirs = STRV_MAKE(catalog_dir); + assert_se(access(catalog_dirs[0], F_OK) >= 0); + log_notice("Using catalog directory '%s'", catalog_dirs[0]); + +@@ -242,5 +242,9 @@ int main(int argc, char *argv[]) { + assert_se(catalog_get(database, SD_MESSAGE_COREDUMP, &text) >= 0); + printf(">>>%s<<<\n", text); + ++ /* Only in this case, catalog_dir is malloced */ ++ if (test_is_running_from_builddir(NULL)) ++ free(catalog_dir); ++ + return 0; + } +-- +2.27.0 + diff --git a/systemd.spec b/systemd.spec index 7d8278f..e11f603 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1074,6 +1074,7 @@ Patch10006: 10006-cgroup-util-make-definition-of-CGROUP_CONTROLLER_TO_.patch Patch10007: 10007-cgroup-update-only-siblings-that-got-realized-once.patch Patch10008: 10008-core-add-a-config-item-to-support-setting-the-value-.patch Patch10009: 10009-systemd-anolis-support-loongarch64.patch +Patch10010: 10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch %ifarch %{ix86} x86_64 aarch64 %global have_gnu_efi 1 @@ -1715,6 +1716,7 @@ fi - cgroup: update only siblings that got realized once - core: add a config item to support setting the value of cpuset.clone_children when systemd is starting - support loongarch for systemd +- test-catalog: Fix coredump when compiled under GCC10 * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee From da59113ba0869ac34cabc7ebfc4594b622cbd5a2 Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Tue, 26 Jul 2022 22:05:44 +0800 Subject: [PATCH 04/17] hwdb: add Iluvatar CoreX https://bugzilla.openanolis.cn/show_bug.cgi?id=1740 Signed-off-by: Liwei Ge --- 10011-hwdb-add-Iluvatar-CoreX.patch | 44 +++++++++++++++++++++++++++++ systemd.spec | 2 ++ 2 files changed, 46 insertions(+) create mode 100644 10011-hwdb-add-Iluvatar-CoreX.patch diff --git a/10011-hwdb-add-Iluvatar-CoreX.patch b/10011-hwdb-add-Iluvatar-CoreX.patch new file mode 100644 index 0000000..e08657c --- /dev/null +++ b/10011-hwdb-add-Iluvatar-CoreX.patch @@ -0,0 +1,44 @@ +From 28e47526dce925e6f32cf79825d38fd10e1f442a Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Tue, 26 Jul 2022 22:01:58 +0800 +Subject: [PATCH] hwdb: add Iluvatar CoreX + +Signed-off-by: rpm-build +--- + hwdb/20-pci-vendor-model.hwdb | 6 ++++++ + hwdb/pci.ids | 2 ++ + 2 files changed, 8 insertions(+) + +diff --git a/hwdb/20-pci-vendor-model.hwdb b/hwdb/20-pci-vendor-model.hwdb +index 0020046..78926f8 100644 +--- a/hwdb/20-pci-vendor-model.hwdb ++++ b/hwdb/20-pci-vendor-model.hwdb +@@ -71141,6 +71141,12 @@ pci:v00001EEC* + pci:v00001EFB* + ID_VENDOR_FROM_DATABASE=Flexxon Pte Ltd + ++pci:v00001E3E* ++ ID_VENDOR_FROM_DATABASE=Iluvatar CoreX ++ ++pci:v00001E3Ed00000001* ++ ID_MODEL_FROM_DATABASE=Iluvatar BI-V100 ++ + pci:v00001FC0* + ID_VENDOR_FROM_DATABASE=Ascom (Finland) Oy + +diff --git a/hwdb/pci.ids b/hwdb/pci.ids +index 40ee143..d6661c7 100644 +--- a/hwdb/pci.ids ++++ b/hwdb/pci.ids +@@ -21543,6 +21543,8 @@ + 0003 alst4x + 1dfc JSC NT-COM + 1181 TDM 8 Port E1/T1/J1 Adapter ++1e3e Iluvatar CoreX ++ 0001 Iluvatar BI-V100 + # nee Tumsan Oy + 1fc0 Ascom (Finland) Oy + 0300 E2200 Dual E1/Rawpipe Card +-- +2.27.0 + diff --git a/systemd.spec b/systemd.spec index e11f603..dbadb29 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1075,6 +1075,7 @@ Patch10007: 10007-cgroup-update-only-siblings-that-got-realized-once.patch Patch10008: 10008-core-add-a-config-item-to-support-setting-the-value-.patch Patch10009: 10009-systemd-anolis-support-loongarch64.patch Patch10010: 10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch +Patch10011: 10011-hwdb-add-Iluvatar-CoreX.patch %ifarch %{ix86} x86_64 aarch64 %global have_gnu_efi 1 @@ -1717,6 +1718,7 @@ fi - core: add a config item to support setting the value of cpuset.clone_children when systemd is starting - support loongarch for systemd - test-catalog: Fix coredump when compiled under GCC10 +- add Iluvatar CoreX pci id(Liwei Ge) * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee From a7bbbbe01648dcea27421160dc08e968186cb2aa Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Thu, 22 Sep 2022 10:38:05 +0800 Subject: [PATCH 05/17] seccomp: add loongarch support --- 10012-seccomp-add-loongarch-support.patch | 79 +++++++++++++++++++++++ systemd.spec | 4 +- 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 10012-seccomp-add-loongarch-support.patch diff --git a/10012-seccomp-add-loongarch-support.patch b/10012-seccomp-add-loongarch-support.patch new file mode 100644 index 0000000..69b1b90 --- /dev/null +++ b/10012-seccomp-add-loongarch-support.patch @@ -0,0 +1,79 @@ +From 1894533699f7e01c80e896c5d022275777344492 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Thu, 22 Sep 2022 10:33:54 +0800 +Subject: [PATCH] seccomp: add loongarch support + +--- + src/shared/seccomp-util.c | 21 +++++++++++++++++++++ + 1 file changed, 21 insertions(+) + +diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c +index c57c409..63a875c 100644 +--- a/src/shared/seccomp-util.c ++++ b/src/shared/seccomp-util.c +@@ -42,6 +42,8 @@ const uint32_t seccomp_local_archs[] = { + SCMP_ARCH_AARCH64, /* native */ + #elif defined(__arm__) + SCMP_ARCH_ARM, ++#elif defined(__loongarch__) ++ SCMP_ARCH_LOONGARCH64, + #elif defined(__mips__) && __BYTE_ORDER == __BIG_ENDIAN && _MIPS_SIM == _MIPS_SIM_ABI32 + SCMP_ARCH_MIPSEL, + SCMP_ARCH_MIPS, /* native */ +@@ -136,6 +138,10 @@ const char* seccomp_arch_to_string(uint32_t c) { + return "s390"; + case SCMP_ARCH_S390X: + return "s390x"; ++#if defined(__loongarch__) ++ case SCMP_ARCH_LOONGARCH64: ++ return "loongarch64"; ++#endif + default: + return NULL; + } +@@ -181,6 +187,10 @@ int seccomp_arch_from_string(const char *n, uint32_t *ret) { + *ret = SCMP_ARCH_S390; + else if (streq(n, "s390x")) + *ret = SCMP_ARCH_S390X; ++#if defined(__loongarch__) ++ else if (streq(n, "loongarch64")) ++ *ret = SCMP_ARCH_LOONGARCH64; ++#endif + else + return -EINVAL; + +@@ -1209,6 +1219,11 @@ int seccomp_protect_sysctl(void) { + if (IN_SET(arch, SCMP_ARCH_X32, SCMP_ARCH_AARCH64)) + /* No _sysctl syscall */ + continue; ++#if defined(__loongarch__) ++ if (IN_SET(arch, SCMP_ARCH_LOONGARCH64)) ++ /* No _sysctl syscall */ ++ continue; ++#endif + + r = seccomp_init_for_arch(&seccomp, arch, SCMP_ACT_ALLOW); + if (r < 0) +@@ -1267,6 +1282,9 @@ int seccomp_restrict_address_families(Set *address_families, bool whitelist) { + case SCMP_ARCH_PPC: + case SCMP_ARCH_PPC64: + case SCMP_ARCH_PPC64LE: ++#if defined(__loongarch__) ++ case SCMP_ARCH_LOONGARCH64: ++#endif + default: + /* These we either know we don't support (i.e. are the ones that do use socketcall()), or we + * don't know */ +@@ -1543,6 +1561,9 @@ int seccomp_memory_deny_write_execute(void) { + case SCMP_ARCH_X86_64: + case SCMP_ARCH_X32: + case SCMP_ARCH_AARCH64: ++#if defined(__loongarch__) ++ case SCMP_ARCH_LOONGARCH64: ++#endif + filter_syscall = SCMP_SYS(mmap); /* amd64, x32, and arm64 have only mmap */ + shmat_syscall = SCMP_SYS(shmat); + break; +-- +2.27.0 + diff --git a/systemd.spec b/systemd.spec index dbadb29..bc5ad37 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1076,6 +1076,7 @@ Patch10008: 10008-core-add-a-config-item-to-support-setting-the-value-.patch Patch10009: 10009-systemd-anolis-support-loongarch64.patch Patch10010: 10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch Patch10011: 10011-hwdb-add-Iluvatar-CoreX.patch +Patch10012: 10012-seccomp-add-loongarch-support.patch %ifarch %{ix86} x86_64 aarch64 %global have_gnu_efi 1 @@ -1718,7 +1719,8 @@ fi - core: add a config item to support setting the value of cpuset.clone_children when systemd is starting - support loongarch for systemd - test-catalog: Fix coredump when compiled under GCC10 -- add Iluvatar CoreX pci id(Liwei Ge) +- add Iluvatar CoreX pci id (Liwei Ge) +- seccomp: add loongarch64 support (Liwei Ge) * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee From d35f64ab7b1d91c76f5fbfe68f737074e1767e6b Mon Sep 17 00:00:00 2001 From: Liwei Ge Date: Tue, 6 Dec 2022 16:16:34 +0800 Subject: [PATCH 06/17] seccomp: remove loongarch condition since seccomp is fit into loongarch64 now these condition code cloud be removed --- 10012-seccomp-add-loongarch-support.patch | 106 +++++++++++++--------- systemd.spec | 1 + 2 files changed, 65 insertions(+), 42 deletions(-) diff --git a/10012-seccomp-add-loongarch-support.patch b/10012-seccomp-add-loongarch-support.patch index 69b1b90..6aba34f 100644 --- a/10012-seccomp-add-loongarch-support.patch +++ b/10012-seccomp-add-loongarch-support.patch @@ -1,14 +1,14 @@ -From 1894533699f7e01c80e896c5d022275777344492 Mon Sep 17 00:00:00 2001 +From 4c7025f5198be3d055c0e5ad68d364a57e8a7dcc Mon Sep 17 00:00:00 2001 From: rpm-build Date: Thu, 22 Sep 2022 10:33:54 +0800 Subject: [PATCH] seccomp: add loongarch support --- - src/shared/seccomp-util.c | 21 +++++++++++++++++++++ - 1 file changed, 21 insertions(+) + src/shared/seccomp-util.c | 18 +++++++++++++----- + 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c -index c57c409..63a875c 100644 +index c57c409..1eec0be 100644 --- a/src/shared/seccomp-util.c +++ b/src/shared/seccomp-util.c @@ -42,6 +42,8 @@ const uint32_t seccomp_local_archs[] = { @@ -20,60 +20,82 @@ index c57c409..63a875c 100644 #elif defined(__mips__) && __BYTE_ORDER == __BIG_ENDIAN && _MIPS_SIM == _MIPS_SIM_ABI32 SCMP_ARCH_MIPSEL, SCMP_ARCH_MIPS, /* native */ -@@ -136,6 +138,10 @@ const char* seccomp_arch_to_string(uint32_t c) { - return "s390"; - case SCMP_ARCH_S390X: - return "s390x"; -+#if defined(__loongarch__) +@@ -114,6 +116,8 @@ const char* seccomp_arch_to_string(uint32_t c) { + return "arm"; + case SCMP_ARCH_AARCH64: + return "arm64"; + case SCMP_ARCH_LOONGARCH64: + return "loongarch64"; -+#endif - default: - return NULL; - } -@@ -181,6 +187,10 @@ int seccomp_arch_from_string(const char *n, uint32_t *ret) { - *ret = SCMP_ARCH_S390; - else if (streq(n, "s390x")) - *ret = SCMP_ARCH_S390X; -+#if defined(__loongarch__) + case SCMP_ARCH_MIPS: + return "mips"; + case SCMP_ARCH_MIPS64: +@@ -159,6 +163,8 @@ int seccomp_arch_from_string(const char *n, uint32_t *ret) { + *ret = SCMP_ARCH_ARM; + else if (streq(n, "arm64")) + *ret = SCMP_ARCH_AARCH64; + else if (streq(n, "loongarch64")) + *ret = SCMP_ARCH_LOONGARCH64; -+#endif - else - return -EINVAL; + else if (streq(n, "mips")) + *ret = SCMP_ARCH_MIPS; + else if (streq(n, "mips64")) +@@ -1206,7 +1212,7 @@ int seccomp_protect_sysctl(void) { -@@ -1209,6 +1219,11 @@ int seccomp_protect_sysctl(void) { - if (IN_SET(arch, SCMP_ARCH_X32, SCMP_ARCH_AARCH64)) + log_debug("Operating on architecture: %s", seccomp_arch_to_string(arch)); + +- if (IN_SET(arch, SCMP_ARCH_X32, SCMP_ARCH_AARCH64)) ++ if (IN_SET(arch, SCMP_ARCH_X32, SCMP_ARCH_AARCH64, SCMP_ARCH_LOONGARCH64)) /* No _sysctl syscall */ continue; -+#if defined(__loongarch__) -+ if (IN_SET(arch, SCMP_ARCH_LOONGARCH64)) -+ /* No _sysctl syscall */ -+ continue; -+#endif - r = seccomp_init_for_arch(&seccomp, arch, SCMP_ACT_ALLOW); - if (r < 0) -@@ -1267,6 +1282,9 @@ int seccomp_restrict_address_families(Set *address_families, bool whitelist) { - case SCMP_ARCH_PPC: - case SCMP_ARCH_PPC64: - case SCMP_ARCH_PPC64LE: -+#if defined(__loongarch__) +@@ -1251,6 +1257,7 @@ int seccomp_restrict_address_families(Set *address_families, bool whitelist) { + case SCMP_ARCH_X32: + case SCMP_ARCH_ARM: + case SCMP_ARCH_AARCH64: + case SCMP_ARCH_LOONGARCH64: -+#endif - default: - /* These we either know we don't support (i.e. are the ones that do use socketcall()), or we - * don't know */ -@@ -1543,6 +1561,9 @@ int seccomp_memory_deny_write_execute(void) { + case SCMP_ARCH_MIPSEL64N32: + case SCMP_ARCH_MIPS64N32: + case SCMP_ARCH_MIPSEL64: +@@ -1496,7 +1503,7 @@ static int add_seccomp_syscall_filter(scmp_filter_ctx seccomp, + } + + /* For known architectures, check that syscalls are indeed defined or not. */ +-#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) ++#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__loongarch__) + assert_cc(SCMP_SYS(shmget) > 0); + assert_cc(SCMP_SYS(shmat) > 0); + assert_cc(SCMP_SYS(shmdt) > 0); +@@ -1543,13 +1550,14 @@ int seccomp_memory_deny_write_execute(void) { case SCMP_ARCH_X86_64: case SCMP_ARCH_X32: case SCMP_ARCH_AARCH64: -+#if defined(__loongarch__) + case SCMP_ARCH_LOONGARCH64: -+#endif filter_syscall = SCMP_SYS(mmap); /* amd64, x32, and arm64 have only mmap */ shmat_syscall = SCMP_SYS(shmat); break; + + /* Please add more definitions here, if you port systemd to other architectures! */ + +-#if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__) && !defined(__powerpc64__) && !defined(__arm__) && !defined(__aarch64__) ++#if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__) && !defined(__powerpc64__) && !defined(__arm__) && !defined(__aarch64__) && !defined(__loongarch__) + #warning "Consider adding the right mmap() syscall definitions here!" + #endif + } +@@ -1573,13 +1581,13 @@ int seccomp_memory_deny_write_execute(void) { + if (r < 0) + continue; + } +- ++ if (!IN_SET(arch, SCMP_ARCH_LOONGARCH64)){ + r = add_seccomp_syscall_filter(seccomp, arch, SCMP_SYS(mprotect), + 1, + SCMP_A2(SCMP_CMP_MASKED_EQ, PROT_EXEC, PROT_EXEC)); + if (r < 0) + continue; +- ++ } + #ifdef __NR_pkey_mprotect + r = add_seccomp_syscall_filter(seccomp, arch, SCMP_SYS(pkey_mprotect), + 1, -- 2.27.0 diff --git a/systemd.spec b/systemd.spec index bc5ad37..4d480fd 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1721,6 +1721,7 @@ fi - test-catalog: Fix coredump when compiled under GCC10 - add Iluvatar CoreX pci id (Liwei Ge) - seccomp: add loongarch64 support (Liwei Ge) +- seccomp: remove loongarch64 switch(Liwei Ge) * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee From a9ffd95aa8333332ad10942c40e5c3e2aeb8b949 Mon Sep 17 00:00:00 2001 From: yuanhui Date: Mon, 6 Mar 2023 17:48:29 +0800 Subject: [PATCH 07/17] umount: check LO_FLAGS_AUTOCLEAR after LOOP_CLR_FD claimed success Signed-off-by: yuanhui --- ...FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch | 69 +++++++++++++++++++ systemd.spec | 2 + 2 files changed, 71 insertions(+) create mode 100644 10013-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch diff --git a/10013-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch b/10013-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch new file mode 100644 index 0000000..fbc76ac --- /dev/null +++ b/10013-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch @@ -0,0 +1,69 @@ +From b877c3b06f15a025748b9f09621ddf1bd00cacce Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 20 Dec 2019 17:58:03 +0100 +Subject: [PATCH] umount: check LO_FLAGS_AUTOCLEAR after LOOP_CLR_FD claimed + success + +Fixes: #14410 +Replaces: #14386 + +For Lifsea-ng, this patch fixes the problem that the system occasionally +fail to shutdown caused by /sysroot unable to umount. + +--- + systemd-239/src/core/umount.c | 29 ++++++++++++++++++++++------- + 1 file changed, 22 insertions(+), 7 deletions(-) + +diff --git a/src/core/umount.c b/src/core/umount.c +index 241fe6f..4400b3c 100644 +--- a/src/core/umount.c ++++ b/src/core/umount.c +@@ -334,23 +334,38 @@ static int dm_list_get(MountPoint **head) { + + static int delete_loopback(const char *device) { + _cleanup_close_ int fd = -1; +- int r; ++ struct loop_info64 info; + + assert(device); + + fd = open(device, O_RDONLY|O_CLOEXEC); + if (fd < 0) + return errno == ENOENT ? 0 : -errno; ++ ++ if (ioctl(fd, LOOP_CLR_FD, 0) < 0) { ++ if (errno == ENXIO) /* Nothing bound, didn't do anything */ ++ return 0; ++ ++ return -errno; ++ } + +- r = ioctl(fd, LOOP_CLR_FD, 0); +- if (r >= 0) ++ if (ioctl(fd, LOOP_GET_STATUS64, &info) < 0) { ++ /* If the LOOP_CLR_FD above succeeded we'll see ENXIO here. */ ++ if (errno == ENXIO) ++ log_debug("Successfully detached loopback device %s.", device); ++ else ++ log_debug_errno(errno, "Failed to invoke LOOP_GET_STATUS64 on loopback device %s, ignoring: %m", device); /* the LOOP_CLR_FD at least worked, let's hope for the best */ + return 1; ++ } + +- /* ENXIO: not bound, so no error */ +- if (errno == ENXIO) +- return 0; ++ /* Linux makes LOOP_CLR_FD succeed whenever LO_FLAGS_AUTOCLEAR is set without actually doing ++ * anything. Very confusing. Let's hence not claim we did anything in this case. */ ++ if (FLAGS_SET(info.lo_flags, LO_FLAGS_AUTOCLEAR)) ++ log_debug("Successfully called LOOP_CLR_FD on a loopback device %s with autoclear set, which is a NOP.", device); ++ else ++ log_debug("Weird, LOOP_CLR_FD succeeded but the device is still attached on %s.", device); + +- return -errno; ++ return -EBUSY; /* Nothing changed, the device is still attached, hence it apparently is still busy */; + } + + static int delete_dm(dev_t devnum) { +-- +2.31.1 + diff --git a/systemd.spec b/systemd.spec index 4d480fd..9360eb7 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1077,6 +1077,7 @@ Patch10009: 10009-systemd-anolis-support-loongarch64.patch Patch10010: 10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch Patch10011: 10011-hwdb-add-Iluvatar-CoreX.patch Patch10012: 10012-seccomp-add-loongarch-support.patch +Patch10013: 10013-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch %ifarch %{ix86} x86_64 aarch64 %global have_gnu_efi 1 @@ -1722,6 +1723,7 @@ fi - add Iluvatar CoreX pci id (Liwei Ge) - seccomp: add loongarch64 support (Liwei Ge) - seccomp: remove loongarch64 switch(Liwei Ge) +- umount: check LO_FLAGS_AUTOCLEAR after LOOP_CLR_FD claimed success(yuanhui) * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee From 57f94c3ef5d436bbb4e54e0961b7b4863fcb8cfc Mon Sep 17 00:00:00 2001 From: Guorui Yu Date: Wed, 2 Aug 2023 22:44:03 +0800 Subject: [PATCH 08/17] cryptsetup: if keyfile is specified as AF_UNIX socket in the fs, connect to it, and read key data from it Signed-off-by: Guorui Yu --- ...ding-a-full-file-into-memory-refuse-.patch | 120 ++++++++ ...explicit_bzero_safe-for-explicit-mem.patch | 61 ++++ ...util-introduce-erase_and_free-helper.patch | 48 ++++ ...READ_FULL_FILE_SECURE-flag-for-readi.patch | 207 +++++++++++++ ...roduce-warn_file_is_world_accessible.patch | 67 +++++ ...l_file_full-also-warns-when-file-is-.patch | 64 +++++ ...x-memory-leak-if-READ_FULL_FILE_SECU.patch | 30 ++ ...icit-flag-for-generating-world-execu.patch | 44 +++ ..._fd-parameter-to-read_full_file_full.patch | 142 +++++++++ ...ort-for-read_full_file-on-AF_UNIX-st.patch | 271 ++++++++++++++++++ ...READ_FULL_FILE_CONNECT_SOCKET-to-all.patch | 181 ++++++++++++ ...ad_full_file_full-to-read-from-offse.patch | 246 ++++++++++++++++ ...-cryptsetup-s-main-key-file-logic-ov.patch | 95 ++++++ systemd.spec | 26 ++ 14 files changed, 1602 insertions(+) create mode 100644 10014-fileio-when-reading-a-full-file-into-memory-refuse-.patch create mode 100644 10015-util-introduce-explicit_bzero_safe-for-explicit-mem.patch create mode 100644 10016-util-introduce-erase_and_free-helper.patch create mode 100644 10017-util-introduce-READ_FULL_FILE_SECURE-flag-for-readi.patch create mode 100644 10018-fileio-introduce-warn_file_is_world_accessible.patch create mode 100644 10019-fileio-read_full_file_full-also-warns-when-file-is-.patch create mode 100644 10020-basic-fileio-Fix-memory-leak-if-READ_FULL_FILE_SECU.patch create mode 100644 10021-fileio-add-explicit-flag-for-generating-world-execu.patch create mode 100644 10022-fileio-add-dir_fd-parameter-to-read_full_file_full.patch create mode 100644 10023-fileio-add-support-for-read_full_file-on-AF_UNIX-st.patch create mode 100644 10024-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch create mode 100644 10025-fileio-teach-read_full_file_full-to-read-from-offse.patch create mode 100644 10026-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch diff --git a/10014-fileio-when-reading-a-full-file-into-memory-refuse-.patch b/10014-fileio-when-reading-a-full-file-into-memory-refuse-.patch new file mode 100644 index 0000000..f2eeed5 --- /dev/null +++ b/10014-fileio-when-reading-a-full-file-into-memory-refuse-.patch @@ -0,0 +1,120 @@ +From 9f181efdd59bd3e9134cf94007953562ca8b57fa Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Sat, 15 Dec 2018 12:25:32 +0100 +Subject: [PATCH] fileio: when reading a full file into memory, refuse inner + NUL bytes + +Just some extra care to avoid any ambiguities in what we read. + +(cherry picked from commit beb90929913354eec50c3524086fe70d14f97e2f) + +Signed-off-by: Guorui Yu +--- + src/basic/fileio.c | 25 +++++++++++++++++++------ + src/test/test-unit-file.c | 10 +++++----- + 2 files changed, 24 insertions(+), 11 deletions(-) + +diff --git a/src/basic/fileio.c b/src/basic/fileio.c +index 733fb42463..9fef97ff0c 100644 +--- a/src/basic/fileio.c ++++ b/src/basic/fileio.c +@@ -383,16 +383,20 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re + return 0; + } + +-int read_full_stream(FILE *f, char **contents, size_t *size) { ++int read_full_stream( ++ FILE *f, ++ char **ret_contents, ++ size_t *ret_size) { ++ + _cleanup_free_ char *buf = NULL; + struct stat st; + size_t n, l; + int fd; + + assert(f); +- assert(contents); ++ assert(ret_contents); + +- n = LINE_MAX; ++ n = LINE_MAX; /* Start size */ + + fd = fileno(f); + if (fd >= 0) { /* If the FILE* object is backed by an fd (as opposed to memory or such, see fmemopen(), let's +@@ -448,11 +452,20 @@ int read_full_stream(FILE *f, char **contents, size_t *size) { + n = MIN(n * 2, READ_FULL_BYTES_MAX); + } + ++ if (!ret_size) { ++ /* Safety check: if the caller doesn't want to know the size of what we just read it will rely on the ++ * trailing NUL byte. But if there's an embedded NUL byte, then we should refuse operation as otherwise ++ * there'd be ambiguity about what we just read. */ ++ ++ if (memchr(buf, 0, l)) ++ return -EBADMSG; ++ } ++ + buf[l] = 0; +- *contents = TAKE_PTR(buf); ++ *ret_contents = TAKE_PTR(buf); + +- if (size) +- *size = l; ++ if (ret_size) ++ *ret_size = l; + + return 0; + } +diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c +index 09b0179fa1..e64a27dd39 100644 +--- a/src/test/test-unit-file.c ++++ b/src/test/test-unit-file.c +@@ -532,7 +532,7 @@ static void test_load_env_file_1(void) { + + fd = mkostemp_safe(name); + assert_se(fd >= 0); +- assert_se(write(fd, env_file_1, sizeof(env_file_1)) == sizeof(env_file_1)); ++ assert_se(write(fd, env_file_1, strlen(env_file_1)) == strlen(env_file_1)); + + r = load_env_file(NULL, name, NULL, &data); + assert_se(r == 0); +@@ -554,7 +554,7 @@ static void test_load_env_file_2(void) { + + fd = mkostemp_safe(name); + assert_se(fd >= 0); +- assert_se(write(fd, env_file_2, sizeof(env_file_2)) == sizeof(env_file_2)); ++ assert_se(write(fd, env_file_2, strlen(env_file_2)) == strlen(env_file_2)); + + r = load_env_file(NULL, name, NULL, &data); + assert_se(r == 0); +@@ -571,7 +571,7 @@ static void test_load_env_file_3(void) { + + fd = mkostemp_safe(name); + assert_se(fd >= 0); +- assert_se(write(fd, env_file_3, sizeof(env_file_3)) == sizeof(env_file_3)); ++ assert_se(write(fd, env_file_3, strlen(env_file_3)) == strlen(env_file_3)); + + r = load_env_file(NULL, name, NULL, &data); + assert_se(r == 0); +@@ -586,7 +586,7 @@ static void test_load_env_file_4(void) { + + fd = mkostemp_safe(name); + assert_se(fd >= 0); +- assert_se(write(fd, env_file_4, sizeof(env_file_4)) == sizeof(env_file_4)); ++ assert_se(write(fd, env_file_4, strlen(env_file_4)) == strlen(env_file_4)); + + r = load_env_file(NULL, name, NULL, &data); + assert_se(r == 0); +@@ -605,7 +605,7 @@ static void test_load_env_file_5(void) { + + fd = mkostemp_safe(name); + assert_se(fd >= 0); +- assert_se(write(fd, env_file_5, sizeof(env_file_5)) == sizeof(env_file_5)); ++ assert_se(write(fd, env_file_5, strlen(env_file_5)) == strlen(env_file_5)); + + r = load_env_file(NULL, name, NULL, &data); + assert_se(r == 0); +-- +2.39.1 + diff --git a/10015-util-introduce-explicit_bzero_safe-for-explicit-mem.patch b/10015-util-introduce-explicit_bzero_safe-for-explicit-mem.patch new file mode 100644 index 0000000..c0ec4be --- /dev/null +++ b/10015-util-introduce-explicit_bzero_safe-for-explicit-mem.patch @@ -0,0 +1,61 @@ +From 17037ec625fca9e9a473a33954d011065f0088e3 Mon Sep 17 00:00:00 2001 +From: Guorui Yu +Date: Fri, 23 Jun 2023 13:01:24 +0800 +Subject: [PATCH] util: introduce explicit_bzero_safe for explicit memset + +(cherry picked from commit f441ae81ef70e9bdfddbb9e0a276bbb8ca2151d4) + +Signed-off-by: Guorui Yu +--- + src/basic/util.c | 18 ++++++++++++++++++ + src/basic/util.h | 11 +++++++++++ + 2 files changed, 29 insertions(+) + +diff --git a/src/basic/util.c b/src/basic/util.c +index 548e3652cc..bdfaca4aed 100644 +--- a/src/basic/util.c ++++ b/src/basic/util.c +@@ -684,3 +684,21 @@ void disable_coredumps(void) { + if (r < 0) + log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m"); + } ++ ++#if !HAVE_EXPLICIT_BZERO ++/* ++ * The pointer to memset() is volatile so that compiler must de-reference the pointer and can't assume that ++ * it points to any function in particular (such as memset(), which it then might further "optimize"). This ++ * approach is inspired by openssl's crypto/mem_clr.c. ++ */ ++typedef void *(*memset_t)(void *,int,size_t); ++ ++static volatile memset_t memset_func = memset; ++ ++void* explicit_bzero_safe(void *p, size_t l) { ++ if (l > 0) ++ memset_func(p, '\0', l); ++ ++ return p; ++} ++#endif +diff --git a/src/basic/util.h b/src/basic/util.h +index 195f02cf5f..ab3314f82e 100644 +--- a/src/basic/util.h ++++ b/src/basic/util.h +@@ -240,3 +240,14 @@ int version(void); + int str_verscmp(const char *s1, const char *s2); + + void disable_coredumps(void); ++ ++#if HAVE_EXPLICIT_BZERO ++static inline void* explicit_bzero_safe(void *p, size_t l) { ++ if (l > 0) ++ explicit_bzero(p, l); ++ ++ return p; ++} ++#else ++void *explicit_bzero_safe(void *p, size_t l); ++#endif +-- +2.39.1 + diff --git a/10016-util-introduce-erase_and_free-helper.patch b/10016-util-introduce-erase_and_free-helper.patch new file mode 100644 index 0000000..43c42fc --- /dev/null +++ b/10016-util-introduce-erase_and_free-helper.patch @@ -0,0 +1,48 @@ +From 7c48fe64e3f1cdc61d9191d5e004d56d5244aa2c Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Thu, 8 Aug 2019 19:53:17 +0200 +Subject: [PATCH] util: introduce erase_and_free() helper + +(cherry picked from commit a20dda788d5a0f3b300e0d8bb34e45be335e2915) + +Signed-off-by: Guorui Yu +--- + src/basic/util.h | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/src/basic/util.h b/src/basic/util.h +index ab3314f82e..4f4877b6b0 100644 +--- a/src/basic/util.h ++++ b/src/basic/util.h +@@ -5,6 +5,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -251,3 +252,20 @@ static inline void* explicit_bzero_safe(void *p, size_t l) { + #else + void *explicit_bzero_safe(void *p, size_t l); + #endif ++ ++static inline void* erase_and_free(void *p) { ++ size_t l; ++ ++ if (!p) ++ return NULL; ++ ++ l = malloc_usable_size(p); ++ explicit_bzero_safe(p, l); ++ free(p); ++ ++ return NULL; ++} ++ ++static inline void erase_and_freep(void *p) { ++ erase_and_free(*(void**) p); ++} +-- +2.39.1 + diff --git a/10017-util-introduce-READ_FULL_FILE_SECURE-flag-for-readi.patch b/10017-util-introduce-READ_FULL_FILE_SECURE-flag-for-readi.patch new file mode 100644 index 0000000..a37d579 --- /dev/null +++ b/10017-util-introduce-READ_FULL_FILE_SECURE-flag-for-readi.patch @@ -0,0 +1,207 @@ +From bc781489901fc6447cbd27b8d33f4f4439d6a5db Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Mon, 8 Apr 2019 02:22:40 +0900 +Subject: [PATCH] util: introduce READ_FULL_FILE_SECURE flag for reading secure + data + +(cherry picked from commit e0721f97b05c0a5f782233711ea95c1e02ccba44) + +[Guorui Yu: include util.h for explicit_bzero_safe] +Signed-off-by: Guorui Yu +--- + src/basic/fileio.c | 68 ++++++++++++++++++++++++++++++++-------------- + src/basic/fileio.h | 16 +++++++++-- + 2 files changed, 60 insertions(+), 24 deletions(-) + +diff --git a/src/basic/fileio.c b/src/basic/fileio.c +index 9fef97ff0c..cf7c92ebc7 100644 +--- a/src/basic/fileio.c ++++ b/src/basic/fileio.c +@@ -35,6 +35,7 @@ + #include "time-util.h" + #include "umask-util.h" + #include "utf8.h" ++#include "util.h" + + #define READ_FULL_BYTES_MAX (4U*1024U*1024U) + +@@ -383,26 +384,27 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re + return 0; + } + +-int read_full_stream( ++int read_full_stream_full( + FILE *f, ++ ReadFullFileFlags flags, + char **ret_contents, + size_t *ret_size) { + + _cleanup_free_ char *buf = NULL; + struct stat st; +- size_t n, l; +- int fd; ++ size_t n, n_next, l; ++ int fd, r; + + assert(f); + assert(ret_contents); + +- n = LINE_MAX; /* Start size */ ++ n_next = LINE_MAX; /* Start size */ + + fd = fileno(f); + if (fd >= 0) { /* If the FILE* object is backed by an fd (as opposed to memory or such, see fmemopen(), let's + * optimize our buffering) */ + +- if (fstat(fileno(f), &st) < 0) ++ if (fstat(fd, &st) < 0) + return -errno; + + if (S_ISREG(st.st_mode)) { +@@ -415,27 +417,41 @@ int read_full_stream( + * to read here by one, so that the first read attempt already + * makes us notice the EOF. */ + if (st.st_size > 0) +- n = st.st_size + 1; ++ n_next = st.st_size + 1; + } + } + +- l = 0; ++ n = l = 0; + for (;;) { + char *t; + size_t k; + +- t = realloc(buf, n + 1); +- if (!t) +- return -ENOMEM; ++ if (flags & READ_FULL_FILE_SECURE) { ++ t = malloc(n_next + 1); ++ if (!t) { ++ r = -ENOMEM; ++ goto finalize; ++ } ++ memcpy_safe(t, buf, n); ++ explicit_bzero_safe(buf, n); ++ } else { ++ t = realloc(buf, n_next + 1); ++ if (!t) ++ return -ENOMEM; ++ } + + buf = t; ++ n = n_next; ++ + errno = 0; + k = fread(buf + l, 1, n - l, f); + if (k > 0) + l += k; + +- if (ferror(f)) +- return errno > 0 ? -errno : -EIO; ++ if (ferror(f)) { ++ r = errno > 0 ? -errno : -EIO; ++ goto finalize; ++ } + + if (feof(f)) + break; +@@ -446,10 +462,12 @@ int read_full_stream( + assert(l == n); + + /* Safety check */ +- if (n >= READ_FULL_BYTES_MAX) +- return -E2BIG; ++ if (n >= READ_FULL_BYTES_MAX) { ++ r = -E2BIG; ++ goto finalize; ++ } + +- n = MIN(n * 2, READ_FULL_BYTES_MAX); ++ n_next = MIN(n * 2, READ_FULL_BYTES_MAX); + } + + if (!ret_size) { +@@ -457,8 +475,10 @@ int read_full_stream( + * trailing NUL byte. But if there's an embedded NUL byte, then we should refuse operation as otherwise + * there'd be ambiguity about what we just read. */ + +- if (memchr(buf, 0, l)) +- return -EBADMSG; ++ if (memchr(buf, 0, l)) { ++ r = -EBADMSG; ++ goto finalize; ++ } + } + + buf[l] = 0; +@@ -468,21 +488,27 @@ int read_full_stream( + *ret_size = l; + + return 0; ++ ++finalize: ++ if (flags & READ_FULL_FILE_SECURE) ++ explicit_bzero_safe(buf, n); ++ ++ return r; + } + +-int read_full_file(const char *fn, char **contents, size_t *size) { ++int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **contents, size_t *size) { + _cleanup_fclose_ FILE *f = NULL; + +- assert(fn); ++ assert(filename); + assert(contents); + +- f = fopen(fn, "re"); ++ f = fopen(filename, "re"); + if (!f) + return -errno; + + (void) __fsetlocking(f, FSETLOCKING_BYCALLER); + +- return read_full_stream(f, contents, size); ++ return read_full_stream_full(f, flags, contents, size); + } + + static int parse_env_file_internal( +diff --git a/src/basic/fileio.h b/src/basic/fileio.h +index c6ad375b8d..06649ef7e6 100644 +--- a/src/basic/fileio.h ++++ b/src/basic/fileio.h +@@ -24,6 +24,10 @@ typedef enum { + + } WriteStringFileFlags; + ++typedef enum { ++ READ_FULL_FILE_SECURE = 1 << 0, ++} ReadFullFileFlags; ++ + int write_string_stream_ts(FILE *f, const char *line, WriteStringFileFlags flags, struct timespec *ts); + static inline int write_string_stream(FILE *f, const char *line, WriteStringFileFlags flags) { + return write_string_stream_ts(f, line, flags, NULL); +@@ -35,9 +39,15 @@ static inline int write_string_file(const char *fn, const char *line, WriteStrin + + int write_string_filef(const char *fn, WriteStringFileFlags flags, const char *format, ...) _printf_(3, 4); + +-int read_one_line_file(const char *fn, char **line); +-int read_full_file(const char *fn, char **contents, size_t *size); +-int read_full_stream(FILE *f, char **contents, size_t *size); ++int read_one_line_file(const char *filename, char **line); ++int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); ++static inline int read_full_file(const char *filename, char **contents, size_t *size) { ++ return read_full_file_full(filename, 0, contents, size); ++} ++int read_full_stream_full(FILE *f, ReadFullFileFlags flags, char **contents, size_t *size); ++static inline int read_full_stream(FILE *f, char **contents, size_t *size) { ++ return read_full_stream_full(f, 0, contents, size); ++} + int read_full_virtual_file(const char *filename, char **ret_contents, size_t *ret_size); + + int verify_file(const char *fn, const char *blob, bool accept_extra_nl); +-- +2.39.1 + diff --git a/10018-fileio-introduce-warn_file_is_world_accessible.patch b/10018-fileio-introduce-warn_file_is_world_accessible.patch new file mode 100644 index 0000000..02f9518 --- /dev/null +++ b/10018-fileio-introduce-warn_file_is_world_accessible.patch @@ -0,0 +1,67 @@ +From e4c4f0bc712e43776c4f58712f47260711607098 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Mon, 8 Apr 2019 03:48:30 +0900 +Subject: [PATCH] fileio: introduce warn_file_is_world_accessible() + +(cherry picked from commit fc0895034d4811e8c6b263c0d902b31535613d76) + +Signed-off-by: Guorui Yu +--- + src/basic/fileio.c | 25 +++++++++++++++++++++++++ + src/basic/fileio.h | 3 +++ + 2 files changed, 28 insertions(+) + +diff --git a/src/basic/fileio.c b/src/basic/fileio.c +index cf7c92ebc7..2e74aac554 100644 +--- a/src/basic/fileio.c ++++ b/src/basic/fileio.c +@@ -1797,3 +1797,28 @@ int read_line(FILE *f, size_t limit, char **ret) { + + return (int) count; + } ++ ++int warn_file_is_world_accessible(const char *filename, struct stat *st, const char *unit, unsigned line) { ++ struct stat _st; ++ ++ if (!filename) ++ return 0; ++ ++ if (!st) { ++ if (stat(filename, &_st) < 0) ++ return -errno; ++ st = &_st; ++ } ++ ++ if ((st->st_mode & S_IRWXO) == 0) ++ return 0; ++ ++ if (unit) ++ log_syntax(unit, LOG_WARNING, filename, line, 0, ++ "%s has %04o mode that is too permissive, please adjust the access mode.", ++ filename, st->st_mode & 07777); ++ else ++ log_warning("%s has %04o mode that is too permissive, please adjust the access mode.", ++ filename, st->st_mode & 07777); ++ return 0; ++} +diff --git a/src/basic/fileio.h b/src/basic/fileio.h +index 06649ef7e6..2c9ce4355b 100644 +--- a/src/basic/fileio.h ++++ b/src/basic/fileio.h +@@ -5,6 +5,7 @@ + #include + #include + #include ++#include + #include + + #include "macro.h" +@@ -105,3 +106,5 @@ int read_nul_string(FILE *f, char **ret); + int mkdtemp_malloc(const char *template, char **ret); + + int read_line(FILE *f, size_t limit, char **ret); ++ ++int warn_file_is_world_accessible(const char *filename, struct stat *st, const char *unit, unsigned line); +-- +2.39.1 + diff --git a/10019-fileio-read_full_file_full-also-warns-when-file-is-.patch b/10019-fileio-read_full_file_full-also-warns-when-file-is-.patch new file mode 100644 index 0000000..af813a5 --- /dev/null +++ b/10019-fileio-read_full_file_full-also-warns-when-file-is-.patch @@ -0,0 +1,64 @@ +From 0dbf69ccdfa7b1f99935c3932445fbfa16dbbe75 Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Mon, 8 Apr 2019 14:15:10 +0900 +Subject: [PATCH] fileio: read_full_file_full() also warns when file is world + readable and secure flag is set + +(cherry picked from commit 65dcd394d8223bc6bc194f3fe5bd70fed9d9a4fe) + +Signed-off-by: Guorui Yu +--- + src/basic/fileio.c | 6 +++++- + src/basic/fileio.h | 4 ++-- + 2 files changed, 7 insertions(+), 3 deletions(-) + +diff --git a/src/basic/fileio.c b/src/basic/fileio.c +index 2e74aac554..3abeb0d7f4 100644 +--- a/src/basic/fileio.c ++++ b/src/basic/fileio.c +@@ -386,6 +386,7 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re + + int read_full_stream_full( + FILE *f, ++ const char *filename, + ReadFullFileFlags flags, + char **ret_contents, + size_t *ret_size) { +@@ -418,6 +419,9 @@ int read_full_stream_full( + * makes us notice the EOF. */ + if (st.st_size > 0) + n_next = st.st_size + 1; ++ ++ if (flags & READ_FULL_FILE_SECURE) ++ (void) warn_file_is_world_accessible(filename, &st, NULL, 0); + } + } + +@@ -508,7 +512,7 @@ int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **co + + (void) __fsetlocking(f, FSETLOCKING_BYCALLER); + +- return read_full_stream_full(f, flags, contents, size); ++ return read_full_stream_full(f, filename, flags, contents, size); + } + + static int parse_env_file_internal( +diff --git a/src/basic/fileio.h b/src/basic/fileio.h +index 2c9ce4355b..3e572dc0de 100644 +--- a/src/basic/fileio.h ++++ b/src/basic/fileio.h +@@ -45,9 +45,9 @@ int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **co + static inline int read_full_file(const char *filename, char **contents, size_t *size) { + return read_full_file_full(filename, 0, contents, size); + } +-int read_full_stream_full(FILE *f, ReadFullFileFlags flags, char **contents, size_t *size); ++int read_full_stream_full(FILE *f, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); + static inline int read_full_stream(FILE *f, char **contents, size_t *size) { +- return read_full_stream_full(f, 0, contents, size); ++ return read_full_stream_full(f, NULL, 0, contents, size); + } + int read_full_virtual_file(const char *filename, char **ret_contents, size_t *ret_size); + +-- +2.39.1 + diff --git a/10020-basic-fileio-Fix-memory-leak-if-READ_FULL_FILE_SECU.patch b/10020-basic-fileio-Fix-memory-leak-if-READ_FULL_FILE_SECU.patch new file mode 100644 index 0000000..e434089 --- /dev/null +++ b/10020-basic-fileio-Fix-memory-leak-if-READ_FULL_FILE_SECU.patch @@ -0,0 +1,30 @@ +From 14e0760c251fd5fc51731f7b58079c73f5055d64 Mon Sep 17 00:00:00 2001 +From: Benjamin Robin +Date: Sun, 14 Apr 2019 17:21:27 +0200 +Subject: [PATCH] basic/fileio: Fix memory leak if READ_FULL_FILE_SECURE flag + is used + +The memory leak introduced in #12223 (15f8f02) + +(cherry picked from commit 315a51982af2d480de9f7539346f30425e37a01e) + +Signed-off-by: Guorui Yu +--- + src/basic/fileio.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/basic/fileio.c b/src/basic/fileio.c +index 3abeb0d7f4..bb804e3afa 100644 +--- a/src/basic/fileio.c ++++ b/src/basic/fileio.c +@@ -438,6 +438,7 @@ int read_full_stream_full( + } + memcpy_safe(t, buf, n); + explicit_bzero_safe(buf, n); ++ buf = mfree(buf); + } else { + t = realloc(buf, n_next + 1); + if (!t) +-- +2.39.1 + diff --git a/10021-fileio-add-explicit-flag-for-generating-world-execu.patch b/10021-fileio-add-explicit-flag-for-generating-world-execu.patch new file mode 100644 index 0000000..1a93b5a --- /dev/null +++ b/10021-fileio-add-explicit-flag-for-generating-world-execu.patch @@ -0,0 +1,44 @@ +From 1e0dcd6fa1abea9c561f46556f7f7561b2a46e62 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 17 Jul 2020 11:53:22 +0200 +Subject: [PATCH] fileio: add explicit flag for generating world executable + warning when reading file + +(cherry picked from commit 684aa979f1c4ce5f75ccdc131f32fc0434999918) + +Signed-off-by: Guorui Yu +--- + src/basic/fileio.c | 2 +- + src/basic/fileio.h | 3 ++- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/basic/fileio.c b/src/basic/fileio.c +index bb804e3afa..833c55b030 100644 +--- a/src/basic/fileio.c ++++ b/src/basic/fileio.c +@@ -420,7 +420,7 @@ int read_full_stream_full( + if (st.st_size > 0) + n_next = st.st_size + 1; + +- if (flags & READ_FULL_FILE_SECURE) ++ if (flags & READ_FULL_FILE_WARN_WORLD_READABLE) + (void) warn_file_is_world_accessible(filename, &st, NULL, 0); + } + } +diff --git a/src/basic/fileio.h b/src/basic/fileio.h +index 3e572dc0de..be10ac77b6 100644 +--- a/src/basic/fileio.h ++++ b/src/basic/fileio.h +@@ -26,7 +26,8 @@ typedef enum { + } WriteStringFileFlags; + + typedef enum { +- READ_FULL_FILE_SECURE = 1 << 0, ++ READ_FULL_FILE_SECURE = 1 << 0, ++ READ_FULL_FILE_WARN_WORLD_READABLE = 1 << 3, + } ReadFullFileFlags; + + int write_string_stream_ts(FILE *f, const char *line, WriteStringFileFlags flags, struct timespec *ts); +-- +2.39.1 + diff --git a/10022-fileio-add-dir_fd-parameter-to-read_full_file_full.patch b/10022-fileio-add-dir_fd-parameter-to-read_full_file_full.patch new file mode 100644 index 0000000..f6dc153 --- /dev/null +++ b/10022-fileio-add-dir_fd-parameter-to-read_full_file_full.patch @@ -0,0 +1,142 @@ +From 3f4ca11498028756ebde239ae469c0f88e5d3ecc Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Tue, 8 Jan 2019 18:29:36 +0100 +Subject: [PATCH] fileio: add 'dir_fd' parameter to read_full_file_full() + +Let's introduce an "at" version of read_full_file(). + +(cherry picked from commit f6be4db4530b7cfea191227c141343a4fb10d4c6) + +Signed-off-by: Guorui Yu +--- + src/basic/fileio.c | 84 +++++++++++++++++++++++++++++++++++++++++++--- + src/basic/fileio.h | 5 +-- + 2 files changed, 83 insertions(+), 6 deletions(-) + +diff --git a/src/basic/fileio.c b/src/basic/fileio.c +index 833c55b030..d7da834a74 100644 +--- a/src/basic/fileio.c ++++ b/src/basic/fileio.c +@@ -501,15 +501,91 @@ finalize: + return r; + } + +-int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **contents, size_t *size) { ++static int mode_to_flags(const char *mode) { ++ const char *p; ++ int flags; ++ ++ if ((p = startswith(mode, "r+"))) ++ flags = O_RDWR; ++ else if ((p = startswith(mode, "r"))) ++ flags = O_RDONLY; ++ else if ((p = startswith(mode, "w+"))) ++ flags = O_RDWR|O_CREAT|O_TRUNC; ++ else if ((p = startswith(mode, "w"))) ++ flags = O_WRONLY|O_CREAT|O_TRUNC; ++ else if ((p = startswith(mode, "a+"))) ++ flags = O_RDWR|O_CREAT|O_APPEND; ++ else if ((p = startswith(mode, "a"))) ++ flags = O_WRONLY|O_CREAT|O_APPEND; ++ else ++ return -EINVAL; ++ ++ for (; *p != 0; p++) { ++ ++ switch (*p) { ++ ++ case 'e': ++ flags |= O_CLOEXEC; ++ break; ++ ++ case 'x': ++ flags |= O_EXCL; ++ break; ++ ++ case 'm': ++ /* ignore this here, fdopen() might care later though */ ++ break; ++ ++ case 'c': /* not sure what to do about this one */ ++ default: ++ return -EINVAL; ++ } ++ } ++ ++ return flags; ++} ++ ++static int xfopenat(int dir_fd, const char *path, const char *mode, int flags, FILE **ret) { ++ FILE *f; ++ ++ /* A combination of fopen() with openat() */ ++ ++ if (dir_fd == AT_FDCWD && flags == 0) { ++ f = fopen(path, mode); ++ if (!f) ++ return -errno; ++ } else { ++ int fd, mode_flags; ++ ++ mode_flags = mode_to_flags(mode); ++ if (mode_flags < 0) ++ return mode_flags; ++ ++ fd = openat(dir_fd, path, mode_flags | flags); ++ if (fd < 0) ++ return -errno; ++ ++ f = fdopen(fd, mode); ++ if (!f) { ++ safe_close(fd); ++ return -errno; ++ } ++ } ++ ++ *ret = f; ++ return 0; ++} ++ ++int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size) { + _cleanup_fclose_ FILE *f = NULL; ++ int r; + + assert(filename); + assert(contents); + +- f = fopen(filename, "re"); +- if (!f) +- return -errno; ++ r = xfopenat(dir_fd, filename, "re", 0, &f); ++ if (r < 0) ++ return r; + + (void) __fsetlocking(f, FSETLOCKING_BYCALLER); + +diff --git a/src/basic/fileio.h b/src/basic/fileio.h +index be10ac77b6..916ddc5e47 100644 +--- a/src/basic/fileio.h ++++ b/src/basic/fileio.h +@@ -6,6 +6,7 @@ + #include + #include + #include ++#include + #include + + #include "macro.h" +@@ -42,9 +43,9 @@ static inline int write_string_file(const char *fn, const char *line, WriteStrin + int write_string_filef(const char *fn, WriteStringFileFlags flags, const char *format, ...) _printf_(3, 4); + + int read_one_line_file(const char *filename, char **line); +-int read_full_file_full(const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); ++int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); + static inline int read_full_file(const char *filename, char **contents, size_t *size) { +- return read_full_file_full(filename, 0, contents, size); ++ return read_full_file_full(AT_FDCWD, filename, 0, contents, size); + } + int read_full_stream_full(FILE *f, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); + static inline int read_full_stream(FILE *f, char **contents, size_t *size) { +-- +2.39.1 + diff --git a/10023-fileio-add-support-for-read_full_file-on-AF_UNIX-st.patch b/10023-fileio-add-support-for-read_full_file-on-AF_UNIX-st.patch new file mode 100644 index 0000000..bb392bc --- /dev/null +++ b/10023-fileio-add-support-for-read_full_file-on-AF_UNIX-st.patch @@ -0,0 +1,271 @@ +From 054669a4cc4897792b6c209fd55ab1fc1d7b9bd5 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 17 Jul 2020 12:26:01 +0200 +Subject: [PATCH] fileio: add support for read_full_file() on AF_UNIX stream + sockets + +Optionally, teach read_full_file() the ability to connect to an AF_UNIX +socket if the specified path points to one. + +(cherry picked from commit 412b888ec803cdf96fb1d005bb245d20abdb8f2e) + +[Guorui Yu: Adds sockaddr_un_set_path function to socket-util.{c,h}] +Signed-off-by: Guorui Yu +--- + src/basic/fileio.c | 62 +++++++++++++++++++++++++++++++++++------ + src/basic/fileio.h | 1 + + src/basic/socket-util.c | 42 ++++++++++++++++++++++++++++ + src/basic/socket-util.h | 1 + + src/test/test-fileio.c | 50 +++++++++++++++++++++++++++++++++ + 5 files changed, 147 insertions(+), 9 deletions(-) + +diff --git a/src/basic/fileio.c b/src/basic/fileio.c +index d7da834a74..9cb0a2bd28 100644 +--- a/src/basic/fileio.c ++++ b/src/basic/fileio.c +@@ -27,6 +27,7 @@ + #include "missing.h" + #include "parse-util.h" + #include "path-util.h" ++#include "socket-util.h" + #include "process-util.h" + #include "random-util.h" + #include "stdio-util.h" +@@ -450,21 +451,18 @@ int read_full_stream_full( + + errno = 0; + k = fread(buf + l, 1, n - l, f); +- if (k > 0) +- l += k; ++ ++ assert(k <= n - l); ++ l += k; + + if (ferror(f)) { + r = errno > 0 ? -errno : -EIO; + goto finalize; + } +- + if (feof(f)) + break; + +- /* We aren't expecting fread() to return a short read outside +- * of (error && eof), assert buffer is full and enlarge buffer. +- */ +- assert(l == n); ++ assert(k > 0); /* we can't have read zero bytes because that would have been EOF */ + + /* Safety check */ + if (n >= READ_FULL_BYTES_MAX) { +@@ -584,8 +582,54 @@ int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flag + assert(contents); + + r = xfopenat(dir_fd, filename, "re", 0, &f); +- if (r < 0) +- return r; ++ if (r < 0) { ++ _cleanup_close_ int dfd = -1, sk = -1; ++ union sockaddr_union sa; ++ ++ /* ENXIO is what Linux returns if we open a node that is an AF_UNIX socket */ ++ if (r != -ENXIO) ++ return r; ++ ++ /* If this is enabled, let's try to connect to it */ ++ if (!FLAGS_SET(flags, READ_FULL_FILE_CONNECT_SOCKET)) ++ return -ENXIO; ++ ++ if (dir_fd == AT_FDCWD) ++ r = sockaddr_un_set_path(&sa.un, filename); ++ else { ++ char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)]; ++ ++ /* If we shall operate relative to some directory, then let's use O_PATH first to ++ * open the socket inode, and then connect to it via /proc/self/fd/. We have to do ++ * this since there's not connectat() that takes a directory fd as first arg. */ ++ ++ dfd = openat(dir_fd, filename, O_PATH|O_CLOEXEC); ++ if (dfd < 0) ++ return -errno; ++ ++ xsprintf(procfs_path, "/proc/self/fd/%i", dfd); ++ r = sockaddr_un_set_path(&sa.un, procfs_path); ++ } ++ if (r < 0) ++ return r; ++ ++ sk = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0); ++ if (sk < 0) ++ return -errno; ++ ++ if (connect(sk, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0) ++ return errno == ENOTSOCK ? -ENXIO : -errno; /* propagate original error if this is ++ * not a socket after all */ ++ ++ if (shutdown(sk, SHUT_WR) < 0) ++ return -errno; ++ ++ f = fdopen(sk, "r"); ++ if (!f) ++ return -errno; ++ ++ TAKE_FD(sk); ++ } + + (void) __fsetlocking(f, FSETLOCKING_BYCALLER); + +diff --git a/src/basic/fileio.h b/src/basic/fileio.h +index 916ddc5e47..1a16e0fd13 100644 +--- a/src/basic/fileio.h ++++ b/src/basic/fileio.h +@@ -29,6 +29,7 @@ typedef enum { + typedef enum { + READ_FULL_FILE_SECURE = 1 << 0, + READ_FULL_FILE_WARN_WORLD_READABLE = 1 << 3, ++ READ_FULL_FILE_CONNECT_SOCKET = 1 << 4, + } ReadFullFileFlags; + + int write_string_stream_ts(FILE *f, const char *line, WriteStringFileFlags flags, struct timespec *ts); +diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c +index 7f8066123b..427c8b89bb 100644 +--- a/src/basic/socket-util.c ++++ b/src/basic/socket-util.c +@@ -1253,6 +1253,48 @@ int socket_ioctl_fd(void) { + return fd; + } + ++int sockaddr_un_set_path(struct sockaddr_un *ret, const char *path) { ++ size_t l; ++ ++ assert(ret); ++ assert(path); ++ ++ /* Initialize ret->sun_path from the specified argument. This will interpret paths starting with '@' as ++ * abstract namespace sockets, and those starting with '/' as regular filesystem sockets. It won't accept ++ * anything else (i.e. no relative paths), to avoid ambiguities. Note that this function cannot be used to ++ * reference paths in the abstract namespace that include NUL bytes in the name. */ ++ ++ l = strlen(path); ++ if (l < 2) ++ return -EINVAL; ++ if (!IN_SET(path[0], '/', '@')) ++ return -EINVAL; ++ ++ /* Don't allow paths larger than the space in sockaddr_un. Note that we are a tiny bit more restrictive than ++ * the kernel is: we insist on NUL termination (both for abstract namespace and regular file system socket ++ * addresses!), which the kernel doesn't. We do this to reduce chance of incompatibility with other apps that ++ * do not expect non-NUL terminated file system path*/ ++ if (l+1 > sizeof(ret->sun_path)) ++ return -EINVAL; ++ ++ *ret = (struct sockaddr_un) { ++ .sun_family = AF_UNIX, ++ }; ++ ++ if (path[0] == '@') { ++ /* Abstract namespace socket */ ++ memcpy(ret->sun_path + 1, path + 1, l); /* copy *with* trailing NUL byte */ ++ return (int) (offsetof(struct sockaddr_un, sun_path) + l); /* 🔥 *don't* 🔥 include trailing NUL in size */ ++ ++ } else { ++ assert(path[0] == '/'); ++ ++ /* File system socket */ ++ memcpy(ret->sun_path, path, l + 1); /* copy *with* trailing NUL byte */ ++ return (int) (offsetof(struct sockaddr_un, sun_path) + l + 1); /* include trailing NUL in size */ ++ } ++} ++ + int socket_pass_pktinfo(int fd, bool b) { + int af; + socklen_t sl = sizeof(af); +diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h +index 30baba6c03..36edc58caf 100644 +--- a/src/basic/socket-util.h ++++ b/src/basic/socket-util.h +@@ -186,6 +186,7 @@ struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t leng + }) + + int socket_ioctl_fd(void); ++int sockaddr_un_set_path(struct sockaddr_un *ret, const char *path); + + static inline int setsockopt_int(int fd, int level, int optname, int value) { + if (setsockopt(fd, level, optname, &value, sizeof(value)) < 0) +diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c +index 14ba075144..82b7cb1242 100644 +--- a/src/test/test-fileio.c ++++ b/src/test/test-fileio.c +@@ -14,6 +14,8 @@ + #include "io-util.h" + #include "parse-util.h" + #include "process-util.h" ++#include "rm-rf.h" ++#include "socket-util.h" + #include "string-util.h" + #include "strv.h" + #include "util.h" +@@ -709,6 +711,53 @@ static void test_read_line3(void) { + assert_se(read_line(f, LINE_MAX, NULL) == 0); + } + ++static void test_read_full_file_socket(void) { ++ _cleanup_(rm_rf_physical_and_freep) char *z = NULL; ++ _cleanup_close_ int listener = -1; ++ _cleanup_free_ char *data = NULL; ++ union sockaddr_union sa; ++ const char *j; ++ size_t size; ++ pid_t pid; ++ int r; ++ ++ log_info("/* %s */", __func__); ++ ++ listener = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0); ++ assert_se(listener >= 0); ++ ++ assert_se(mkdtemp_malloc(NULL, &z) >= 0); ++ j = strjoina(z, "/socket"); ++ ++ assert_se(sockaddr_un_set_path(&sa.un, j) >= 0); ++ ++ assert_se(bind(listener, &sa.sa, SOCKADDR_UN_LEN(sa.un)) >= 0); ++ assert_se(listen(listener, 1) >= 0); ++ ++ r = safe_fork("(server)", FORK_DEATHSIG|FORK_LOG, &pid); ++ assert_se(r >= 0); ++ if (r == 0) { ++ _cleanup_close_ int rfd = -1; ++ /* child */ ++ ++ rfd = accept4(listener, NULL, 0, SOCK_CLOEXEC); ++ assert_se(rfd >= 0); ++ ++#define TEST_STR "This is a test\nreally." ++ ++ assert_se(write(rfd, TEST_STR, strlen(TEST_STR)) == strlen(TEST_STR)); ++ _exit(EXIT_SUCCESS); ++ } ++ ++ assert_se(read_full_file_full(AT_FDCWD, j, 0, &data, &size) == -ENXIO); ++ assert_se(read_full_file_full(AT_FDCWD, j, READ_FULL_FILE_CONNECT_SOCKET, &data, &size) >= 0); ++ assert_se(size == strlen(TEST_STR)); ++ assert_se(streq(data, TEST_STR)); ++ ++ assert_se(wait_for_terminate_and_check("(server)", pid, WAIT_LOG) >= 0); ++#undef TEST_STR ++} ++ + int main(int argc, char *argv[]) { + log_set_max_level(LOG_DEBUG); + log_parse_environment(); +@@ -733,6 +782,7 @@ int main(int argc, char *argv[]) { + test_read_line(); + test_read_line2(); + test_read_line3(); ++ test_read_full_file_socket(); + + return 0; + } +-- +2.39.1 + diff --git a/10024-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch b/10024-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch new file mode 100644 index 0000000..2edc538 --- /dev/null +++ b/10024-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch @@ -0,0 +1,181 @@ +From 0717de25e6508b10ea034fa1b96675f18100ac01 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Mon, 2 Nov 2020 12:07:51 +0100 +Subject: [PATCH] fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow + setting sender socket name + +This beefs up the READ_FULL_FILE_CONNECT_SOCKET logic of +read_full_file_full() a bit: when used a sender socket name may be +specified. If specified as NULL behaviour is as before: the client +socket name is picked by the kernel. But if specified as non-NULL the +client can pick a socket name to use when connecting. This is useful to +communicate a minimal amount of metainformation from client to server, +outside of the transport payload. + +Specifically, these beefs up the service credential logic to pass an +abstract AF_UNIX socket name as client socket name when connecting via +READ_FULL_FILE_CONNECT_SOCKET, that includes the requesting unit name +and the eventual credential name. This allows servers implementing the +trivial credential socket logic to distinguish clients: via a simple +getpeername() it can be determined which unit is requesting a +credential, and which credential specifically. + +Example: with this patch in place, in a unit file "waldo.service" a +configuration line like the following: + + LoadCredential=foo:/run/quux/creds.sock + +will result in a connection to the AF_UNIX socket /run/quux/creds.sock, +originating from an abstract namespace AF_UNIX socket: + + @$RANDOM/unit/waldo.service/foo + +(The $RANDOM is replaced by some randomized string. This is included in +the socket name order to avoid namespace squatting issues: the abstract +socket namespace is open to unprivileged users after all, and care needs +to be taken not to use guessable names) + +The services listening on the /run/quux/creds.sock socket may thus +easily retrieve the name of the unit the credential is requested for +plus the credential name, via a simpler getpeername(), discarding the +random preifx and the /unit/ string. + +This logic uses "/" as separator between the fields, since both unit +names and credential names appear in the file system, and thus are +designed to use "/" as outer separators. Given that it's a good safe +choice to use as separators here, too avoid any conflicts. + +This is a minimal patch only: the new logic is used only for the unit +file credential logic. For other places where we use +READ_FULL_FILE_CONNECT_SOCKET it is probably a good idea to use this +scheme too, but this should be done carefully in later patches, since +the socket names become API that way, and we should determine the right +amount of info to pass over. + +(cherry picked from commit 142e9756c98c69cdd5d03df4028700acb5739f72) + +Signed-off-by: Guorui Yu +--- + src/basic/fileio.c | 22 +++++++++++++++++++++- + src/basic/fileio.h | 4 ++-- + src/test/test-fileio.c | 19 ++++++++++++++++--- + 3 files changed, 39 insertions(+), 6 deletions(-) + +diff --git a/src/basic/fileio.c b/src/basic/fileio.c +index 9cb0a2bd28..35eaa3c1c7 100644 +--- a/src/basic/fileio.c ++++ b/src/basic/fileio.c +@@ -574,7 +574,13 @@ static int xfopenat(int dir_fd, const char *path, const char *mode, int flags, F + return 0; + } + +-int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size) { ++int read_full_file_full( ++ int dir_fd, ++ const char *filename, ++ ReadFullFileFlags flags, ++ const char *bind_name, ++ char **contents, size_t *size) { ++ + _cleanup_fclose_ FILE *f = NULL; + int r; + +@@ -617,6 +623,20 @@ int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flag + if (sk < 0) + return -errno; + ++ if (bind_name) { ++ /* If the caller specified a socket name to bind to, do so before connecting. This is ++ * useful to communicate some minor, short meta-information token from the client to ++ * the server. */ ++ union sockaddr_union bsa; ++ ++ r = sockaddr_un_set_path(&bsa.un, bind_name); ++ if (r < 0) ++ return r; ++ ++ if (bind(sk, &bsa.sa, r) < 0) ++ return r; ++ } ++ + if (connect(sk, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0) + return errno == ENOTSOCK ? -ENXIO : -errno; /* propagate original error if this is + * not a socket after all */ +diff --git a/src/basic/fileio.h b/src/basic/fileio.h +index 1a16e0fd13..82897e209c 100644 +--- a/src/basic/fileio.h ++++ b/src/basic/fileio.h +@@ -44,9 +44,9 @@ static inline int write_string_file(const char *fn, const char *line, WriteStrin + int write_string_filef(const char *fn, WriteStringFileFlags flags, const char *format, ...) _printf_(3, 4); + + int read_one_line_file(const char *filename, char **line); +-int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); ++int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flags, const char *bind_name, char **contents, size_t *size); + static inline int read_full_file(const char *filename, char **contents, size_t *size) { +- return read_full_file_full(AT_FDCWD, filename, 0, contents, size); ++ return read_full_file_full(AT_FDCWD, filename, 0, NULL, contents, size); + } + int read_full_stream_full(FILE *f, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); + static inline int read_full_stream(FILE *f, char **contents, size_t *size) { +diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c +index 82b7cb1242..5ec70eec14 100644 +--- a/src/test/test-fileio.c ++++ b/src/test/test-fileio.c +@@ -14,6 +14,7 @@ + #include "io-util.h" + #include "parse-util.h" + #include "process-util.h" ++#include "random-util.h" + #include "rm-rf.h" + #include "socket-util.h" + #include "string-util.h" +@@ -714,7 +715,7 @@ static void test_read_line3(void) { + static void test_read_full_file_socket(void) { + _cleanup_(rm_rf_physical_and_freep) char *z = NULL; + _cleanup_close_ int listener = -1; +- _cleanup_free_ char *data = NULL; ++ _cleanup_free_ char *data = NULL, *clientname = NULL; + union sockaddr_union sa; + const char *j; + size_t size; +@@ -734,23 +735,35 @@ static void test_read_full_file_socket(void) { + assert_se(bind(listener, &sa.sa, SOCKADDR_UN_LEN(sa.un)) >= 0); + assert_se(listen(listener, 1) >= 0); + ++ /* Bind the *client* socket to some randomized name, to verify that this works correctly. */ ++ assert_se(asprintf(&clientname, "@%" PRIx64 "/test-bindname", random_u64()) >= 0); ++ + r = safe_fork("(server)", FORK_DEATHSIG|FORK_LOG, &pid); + assert_se(r >= 0); + if (r == 0) { ++ union sockaddr_union peer = {}; ++ socklen_t peerlen = sizeof(peer); + _cleanup_close_ int rfd = -1; + /* child */ + + rfd = accept4(listener, NULL, 0, SOCK_CLOEXEC); + assert_se(rfd >= 0); + ++ assert_se(getpeername(rfd, &peer.sa, &peerlen) >= 0); ++ ++ assert_se(peer.un.sun_family == AF_UNIX); ++ assert_se(peerlen > offsetof(struct sockaddr_un, sun_path)); ++ assert_se(peer.un.sun_path[0] == 0); ++ assert_se(streq(peer.un.sun_path + 1, clientname + 1)); ++ + #define TEST_STR "This is a test\nreally." + + assert_se(write(rfd, TEST_STR, strlen(TEST_STR)) == strlen(TEST_STR)); + _exit(EXIT_SUCCESS); + } + +- assert_se(read_full_file_full(AT_FDCWD, j, 0, &data, &size) == -ENXIO); +- assert_se(read_full_file_full(AT_FDCWD, j, READ_FULL_FILE_CONNECT_SOCKET, &data, &size) >= 0); ++ assert_se(read_full_file_full(AT_FDCWD, j, 0, NULL, &data, &size) == -ENXIO); ++ assert_se(read_full_file_full(AT_FDCWD, j, READ_FULL_FILE_CONNECT_SOCKET, clientname, &data, &size) >= 0); + assert_se(size == strlen(TEST_STR)); + assert_se(streq(data, TEST_STR)); + +-- +2.39.1 + diff --git a/10025-fileio-teach-read_full_file_full-to-read-from-offse.patch b/10025-fileio-teach-read_full_file_full-to-read-from-offse.patch new file mode 100644 index 0000000..08e8f40 --- /dev/null +++ b/10025-fileio-teach-read_full_file_full-to-read-from-offse.patch @@ -0,0 +1,246 @@ +From 5be0e8a2c3e683c195fd872979d6e5741c80d13f Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 4 Nov 2020 20:25:06 +0100 +Subject: [PATCH] fileio: teach read_full_file_full() to read from offset/with + maximum size + +(cherry picked from commit 7399b3f8083b65db4cb9acb17e4b5c897ba7946d) + +Signed-off-by: Guorui Yu +--- + src/basic/fileio.c | 60 ++++++++++++++++++++++++++++++------------ + src/basic/fileio.h | 12 ++++----- + src/test/test-fileio.c | 49 ++++++++++++++++++++++++++++++++-- + 3 files changed, 96 insertions(+), 25 deletions(-) + +diff --git a/src/basic/fileio.c b/src/basic/fileio.c +index 35eaa3c1c7..c14f9797bd 100644 +--- a/src/basic/fileio.c ++++ b/src/basic/fileio.c +@@ -388,44 +388,58 @@ int read_full_virtual_file(const char *filename, char **ret_contents, size_t *re + int read_full_stream_full( + FILE *f, + const char *filename, ++ uint64_t offset, ++ size_t size, + ReadFullFileFlags flags, + char **ret_contents, + size_t *ret_size) { + + _cleanup_free_ char *buf = NULL; +- struct stat st; + size_t n, n_next, l; + int fd, r; + + assert(f); + assert(ret_contents); + +- n_next = LINE_MAX; /* Start size */ ++ if (offset != UINT64_MAX && offset > LONG_MAX) ++ return -ERANGE; ++ ++ n_next = size != SIZE_MAX ? size : LINE_MAX; /* Start size */ + + fd = fileno(f); +- if (fd >= 0) { /* If the FILE* object is backed by an fd (as opposed to memory or such, see fmemopen(), let's +- * optimize our buffering) */ ++ if (fd >= 0) { /* If the FILE* object is backed by an fd (as opposed to memory or such, see ++ * fmemopen()), let's optimize our buffering */ ++ struct stat st; + + if (fstat(fd, &st) < 0) + return -errno; + + if (S_ISREG(st.st_mode)) { +- +- /* Safety check */ +- if (st.st_size > READ_FULL_BYTES_MAX) +- return -E2BIG; +- +- /* Start with the right file size. Note that we increase the size +- * to read here by one, so that the first read attempt already +- * makes us notice the EOF. */ +- if (st.st_size > 0) +- n_next = st.st_size + 1; ++ if (size == SIZE_MAX) { ++ uint64_t rsize = ++ LESS_BY((uint64_t) st.st_size, offset == UINT64_MAX ? 0 : offset); ++ ++ /* Safety check */ ++ if (rsize > READ_FULL_BYTES_MAX) ++ return -E2BIG; ++ ++ /* Start with the right file size. Note that we increase the size to read ++ * here by one, so that the first read attempt already makes us notice the ++ * EOF. If the reported size of the file is zero, we avoid this logic ++ * however, since quite likely it might be a virtual file in procfs that all ++ * report a zero file size. */ ++ if (st.st_size > 0) ++ n_next = rsize + 1; ++ } + + if (flags & READ_FULL_FILE_WARN_WORLD_READABLE) + (void) warn_file_is_world_accessible(filename, &st, NULL, 0); + } + } + ++ if (offset != UINT64_MAX && fseek(f, offset, SEEK_SET) < 0) ++ return -errno; ++ + n = l = 0; + for (;;) { + char *t; +@@ -462,6 +476,11 @@ int read_full_stream_full( + if (feof(f)) + break; + ++ if (size != SIZE_MAX) { /* If we got asked to read some specific size, we already sized the buffer right, hence leave */ ++ assert(l == size); ++ break; ++ } ++ + assert(k > 0); /* we can't have read zero bytes because that would have been EOF */ + + /* Safety check */ +@@ -577,15 +596,18 @@ static int xfopenat(int dir_fd, const char *path, const char *mode, int flags, F + int read_full_file_full( + int dir_fd, + const char *filename, ++ uint64_t offset, ++ size_t size, + ReadFullFileFlags flags, + const char *bind_name, +- char **contents, size_t *size) { ++ char **ret_contents, ++ size_t *ret_size) { + + _cleanup_fclose_ FILE *f = NULL; + int r; + + assert(filename); +- assert(contents); ++ assert(ret_contents); + + r = xfopenat(dir_fd, filename, "re", 0, &f); + if (r < 0) { +@@ -600,6 +622,10 @@ int read_full_file_full( + if (!FLAGS_SET(flags, READ_FULL_FILE_CONNECT_SOCKET)) + return -ENXIO; + ++ /* Seeking is not supported on AF_UNIX sockets */ ++ if (offset != UINT64_MAX) ++ return -ESPIPE; ++ + if (dir_fd == AT_FDCWD) + r = sockaddr_un_set_path(&sa.un, filename); + else { +@@ -653,7 +679,7 @@ int read_full_file_full( + + (void) __fsetlocking(f, FSETLOCKING_BYCALLER); + +- return read_full_stream_full(f, filename, flags, contents, size); ++ return read_full_stream_full(f, filename, offset, size, flags, ret_contents, ret_size); + } + + static int parse_env_file_internal( +diff --git a/src/basic/fileio.h b/src/basic/fileio.h +index 82897e209c..03150ce776 100644 +--- a/src/basic/fileio.h ++++ b/src/basic/fileio.h +@@ -44,13 +44,13 @@ static inline int write_string_file(const char *fn, const char *line, WriteStrin + int write_string_filef(const char *fn, WriteStringFileFlags flags, const char *format, ...) _printf_(3, 4); + + int read_one_line_file(const char *filename, char **line); +-int read_full_file_full(int dir_fd, const char *filename, ReadFullFileFlags flags, const char *bind_name, char **contents, size_t *size); +-static inline int read_full_file(const char *filename, char **contents, size_t *size) { +- return read_full_file_full(AT_FDCWD, filename, 0, NULL, contents, size); ++int read_full_file_full(int dir_fd, const char *filename, uint64_t offset, size_t size, ReadFullFileFlags flags, const char *bind_name, char **ret_contents, size_t *ret_size); ++static inline int read_full_file(const char *filename, char **ret_contents, size_t *ret_size) { ++ return read_full_file_full(AT_FDCWD, filename, UINT64_MAX, SIZE_MAX, 0, NULL, ret_contents, ret_size); + } +-int read_full_stream_full(FILE *f, const char *filename, ReadFullFileFlags flags, char **contents, size_t *size); +-static inline int read_full_stream(FILE *f, char **contents, size_t *size) { +- return read_full_stream_full(f, NULL, 0, contents, size); ++int read_full_stream_full(FILE *f, const char *filename, uint64_t offset, size_t size, ReadFullFileFlags flags, char **ret_contents, size_t *ret_size); ++static inline int read_full_stream(FILE *f, char **ret_contents, size_t *ret_size) { ++ return read_full_stream_full(f, NULL, UINT64_MAX, SIZE_MAX, 0, ret_contents, ret_size); + } + int read_full_virtual_file(const char *filename, char **ret_contents, size_t *ret_size); + +diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c +index 5ec70eec14..5d0006149b 100644 +--- a/src/test/test-fileio.c ++++ b/src/test/test-fileio.c +@@ -762,8 +762,8 @@ static void test_read_full_file_socket(void) { + _exit(EXIT_SUCCESS); + } + +- assert_se(read_full_file_full(AT_FDCWD, j, 0, NULL, &data, &size) == -ENXIO); +- assert_se(read_full_file_full(AT_FDCWD, j, READ_FULL_FILE_CONNECT_SOCKET, clientname, &data, &size) >= 0); ++ assert_se(read_full_file_full(AT_FDCWD, j, UINT64_MAX, SIZE_MAX, 0, NULL, &data, &size) == -ENXIO); ++ assert_se(read_full_file_full(AT_FDCWD, j, UINT64_MAX, SIZE_MAX, READ_FULL_FILE_CONNECT_SOCKET, clientname, &data, &size) >= 0); + assert_se(size == strlen(TEST_STR)); + assert_se(streq(data, TEST_STR)); + +@@ -771,6 +771,50 @@ static void test_read_full_file_socket(void) { + #undef TEST_STR + } + ++static void test_read_full_file_offset_size(void) { ++ _cleanup_fclose_ FILE *f = NULL; ++ _cleanup_(unlink_and_freep) char *fn = NULL; ++ _cleanup_free_ char *rbuf = NULL; ++ size_t rbuf_size; ++ uint8_t buf[4711]; ++ ++ random_bytes(buf, sizeof(buf)); ++ ++ assert_se(tempfn_random_child(NULL, NULL, &fn) >= 0); ++ assert_se(f = fopen(fn, "we")); ++ assert_se(fwrite(buf, 1, sizeof(buf), f) == sizeof(buf)); ++ assert_se(fflush_and_check(f) >= 0); ++ ++ assert_se(read_full_file_full(AT_FDCWD, fn, UINT64_MAX, SIZE_MAX, 0, NULL, &rbuf, &rbuf_size) >= 0); ++ assert_se(rbuf_size == sizeof(buf)); ++ assert_se(memcmp(buf, rbuf, rbuf_size) == 0); ++ rbuf = mfree(rbuf); ++ ++ assert_se(read_full_file_full(AT_FDCWD, fn, UINT64_MAX, 128, 0, NULL, &rbuf, &rbuf_size) >= 0); ++ assert_se(rbuf_size == 128); ++ assert_se(memcmp(buf, rbuf, rbuf_size) == 0); ++ rbuf = mfree(rbuf); ++ ++ assert_se(read_full_file_full(AT_FDCWD, fn, 1234, SIZE_MAX, 0, NULL, &rbuf, &rbuf_size) >= 0); ++ assert_se(rbuf_size == sizeof(buf) - 1234); ++ assert_se(memcmp(buf + 1234, rbuf, rbuf_size) == 0); ++ rbuf = mfree(rbuf); ++ ++ assert_se(read_full_file_full(AT_FDCWD, fn, 2345, 777, 0, NULL, &rbuf, &rbuf_size) >= 0); ++ assert_se(rbuf_size == 777); ++ assert_se(memcmp(buf + 2345, rbuf, rbuf_size) == 0); ++ rbuf = mfree(rbuf); ++ ++ assert_se(read_full_file_full(AT_FDCWD, fn, 4700, 20, 0, NULL, &rbuf, &rbuf_size) >= 0); ++ assert_se(rbuf_size == 11); ++ assert_se(memcmp(buf + 4700, rbuf, rbuf_size) == 0); ++ rbuf = mfree(rbuf); ++ ++ assert_se(read_full_file_full(AT_FDCWD, fn, 10000, 99, 0, NULL, &rbuf, &rbuf_size) >= 0); ++ assert_se(rbuf_size == 0); ++ rbuf = mfree(rbuf); ++} ++ + int main(int argc, char *argv[]) { + log_set_max_level(LOG_DEBUG); + log_parse_environment(); +@@ -796,6 +840,7 @@ int main(int argc, char *argv[]) { + test_read_line2(); + test_read_line3(); + test_read_full_file_socket(); ++ test_read_full_file_offset_size(); + + return 0; + } +-- +2.39.1 + diff --git a/10026-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch b/10026-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch new file mode 100644 index 0000000..bb66170 --- /dev/null +++ b/10026-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch @@ -0,0 +1,95 @@ +From 8ef03861b75cf0a70511760c395cb4bd228c37b9 Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Wed, 4 Nov 2020 17:24:53 +0100 +Subject: [PATCH] cryptsetup: port cryptsetup's main key file logic over to + read_full_file_full() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Previously, we'd load the file with libcryptsetup's calls. Let's do that +in our own, so that we can make use of READ_FULL_FILE_CONNECT_SOCKET, +i.e. read in keys via AF_UNIX sockets, so that people can plug key +providers into our logic. + +This provides functionality similar to Debian's keyscript= crypttab +option (see → #3007), as it allows key scripts to be run as socket +activated services, that have stdout connected to the activated socket. +In contrast to traditional keyscript= support this logic runs stuff out +of process however, which is beneficial, since it allows sandboxing and +similar. + +(cherry picked from commit 165a476841ff1aa3aab3508771db9495ab073c7a) + +Signed-off-by: Guorui Yu +--- + src/cryptsetup/cryptsetup.c | 37 ++++++++++++++++++++++++++++++++----- + 1 file changed, 32 insertions(+), 5 deletions(-) + +diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c +index 11162eb722..9251e0eba8 100644 +--- a/src/cryptsetup/cryptsetup.c ++++ b/src/cryptsetup/cryptsetup.c +@@ -17,6 +17,7 @@ + #include "mount-util.h" + #include "parse-util.h" + #include "path-util.h" ++#include "random-util.h" + #include "string-util.h" + #include "strv.h" + #include "util.h" +@@ -480,6 +481,15 @@ static int attach_tcrypt( + return 0; + } + ++static char *make_bindname(const char *volume) { ++ char *s; ++ ++ if (asprintf(&s, "@%" PRIx64"/cryptsetup/%s", random_u64(), volume) < 0) ++ return NULL; ++ ++ return s; ++} ++ + static int attach_luks_or_plain(struct crypt_device *cd, + const char *name, + const char *key_file, +@@ -553,13 +563,30 @@ static int attach_luks_or_plain(struct crypt_device *cd, + crypt_get_device_name(cd)); + + if (key_file) { +- r = crypt_activate_by_keyfile_offset(cd, name, arg_key_slot, key_file, arg_keyfile_size, arg_keyfile_offset, flags); +- if (r == -EPERM) { +- log_error_errno(r, "Failed to activate with key file '%s'. (Key data incorrect?)", key_file); ++ _cleanup_(erase_and_freep) char *kfdata = NULL; ++ _cleanup_free_ char *bindname = NULL; ++ size_t kfsize; ++ ++ /* If we read the key via AF_UNIX, make this client recognizable */ ++ bindname = make_bindname(name); ++ if (!bindname) ++ return log_oom(); ++ ++ r = read_full_file_full( ++ AT_FDCWD, key_file, ++ arg_keyfile_offset == 0 ? UINT64_MAX : arg_keyfile_offset, ++ arg_keyfile_size == 0 ? SIZE_MAX : arg_keyfile_size, ++ READ_FULL_FILE_SECURE|READ_FULL_FILE_WARN_WORLD_READABLE|READ_FULL_FILE_CONNECT_SOCKET, ++ bindname, ++ &kfdata, &kfsize); ++ if (r == -ENOENT) { ++ log_error_errno(r, "Failed to activate, key file '%s' missing.", key_file); + return -EAGAIN; /* Log actual error, but return EAGAIN */ + } +- if (r == -EINVAL) { +- log_error_errno(r, "Failed to activate with key file '%s'. (Key file missing?)", key_file); ++ ++ r = crypt_activate_by_passphrase(cd, name, arg_key_slot, kfdata, kfsize, flags); ++ if (r == -EPERM) { ++ log_error_errno(r, "Failed to activate with key file '%s'. (Key data incorrect?)", key_file); + return -EAGAIN; /* Log actual error, but return EAGAIN */ + } + if (r < 0) +-- +2.39.1 + diff --git a/systemd.spec b/systemd.spec index 9360eb7..842b45e 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1078,6 +1078,19 @@ Patch10010: 10010-test-catalog-Fix-coredump-when-compiled-under-GCC10.patch Patch10011: 10011-hwdb-add-Iluvatar-CoreX.patch Patch10012: 10012-seccomp-add-loongarch-support.patch Patch10013: 10013-umount-check-LO_FLAGS_AUTOCLEAR-after-LOOP_CLR_FD-cl.patch +Patch10014: 10014-fileio-when-reading-a-full-file-into-memory-refuse-.patch +Patch10015: 10015-util-introduce-explicit_bzero_safe-for-explicit-mem.patch +Patch10016: 10016-util-introduce-erase_and_free-helper.patch +Patch10017: 10017-util-introduce-READ_FULL_FILE_SECURE-flag-for-readi.patch +Patch10018: 10018-fileio-introduce-warn_file_is_world_accessible.patch +Patch10019: 10019-fileio-read_full_file_full-also-warns-when-file-is-.patch +Patch10020: 10020-basic-fileio-Fix-memory-leak-if-READ_FULL_FILE_SECU.patch +Patch10021: 10021-fileio-add-explicit-flag-for-generating-world-execu.patch +Patch10022: 10022-fileio-add-dir_fd-parameter-to-read_full_file_full.patch +Patch10023: 10023-fileio-add-support-for-read_full_file-on-AF_UNIX-st.patch +Patch10024: 10024-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch +Patch10025: 10025-fileio-teach-read_full_file_full-to-read-from-offse.patch +Patch10026: 10026-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch %ifarch %{ix86} x86_64 aarch64 %global have_gnu_efi 1 @@ -1724,6 +1737,19 @@ fi - seccomp: add loongarch64 support (Liwei Ge) - seccomp: remove loongarch64 switch(Liwei Ge) - umount: check LO_FLAGS_AUTOCLEAR after LOOP_CLR_FD claimed success(yuanhui) +- fileio: when reading a full file into memory, refuse inner NUL bytes (Guorui Yu) +- util: introduce explicit_bzero_safe for explicit memset (Guorui Yu) +- util: introduce erase_and_free() helper (Guorui Yu) +- util: introduce READ_FULL_FILE_SECURE flag for reading secure data (Guorui Yu) +- fileio: introduce warn_file_is_world_accessible() (Guorui Yu) +- fileio: read_full_file_full() also warns when file is world readable and secure flag is set (Guorui Yu) +- basic/fileio: Fix memory leak if READ_FULL_FILE_SECURE flag is used (Guorui Yu) +- fileio: add explicit flag for generating world executable warning when reading file (Guorui Yu) +- fileio: add 'dir_fd' parameter to read_full_file_full() (Guorui Yu) +- fileio: add support for read_full_file() on AF_UNIX stream sockets (Guorui Yu) +- fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name (Guorui Yu) +- fileio: teach read_full_file_full() to read from offset/with maximum size (Guorui Yu) +- cryptsetup: port cryptsetup's main key file logic over to read_full_file_full() (Guorui Yu) * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee From 38e1f36fe38fe132ebc24c4dd0f5334f132f87f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=A0=E5=87=8C?= Date: Mon, 30 Oct 2023 15:54:33 +0800 Subject: [PATCH 09/17] Add optimized patches (hwdb,cgroup) - Update upstream parse_hwdb.py to fix parse-hwdb error - cgroup: do not refresh cgroup devices config when daemon-reload - core: introduce cgroup full delegation for compability --- 20001-hwdb-parse_hwdb_dot_py.patch | 299 ++++++++++++++++++ ...fresh-cgroup-devices-config-when-dae.patch | 26 ++ ...group-full-delegation-for-compabilit.patch | 133 ++++++++ systemd.spec | 7 + 4 files changed, 465 insertions(+) create mode 100644 20001-hwdb-parse_hwdb_dot_py.patch create mode 100644 20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch create mode 100644 20003-core-introduce-cgroup-full-delegation-for-compabilit.patch diff --git a/20001-hwdb-parse_hwdb_dot_py.patch b/20001-hwdb-parse_hwdb_dot_py.patch new file mode 100644 index 0000000..71bf1c5 --- /dev/null +++ b/20001-hwdb-parse_hwdb_dot_py.patch @@ -0,0 +1,299 @@ +From: rpm-build +Date: Thu, 28 Apr 2022 01:49:39 +0000 +Subject: [PATCH] Update upstream parse_hwdb.py to fix parse-hwdb error + +This patch does not correspond to a specific commit from upstream. Instead, it +is directly taken from + +https://github.com/systemd/systemd/blob/f2c36c0e2445fa95ba109017d4b768b2fd825c43/hwdb.d/parse_hwdb.py. + +This patch allows systemd-udev to parse newer hwdb. Hwdb is updated mostly +because of new hardware. Therefore, this patch allows systemd-udev to recongnize +these new hardware. + +--- +diff -uNrp systemd-239.orig/hwdb/parse_hwdb.py systemd-239/hwdb/parse_hwdb.py +--- systemd-239.orig/hwdb/parse_hwdb.py 2022-04-28 11:32:08.740731756 +0800 ++++ systemd-239/hwdb/parse_hwdb.py 2022-04-28 11:32:08.741731786 +0800 +@@ -1,6 +1,5 @@ + #!/usr/bin/env python3 +-# -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */ +-# SPDX-License-Identifier: MIT ++# SPDX-License-Identifier: MIT + # + # This file is distributed under the MIT license, see below. + # +@@ -30,12 +29,11 @@ import sys + import os + + try: +- from pyparsing import (Word, White, Literal, ParserElement, Regex, +- LineStart, LineEnd, ++ from pyparsing import (Word, White, Literal, ParserElement, Regex, LineEnd, + OneOrMore, Combine, Or, Optional, Suppress, Group, + nums, alphanums, printables, +- stringEnd, pythonStyleComment, QuotedString, +- ParseBaseException) ++ stringEnd, pythonStyleComment, ++ ParseBaseException, __diag__) + except ImportError: + print('pyparsing is not available') + sys.exit(77) +@@ -52,33 +50,61 @@ except ImportError: + # don't do caching on old python + lru_cache = lambda: (lambda f: f) + ++__diag__.warn_multiple_tokens_in_named_alternation = True ++__diag__.warn_ungrouped_named_tokens_in_collection = True ++__diag__.warn_name_set_on_empty_Forward = True ++__diag__.warn_on_multiple_string_args_to_oneof = True ++__diag__.enable_debug_on_named_expressions = True ++ + EOL = LineEnd().suppress() + EMPTYLINE = LineEnd() + COMMENTLINE = pythonStyleComment + EOL + INTEGER = Word(nums) +-STRING = QuotedString('"') + REAL = Combine((INTEGER + Optional('.' + Optional(INTEGER))) ^ ('.' + INTEGER)) + SIGNED_REAL = Combine(Optional(Word('-+')) + REAL) + UDEV_TAG = Word(string.ascii_uppercase, alphanums + '_') + ++# Those patterns are used in type-specific matches + TYPES = {'mouse': ('usb', 'bluetooth', 'ps2', '*'), + 'evdev': ('name', 'atkbd', 'input'), ++ 'fb': ('pci'), + 'id-input': ('modalias'), + 'touchpad': ('i8042', 'rmi', 'bluetooth', 'usb'), + 'joystick': ('i8042', 'rmi', 'bluetooth', 'usb'), + 'keyboard': ('name', ), + 'sensor': ('modalias', ), ++ 'ieee1394-unit-function' : ('node', ), ++ 'camera': ('usb'), + } + ++# Patterns that are used to set general properties on a device ++GENERAL_MATCHES = {'acpi', ++ 'bluetooth', ++ 'usb', ++ 'pci', ++ 'sdio', ++ 'vmbus', ++ 'OUI', ++ 'ieee1394', ++ } ++ ++def upperhex_word(length): ++ return Word(nums + 'ABCDEF', exact=length) ++ + @lru_cache() + def hwdb_grammar(): + ParserElement.setDefaultWhitespaceChars('') + + prefix = Or(category + ':' + Or(conn) + ':' + for category, conn in TYPES.items()) +- matchline = Combine(prefix + Word(printables + ' ' + '®')) + EOL ++ ++ matchline_typed = Combine(prefix + Word(printables + ' ' + '®')) ++ matchline_general = Combine(Or(GENERAL_MATCHES) + ':' + Word(printables + ' ' + '®')) ++ matchline = (matchline_typed | matchline_general) + EOL ++ + propertyline = (White(' ', exact=1).suppress() + +- Combine(UDEV_TAG - '=' - Word(alphanums + '_=:@*.!-;, "') - Optional(pythonStyleComment)) + ++ Combine(UDEV_TAG - '=' - Optional(Word(alphanums + '_=:@*.!-;, "/')) ++ - Optional(pythonStyleComment)) + + EOL) + propertycomment = White(' ', exact=1) + pythonStyleComment + EOL + +@@ -87,7 +113,7 @@ def hwdb_grammar(): + (EMPTYLINE ^ stringEnd()).suppress()) + commentgroup = OneOrMore(COMMENTLINE).suppress() - EMPTYLINE.suppress() + +- grammar = OneOrMore(group('GROUPS*') ^ commentgroup) + stringEnd() ++ grammar = OneOrMore(Group(group)('GROUPS*') ^ commentgroup) + stringEnd() + + return grammar + +@@ -95,39 +121,57 @@ def hwdb_grammar(): + def property_grammar(): + ParserElement.setDefaultWhitespaceChars(' ') + +- dpi_setting = (Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ'))('SETTINGS*') ++ dpi_setting = Group(Optional('*')('DEFAULT') + INTEGER('DPI') + Optional(Suppress('@') + INTEGER('HZ')))('SETTINGS*') + mount_matrix_row = SIGNED_REAL + ',' + SIGNED_REAL + ',' + SIGNED_REAL +- mount_matrix = (mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX') ++ mount_matrix = Group(mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX') ++ xkb_setting = Optional(Word(alphanums + '+-/@._')) ++ ++ # Although this set doesn't cover all of characters in database entries, it's enough for test targets. ++ name_literal = Word(printables + ' ') + + props = (('MOUSE_DPI', Group(OneOrMore(dpi_setting))), + ('MOUSE_WHEEL_CLICK_ANGLE', INTEGER), + ('MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL', INTEGER), + ('MOUSE_WHEEL_CLICK_COUNT', INTEGER), + ('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', INTEGER), +- ('ID_INPUT', Literal('1')), +- ('ID_INPUT_ACCELEROMETER', Literal('1')), +- ('ID_INPUT_JOYSTICK', Literal('1')), +- ('ID_INPUT_KEY', Literal('1')), +- ('ID_INPUT_KEYBOARD', Literal('1')), +- ('ID_INPUT_MOUSE', Literal('1')), +- ('ID_INPUT_POINTINGSTICK', Literal('1')), +- ('ID_INPUT_SWITCH', Literal('1')), +- ('ID_INPUT_TABLET', Literal('1')), +- ('ID_INPUT_TABLET_PAD', Literal('1')), +- ('ID_INPUT_TOUCHPAD', Literal('1')), +- ('ID_INPUT_TOUCHSCREEN', Literal('1')), +- ('ID_INPUT_TRACKBALL', Literal('1')), +- ('MOUSE_WHEEL_TILT_HORIZONTAL', Literal('1')), +- ('MOUSE_WHEEL_TILT_VERTICAL', Literal('1')), ++ ('ID_AUTOSUSPEND', Or((Literal('0'), Literal('1')))), ++ ('ID_AV_PRODUCTION_CONTROLLER', Or((Literal('0'), Literal('1')))), ++ ('ID_PERSIST', Or((Literal('0'), Literal('1')))), ++ ('ID_PDA', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_ACCELEROMETER', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_JOYSTICK', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_KEY', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_KEYBOARD', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_MOUSE', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_POINTINGSTICK', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_SWITCH', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_TABLET', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_TABLET_PAD', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_TOUCHPAD', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_TOUCHSCREEN', Or((Literal('0'), Literal('1')))), ++ ('ID_INPUT_TRACKBALL', Or((Literal('0'), Literal('1')))), ++ ('ID_SIGNAL_ANALYZER', Or((Literal('0'), Literal('1')))), + ('POINTINGSTICK_SENSITIVITY', INTEGER), + ('POINTINGSTICK_CONST_ACCEL', REAL), + ('ID_INPUT_JOYSTICK_INTEGRATION', Or(('internal', 'external'))), + ('ID_INPUT_TOUCHPAD_INTEGRATION', Or(('internal', 'external'))), +- ('XKB_FIXED_LAYOUT', STRING), +- ('XKB_FIXED_VARIANT', STRING), ++ ('XKB_FIXED_LAYOUT', xkb_setting), ++ ('XKB_FIXED_VARIANT', xkb_setting), ++ ('XKB_FIXED_MODEL', xkb_setting), + ('KEYBOARD_LED_NUMLOCK', Literal('0')), + ('KEYBOARD_LED_CAPSLOCK', Literal('0')), + ('ACCEL_MOUNT_MATRIX', mount_matrix), ++ ('ACCEL_LOCATION', Or(('display', 'base'))), ++ ('PROXIMITY_NEAR_LEVEL', INTEGER), ++ ('IEEE1394_UNIT_FUNCTION_MIDI', Or((Literal('0'), Literal('1')))), ++ ('IEEE1394_UNIT_FUNCTION_AUDIO', Or((Literal('0'), Literal('1')))), ++ ('IEEE1394_UNIT_FUNCTION_VIDEO', Or((Literal('0'), Literal('1')))), ++ ('ID_VENDOR_FROM_DATABASE', name_literal), ++ ('ID_MODEL_FROM_DATABASE', name_literal), ++ ('ID_TAG_MASTER_OF_SEAT', Literal('1')), ++ ('ID_INFRARED_CAMERA', Or((Literal('0'), Literal('1')))), ++ ('ID_CAMERA_DIRECTION', Or(('front', 'rear'))), + ) + fixed_props = [Literal(name)('NAME') - Suppress('=') - val('VALUE') + for name, val in props] +@@ -165,8 +209,29 @@ def parse(fname): + return [] + return [convert_properties(g) for g in parsed.GROUPS] + +-def check_match_uniqueness(groups): ++def check_matches(groups): + matches = sum((group[0] for group in groups), []) ++ ++ # This is a partial check. The other cases could be also done, but those ++ # two are most commonly wrong. ++ grammars = { 'usb' : 'v' + upperhex_word(4) + Optional('p' + upperhex_word(4) + Optional(':')) + '*', ++ 'pci' : 'v' + upperhex_word(8) + Optional('d' + upperhex_word(8) + Optional(':')) + '*', ++ } ++ ++ for match in matches: ++ prefix, rest = match.split(':', maxsplit=1) ++ gr = grammars.get(prefix) ++ if gr: ++ # we check this first to provide an easy error message ++ if rest[-1] not in '*:': ++ error('pattern {} does not end with "*" or ":"', match) ++ ++ try: ++ gr.parseString(rest) ++ except ParseBaseException as e: ++ error('Pattern {!r} is invalid: {}', rest, e) ++ continue ++ + matches.sort() + prev = None + for match in matches: +@@ -196,15 +261,25 @@ def check_one_mount_matrix(prop, value): + def check_one_keycode(prop, value): + if value != '!' and ecodes is not None: + key = 'KEY_' + value.upper() +- if key not in ecodes: +- key = value.upper() +- if key not in ecodes: +- error('Keycode {} unknown', key) ++ if not (key in ecodes or ++ value.upper() in ecodes or ++ # new keys added in kernel 5.5 ++ 'KBD_LCD_MENU' in key): ++ error('Keycode {} unknown', key) ++ ++def check_wheel_clicks(properties): ++ pairs = (('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', 'MOUSE_WHEEL_CLICK_COUNT'), ++ ('MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL', 'MOUSE_WHEEL_CLICK_ANGLE'), ++ ('MOUSE_WHEEL_CLICK_COUNT_HORIZONTAL', 'MOUSE_WHEEL_CLICK_ANGLE_HORIZONTAL'), ++ ('MOUSE_WHEEL_CLICK_COUNT', 'MOUSE_WHEEL_CLICK_ANGLE')) ++ for pair in pairs: ++ if pair[0] in properties and pair[1] not in properties: ++ error('{} requires {} to be specified', *pair) + + def check_properties(groups): + grammar = property_grammar() + for matches, props in groups: +- prop_names = set() ++ seen_props = {} + for prop in props: + # print('--', prop) + prop = prop.partition('#')[0].rstrip() +@@ -214,30 +289,35 @@ def check_properties(groups): + error('Failed to parse: {!r}', prop) + continue + # print('{!r}'.format(parsed)) +- if parsed.NAME in prop_names: ++ if parsed.NAME in seen_props: + error('Property {} is duplicated', parsed.NAME) +- prop_names.add(parsed.NAME) ++ seen_props[parsed.NAME] = parsed.VALUE + if parsed.NAME == 'MOUSE_DPI': + check_one_default(prop, parsed.VALUE.SETTINGS) + elif parsed.NAME == 'ACCEL_MOUNT_MATRIX': + check_one_mount_matrix(prop, parsed.VALUE) + elif parsed.NAME.startswith('KEYBOARD_KEY_'): +- check_one_keycode(prop, parsed.VALUE) ++ val = parsed.VALUE if isinstance(parsed.VALUE, str) else parsed.VALUE[0] ++ check_one_keycode(prop, val) ++ ++ check_wheel_clicks(seen_props) + + def print_summary(fname, groups): ++ n_matches = sum(len(matches) for matches, props in groups) ++ n_props = sum(len(props) for matches, props in groups) + print('{}: {} match groups, {} matches, {} properties' +- .format(fname, +- len(groups), +- sum(len(matches) for matches, props in groups), +- sum(len(props) for matches, props in groups))) ++ .format(fname, len(groups), n_matches, n_props)) ++ ++ if n_matches == 0 or n_props == 0: ++ error('{}: no matches or props'.format(fname)) + + if __name__ == '__main__': +- args = sys.argv[1:] or glob.glob(os.path.dirname(sys.argv[0]) + '/[67]0-*.hwdb') ++ args = sys.argv[1:] or sorted(glob.glob(os.path.dirname(sys.argv[0]) + '/[678][0-9]-*.hwdb')) + + for fname in args: + groups = parse(fname) + print_summary(fname, groups) +- check_match_uniqueness(groups) ++ check_matches(groups) + check_properties(groups) + + sys.exit(ERROR) diff --git a/20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch b/20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch new file mode 100644 index 0000000..7d81489 --- /dev/null +++ b/20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch @@ -0,0 +1,26 @@ +From 62f8dac80e5f908f83b6e7cd06629055184c25d7 Mon Sep 17 00:00:00 2001 +From: Forrestly +Date: Thu, 23 Mar 2023 10:08:33 +0800 +Subject: [PATCH] cgroup: do not refresh cgroup devices config when + daemon-reload(#42937798) + +Signed-off-by: Forrestly +--- + src/core/cgroup.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 50d2738..ea92aa6 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -1920,6 +1920,7 @@ static int unit_realize_cgroup_now(Unit *u, ManagerState state) { + enable_mask = unit_get_enable_mask(u); + needs_bpf = unit_get_needs_bpf(u); + ++ target_mask &= ~CGROUP_MASK_DEVICES; + if (unit_has_mask_realized(u, target_mask, enable_mask, needs_bpf)) + return 0; + +-- +2.34.1 + diff --git a/20003-core-introduce-cgroup-full-delegation-for-compabilit.patch b/20003-core-introduce-cgroup-full-delegation-for-compabilit.patch new file mode 100644 index 0000000..21c5557 --- /dev/null +++ b/20003-core-introduce-cgroup-full-delegation-for-compabilit.patch @@ -0,0 +1,133 @@ +From f25124fabe1ed973840291d46549af6e1c5fad56 Mon Sep 17 00:00:00 2001 +From: "zhongling.h" +Date: Fri, 4 Aug 2023 10:08:16 +0800 +Subject: [PATCH] core: introduce cgroup full delegation for compability + +While using systemd-219, users can set 'delegate=y' to claim the +possession of cgroup settings. By then, users are able to write raw +values under /sys/fs/cgroup to adjust cgroup settings and systemd +won't touch these values any longer. + +However, this is likely to be an undefined behaviour for systemd-219. +Upon releasing systemd-239, a documentation of cgroup delegation was +added, +https://github.com/systemd/systemd/commit/e30eaff3a32523b09d61af67fc999f1f62f4e0cb. +It states that: + +Only sub-trees can be delegated (though whoever decides to request a +sub-tree can delegate sub-sub-trees further to somebody else if they +like it).' + +Which is quite different from what people understand the delegation of +systemd-219. Currently, whether a unit is delegated or not, systemd always +possesses any cgroup it created, only ignoring the sub-tree ones +according to delegation settings. + +This behaviour change causes confusion if users switch from systemd-219 to +systemd-239. As a result, we introduce 'FullDelegation', a feature that +brings what users are already familiar with to systemd-239. If users set +'FullDelegation=yes' in /etc/systemd/system.conf, they can control raw +values under /sys/fs/cgroup without worrying systemd touching these +values, which is the same as what they expected with systemd-219. + +--- + src/core/cgroup.c | 16 ++++++++++++++++ + src/core/main.c | 4 ++++ + src/core/manager.h | 1 + + src/core/system.conf.in | 1 + + 4 files changed, 22 insertions(+) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index ea92aa6f7b..17e3b90e37 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -1692,6 +1692,15 @@ static int unit_create_cgroup( + /* Keep track that this is now realized */ + u->cgroup_realized = true; + u->cgroup_realized_mask = target_mask; ++ ++ // While realizing cgroup, we don't realize delegated cgroup, therefore, target_mask ++ // doesn't contain delegated cgroup controller bit, and u->cgroup_realized_mask will ++ // not contain delegated cgroup controller bit as well. This unit will be in a state ++ // as if delegated cgroup is not set, which is not expected. ++ // If this is not present, delegated cgroup will be set every 2 systemctl daemon-reload ++ if (u->manager->full_delegation && unit_cgroup_delegate(u)) ++ u->cgroup_realized_mask |= unit_get_delegate_mask(u); ++ + u->cgroup_enabled_mask = enable_mask; + u->cgroup_bpf_state = needs_bpf ? UNIT_CGROUP_BPF_ON : UNIT_CGROUP_BPF_OFF; + +@@ -1921,6 +1930,10 @@ static int unit_realize_cgroup_now(Unit *u, ManagerState state) { + needs_bpf = unit_get_needs_bpf(u); + + target_mask &= ~CGROUP_MASK_DEVICES; ++ ++ if (u->manager->full_delegation && unit_cgroup_delegate(u)) ++ target_mask ^= u->cgroup_realized_mask; ++ + if (unit_has_mask_realized(u, target_mask, enable_mask, needs_bpf)) + return 0; + +@@ -2883,6 +2896,9 @@ int unit_reset_ip_accounting(Unit *u) { + void unit_invalidate_cgroup(Unit *u, CGroupMask m) { + assert(u); + ++ if (u->manager->full_delegation) ++ m ^= unit_get_delegate_mask(u); // don't invalidate delegated cgroup ++ + if (!UNIT_HAS_CGROUP_CONTEXT(u)) + return; + +diff --git a/src/core/main.c b/src/core/main.c +index 546bf0d870..68daf07077 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -142,6 +142,7 @@ static bool reexec_jmp_can = false; + static bool reexec_jmp_inited = false; + static sigjmp_buf reexec_jmp_buf; + static bool arg_default_cpuset_clone_children = false; ++static bool arg_full_delegation = false; + + static int parse_configuration(const struct rlimit *saved_rlimit_nofile, + const struct rlimit *saved_rlimit_memlock); +@@ -768,6 +769,8 @@ static int parse_config_file(void) { + { "Manager", "DefaultTasksMax", config_parse_tasks_max, 0, &arg_default_tasks_max }, + { "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, 0, &arg_cad_burst_action }, + { "Manager", "DefaultCPUSetCloneChildren",config_parse_bool, 0, &arg_default_cpuset_clone_children }, ++ { "Manager", "FullDelegation", config_parse_bool, 0, &arg_full_delegation }, ++ + {} + }; + +@@ -817,6 +820,7 @@ static void set_manager_defaults(Manager *m) { + m->default_memory_accounting = arg_default_memory_accounting; + m->default_tasks_accounting = arg_default_tasks_accounting; + m->default_tasks_max = arg_default_tasks_max; ++ m->full_delegation = arg_full_delegation; + + manager_set_default_rlimits(m, arg_default_rlimit); + manager_environment_add(m, NULL, arg_default_environment); +diff --git a/src/core/manager.h b/src/core/manager.h +index 98d381bc5b..91f2c05afe 100644 +--- a/src/core/manager.h ++++ b/src/core/manager.h +@@ -297,6 +297,7 @@ struct Manager { + bool default_blockio_accounting; + bool default_tasks_accounting; + bool default_ip_accounting; ++ bool full_delegation; + + uint64_t default_tasks_max; + usec_t default_timer_accuracy_usec; +diff --git a/src/core/system.conf.in b/src/core/system.conf.in +index 2f6852a89f..6c84a55401 100644 +--- a/src/core/system.conf.in ++++ b/src/core/system.conf.in +@@ -67,3 +67,4 @@ DefaultLimitCORE=0:infinity + #DefaultLimitRTTIME= + #IPAddressAllow= + #IPAddressDeny= ++#FullDelegation=no +-- +2.39.3 + diff --git a/systemd.spec b/systemd.spec index 842b45e..b78f299 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1092,6 +1092,10 @@ Patch10024: 10024-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch Patch10025: 10025-fileio-teach-read_full_file_full-to-read-from-offse.patch Patch10026: 10026-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch +Patch20001: 20001-hwdb-parse_hwdb_dot_py.patch +Patch20002: 20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch +Patch20003: 20003-core-introduce-cgroup-full-delegation-for-compabilit.patch + %ifarch %{ix86} x86_64 aarch64 %global have_gnu_efi 1 %endif @@ -1750,6 +1754,9 @@ fi - fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name (Guorui Yu) - fileio: teach read_full_file_full() to read from offset/with maximum size (Guorui Yu) - cryptsetup: port cryptsetup's main key file logic over to read_full_file_full() (Guorui Yu) +- Update upstream parse_hwdb.py to fix parse-hwdb error (Zhongling He) +- cgroup: do not refresh cgroup devices config when daemon-reload (Zhongling He) +- core: introduce cgroup full delegation for compability (Zhongling He) * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee From 692e889e67afea40b881162b03330e5cf853d7ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=A0=E5=87=8C?= Date: Tue, 12 Dec 2023 17:15:44 +0800 Subject: [PATCH 10/17] add README.md to especially address patch indexing convention --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..7d30ca3 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# systemd-239 + +This is the repository of systemd-239 for Anolis OS 8. + +## Patch index convention + +Below is the patch index convention of this repository: + +- 0001 ... 0xxx : patches from upstream srpm +- 10001 ... 10xxx : patches cherry-picked from systemd github upstream +- 20001 ... 20xxx : original patch by OpenAnolis community \ No newline at end of file -- Gitee From f3392ac085ddd9d6d6e506db98b2518082776ace Mon Sep 17 00:00:00 2001 From: wangkaiyuan Date: Wed, 31 Jan 2024 19:37:11 +0800 Subject: [PATCH 11/17] Update vendor ids for ieisystem 0750 --- ...Update-vendor-ids-for-ieisystem-0750.patch | 27 +++++++++++++++++++ systemd.spec | 2 ++ 2 files changed, 29 insertions(+) create mode 100644 20004-Update-vendor-ids-for-ieisystem-0750.patch diff --git a/20004-Update-vendor-ids-for-ieisystem-0750.patch b/20004-Update-vendor-ids-for-ieisystem-0750.patch new file mode 100644 index 0000000..ca0b4c2 --- /dev/null +++ b/20004-Update-vendor-ids-for-ieisystem-0750.patch @@ -0,0 +1,27 @@ +From 2afcc209fb4677581294421f20bb0d057238539e Mon Sep 17 00:00:00 2001 +From: wangkaiyuan +Date: Wed, 31 Jan 2024 19:30:33 +0800 +Subject: [PATCH] Update vendor ids for ieisystem 0750 + +Signed-off-by: wangkaiyuan +--- + hwdb/20-pci-vendor-model.hwdb | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/hwdb/20-pci-vendor-model.hwdb b/hwdb/20-pci-vendor-model.hwdb +index cdbd8ff..4b666e8 100644 +--- a/hwdb/20-pci-vendor-model.hwdb ++++ b/hwdb/20-pci-vendor-model.hwdb +@@ -69122,6 +69122,9 @@ pci:v00001BD0d00001203* + pci:v00001BD4* + ID_VENDOR_FROM_DATABASE=Inspur Electronic Information Industry Co., Ltd. + ++pci:v00001BD4d00000750* ++ ID_MODEL_FROM_DATABASE=YHGCH ZX1000 ++ + pci:v00001BD4d00000911* + ID_MODEL_FROM_DATABASE=Arria10_PCIe_F10A1150 + +-- +2.31.1 + diff --git a/systemd.spec b/systemd.spec index b78f299..5215ec9 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1095,6 +1095,7 @@ Patch10026: 10026-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch Patch20001: 20001-hwdb-parse_hwdb_dot_py.patch Patch20002: 20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch Patch20003: 20003-core-introduce-cgroup-full-delegation-for-compabilit.patch +Patch20004: 20004-Update-vendor-ids-for-ieisystem-0750.patch %ifarch %{ix86} x86_64 aarch64 %global have_gnu_efi 1 @@ -1757,6 +1758,7 @@ fi - Update upstream parse_hwdb.py to fix parse-hwdb error (Zhongling He) - cgroup: do not refresh cgroup devices config when daemon-reload (Zhongling He) - core: introduce cgroup full delegation for compability (Zhongling He) +- Update vendor ids for ieisystem 0750 (wangkaiyuan@inspur.com) * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee From f2a05caf9438bf4e6db0636f4abc49a41fa7e01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=A0=E5=87=8C?= Date: Tue, 19 Mar 2024 11:49:45 +0800 Subject: [PATCH 12/17] update lifsea patch numbering convention --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d30ca3..b91be56 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,6 @@ Below is the patch index convention of this repository: - 0001 ... 0xxx : patches from upstream srpm - 10001 ... 10xxx : patches cherry-picked from systemd github upstream -- 20001 ... 20xxx : original patch by OpenAnolis community \ No newline at end of file +- 20001 ... 20xxx : original patch by OpenAnolis community +- 910001 ... 910xxx : LifseaOS patches that cherry-picked from systemd github upstream +- 920001 ... 920xxx : LifseaOS original patches -- Gitee From c8e94388b80d69b7493d84ea18f41f34232344b1 Mon Sep 17 00:00:00 2001 From: yuanhui Date: Thu, 29 Feb 2024 16:55:29 +0800 Subject: [PATCH 13/17] Merge LifseaOS modification to anolis8 Signed-off-by: yuanhui --- 10027-fix-compilation-without-utmp.patch | 24 +++ ...ormation-from-hostnamed-in-plot-even.patch | 101 ++++++++++ ...nd-a-requirement-of-user-runtime-dir.patch | 44 +++++ ...pendency-of-libcryptsetup-if-HAVE_LI.patch | 40 ++++ ...group-path-which-not-created-by-syst.patch | 31 ++++ systemd.spec | 172 +++++++++++++++--- 6 files changed, 386 insertions(+), 26 deletions(-) create mode 100644 10027-fix-compilation-without-utmp.patch create mode 100644 91000-analyze-show-information-from-hostnamed-in-plot-even.patch create mode 100644 92000-meson-Make-logind-a-requirement-of-user-runtime-dir.patch create mode 100644 92001-shared-Remove-dependency-of-libcryptsetup-if-HAVE_LI.patch create mode 100644 92002-Do-not-remove-cgroup-path-which-not-created-by-syst.patch diff --git a/10027-fix-compilation-without-utmp.patch b/10027-fix-compilation-without-utmp.patch new file mode 100644 index 0000000..4526be3 --- /dev/null +++ b/10027-fix-compilation-without-utmp.patch @@ -0,0 +1,24 @@ +From 813c9418ca8f6eabd179feace3f115b874e6a1a6 Mon Sep 17 00:00:00 2001 +From: Steven Allen +Date: Wed, 7 Nov 2018 07:44:36 -0800 +Subject: [PATCH] fix compilation without utmp + +--- + src/login/logind-core.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/login/logind-core.c b/src/login/logind-core.c +index abe6eec..519abf5 100644 +--- a/src/login/logind-core.c ++++ b/src/login/logind-core.c +@@ -779,7 +779,7 @@ int manager_read_utmp(Manager *m) { + endutxent(); + return r; + #else +- return 0 ++ return 0; + #endif + } + +-- +2.39.3 diff --git a/91000-analyze-show-information-from-hostnamed-in-plot-even.patch b/91000-analyze-show-information-from-hostnamed-in-plot-even.patch new file mode 100644 index 0000000..272abec --- /dev/null +++ b/91000-analyze-show-information-from-hostnamed-in-plot-even.patch @@ -0,0 +1,101 @@ +From af0841e9fc99fbab958a53fc43424ada6b9a19ad Mon Sep 17 00:00:00 2001 +From: Yu Watanabe +Date: Sun, 22 Jul 2018 14:33:31 +0900 +Subject: [PATCH] analyze: show information from hostnamed in plot even when + user mode + +(cherry-picked from upstream 4f481d76fcbb72fc91789a464cd2b75f0bd47e20) + +This will resolve the following issue after systemd-hostnamed is +disabled: + +``` +[root@localhost ~]# systemd-analyze plot +Failed to get host information from systemd: The name org.freedesktop.hostname1 was not provided by any .service files +``` + +Signed-off-by: Yuanhong Peng +--- + src/analyze/analyze.c | 28 ++++++++++++++++++++-------- + 1 file changed, 20 insertions(+), 8 deletions(-) + +diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c +index c30a133..1ae096d 100644 +--- a/src/analyze/analyze.c ++++ b/src/analyze/analyze.c +@@ -448,6 +448,7 @@ static int acquire_host_info(sd_bus *bus, struct host_info **hi) { + }; + + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; ++ _cleanup_(sd_bus_flush_close_unrefp) sd_bus *system_bus = NULL; + _cleanup_(free_host_infop) struct host_info *host; + int r; + +@@ -455,7 +456,15 @@ static int acquire_host_info(sd_bus *bus, struct host_info **hi) { + if (!host) + return log_oom(); + +- r = bus_map_all_properties(bus, ++ if (arg_scope != UNIT_FILE_SYSTEM) { ++ r = bus_connect_transport(arg_transport, arg_host, false, &system_bus); ++ if (r < 0) { ++ log_debug_errno(r, "Failed to connect to system bus, ignoring: %m"); ++ goto manager; ++ } ++ } ++ ++ r = bus_map_all_properties(system_bus ?: bus, + "org.freedesktop.hostname1", + "/org/freedesktop/hostname1", + hostname_map, +@@ -463,9 +472,12 @@ static int acquire_host_info(sd_bus *bus, struct host_info **hi) { + &error, + NULL, + host); +- if (r < 0) +- log_debug_errno(r, "Failed to get host information from systemd-hostnamed: %s", bus_error_message(&error, r)); ++ if (r < 0) { ++ log_debug_errno(r, "Failed to get host information from systemd-hostnamed, ignoring: %s", bus_error_message(&error, r)); ++ sd_bus_error_free(&error); ++ } + ++manager: + r = bus_map_all_properties(bus, + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", +@@ -584,12 +596,12 @@ static int analyze_plot(int argc, char *argv[], void *userdata) { + _cleanup_(free_host_infop) struct host_info *host = NULL; + _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; + _cleanup_(unit_times_freep) struct unit_times *times = NULL; ++ _cleanup_free_ char *pretty_times = NULL; ++ bool use_full_bus = arg_scope == UNIT_FILE_SYSTEM; + struct boot_times *boot; ++ struct unit_times *u; + int n, m = 1, y = 0, r; +- bool use_full_bus = true; + double width; +- _cleanup_free_ char *pretty_times = NULL; +- struct unit_times *u; + + r = acquire_bus(&bus, &use_full_bus); + if (r < 0) +@@ -603,7 +615,7 @@ static int analyze_plot(int argc, char *argv[], void *userdata) { + if (n < 0) + return n; + +- if (use_full_bus) { ++ if (use_full_bus || arg_scope != UNIT_FILE_SYSTEM) { + n = acquire_host_info(bus, &host); + if (n < 0) + return n; +@@ -705,7 +717,7 @@ static int analyze_plot(int argc, char *argv[], void *userdata) { + + svg("\n"); + svg("%s", pretty_times); +- if (use_full_bus) ++ if (host) + svg("%s %s (%s %s %s) %s %s", + isempty(host->os_pretty_name) ? "Linux" : host->os_pretty_name, + strempty(host->hostname), +-- +2.18.1 \ No newline at end of file diff --git a/92000-meson-Make-logind-a-requirement-of-user-runtime-dir.patch b/92000-meson-Make-logind-a-requirement-of-user-runtime-dir.patch new file mode 100644 index 0000000..16bea35 --- /dev/null +++ b/92000-meson-Make-logind-a-requirement-of-user-runtime-dir.patch @@ -0,0 +1,44 @@ +From b7da107bc80d65ebf6a1e6838f780f756f2fb25c Mon Sep 17 00:00:00 2001 +From: Yuanhong Peng +Date: Fri, 26 Feb 2021 19:20:48 +0800 +Subject: [PATCH] meson: Make logind a requirement of user-runtime-dir + +Partly cherry-picked from upstream 07ee5adb. Since we don't +enable logind in LifseaOS, this is the simplest way to cut +off the user-runtime-dir binary and service file. + +Signed-off-by: Yuanhong Peng +--- + meson.build | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/meson.build b/meson.build +index cf6990a..fd47e75 100644 +--- a/meson.build ++++ b/meson.build +@@ -1735,15 +1735,15 @@ if conf.get('ENABLE_LOGIND') == 1 + test_dlopen, + args : [pam_systemd.full_path()]) # path to dlopen must include a slash + endif +-endif + +-executable('systemd-user-runtime-dir', +- user_runtime_dir_sources, +- include_directories : includes, +- link_with : [libshared, liblogind_core], +- install_rpath : rootlibexecdir, +- install : true, +- install_dir : rootlibexecdir) ++ executable('systemd-user-runtime-dir', ++ user_runtime_dir_sources, ++ include_directories : includes, ++ link_with : [libshared, liblogind_core], ++ install_rpath : rootlibexecdir, ++ install : true, ++ install_dir : rootlibexecdir) ++endif + + if conf.get('HAVE_PAM') == 1 + executable('systemd-user-sessions', +-- +2.18.1 \ No newline at end of file diff --git a/92001-shared-Remove-dependency-of-libcryptsetup-if-HAVE_LI.patch b/92001-shared-Remove-dependency-of-libcryptsetup-if-HAVE_LI.patch new file mode 100644 index 0000000..433c611 --- /dev/null +++ b/92001-shared-Remove-dependency-of-libcryptsetup-if-HAVE_LI.patch @@ -0,0 +1,40 @@ +From afaeb794b5ecf2772765f4a92e92f9be831ef1ea Mon Sep 17 00:00:00 2001 +From: Yuanhong Peng +Date: Fri, 26 Mar 2021 10:37:15 +0800 +Subject: [PATCH] shared: Remove dependency of libcryptsetup if + HAVE_LIBCRYPTSETUP is not defined + +We do not enable libcryptsetup in configuration, so this dependency is +fake. Remove dependency of libcryptsetup will reduce more than ten +dependencies of libsystemd-shared-239.so. + +Signed-off-by: Yuanhong Peng +--- + src/shared/meson.build | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/src/shared/meson.build b/src/shared/meson.build +index d0a1bba..e492ce9 100644 +--- a/src/shared/meson.build ++++ b/src/shared/meson.build +@@ -131,7 +131,6 @@ libshared_deps = [threads, + librt, + libcap, + libacl, +- libcryptsetup, + libgcrypt, + libiptc, + libseccomp, +@@ -141,6 +140,10 @@ libshared_deps = [threads, + liblz4, + libblkid] + ++if conf.get('HAVE_LIBCRYPTSETUP') == 1 ++ libshared_deps += [libcryptsetup] ++endif ++ + libshared_sym_path = '@0@/libshared.sym'.format(meson.current_source_dir()) + + libshared_static = static_library( +-- +2.18.1 \ No newline at end of file diff --git a/92002-Do-not-remove-cgroup-path-which-not-created-by-syst.patch b/92002-Do-not-remove-cgroup-path-which-not-created-by-syst.patch new file mode 100644 index 0000000..aec1813 --- /dev/null +++ b/92002-Do-not-remove-cgroup-path-which-not-created-by-syst.patch @@ -0,0 +1,31 @@ +From 327dab8117c7b478a928387b4384ae7815ad4f06 Mon Sep 17 00:00:00 2001 +From: Yuanhong Peng +Date: Wed, 22 Nov 2023 17:03:33 +0800 +Subject: [PATCH] Do not remove cgroup path which not created by systemd + +It's a workaround for #52520469 + +Details in https://issues.redhat.com/browse/RHEL-16781 + +Signed-off-by: Yuanhong Peng +--- + src/basic/cgroup-util.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c +index 14abe6e..5c87a7a 100644 +--- a/src/basic/cgroup-util.c ++++ b/src/basic/cgroup-util.c +@@ -719,6 +719,10 @@ static int trim_cb(const char *path, const struct stat *sb, int typeflag, struct + if (ftwbuf->level < 1) + return 0; + ++ // workaround: do not remove cgroup path which not created by systemd ++ if (!strstr(path, ".slice/") && !strstr(path, ".service/")) ++ return 0; ++ + (void) rmdir(path); + return 0; + } +-- +2.39.3 \ No newline at end of file diff --git a/systemd.spec b/systemd.spec index 5215ec9..13a1662 100644 --- a/systemd.spec +++ b/systemd.spec @@ -14,7 +14,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd Version: 239 -Release: 82%{anolis_release}%{?dist}.1 +Release: 82%{anolis_release}%{?dist}%{?lifsea_dist}.1 # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: System and Service Manager @@ -41,7 +41,9 @@ Source8: systemd-journal-gatewayd.xml Source9: 20-yama-ptrace.conf Source10: systemd-udev-trigger-no-reload.conf Source11: 20-grubby.install +%if ! %{defined lifsea_dist} Source12: systemd-user +%endif Source13: rc.local %if 0 @@ -1091,12 +1093,21 @@ Patch10023: 10023-fileio-add-support-for-read_full_file-on-AF_UNIX-st.patch Patch10024: 10024-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch Patch10025: 10025-fileio-teach-read_full_file_full-to-read-from-offse.patch Patch10026: 10026-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch +Patch10027: 10027-fix-compilation-without-utmp.patch Patch20001: 20001-hwdb-parse_hwdb_dot_py.patch Patch20002: 20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch Patch20003: 20003-core-introduce-cgroup-full-delegation-for-compabilit.patch Patch20004: 20004-Update-vendor-ids-for-ieisystem-0750.patch +# lifsea only patch +%if %{defined lifsea_dist} +Patch91000: 91000-analyze-show-information-from-hostnamed-in-plot-even.patch +Patch92000: 92000-meson-Make-logind-a-requirement-of-user-runtime-dir.patch +Patch92001: 92001-shared-Remove-dependency-of-libcryptsetup-if-HAVE_LI.patch +Patch92002: 92002-Do-not-remove-cgroup-path-which-not-created-by-syst.patch +%endif + %ifarch %{ix86} x86_64 aarch64 %global have_gnu_efi 1 %endif @@ -1105,7 +1116,8 @@ BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: libcap-devel BuildRequires: libmount-devel -BuildRequires: pam-devel +%{!?lifsea_dist:BuildRequires: pam-devel} +%{?lifsea_dist:BuildRequires: acl} BuildRequires: libselinux-devel BuildRequires: audit-libs-devel BuildRequires: cryptsetup-devel @@ -1146,15 +1158,19 @@ BuildRequires: gettext Requires(post): coreutils Requires(post): sed -Requires(post): acl +%{!?lifsea_dist:Requires(post): acl} Requires(post): grep # systemd-machine-id-setup requires libssl Requires(post): openssl-libs Requires(pre): coreutils Requires(pre): /usr/bin/getent Requires(pre): /usr/sbin/groupadd +%if ! %{defined lifsea_dist} Requires: dbus >= 1.9.18 Requires: %{name}-pam = %{version}-%{release} +%else +Recommends: dbus >= 1.9.18 +%endif Requires: %{name}-libs = %{version}-%{release} Recommends: diffutils Requires: util-linux @@ -1198,9 +1214,11 @@ Obsoletes: libudev < 183 Obsoletes: systemd < 185-4 Conflicts: systemd < 185-4 Obsoletes: systemd-compat-libs < 230 +%if ! %{defined lifsea_dist} Obsoletes: nss-myhostname < 0.4 Provides: nss-myhostname = 0.4 Provides: nss-myhostname%{_isa} = 0.4 +%endif Requires(post): coreutils Requires(post): sed Requires(post): grep @@ -1209,12 +1227,14 @@ Requires(post): /usr/bin/getent %description libs Libraries for systemd and udev. +%if ! %{defined lifsea_dist} %package pam Summary: systemd PAM module Requires: %{name} = %{version}-%{release} %description pam Systemd PAM module registers the session with systemd-logind. +%endif %package devel Summary: Development headers for systemd @@ -1223,8 +1243,10 @@ Requires: %{name}-libs%{?_isa} = %{version}-%{release} Provides: libudev-devel = %{version} Provides: libudev-devel%{_isa} = %{version} Obsoletes: libudev-devel < 183 +%if ! %{defined lifsea_dist} # Fake dependency to make sure systemd-pam is pulled into multilib (#1414153) Requires: %{name}-pam = %{version}-%{release} +%endif %description devel Development headers and auxiliary files for developing applications linking @@ -1299,8 +1321,15 @@ License: LGPLv2+ "Installed tests" that are usually run as part of the build system. They can be useful to test systemd internals. +# To avoid users installing the LifseaOS package in other os +%define common_pre_scripts() \ +if ! grep -q 'ID="lifsea"' /etc/os-release; then \ + echo "This package is only for LifseaOS!" \ + exit 1 \ +fi + %prep -%autosetup %{?gitcommit:-n %{name}-%{gitcommit}} -S git_am +%autosetup %{?gitcommit:-n %{name}-%{gitcommit}}%{?lifsea_dist: -n %{name}-%{version}} -S git_am %build %define ntpvendor %(source /etc/os-release; echo ${ID}) @@ -1313,35 +1342,34 @@ CONFIGURE_OPTS=( -Ddns-servers='' -Ddev-kvm-mode=0666 -Dkmod=true - -Dxkbcommon=true + -Dxkbcommon=%{!?lifsea_dist:true}%{?lifsea_dist:false} -Dblkid=true -Dseccomp=true -Dima=true -Dselinux=true -Dapparmor=false - -Dpolkit=true - -Dxz=true - -Dzlib=true - -Dbzip2=true - -Dlz4=true - -Dpam=true + -Dpolkit=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dxz=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dzlib=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dbzip2=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dlz4=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dpam=%{!?lifsea_dist:true}%{?lifsea_dist:false} -Dacl=true - -Dsmack=true + -Dsmack=%{!?lifsea_dist:true}%{?lifsea_dist:false} -Dgcrypt=true - -Daudit=true - -Delfutils=true - -Dlibcryptsetup=true - -Delfutils=true + -Daudit=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Delfutils=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dlibcryptsetup=%{!?lifsea_dist:true}%{?lifsea_dist:false} -Dqrencode=false - -Dgnutls=true - -Dmicrohttpd=true - -Dlibidn2=true + -Dgnutls=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dmicrohttpd=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dlibidn2=%{!?lifsea_dist:true}%{?lifsea_dist:false} -Dlibiptc=false - -Dlibcurl=true - -Defi=true - -Dgnu-efi=%{?have_gnu_efi:true}%{?!have_gnu_efi:false} - -Dtpm=true - -Dhwdb=true + -Dlibcurl=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Defi=%{!?lifsea_dist:true}%{?lifsea_dist:false} + %{!?lifsea_dist:-Dgnu-efi=%{?have_gnu_efi:true}%{?!have_gnu_efi:false}} + -Dtpm=%{!?lifsea_dist:true}%{?lifsea_dist:false} + -Dhwdb=%{!?lifsea_dist:true}%{?lifsea_dist:false} -Dsysusers=true -Ddefault-kill-user-processes=false -Dtests=unsafe @@ -1357,6 +1385,36 @@ CONFIGURE_OPTS=( -Dtimesyncd=false -Ddefault-hierarchy=legacy -Dversion-tag=%{version}-%{release} + %if %{defined lifsea_dist} + # remove many useless tools + -Dtimedated=true + -Dman=false + -Dhtml=false + -Dzshcompletiondir=no + -Dbashcompletiondir=no + -Dlogind=false + -Dcoredump=false + -Dbacklight=false + -Dbinfmt=false + -Dimportd=false + -Dhibernate=false + -Dportabled=false + -Dquotacheck=false + -Drfkill=false + -Dvconsole=false + -Dhostnamed=true + -Dlocaled=false + -Dfirstboot=false + -Denvironment-d=false + -Dutmp=false + -Didn=false + -Dlibidn=false + -Dpcre2=false + -Dgcrypt=false + -Dnss-myhostname=false + -Dnss-resolve=false + -Dnss-systemd=false + %endif ) # Don't ship /var/log/README. The relationship between journal and syslog should be documented @@ -1413,7 +1471,7 @@ mkdir -p %{buildroot}%{pkgdir}/user-generators # Create new-style configuration files so that we can ghost-own them touch %{buildroot}%{_sysconfdir}/hostname touch %{buildroot}%{_sysconfdir}/vconsole.conf -touch %{buildroot}%{_sysconfdir}/locale.conf +%{!?lifsea_dist:touch %{buildroot}%{_sysconfdir}/locale.conf} touch %{buildroot}%{_sysconfdir}/machine-id touch %{buildroot}%{_sysconfdir}/machine-info touch %{buildroot}%{_sysconfdir}/localtime @@ -1428,7 +1486,7 @@ mkdir -p %{buildroot}%{pkgdir}/system-sleep/ mkdir -p %{buildroot}%{_localstatedir}/lib/systemd/coredump mkdir -p %{buildroot}%{_localstatedir}/lib/systemd/catalog mkdir -p %{buildroot}%{_localstatedir}/lib/systemd/backlight -mkdir -p %{buildroot}%{_localstatedir}/lib/systemd/rfkill +%{!?lifsea_dist:mkdir -p %{buildroot}%{_localstatedir}/lib/systemd/rfkill} mkdir -p %{buildroot}%{_localstatedir}/lib/systemd/linger mkdir -p %{buildroot}%{_localstatedir}/lib/private mkdir -p %{buildroot}%{_localstatedir}/log/private @@ -1451,8 +1509,10 @@ install -Dm0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/dnf/protected.d/systemd.co install -Dm0644 -t %{buildroot}/usr/lib/firewalld/services/ %{SOURCE7} %{SOURCE8} +%if ! %{defined lifsea_dist} # Restore systemd-user pam config from before "removal of Fedora-specific bits" install -Dm0644 -t %{buildroot}/etc/pam.d/ %{SOURCE12} +%endif # Install additional docs # https://bugzilla.redhat.com/show_bug.cgi?id=1234951 @@ -1490,7 +1550,9 @@ python3 %{SOURCE2} %buildroot </dev/null || groupadd -r -g 11 cdrom &>/dev/null || : getent group utmp &>/dev/null || groupadd -r -g 22 utmp &>/dev/null || : getent group tape &>/dev/null || groupadd -r -g 33 tape &>/dev/null || : @@ -1530,8 +1614,10 @@ getent group kvm &>/dev/null || groupadd -r -g 36 kvm &>/dev/null || : getent group render &>/dev/null || groupadd -r render &>/dev/null || : getent group systemd-journal &>/dev/null || groupadd -r -g 190 systemd-journal 2>&1 || : +%if ! %{defined lifsea_dist} getent group systemd-coredump &>/dev/null || groupadd -r systemd-coredump 2>&1 || : getent passwd systemd-coredump &>/dev/null || useradd -r -l -g systemd-coredump -d / -s /sbin/nologin -c "systemd Core Dumper" systemd-coredump &>/dev/null || : +%endif getent group systemd-resolve &>/dev/null || groupadd -r -g 193 systemd-resolve 2>&1 || : getent passwd systemd-resolve &>/dev/null || useradd -r -u 193 -l -g systemd-resolve -d / -s /sbin/nologin -c "systemd Resolver" systemd-resolve &>/dev/null || : @@ -1546,8 +1632,10 @@ systemd-tmpfiles --create &>/dev/null || : chgrp systemd-journal /run/log/journal/ /run/log/journal/`cat /etc/machine-id 2>/dev/null` /var/log/journal/ /var/log/journal/`cat /etc/machine-id 2>/dev/null` &>/dev/null || : chmod g+s /run/log/journal/ /run/log/journal/`cat /etc/machine-id 2>/dev/null` /var/log/journal/ /var/log/journal/`cat /etc/machine-id 2>/dev/null` &>/dev/null || : +%if ! %{defined lifsea_dist} # Apply ACL to the journal directory setfacl -Rnm g:wheel:rx,d:g:wheel:rx,g:adm:rx,d:g:adm:rx /var/log/journal/ &>/dev/null || : +%endif # Stop-gap until rsyslog.rpm does this on its own. (This is supposed # to fail when the link already exists) @@ -1592,6 +1680,7 @@ fi %post libs %{?ldconfig} +%if ! %{defined lifsea_dist} function mod_nss() { if [ $1 -eq 1 ] && [ -f "$2" ]; then # sed-fu to add myhostname to hosts line (only once, on install) @@ -1620,6 +1709,7 @@ else # possible future authselect configuration mod_nss $1 "/etc/authselect/user-nsswitch.conf" fi +%endif # check if nobody or nfsnobody is defined export SYSTEMD_NSS_BYPASS_SYNTHETIC=1 @@ -1661,6 +1751,9 @@ grep -q -E '^KEYMAP="?fi-latin[19]"?' /etc/vconsole.conf 2>/dev/null && %systemd_postun_with_restart systemd-udevd.service %pre journal-remote +%if %{defined lifsea_dist} +%{common_pre_scripts} +%endif getent group systemd-journal-remote &>/dev/null || groupadd -r systemd-journal-remote 2>&1 || : getent passwd systemd-journal-remote &>/dev/null || useradd -r -l -g systemd-journal-remote -d %{_localstatedir}/log/journal/remote -s /sbin/nologin -c "Journal Remote" systemd-journal-remote &>/dev/null || : @@ -1709,11 +1802,17 @@ fi %ghost %dir %attr(0755,-,-) /etc/systemd/system/system-update.target.wants %ghost %dir %attr(0755,-,-) /etc/systemd/system/timers.target.wants %ghost %dir %attr(0755,-,-) /var/lib/rpm-state/systemd +%if %{defined lifsea_dist} +%exclude %{_prefix}/lib/tmpfiles.d/systemd-nologin.conf +%exclude %{_datarootdir}/polkit-1 +%endif %files libs -f .file-list-libs %license LICENSE.LGPL2.1 +%if ! %{defined lifsea_dist} %files pam -f .file-list-pam +%endif %files devel -f .file-list-devel @@ -1759,6 +1858,27 @@ fi - cgroup: do not refresh cgroup devices config when daemon-reload (Zhongling He) - core: introduce cgroup full delegation for compability (Zhongling He) - Update vendor ids for ieisystem 0750 (wangkaiyuan@inspur.com) +- LifseaOS: Add back hostnamectl (yuanhui@linux.alibaba.com) +- LifseaOS: Add back timedatectl (yuanhui@linux.alibaba.com) +- LifseaOS: shared: Remove dependency of libcryptsetup if HAVE_LIBCRYPTSETUP is not defined (yuanhui@linux.alibaba.com) +- LifseaOS: analyze: show information from hostnamed in plot even when user mode (yuanhui@linux.alibaba.com) +- LifseaOS: configure: Disable smack (yuanhui@linux.alibaba.com) +- LifseaOS: Remove nss module provided by systemd (yuanhui@linux.alibaba.com) +- LifseaOS: configure: Remove multiple non-essential features (yuanhui@linux.alibaba.com) +- LifseaOS: configure: Disable firstboot (yuanhui@linux.alibaba.com) +- LifseaOS: Remove user-runtime-dir binary and service file (yuanhui@linux.alibaba.com) +- LifseaOS: Remove the dependency of acl package (yuanhui@linux.alibaba.com) +- LifseaOS: Remove locale and hostname related tools (yuanhui@linux.alibaba.com) +- LifseaOS: Remove multiple unnecessary modules (yuanhui@linux.alibaba.com) +- LifseaOS: Remove compression algorithm (yuanhui@linux.alibaba.com) +- LifseaOS: Remove many tools of little use (yuanhui@linux.alibaba.com) +- LifseaOS: Remove coredump tools (yuanhui@linux.alibaba.com) +- LifseaOS: configure: Disable cryptsetup (yuanhui@linux.alibaba.com) +- LifseaOS: configure: Disable polkit (yuanhui@linux.alibaba.com) +- LifseaOS: configure: Disable logind (yuanhui@linux.alibaba.com) +- LifseaOS: Remove systemd-pam module (yuanhui@linux.alibaba.com) +- LifseaOS: configure: Remove manpage and bash/zsh completion (yuanhui@linux.alibaba.com) +- LifseaOS: cgroup: Do not remove cgroup path which not created by systemd (yuanhui@linux.alibaba.com) * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee From 6e08f92e59efd06b80f099a4feea0f5d74469c47 Mon Sep 17 00:00:00 2001 From: ZHe Date: Tue, 19 Mar 2024 16:06:11 +0800 Subject: [PATCH 14/17] default enable full delegation on device cgroup --- ...group-full-delegation-for-compabilit.patch | 24 ++--- ...ble-full-delegation-on-device-cgroup.patch | 98 +++++++++++++++++++ systemd.spec | 5 +- 3 files changed, 110 insertions(+), 17 deletions(-) create mode 100644 20005-default-enable-full-delegation-on-device-cgroup.patch diff --git a/20003-core-introduce-cgroup-full-delegation-for-compabilit.patch b/20003-core-introduce-cgroup-full-delegation-for-compabilit.patch index 21c5557..a09eaa2 100644 --- a/20003-core-introduce-cgroup-full-delegation-for-compabilit.patch +++ b/20003-core-introduce-cgroup-full-delegation-for-compabilit.patch @@ -1,4 +1,4 @@ -From f25124fabe1ed973840291d46549af6e1c5fad56 Mon Sep 17 00:00:00 2001 +From ce2e0936e03f6cef91a326186978643b93403052 Mon Sep 17 00:00:00 2001 From: "zhongling.h" Date: Fri, 4 Aug 2023 10:08:16 +0800 Subject: [PATCH] core: introduce cgroup full delegation for compability @@ -30,15 +30,8 @@ brings what users are already familiar with to systemd-239. If users set values under /sys/fs/cgroup without worrying systemd touching these values, which is the same as what they expected with systemd-219. ---- - src/core/cgroup.c | 16 ++++++++++++++++ - src/core/main.c | 4 ++++ - src/core/manager.h | 1 + - src/core/system.conf.in | 1 + - 4 files changed, 22 insertions(+) - diff --git a/src/core/cgroup.c b/src/core/cgroup.c -index ea92aa6f7b..17e3b90e37 100644 +index 8e474f6..461f9df 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -1692,6 +1692,15 @@ static int unit_create_cgroup( @@ -57,18 +50,17 @@ index ea92aa6f7b..17e3b90e37 100644 u->cgroup_enabled_mask = enable_mask; u->cgroup_bpf_state = needs_bpf ? UNIT_CGROUP_BPF_ON : UNIT_CGROUP_BPF_OFF; -@@ -1921,6 +1930,10 @@ static int unit_realize_cgroup_now(Unit *u, ManagerState state) { +@@ -1920,6 +1929,9 @@ static int unit_realize_cgroup_now(Unit *u, ManagerState state) { + enable_mask = unit_get_enable_mask(u); needs_bpf = unit_get_needs_bpf(u); - target_mask &= ~CGROUP_MASK_DEVICES; -+ + if (u->manager->full_delegation && unit_cgroup_delegate(u)) + target_mask ^= u->cgroup_realized_mask; + if (unit_has_mask_realized(u, target_mask, enable_mask, needs_bpf)) return 0; -@@ -2883,6 +2896,9 @@ int unit_reset_ip_accounting(Unit *u) { +@@ -2882,6 +2894,9 @@ int unit_reset_ip_accounting(Unit *u) { void unit_invalidate_cgroup(Unit *u, CGroupMask m) { assert(u); @@ -79,7 +71,7 @@ index ea92aa6f7b..17e3b90e37 100644 return; diff --git a/src/core/main.c b/src/core/main.c -index 546bf0d870..68daf07077 100644 +index 546bf0d..68daf07 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -142,6 +142,7 @@ static bool reexec_jmp_can = false; @@ -108,7 +100,7 @@ index 546bf0d870..68daf07077 100644 manager_set_default_rlimits(m, arg_default_rlimit); manager_environment_add(m, NULL, arg_default_environment); diff --git a/src/core/manager.h b/src/core/manager.h -index 98d381bc5b..91f2c05afe 100644 +index 98d381b..91f2c05 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -297,6 +297,7 @@ struct Manager { @@ -120,7 +112,7 @@ index 98d381bc5b..91f2c05afe 100644 uint64_t default_tasks_max; usec_t default_timer_accuracy_usec; diff --git a/src/core/system.conf.in b/src/core/system.conf.in -index 2f6852a89f..6c84a55401 100644 +index 2f6852a..6c84a55 100644 --- a/src/core/system.conf.in +++ b/src/core/system.conf.in @@ -67,3 +67,4 @@ DefaultLimitCORE=0:infinity diff --git a/20005-default-enable-full-delegation-on-device-cgroup.patch b/20005-default-enable-full-delegation-on-device-cgroup.patch new file mode 100644 index 0000000..bf11aa5 --- /dev/null +++ b/20005-default-enable-full-delegation-on-device-cgroup.patch @@ -0,0 +1,98 @@ +From 0c54a1eda08dc8a1c40274c1f90e5e809e054706 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Tue, 19 Mar 2024 15:53:21 +0800 +Subject: [PATCH] default enable full delegation on device cgroup + +--- + src/core/cgroup.c | 9 +++++++++ + src/core/main.c | 3 +++ + src/core/manager.h | 1 + + src/core/system.conf.in | 1 + + 4 files changed, 14 insertions(+) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 461f9df..bc677d8 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -1701,6 +1701,9 @@ static int unit_create_cgroup( + if (u->manager->full_delegation && unit_cgroup_delegate(u)) + u->cgroup_realized_mask |= unit_get_delegate_mask(u); + ++ if (u->manager->full_delegation_devicecg && unit_cgroup_delegate(u)) ++ u->cgroup_realized_mask |= (unit_get_delegate_mask(u) & CGROUP_MASK_DEVICES); ++ + u->cgroup_enabled_mask = enable_mask; + u->cgroup_bpf_state = needs_bpf ? UNIT_CGROUP_BPF_ON : UNIT_CGROUP_BPF_OFF; + +@@ -1932,6 +1935,9 @@ static int unit_realize_cgroup_now(Unit *u, ManagerState state) { + if (u->manager->full_delegation && unit_cgroup_delegate(u)) + target_mask ^= u->cgroup_realized_mask; + ++ if (u->manager->full_delegation_devicecg && unit_cgroup_delegate(u)) ++ target_mask ^= (u->cgroup_realized_mask & CGROUP_MASK_DEVICES); ++ + if (unit_has_mask_realized(u, target_mask, enable_mask, needs_bpf)) + return 0; + +@@ -2897,6 +2903,9 @@ void unit_invalidate_cgroup(Unit *u, CGroupMask m) { + if (u->manager->full_delegation) + m ^= unit_get_delegate_mask(u); // don't invalidate delegated cgroup + ++ if (u->manager->full_delegation_devicecg) ++ m ^= (unit_get_delegate_mask(u) & CGROUP_MASK_DEVICES); // don't invalidate device cgroup if delegate=yes ++ + if (!UNIT_HAS_CGROUP_CONTEXT(u)) + return; + +diff --git a/src/core/main.c b/src/core/main.c +index 68daf07..e27f0a5 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -143,6 +143,7 @@ static bool reexec_jmp_inited = false; + static sigjmp_buf reexec_jmp_buf; + static bool arg_default_cpuset_clone_children = false; + static bool arg_full_delegation = false; ++static bool arg_full_delegation_devicecg = true; + + static int parse_configuration(const struct rlimit *saved_rlimit_nofile, + const struct rlimit *saved_rlimit_memlock); +@@ -770,6 +771,7 @@ static int parse_config_file(void) { + { "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, 0, &arg_cad_burst_action }, + { "Manager", "DefaultCPUSetCloneChildren",config_parse_bool, 0, &arg_default_cpuset_clone_children }, + { "Manager", "FullDelegation", config_parse_bool, 0, &arg_full_delegation }, ++ { "Manager", "FullDelegationDeviceCGroup",config_parse_bool, 0, &arg_full_delegation_devicecg }, + + {} + }; +@@ -821,6 +823,7 @@ static void set_manager_defaults(Manager *m) { + m->default_tasks_accounting = arg_default_tasks_accounting; + m->default_tasks_max = arg_default_tasks_max; + m->full_delegation = arg_full_delegation; ++ m->full_delegation_devicecg = arg_full_delegation_devicecg; + + manager_set_default_rlimits(m, arg_default_rlimit); + manager_environment_add(m, NULL, arg_default_environment); +diff --git a/src/core/manager.h b/src/core/manager.h +index 91f2c05..8017d9a 100644 +--- a/src/core/manager.h ++++ b/src/core/manager.h +@@ -298,6 +298,7 @@ struct Manager { + bool default_tasks_accounting; + bool default_ip_accounting; + bool full_delegation; ++ bool full_delegation_devicecg; + + uint64_t default_tasks_max; + usec_t default_timer_accuracy_usec; +diff --git a/src/core/system.conf.in b/src/core/system.conf.in +index 6c84a55..3f9ef7f 100644 +--- a/src/core/system.conf.in ++++ b/src/core/system.conf.in +@@ -68,3 +68,4 @@ DefaultLimitCORE=0:infinity + #IPAddressAllow= + #IPAddressDeny= + #FullDelegation=no ++#FullDelegationDeviceCGroup=yes +-- +2.39.3 + diff --git a/systemd.spec b/systemd.spec index 13a1662..6d7acc4 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1096,9 +1096,10 @@ Patch10026: 10026-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch Patch10027: 10027-fix-compilation-without-utmp.patch Patch20001: 20001-hwdb-parse_hwdb_dot_py.patch -Patch20002: 20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch +# Patch20002: 20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch Patch20003: 20003-core-introduce-cgroup-full-delegation-for-compabilit.patch Patch20004: 20004-Update-vendor-ids-for-ieisystem-0750.patch +Patch20005: 20005-default-enable-full-delegation-on-device-cgroup.patch # lifsea only patch %if %{defined lifsea_dist} @@ -1879,6 +1880,8 @@ fi - LifseaOS: Remove systemd-pam module (yuanhui@linux.alibaba.com) - LifseaOS: configure: Remove manpage and bash/zsh completion (yuanhui@linux.alibaba.com) - LifseaOS: cgroup: Do not remove cgroup path which not created by systemd (yuanhui@linux.alibaba.com) +- Remove patch 20002 as it inhibits systemd device cgroup slice creation (zhonglingh@linux.alibaba.com) +- Add patch 20005 to enable device cgroup full delegation by default (zhonglingh@linux.alibaba.com) * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee From 6f722f6c5489848e20588080fd496d3507388674 Mon Sep 17 00:00:00 2001 From: khy Date: Fri, 12 May 2023 15:35:12 +0800 Subject: [PATCH 15/17] cherry-pick `add sw patch #20ead624ed837d467ff4c9607d46c027bbc84ac3`. Signed-off-by: khy Signed-off-by: Weisson --- 20006-systemd-Add-sw64.patch | 94 ++++++++++++++++++++++++++++++++++++ systemd.spec | 2 + 2 files changed, 96 insertions(+) create mode 100644 20006-systemd-Add-sw64.patch diff --git a/20006-systemd-Add-sw64.patch b/20006-systemd-Add-sw64.patch new file mode 100644 index 0000000..f1e0e6a --- /dev/null +++ b/20006-systemd-Add-sw64.patch @@ -0,0 +1,94 @@ +From 1d1259c0bada01ed92d991b44be1f53042837187 Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Fri, 12 May 2023 15:33:42 +0800 +Subject: [PATCH] Add sw64 architecture + +Signed-off-by: rpm-build +--- + src/basic/architecture.c | 3 +++ + src/basic/architecture.h | 4 ++++ + src/basic/missing.h | 2 +- + src/basic/missing_syscall.h | 4 +++- + 4 files changed, 11 insertions(+), 2 deletions(-) + +diff --git a/src/basic/architecture.c b/src/basic/architecture.c +index 96bbf97..72b98a3 100644 +--- a/src/basic/architecture.c ++++ b/src/basic/architecture.c +@@ -120,6 +120,8 @@ int uname_architecture(void) { + { "arceb", ARCHITECTURE_ARC_BE }, + #elif defined(__loongarch64) + { "loongarch64", ARCHITECTURE_LOONGARCH64 }, ++#elif defined(__sw_64__) ++ { "sw_64" , ARCHITECTURE_SW_64 }, + #else + #error "Please register your architecture here!" + #endif +@@ -176,6 +178,7 @@ static const char *const architecture_table[_ARCHITECTURE_MAX] = { + [ARCHITECTURE_ARC] = "arc", + [ARCHITECTURE_ARC_BE] = "arc-be", + [ARCHITECTURE_LOONGARCH64] = "loongarch64", ++ [ARCHITECTURE_SW_64] = "sw_64", + }; + + DEFINE_STRING_TABLE_LOOKUP(architecture, int); +diff --git a/src/basic/architecture.h b/src/basic/architecture.h +index 22e9108..c317c75 100644 +--- a/src/basic/architecture.h ++++ b/src/basic/architecture.h +@@ -45,6 +45,7 @@ enum { + ARCHITECTURE_ARC, + ARCHITECTURE_ARC_BE, + ARCHITECTURE_LOONGARCH64, ++ ARCHITECTURE_SW_64, + _ARCHITECTURE_MAX, + _ARCHITECTURE_INVALID = -1 + }; +@@ -233,6 +234,9 @@ int uname_architecture(void); + #elif defined(__loongarch64) + # define native_architecture() ARCHITECTURE_LOONGARCH64 + # define LIB_ARCH_TUPLE "loongarch64-linux-gnu" ++#elif defined(__sw_64__) ++# define native_architecture() ARCHITECTURE_SW_64 ++# define LIB_ARCH_TUPLE "sw_64-linux-gnu" + #else + # error "Please register your architecture here!" + #endif +diff --git a/src/basic/missing.h b/src/basic/missing.h +index b937661..c2913b5 100644 +--- a/src/basic/missing.h ++++ b/src/basic/missing.h +@@ -646,7 +646,7 @@ struct input_mask { + */ + + #ifndef __O_TMPFILE +-#if defined(__alpha__) ++#if defined(__alpha__) || defined(__sw_64__) + #define __O_TMPFILE 0100000000 + #elif defined(__parisc__) || defined(__hppa__) + #define __O_TMPFILE 0400000000 +diff --git a/src/basic/missing_syscall.h b/src/basic/missing_syscall.h +index 014dd2b..3acf59f 100644 +--- a/src/basic/missing_syscall.h ++++ b/src/basic/missing_syscall.h +@@ -182,7 +182,7 @@ static inline int missing_setns(int fd, int nstype) { + /* ======================================================================= */ + + static inline pid_t raw_getpid(void) { +-#if defined(__alpha__) ++#if defined(__alpha__) || defined(__sw_64__) + return (pid_t) syscall(__NR_getxpid); + #else + return (pid_t) syscall(__NR_getpid); +@@ -405,6 +405,8 @@ static inline int missing_bpf(int cmd, union bpf_attr *attr, size_t size) { + # define __NR_statx 360 + # elif defined __x86_64__ + # define __NR_statx 332 ++# elif defined __sw_64__ ++# define __NR_statx 518 + # else + # warning "__NR_statx not defined for your architecture" + # endif +-- +2.31.1 + diff --git a/systemd.spec b/systemd.spec index 6d7acc4..ef731b3 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1100,6 +1100,7 @@ Patch20001: 20001-hwdb-parse_hwdb_dot_py.patch Patch20003: 20003-core-introduce-cgroup-full-delegation-for-compabilit.patch Patch20004: 20004-Update-vendor-ids-for-ieisystem-0750.patch Patch20005: 20005-default-enable-full-delegation-on-device-cgroup.patch +Patch20006: 20006-systemd-Add-sw64.patch # lifsea only patch %if %{defined lifsea_dist} @@ -1882,6 +1883,7 @@ fi - LifseaOS: cgroup: Do not remove cgroup path which not created by systemd (yuanhui@linux.alibaba.com) - Remove patch 20002 as it inhibits systemd device cgroup slice creation (zhonglingh@linux.alibaba.com) - Add patch 20005 to enable device cgroup full delegation by default (zhonglingh@linux.alibaba.com) +- cherry-pick `add sw patch #20ead624ed837d467ff4c9607d46c027bbc84ac3`. (nijie@wxiat.com) * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee From 1509b5514b2b84e14cd767a05cea2bf83f6140e0 Mon Sep 17 00:00:00 2001 From: Weisson Date: Sun, 7 Apr 2024 17:56:24 +0800 Subject: [PATCH 16/17] add seccomp support and test-seccomp test case support for sw_64. Signed-off-by: Weisson --- 20007-add-seccomp-support-for-sw_64.patch | 96 +++++++++++++++++++ ...t-test-test-seccomp-support-on-sw_64.patch | 43 +++++++++ systemd.spec | 4 + 3 files changed, 143 insertions(+) create mode 100644 20007-add-seccomp-support-for-sw_64.patch create mode 100644 20008-Fix-unit-test-test-seccomp-support-on-sw_64.patch diff --git a/20007-add-seccomp-support-for-sw_64.patch b/20007-add-seccomp-support-for-sw_64.patch new file mode 100644 index 0000000..f3cda33 --- /dev/null +++ b/20007-add-seccomp-support-for-sw_64.patch @@ -0,0 +1,96 @@ +From a8b1f7bfc0190af52e863ddc821701d32e6c3c97 Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Sun, 7 Apr 2024 15:45:26 +0800 +Subject: [PATCH 1/1] add seccomp support for sw_64. + +Signed-off-by: Weisson +--- + src/shared/seccomp-util.c | 16 ++++++++++++---- + 1 file changed, 12 insertions(+), 4 deletions(-) + +diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c +index 8b0d366..2cedca5 100644 +--- a/src/shared/seccomp-util.c ++++ b/src/shared/seccomp-util.c +@@ -44,6 +44,8 @@ const uint32_t seccomp_local_archs[] = { + SCMP_ARCH_ARM, + #elif defined(__loongarch__) + SCMP_ARCH_LOONGARCH64, ++#elif defined(__sw_64__) ++ SCMP_ARCH_SW_64, + #elif defined(__mips__) && __BYTE_ORDER == __BIG_ENDIAN && _MIPS_SIM == _MIPS_SIM_ABI32 + SCMP_ARCH_MIPSEL, + SCMP_ARCH_MIPS, /* native */ +@@ -114,6 +116,8 @@ const char* seccomp_arch_to_string(uint32_t c) { + return "x32"; + case SCMP_ARCH_ARM: + return "arm"; ++ case SCMP_ARCH_SW_64: ++ return "sw_64"; + case SCMP_ARCH_AARCH64: + return "arm64"; + case SCMP_ARCH_LOONGARCH64: +@@ -163,6 +167,8 @@ int seccomp_arch_from_string(const char *n, uint32_t *ret) { + *ret = SCMP_ARCH_ARM; + else if (streq(n, "arm64")) + *ret = SCMP_ARCH_AARCH64; ++ else if (streq(n, "sw_64")) ++ *ret = SCMP_ARCH_SW_64; + else if (streq(n, "loongarch64")) + *ret = SCMP_ARCH_LOONGARCH64; + else if (streq(n, "mips")) +@@ -1246,7 +1252,7 @@ int seccomp_protect_sysctl(void) { + + log_debug("Operating on architecture: %s", seccomp_arch_to_string(arch)); + +- if (IN_SET(arch, SCMP_ARCH_X32, SCMP_ARCH_AARCH64, SCMP_ARCH_LOONGARCH64)) ++ if (IN_SET(arch, SCMP_ARCH_X32, SCMP_ARCH_AARCH64, SCMP_ARCH_LOONGARCH64, SCMP_ARCH_SW_64)) + /* No _sysctl syscall */ + continue; + +@@ -1291,6 +1297,7 @@ int seccomp_restrict_address_families(Set *address_families, bool whitelist) { + case SCMP_ARCH_X32: + case SCMP_ARCH_ARM: + case SCMP_ARCH_AARCH64: ++ case SCMP_ARCH_SW_64: + case SCMP_ARCH_LOONGARCH64: + case SCMP_ARCH_MIPSEL64N32: + case SCMP_ARCH_MIPS64N32: +@@ -1536,7 +1543,7 @@ static int add_seccomp_syscall_filter(scmp_filter_ctx seccomp, + } + + /* For known architectures, check that syscalls are indeed defined or not. */ +-#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__loongarch__) ++#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__loongarch__) || defined(__sw_64__) + assert_cc(SCMP_SYS(shmget) > 0); + assert_cc(SCMP_SYS(shmat) > 0); + assert_cc(SCMP_SYS(shmdt) > 0); +@@ -1583,6 +1590,7 @@ int seccomp_memory_deny_write_execute(void) { + case SCMP_ARCH_X86_64: + case SCMP_ARCH_X32: + case SCMP_ARCH_AARCH64: ++ case SCMP_ARCH_SW_64: + case SCMP_ARCH_LOONGARCH64: + filter_syscall = SCMP_SYS(mmap); /* amd64, x32, and arm64 have only mmap */ + shmat_syscall = SCMP_SYS(shmat); +@@ -1590,7 +1598,7 @@ int seccomp_memory_deny_write_execute(void) { + + /* Please add more definitions here, if you port systemd to other architectures! */ + +-#if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__) && !defined(__powerpc64__) && !defined(__arm__) && !defined(__aarch64__) && !defined(__loongarch__) ++#if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__) && !defined(__powerpc64__) && !defined(__arm__) && !defined(__aarch64__) && !defined(__loongarch__) && !defined(__sw_64__) + #warning "Consider adding the right mmap() syscall definitions here!" + #endif + } +@@ -1614,7 +1622,7 @@ int seccomp_memory_deny_write_execute(void) { + if (r < 0) + continue; + } +- if (!IN_SET(arch, SCMP_ARCH_LOONGARCH64)){ ++ if (!IN_SET(arch, SCMP_ARCH_LOONGARCH64, SCMP_ARCH_SW_64)){ + r = add_seccomp_syscall_filter(seccomp, arch, SCMP_SYS(mprotect), + 1, + SCMP_A2(SCMP_CMP_MASKED_EQ, PROT_EXEC, PROT_EXEC)); +-- +2.31.1 + diff --git a/20008-Fix-unit-test-test-seccomp-support-on-sw_64.patch b/20008-Fix-unit-test-test-seccomp-support-on-sw_64.patch new file mode 100644 index 0000000..ac70671 --- /dev/null +++ b/20008-Fix-unit-test-test-seccomp-support-on-sw_64.patch @@ -0,0 +1,43 @@ +From 573700e701553081bd2bdb9081da0a1215f5ed97 Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Sun, 7 Apr 2024 17:13:11 +0800 +Subject: [PATCH] Fix unit-test: test-seccomp support on sw_64. + +Signed-off-by: Weisson +--- + src/test/test-seccomp.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/test/test-seccomp.c b/src/test/test-seccomp.c +index 286f01b..c04eb66 100644 +--- a/src/test/test-seccomp.c ++++ b/src/test/test-seccomp.c +@@ -55,6 +55,7 @@ static void test_architecture_table(void) { + "x32\0" + "arm\0" + "arm64\0" ++ "sw_64\0" + "mips\0" + "mips64\0" + "mips64-n32\0" +@@ -403,7 +404,7 @@ static void test_memory_deny_write_execute_mmap(void) { + assert_se(seccomp_memory_deny_write_execute() >= 0); + + p = mmap(NULL, page_size(), PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1,0); +-#if defined(__x86_64__) || defined(__i386__) || defined(__powerpc64__) || defined(__arm__) || defined(__aarch64__) ++#if defined(__x86_64__) || defined(__i386__) || defined(__powerpc64__) || defined(__arm__) || defined(__aarch64__) || defined(__sw_64__) + assert_se(p == MAP_FAILED); + assert_se(errno == EPERM); + #else /* unknown architectures */ +@@ -450,7 +451,7 @@ static void test_memory_deny_write_execute_shmat(void) { + assert_se(seccomp_memory_deny_write_execute() >= 0); + + p = shmat(shmid, NULL, SHM_EXEC); +-#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) ++#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__sw_64__) + assert_se(p == MAP_FAILED); + assert_se(errno == EPERM); + #else /* __i386__, __powerpc64__, and "unknown" architectures */ +-- +2.31.1 + diff --git a/systemd.spec b/systemd.spec index ef731b3..09401b8 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1101,6 +1101,8 @@ Patch20003: 20003-core-introduce-cgroup-full-delegation-for-compabilit.patch Patch20004: 20004-Update-vendor-ids-for-ieisystem-0750.patch Patch20005: 20005-default-enable-full-delegation-on-device-cgroup.patch Patch20006: 20006-systemd-Add-sw64.patch +Patch20007: 20007-add-seccomp-support-for-sw_64.patch +Patch20008: 20008-Fix-unit-test-test-seccomp-support-on-sw_64.patch # lifsea only patch %if %{defined lifsea_dist} @@ -1884,6 +1886,8 @@ fi - Remove patch 20002 as it inhibits systemd device cgroup slice creation (zhonglingh@linux.alibaba.com) - Add patch 20005 to enable device cgroup full delegation by default (zhonglingh@linux.alibaba.com) - cherry-pick `add sw patch #20ead624ed837d467ff4c9607d46c027bbc84ac3`. (nijie@wxiat.com) +- add seccomp support for sw_64. (Weisson@alinux.alibaba.com) +- add test-seccomp support for sw_64. (Weisson@alinux.alibaba.com) * Thu Apr 11 2024 systemd maintenance team - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee From 86149c5436cdf727fec048c2785849d707f61017 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BF=A0=E5=87=8C?= Date: Mon, 24 Jun 2024 11:49:31 +0800 Subject: [PATCH 17/17] core: Fix 2 subcgroup deletion problems - core: Fix subcgroup deletion introduced by full delegation - core: Fix cgroups members mask cache propagation problem --- ...ly-simplify-caching-of-cgroups-membe.patch | 228 ++++++++++++++++++ ...group-FullDelegation-FullDelegationD.patch | 163 +++++++++++++ systemd.spec | 11 +- 3 files changed, 399 insertions(+), 3 deletions(-) create mode 100644 10028-cgroup-drastically-simplify-caching-of-cgroups-membe.patch create mode 100644 20009-core-introduce-cgroup-FullDelegation-FullDelegationD.patch diff --git a/10028-cgroup-drastically-simplify-caching-of-cgroups-membe.patch b/10028-cgroup-drastically-simplify-caching-of-cgroups-membe.patch new file mode 100644 index 0000000..d69f0ba --- /dev/null +++ b/10028-cgroup-drastically-simplify-caching-of-cgroups-membe.patch @@ -0,0 +1,228 @@ +From 5af8805872809e6de4cc4d9495cb1a904772ab4e Mon Sep 17 00:00:00 2001 +From: Lennart Poettering +Date: Fri, 23 Nov 2018 01:07:34 +0100 +Subject: [PATCH] cgroup: drastically simplify caching of cgroups members mask + +Previously we tried to be smart: when a new unit appeared and it only +added controllers to the cgroup mask we'd update the cached members mask +in all parents by ORing in the controller flags in their cached values. +Unfortunately this was quite broken, as we missed some conditions when +this cache had to be reset (for example, when a unit got unloaded), +moreover the optimization doesn't work when a controller is removed +anyway (as in that case there's no other way for the parent to iterate +though all children if any other, remaining child unit still needs it). +Hence, let's simplify the logic substantially: instead of updating the +cache on the right events (which we didn't get right), let's simply +invalidate the cache, and generate it lazily when we encounter it later. +This should actually result in better behaviour as we don't have to +calculate the new members mask for a whole subtree whever we have the +suspicion something changed, but can delay it to the point where we +actually need the members mask. + +This allows us to simplify things quite a bit, which is good, since +validating this cache for correctness is hard enough. + +Fixes: #9512 +--- + src/core/cgroup.c | 49 +++++------------------------------------ + src/core/cgroup.h | 2 +- + src/core/dbus-mount.c | 2 +- + src/core/dbus-scope.c | 2 +- + src/core/dbus-service.c | 2 +- + src/core/dbus-slice.c | 2 +- + src/core/dbus-socket.c | 2 +- + src/core/dbus-swap.c | 2 +- + src/core/unit.c | 3 ++- + src/core/unit.h | 2 -- + 10 files changed, 14 insertions(+), 54 deletions(-) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 6a5606f..d569077 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -1450,53 +1450,12 @@ bool unit_get_needs_bpf(Unit *u) { + return false; + } + +-/* Recurse from a unit up through its containing slices, propagating +- * mask bits upward. A unit is also member of itself. */ +-void unit_update_cgroup_members_masks(Unit *u) { +- CGroupMask m; +- bool more; +- ++void unit_invalidate_cgroup_members_masks(Unit *u) { + assert(u); +- +- /* Calculate subtree mask */ +- m = unit_get_subtree_mask(u); +- +- /* See if anything changed from the previous invocation. If +- * not, we're done. */ +- if (u->cgroup_subtree_mask_valid && m == u->cgroup_subtree_mask) +- return; +- +- more = +- u->cgroup_subtree_mask_valid && +- ((m & ~u->cgroup_subtree_mask) != 0) && +- ((~m & u->cgroup_subtree_mask) == 0); +- +- u->cgroup_subtree_mask = m; +- u->cgroup_subtree_mask_valid = true; +- +- if (UNIT_ISSET(u->slice)) { +- Unit *s = UNIT_DEREF(u->slice); +- +- if (more) +- /* There's more set now than before. We +- * propagate the new mask to the parent's mask +- * (not caring if it actually was valid or +- * not). */ +- +- s->cgroup_members_mask |= m; +- +- else +- /* There's less set now than before (or we +- * don't know), we need to recalculate +- * everything, so let's invalidate the +- * parent's members mask */ +- +- s->cgroup_members_mask_valid = false; +- +- /* And now make sure that this change also hits our +- * grandparents */ +- unit_update_cgroup_members_masks(s); +- } ++ /* Recurse invalidate the member masks cache all the way up the tree */ ++ u->cgroup_members_mask_valid = false; ++ if (UNIT_ISSET(u->slice)) ++ unit_invalidate_cgroup_members_masks(UNIT_DEREF(u->slice)); + } + + const char *unit_get_realized_cgroup_path(Unit *u, CGroupMask mask) { +diff --git a/src/core/cgroup.h b/src/core/cgroup.h +index 36ea77f..a2e1644 100644 +--- a/src/core/cgroup.h ++++ b/src/core/cgroup.h +@@ -181,7 +181,7 @@ CGroupMask unit_get_enable_mask(Unit *u); + + bool unit_get_needs_bpf(Unit *u); + +-void unit_update_cgroup_members_masks(Unit *u); ++void unit_invalidate_cgroup_members_masks(Unit *u); + + const char *unit_get_realized_cgroup_path(Unit *u, CGroupMask mask); + char *unit_default_cgroup_path(Unit *u); + +diff --git a/src/core/dbus-mount.c b/src/core/dbus-mount.c +index 3f98d3ecf0..b6d61627eb 100644 +--- a/src/core/dbus-mount.c ++++ b/src/core/dbus-mount.c +@@ -145,7 +145,7 @@ int bus_mount_set_property( + int bus_mount_commit_properties(Unit *u) { + assert(u); + +- unit_update_cgroup_members_masks(u); ++ unit_invalidate_cgroup_members_masks(u); + unit_realize_cgroup(u); + + return 0; +diff --git a/src/core/dbus-scope.c b/src/core/dbus-scope.c +index 5d9fe98857..bb807df2e9 100644 +--- a/src/core/dbus-scope.c ++++ b/src/core/dbus-scope.c +@@ -186,7 +186,7 @@ int bus_scope_set_property( + int bus_scope_commit_properties(Unit *u) { + assert(u); + +- unit_update_cgroup_members_masks(u); ++ unit_invalidate_cgroup_members_masks(u); + unit_realize_cgroup(u); + + return 0; +diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c +index fdf6120610..10f53ef401 100644 +--- a/src/core/dbus-service.c ++++ b/src/core/dbus-service.c +@@ -424,7 +424,7 @@ int bus_service_set_property( + int bus_service_commit_properties(Unit *u) { + assert(u); + +- unit_update_cgroup_members_masks(u); ++ unit_invalidate_cgroup_members_masks(u); + unit_realize_cgroup(u); + + return 0; +diff --git a/src/core/dbus-slice.c b/src/core/dbus-slice.c +index 722a5688a5..effd5fa5d7 100644 +--- a/src/core/dbus-slice.c ++++ b/src/core/dbus-slice.c +@@ -28,7 +28,7 @@ int bus_slice_set_property( + int bus_slice_commit_properties(Unit *u) { + assert(u); + +- unit_update_cgroup_members_masks(u); ++ unit_invalidate_cgroup_members_masks(u); + unit_realize_cgroup(u); + + return 0; +diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c +index 4ea5b6c6e5..3819653908 100644 +--- a/src/core/dbus-socket.c ++++ b/src/core/dbus-socket.c +@@ -461,7 +461,7 @@ int bus_socket_set_property( + int bus_socket_commit_properties(Unit *u) { + assert(u); + +- unit_update_cgroup_members_masks(u); ++ unit_invalidate_cgroup_members_masks(u); + unit_realize_cgroup(u); + + return 0; +diff --git a/src/core/dbus-swap.c b/src/core/dbus-swap.c +index b272d10113..353fa20132 100644 +--- a/src/core/dbus-swap.c ++++ b/src/core/dbus-swap.c +@@ -63,7 +63,7 @@ int bus_swap_set_property( + int bus_swap_commit_properties(Unit *u) { + assert(u); + +- unit_update_cgroup_members_masks(u); ++ unit_invalidate_cgroup_members_masks(u); + unit_realize_cgroup(u); + + return 0; +diff --git a/src/core/unit.c b/src/core/unit.c +index 392cc2d7c5..a8c0f08e95 100644 +--- a/src/core/unit.c ++++ b/src/core/unit.c +@@ -1547,7 +1547,8 @@ int unit_load(Unit *u) { + if (u->job_running_timeout != USEC_INFINITY && u->job_running_timeout > u->job_timeout) + log_unit_warning(u, "JobRunningTimeoutSec= is greater than JobTimeoutSec=, it has no effect."); + +- unit_update_cgroup_members_masks(u); ++ /* We finished loading, let's ensure our parents recalculate the members mask */ ++ unit_invalidate_cgroup_members_masks(u); + } + + assert((u->load_state != UNIT_MERGED) == !u->merged_into); +diff --git a/src/core/unit.h b/src/core/unit.h +index b8b9147..e2dd794 100644 +--- a/src/core/unit.h ++++ b/src/core/unit.h +@@ -265,7 +265,6 @@ typedef struct Unit { + char *cgroup_path; + CGroupMask cgroup_realized_mask; + CGroupMask cgroup_enabled_mask; +- CGroupMask cgroup_subtree_mask; + CGroupMask cgroup_members_mask; + int cgroup_inotify_wd; + +@@ -341,7 +340,6 @@ typedef struct Unit { + + bool cgroup_realized:1; + bool cgroup_members_mask_valid:1; +- bool cgroup_subtree_mask_valid:1; + + UnitCGroupBPFState cgroup_bpf_state:2; + + diff --git a/20009-core-introduce-cgroup-FullDelegation-FullDelegationD.patch b/20009-core-introduce-cgroup-FullDelegation-FullDelegationD.patch new file mode 100644 index 0000000..bcd28b5 --- /dev/null +++ b/20009-core-introduce-cgroup-FullDelegation-FullDelegationD.patch @@ -0,0 +1,163 @@ +From f4fc78bb9b250e7e8f5197aa15055239276ec3cd Mon Sep 17 00:00:00 2001 +From: rpm-build +Date: Wed, 10 Jul 2024 17:46:57 +0800 +Subject: [PATCH] core: introduce cgroup FullDelegation, + FullDelegationDeviceCGroup for compability + +Whille using systemd-219, users can set 'delegate=y' to claim the +possession of cgroup settings. By then, users are able to write raw +values under /sys/fs/cgroup to adjust cgroup settings and systemd +won't touch these values any longer. + +However, this is likely to be an undefined behaviour for systemd-219. +Upon releasing systemd-239, a documentation of cgroup delegation was +added, +https://github.com/systemd/systemd/commit/e30eaff3a32523b09d61af67fc999f1f62f4e0cb. +It states that: + +Only sub-trees can be delegated (though whoever decides to request a +sub-tree can delegate sub-sub-trees further to somebody else if they +like it).' + +Which is quite different from what people understand the delegation of +systemd-219. Currently, whether a unit is delegated or not, systemd always +possesses any cgroup it created, only ignoring the sub-tree ones +according to delegation settings. + +This behaviour change causes confusion if users switch from systemd-219 to +systemd-239. As a result, we introduce 'FullDelegation', a feature that +brings what users are already familiar with to systemd-239. If users set +'FullDelegation=yes' in /etc/systemd/system.conf, they can control raw +values under /sys/fs/cgroup without worrying systemd touching these +values, which is the same as what they expected with systemd-219. + +The 'FullDelegation' option should not be enabled by default, as it alters the +default behavior that users are accustomed to or will become familiar with. +However, without enabling this option, GPU containers will not function +correctly. To address this issue, we have introduced +'FullDelegationDeviceCGroup', which replicates the behavior of systemd-219 +specifically for device cgroups. This option is enabled by default. + +During the use of earlier versions of systemd, we encountered bug reports +indicating that when 'FullDelegation' is enabled, subcgroups are removed by +systemd. This issue arises due to a flaw in our modification of the +`unit_realize_cgroup_now` function. We overlooked the fact that, in addition to +creating cgroups, the unit_create_cgroup function also deletes subcgroups based +on unset bits in the `target_mask`. To resolve this, we have adjusted the +procedure by moving the reduction of the `target_mask` to occur after the +execution of `unit_create_cgroup`, thereby preventing the unintended deletion of +subcgroups. +--- + src/core/cgroup.c | 24 ++++++++++++++++++++++++ + src/core/main.c | 7 +++++++ + src/core/manager.h | 2 ++ + src/core/system.conf.in | 2 ++ + 4 files changed, 35 insertions(+) + +diff --git a/src/core/cgroup.c b/src/core/cgroup.c +index 8e474f6..6a5606f 100644 +--- a/src/core/cgroup.c ++++ b/src/core/cgroup.c +@@ -1692,6 +1692,18 @@ static int unit_create_cgroup( + /* Keep track that this is now realized */ + u->cgroup_realized = true; + u->cgroup_realized_mask = target_mask; ++ ++ // While realizing cgroup, we don't realize delegated cgroup, therefore, target_mask ++ // doesn't contain delegated cgroup controller bit, and u->cgroup_realized_mask will ++ // not contain delegated cgroup controller bit as well. This unit will be in a state ++ // as if delegated cgroup is not set, which is not expected. ++ // If this is not present, delegated cgroup will be set every 2 systemctl daemon-reload ++ if (u->manager->full_delegation && unit_cgroup_delegate(u)) ++ u->cgroup_realized_mask |= unit_get_delegate_mask(u); ++ ++ if (u->manager->full_delegation_devicecg && unit_cgroup_delegate(u)) ++ u->cgroup_realized_mask |= (unit_get_delegate_mask(u) & CGROUP_MASK_DEVICES); ++ + u->cgroup_enabled_mask = enable_mask; + u->cgroup_bpf_state = needs_bpf ? UNIT_CGROUP_BPF_ON : UNIT_CGROUP_BPF_OFF; + +@@ -1940,6 +1952,12 @@ static int unit_realize_cgroup_now(Unit *u, ManagerState state) { + if (r < 0) + return r; + ++ if (u->manager->full_delegation && unit_cgroup_delegate(u)) ++ target_mask ^= u->cgroup_realized_mask; ++ ++ if (u->manager->full_delegation_devicecg && unit_cgroup_delegate(u)) ++ target_mask ^= (u->cgroup_realized_mask & CGROUP_MASK_DEVICES); ++ + /* Finally, apply the necessary attributes. */ + cgroup_context_apply(u, target_mask, apply_bpf, state); + cgroup_xattr_apply(u); +@@ -2882,6 +2900,12 @@ int unit_reset_ip_accounting(Unit *u) { + void unit_invalidate_cgroup(Unit *u, CGroupMask m) { + assert(u); + ++ if (u->manager->full_delegation) ++ m ^= unit_get_delegate_mask(u); // don't invalidate delegated cgroup ++ ++ if (u->manager->full_delegation_devicecg) ++ m ^= (unit_get_delegate_mask(u) & CGROUP_MASK_DEVICES); // don't invalidate device cgroup if delegate=yes ++ + if (!UNIT_HAS_CGROUP_CONTEXT(u)) + return; + +diff --git a/src/core/main.c b/src/core/main.c +index 546bf0d..e27f0a5 100644 +--- a/src/core/main.c ++++ b/src/core/main.c +@@ -142,6 +142,8 @@ static bool reexec_jmp_can = false; + static bool reexec_jmp_inited = false; + static sigjmp_buf reexec_jmp_buf; + static bool arg_default_cpuset_clone_children = false; ++static bool arg_full_delegation = false; ++static bool arg_full_delegation_devicecg = true; + + static int parse_configuration(const struct rlimit *saved_rlimit_nofile, + const struct rlimit *saved_rlimit_memlock); +@@ -768,6 +770,9 @@ static int parse_config_file(void) { + { "Manager", "DefaultTasksMax", config_parse_tasks_max, 0, &arg_default_tasks_max }, + { "Manager", "CtrlAltDelBurstAction", config_parse_emergency_action, 0, &arg_cad_burst_action }, + { "Manager", "DefaultCPUSetCloneChildren",config_parse_bool, 0, &arg_default_cpuset_clone_children }, ++ { "Manager", "FullDelegation", config_parse_bool, 0, &arg_full_delegation }, ++ { "Manager", "FullDelegationDeviceCGroup",config_parse_bool, 0, &arg_full_delegation_devicecg }, ++ + {} + }; + +@@ -817,6 +822,8 @@ static void set_manager_defaults(Manager *m) { + m->default_memory_accounting = arg_default_memory_accounting; + m->default_tasks_accounting = arg_default_tasks_accounting; + m->default_tasks_max = arg_default_tasks_max; ++ m->full_delegation = arg_full_delegation; ++ m->full_delegation_devicecg = arg_full_delegation_devicecg; + + manager_set_default_rlimits(m, arg_default_rlimit); + manager_environment_add(m, NULL, arg_default_environment); +diff --git a/src/core/manager.h b/src/core/manager.h +index 98d381b..8017d9a 100644 +--- a/src/core/manager.h ++++ b/src/core/manager.h +@@ -297,6 +297,8 @@ struct Manager { + bool default_blockio_accounting; + bool default_tasks_accounting; + bool default_ip_accounting; ++ bool full_delegation; ++ bool full_delegation_devicecg; + + uint64_t default_tasks_max; + usec_t default_timer_accuracy_usec; +diff --git a/src/core/system.conf.in b/src/core/system.conf.in +index 2f6852a..3f9ef7f 100644 +--- a/src/core/system.conf.in ++++ b/src/core/system.conf.in +@@ -67,3 +67,5 @@ DefaultLimitCORE=0:infinity + #DefaultLimitRTTIME= + #IPAddressAllow= + #IPAddressDeny= ++#FullDelegation=no ++#FullDelegationDeviceCGroup=yes +-- +2.39.3 + diff --git a/systemd.spec b/systemd.spec index 09401b8..3360a88 100644 --- a/systemd.spec +++ b/systemd.spec @@ -1094,15 +1094,17 @@ Patch10024: 10024-fileio-beef-up-READ_FULL_FILE_CONNECT_SOCKET-to-all.patch Patch10025: 10025-fileio-teach-read_full_file_full-to-read-from-offse.patch Patch10026: 10026-cryptsetup-port-cryptsetup-s-main-key-file-logic-ov.patch Patch10027: 10027-fix-compilation-without-utmp.patch +Patch10028: 10028-cgroup-drastically-simplify-caching-of-cgroups-membe.patch Patch20001: 20001-hwdb-parse_hwdb_dot_py.patch # Patch20002: 20002-cgroup-do-not-refresh-cgroup-devices-config-when-dae.patch -Patch20003: 20003-core-introduce-cgroup-full-delegation-for-compabilit.patch +# Patch20003: 20003-core-introduce-cgroup-full-delegation-for-compabilit.patch Patch20004: 20004-Update-vendor-ids-for-ieisystem-0750.patch -Patch20005: 20005-default-enable-full-delegation-on-device-cgroup.patch +# Patch20005: 20005-default-enable-full-delegation-on-device-cgroup.patch Patch20006: 20006-systemd-Add-sw64.patch Patch20007: 20007-add-seccomp-support-for-sw_64.patch Patch20008: 20008-Fix-unit-test-test-seccomp-support-on-sw_64.patch +Patch20009: 20009-core-introduce-cgroup-FullDelegation-FullDelegationD.patch # lifsea only patch %if %{defined lifsea_dist} @@ -1580,10 +1582,11 @@ python3 %{SOURCE2} %buildroot < - 239-82.1 - pid1: by default make user units inherit their umask from the user manager (RHEL-28048) -- Gitee