fix: Fix client crash when created via security context#555
fix: Fix client crash when created via security context#555zccrs merged 1 commit intolinuxdeepin:masterfrom
Conversation
Reviewer's GuideThis PR adds full support for the wp_security_context_v1 protocol by generating its Wayland bindings, introducing WSecurityContextManager, extending WSocket and WClient to carry security context metadata, and updating the commit handler to create and bind dedicated sockets under WClient management to prevent crashes for clients created via a security context. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `waylib/src/server/kernel/wsocket.cpp:124` </location>
<code_context>
+ , parentSocket(nullptr)
+ {}
+
+ WSocketPrivate(WSocket *qq, WSocket *parent)
+ : WObjectPrivate(qq)
+ , freezeClientWhenDisable(WSocketPrivate::get(parent)->freezeClientWhenDisable)
, parentSocket(parent)
</code_context>
<issue_to_address>
The constructor copies freezeClientWhenDisable from parent without null check.
A null check for parent should be added, or ensure parent is always valid to prevent potential crashes.
</issue_to_address>
### Comment 2
<location> `waylib/src/server/protocols/wsecuritycontextmanager.cpp:178` </location>
<code_context>
+ wl_list_remove(&security_context->link);
+ free(security_context);
+
+ security_context->socket->deleteLater();
+}
+
</code_context>
<issue_to_address>
deleteLater may not be safe if called from non-Qt thread context.
Call deleteLater only from the main Qt thread, or use a thread-safe alternative such as delete or a queued connection to prevent crashes.
</issue_to_address>
### Comment 3
<location> `waylib/src/server/kernel/wsocket.h:71` </location>
<code_context>
Q_PROPERTY(QString fullServerName READ fullServerName NOTIFY fullServerNameChanged FINAL)
- Q_PROPERTY(WSocket* parentSocket READ parentSocket WRITE setParentSocket NOTIFY parentSocketChanged FINAL)
+ Q_PROPERTY(WSocket* parentSocket READ parentSocket NOTIFY parentSocketChanged FINAL)
+ Q_PROPERTY(WSocket* rootSocket READ rootSocket CONSTANT FINAL)
+ Q_PROPERTY(QByteArray sandboxEngine READ sandboxEngine CONSTANT FINAL)
+ Q_PROPERTY(QByteArray appId READ appId CONSTANT FINAL)
</code_context>
<issue_to_address>
rootSocket property is declared but no implementation is shown.
Please add the rootSocket accessor to ensure the property works as intended and does not cause runtime issues.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
df3033d to
070999e
Compare
eb90805 to
18385aa
Compare
18385aa to
2900e20
Compare
1. Fixed a crash issue where clients created through the security context could not obtain the corresponding WClient object. 2. Clients created via security context use a new socket connection, which is not managed by WSocket by default. 3. The wlroots protocol provides limited information for monitoring such wl_clients. 4. This commit adapts the wlroots implementation: in `security_context_handle_commit`, a new WSocket object is created for the listening socket, and the new wl_client object created from this socket is added to WClient for management. Influence: 1. Test the creation of clients using the security context. 2. Verify that the created clients can correctly obtain the WClient object. 3. Ensure that newly created sockets are correctly managed. 修复:修复通过安全上下文创建的客户端崩溃问题 1. 修复了通过安全上下文创建的客户端无法获取对应的 WClient 对象导致崩溃的 问题。 2. 通过安全上下文创建的客户端使用新的套接字连接,默认情况下不由 WSocket 管理。 3. wlroots 协议为监控此类 wl_clients 提供的相关信息有限。 4. 本次提交采纳了 wlroots 的实现:在 `security_context_handle_commit` 中,为监听的套接字创建一个新的 WSocket 对象,并将由此套接字创建的新 wl_client 对象添加到 WClient 中进行管理。 Influence: 1. 测试使用安全上下文创建客户端的过程。 2. 验证创建的客户端能否正确获取 WClient 对象。 3. 确保新创建的套接字能够得到正确的管理。
2900e20 to
2d07dfe
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ComixHe, zccrs, zzxyb The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
security_context_handle_commit, a new WSocket object is created for the listening socket, and the new wl_client object created from this socket is added to WClient for management.Influence:
修复:修复通过安全上下文创建的客户端崩溃问题
security_context_handle_commit中,为监听的套接字创建一个新的 WSocket 对象,并将由此套接字创建的新wl_client 对象添加到 WClient 中进行管理。
Influence:
Summary by Sourcery
Support the security-context-v1 Wayland protocol, fix client creation crash in security contexts, and extend socket/client classes to propagate security metadata
New Features:
Bug Fixes:
Enhancements:
Build: