From 9f8b689f8a6def0b58a4a0b14a757d8bf35547a9 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Fri, 27 Dec 2024 09:49:14 -0600 Subject: [PATCH] security-context-v1: fix assertion failure There's a bit of subtlety I missed with the zig-wayland upgrade. Since zig-wayland now generates its own wl_interface structs the pointer comparison we used to do here is no longer sufficient. --- river/Server.zig | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/river/Server.zig b/river/Server.zig index 401689a..ea06842 100644 --- a/river/Server.zig +++ b/river/Server.zig @@ -19,6 +19,7 @@ const Server = @This(); const build_options = @import("build_options"); const std = @import("std"); const assert = std.debug.assert; +const mem = std.mem; const posix = std.posix; const wlr = @import("wlroots"); const wl = @import("wayland").server.wl; @@ -299,13 +300,16 @@ fn allowlist(server: *Server, global: *const wl.Global) bool { // such as wl_output and wl_seat since the wl_global_create() function will // advertise the global to clients and invoke this filter before returning // the new global pointer. - // + if ((mem.orderZ(u8, global.getInterface().name, "wl_output") == .eq) or + (mem.orderZ(u8, global.getInterface().name, "wl_seat") == .eq)) + { + return true; + } + // For other globals I like the current pointer comparison approach as it // should catch river accidentally exposing multiple copies of e.g. wl_shm // with an assertion failure. - return global.getInterface() == wl.Output.interface or - global.getInterface() == wl.Seat.interface or - global == server.shm.global or + return global == server.shm.global or global == server.single_pixel_buffer_manager.global or global == server.viewporter.global or global == server.fractional_scale_manager.global or