Skip to content

fix: keep ddm in the init mount namespace - #120

Merged
zccrs merged 1 commit into
linuxdeepin:masterfrom
Groveer:master
Nov 12, 2026
Merged

zccrs merged 1 commit into
linuxdeepin:masterfrom
Groveer:master

Conversation

@Groveer

@Groveer Groveer commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor
  1. ProtectKernelModules and PrivateIPC both make systemd create a private (slave) mount namespace for the unit: the former hides /usr/lib/modules, the latter needs its own mqueuefs on /dev/mqueue. Every child of ddm inherits that namespace, so mounts made in the PAM session stage, such as the dlnfs long-file-name mount, never propagate to the rest of the system. lightdm.service sets neither option and runs in the init namespace. ProtectClock only installs a seccomp filter and is kept.

Log: Fix dlnfs mounts made during login being invisible to the desktop

Influence:

  1. Enable the long-file-name feature, log in through ddm and check that findmnt shows the dlnfs mount on the home directory
  2. Verify the mount is visible to a newly started desktop application
  3. Verify readlink /proc/$(pgrep -x ddm)/ns/mnt equals /proc/1/ns/mnt
  4. Check that modprobe and pam_mount style mounts work inside a session

fix: 让 ddm 运行在 init 挂载命名空间,与 lightdm 保持一致

  1. ProtectKernelModules 和 PrivateIPC 都会让 systemd 为 unit 创建私有 (slave)挂载命名空间:前者把 /usr/lib/modules 隐藏,后者需要在 /dev/mqueue 上挂自己的 mqueuefs。ddm 的所有子进程都继承该命名空间, 于是在 PAM session 阶段做的挂载(如 dlnfs 长文件名挂载)不会传播到 系统其它部分。lightdm.service 没有这两个选项,运行在 init 命名空间。 ProtectClock 只安装 seccomp 过滤,故保留

Log: 修复登录时挂载的 dlnfs 文件系统对桌面应用不可见的问题

Influence:

  1. 开启长文件名功能后用 ddm 登录,确认 findmnt 能看到主目录上的 dlnfs 挂载
  2. 确认新启动的桌面应用能访问该挂载
  3. 确认 readlink /proc/$(pgrep -x ddm)/ns/mnt 与 /proc/1/ns/mnt 相同
  4. 确认会话内 modprobe 及 pam_mount 类挂载正常

PMS: BUG-346181

Summary by Sourcery

Keep ddm in the init mount namespace to ensure session-created mounts propagate correctly.

Bug Fixes:

  • Run ddm in the init mount namespace so mounts created during PAM sessions, including dlnfs and pam_mount mounts, remain visible to the desktop and the rest of the system.

Enhancements:

  • Align ddm's systemd sandboxing configuration with lightdm while retaining clock protection.

@sourcery-ai

sourcery-ai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Configuration

Remove the systemd hardening options that place ddm in a private mount namespace, while retaining ProtectClock, so session mounts remain visible system-wide.

  • services/ddm.service.in L24-33

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

zccrs
zccrs previously approved these changes Nov 11, 2026
1. ProtectKernelModules and PrivateIPC both make systemd create a private
   (slave) mount namespace for the unit: the former hides /usr/lib/modules,
   the latter needs its own mqueuefs on /dev/mqueue. Every child of ddm
   inherits that namespace, so mounts made in the PAM session stage, such
   as the dlnfs long-file-name mount, never propagate to the rest of the
   system. lightdm.service sets neither option and runs in the init
   namespace. ProtectClock only installs a seccomp filter and is kept.

Log: Fix dlnfs mounts made during login being invisible to the desktop

Influence:
1. Enable the long-file-name feature, log in through ddm and check that
   findmnt shows the dlnfs mount on the home directory
2. Verify the mount is visible to a newly started desktop application
3. Verify readlink /proc/$(pgrep -x ddm)/ns/mnt equals /proc/1/ns/mnt
4. Check that modprobe and pam_mount style mounts work inside a session

fix: 让 ddm 运行在 init 挂载命名空间,与 lightdm 保持一致

1. ProtectKernelModules 和 PrivateIPC 都会让 systemd 为 unit 创建私有
   (slave)挂载命名空间:前者把 /usr/lib/modules 隐藏,后者需要在
   /dev/mqueue 上挂自己的 mqueuefs。ddm 的所有子进程都继承该命名空间,
   于是在 PAM session 阶段做的挂载(如 dlnfs 长文件名挂载)不会传播到
   系统其它部分。lightdm.service 没有这两个选项,运行在 init 命名空间。
   ProtectClock 只安装 seccomp 过滤,故保留

Log: 修复登录时挂载的 dlnfs 文件系统对桌面应用不可见的问题

Influence:
1. 开启长文件名功能后用 ddm 登录,确认 findmnt 能看到主目录上的 dlnfs 挂载
2. 确认新启动的桌面应用能访问该挂载
3. 确认 readlink /proc/$(pgrep -x ddm)/ns/mnt 与 /proc/1/ns/mnt 相同
4. 确认会话内 modprobe 及 pam_mount 类挂载正常

PMS: BUG-346181
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 97 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次变更通过注释禁用 systemd 服务单元中的 PrivateIPC 和 ProtectKernelModules 指令,修复了因私有挂载命名空间导致 PAM 会话挂载无法传播的功能缺陷。变更范围极小(仅1个文件),注释说明详尽充分,语法正确,逻辑清晰。安全方面未引入代码级漏洞,但因禁用 ProtectKernelModules 硬化措施略微降低了安全姿态,属于有正当理由的功能性权衡。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['无需修改,语法和逻辑均正确。']


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['注释质量优秀,建议保持这种 documenting-the-rationale 的风格。']


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['无性能优化建议。']


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: ['建议在未来版本中探索替代方案,例如使用 BindReadOnlyPaths=/usr/lib/modules 来替代 ProtectKernelModules,或通过其他 systemd 指令组合实现既保持挂载传播又限制内核模块加载的安全目标。', '可考虑通过 After/Requires 依赖确保 dlnfs 挂载在 ddm 启动前完成,从而避免依赖挂载命名空间传播。']


💡 改进建议代码示例

# 当前方案(功能正确,但安全姿态略降):
# services/ddm.service.in
#PrivateIPC=true
#ProtectKernelModules=true

# 建议的未来替代方案(兼顾功能与安全):
# 保留 ProtectKernelModules 的等效保护,同时不影响挂载传播:
#ProtectKernelModules=true
# 使用 BindReadOnlyPaths 替代,仅以只读方式映射模块目录,
# 不会创建新的挂载命名空间:
#BindReadOnlyPaths=/usr/lib/modules

# 或者,确保 dlnfs 在 ddm 启动前完成挂载,避免依赖命名空间传播:
# 在 ddm.service.in 中添加:
#After=dlnfs-mount.service
#Requires=dlnfs-mount.service

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Groveer, zccrs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zccrs
zccrs merged commit 1343bc0 into linuxdeepin:master Nov 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants