diff --git a/CVE-2023-38552-node-integrity-checks-according-to-policies.patch b/CVE-2023-38552-node-integrity-checks-according-to-policies.patch new file mode 100644 index 0000000..70d35de --- /dev/null +++ b/CVE-2023-38552-node-integrity-checks-according-to-policies.patch @@ -0,0 +1,168 @@ +From 1c538938ccadfd35fbc699d8e85102736cd5945c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= +Date: Sun, 6 Aug 2023 12:56:02 +0000 +Subject: [PATCH] policy: use tamper-proof integrity check function + +Using the JavaScript Hash class is unsafe because its internals can be +tampered with. In particular, an application can cause +Hash.prototype.digest() to return arbitrary values, thus allowing to +circumvent the integrity verification that policies are supposed to +guarantee. + +Add and use a new C++ binding internalVerifyIntegrity() that (hopefully) +cannot be tampered with from JavaScript. + +PR-URL: https://github.com/nodejs-private/node-private/pull/462 +Backport-PR-URL: https://github.com/nodejs-private/node-private/pull/493 +Reviewed-By: Rafael Gonzaga +CVE-ID: CVE-2023-38552 +--- + lib/internal/policy/manifest.js | 17 ++----- + src/crypto/crypto_hash.cc | 50 +++++++++++++++++++ + src/crypto/crypto_hash.h | 2 + + .../crypto-hash-tampering/.gitattributes | 1 + + .../policy/crypto-hash-tampering/main.js | 8 +++ + .../policy/crypto-hash-tampering/policy.json | 15 ++++++ + .../policy/crypto-hash-tampering/protected.js | 1 + + .../test-policy-crypto-hash-tampering.js | 21 ++++++++ + 8 files changed, 102 insertions(+), 13 deletions(-) + create mode 100644 test/fixtures/policy/crypto-hash-tampering/.gitattributes + create mode 100644 test/fixtures/policy/crypto-hash-tampering/main.js + create mode 100644 test/fixtures/policy/crypto-hash-tampering/policy.json + create mode 100644 test/fixtures/policy/crypto-hash-tampering/protected.js + create mode 100644 test/parallel/test-policy-crypto-hash-tampering.js + +diff --git a/lib/internal/policy/manifest.js b/lib/internal/policy/manifest.js +index 698971ee57f2b..d2afb10ec30e4 100644 +--- a/third_party/electron_node/lib/internal/policy/manifest.js ++++ b/third_party/electron_node/lib/internal/policy/manifest.js +@@ -16,7 +16,6 @@ const { + StringPrototypeEndsWith, + StringPrototypeStartsWith, + Symbol, +- uncurryThis, + } = primordials; + const { + ERR_MANIFEST_ASSERT_INTEGRITY, +@@ -28,13 +27,8 @@ let debug = require('internal/util/debuglog').debuglog('policy', (fn) => { + debug = fn; + }); + const SRI = require('internal/policy/sri'); +-const crypto = require('crypto'); +-const { Buffer } = require('buffer'); + const { URL } = require('internal/url'); +-const { createHash, timingSafeEqual } = crypto; +-const HashUpdate = uncurryThis(crypto.Hash.prototype.update); +-const HashDigest = uncurryThis(crypto.Hash.prototype.digest); +-const BufferToString = uncurryThis(Buffer.prototype.toString); ++const { internalVerifyIntegrity } = internalBinding('crypto'); + const kRelativeURLStringPattern = /^\.{0,2}\//; + const { getOptionValue } = require('internal/options'); + const shouldAbortOnUncaughtException = getOptionValue( +@@ -588,16 +582,13 @@ class Manifest { + // Avoid clobbered Symbol.iterator + for (let i = 0; i < integrityEntries.length; i++) { + const { algorithm, value: expected } = integrityEntries[i]; +- const hash = createHash(algorithm); + // TODO(tniessen): the content should not be passed as a string in the + // first place, see https://github.com/nodejs/node/issues/39707 +- HashUpdate(hash, content, 'utf8'); +- const digest = HashDigest(hash, 'buffer'); +- if (digest.length === expected.length && +- timingSafeEqual(digest, expected)) { ++ const mismatchedIntegrity = internalVerifyIntegrity(algorithm, content, expected); ++ if (mismatchedIntegrity === undefined) { + return true; + } +- realIntegrities.set(algorithm, BufferToString(digest, 'base64')); ++ realIntegrities.set(algorithm, mismatchedIntegrity); + } + } + +diff --git a/src/crypto/crypto_hash.cc b/src/crypto/crypto_hash.cc +index 200603a85ef33..3cb39d795c732 100644 +--- a/third_party/electron_node/src/crypto/crypto_hash.cc ++++ b/third_party/electron_node/src/crypto/crypto_hash.cc +@@ -69,6 +69,9 @@ void Hash::Initialize(Environment* env, Local target) { + SetMethodNoSideEffect(context, target, "getHashes", GetHashes); + + HashJob::Initialize(env, target); ++ ++ SetMethodNoSideEffect( ++ context, target, "internalVerifyIntegrity", InternalVerifyIntegrity); + } + + void Hash::RegisterExternalReferences(ExternalReferenceRegistry* registry) { +@@ -78,6 +81,8 @@ void Hash::RegisterExternalReferences(ExternalReferenceRegistry* registry) { + registry->Register(GetHashes); + + HashJob::RegisterExternalReferences(registry); ++ ++ registry->Register(InternalVerifyIntegrity); + } + + void Hash::New(const FunctionCallbackInfo& args) { +@@ -310,5 +315,50 @@ bool HashTraits::DeriveBits( + return true; + } + ++void InternalVerifyIntegrity(const v8::FunctionCallbackInfo& args) { ++ Environment* env = Environment::GetCurrent(args); ++ ++ CHECK_EQ(args.Length(), 3); ++ ++ CHECK(args[0]->IsString()); ++ Utf8Value algorithm(env->isolate(), args[0]); ++ ++ CHECK(args[1]->IsString() || IsAnyByteSource(args[1])); ++ ByteSource content = ByteSource::FromStringOrBuffer(env, args[1]); ++ ++ CHECK(args[2]->IsArrayBufferView()); ++ ArrayBufferOrViewContents expected(args[2]); ++ ++ const EVP_MD* md_type = EVP_get_digestbyname(*algorithm); ++ unsigned char digest[EVP_MAX_MD_SIZE]; ++ unsigned int digest_size; ++ if (md_type == nullptr || EVP_Digest(content.data(), ++ content.size(), ++ digest, ++ &digest_size, ++ md_type, ++ nullptr) != 1) { ++ return ThrowCryptoError( ++ env, ERR_get_error(), "Digest method not supported"); ++ } ++ ++ if (digest_size != expected.size() || ++ CRYPTO_memcmp(digest, expected.data(), digest_size) != 0) { ++ Local error; ++ MaybeLocal rc = ++ StringBytes::Encode(env->isolate(), ++ reinterpret_cast(digest), ++ digest_size, ++ BASE64, ++ &error); ++ if (rc.IsEmpty()) { ++ CHECK(!error.IsEmpty()); ++ env->isolate()->ThrowException(error); ++ return; ++ } ++ args.GetReturnValue().Set(rc.FromMaybe(Local())); ++ } ++} ++ + } // namespace crypto + } // namespace node +diff --git a/src/crypto/crypto_hash.h b/src/crypto/crypto_hash.h +index 96a9804420db6..2d17c3510ed21 100644 +--- a/third_party/electron_node/src/crypto/crypto_hash.h ++++ b/third_party/electron_node/src/crypto/crypto_hash.h +@@ -82,6 +82,8 @@ struct HashTraits final { + + using HashJob = DeriveBitsJob; + ++void InternalVerifyIntegrity(const v8::FunctionCallbackInfo& args); ++ + } // namespace crypto + } // namespace node + diff --git a/CVE-2023-39333-node-create_dynamic_module-code-injection.patch b/CVE-2023-39333-node-create_dynamic_module-code-injection.patch new file mode 100644 index 0000000..9c37e62 --- /dev/null +++ b/CVE-2023-39333-node-create_dynamic_module-code-injection.patch @@ -0,0 +1,61 @@ +From eaf9083cf1e43bd897ac8244dcc0f4e3500150ca Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= +Date: Sun, 6 Aug 2023 10:41:33 +0000 +Subject: [PATCH] module: fix code injection through export names + +createDynamicModule() properly escapes import names, but not export +names. In WebAssembly, any string is a valid export name. Importing a +WebAssembly module that uses a non-identifier export name leads to +either a syntax error in createDynamicModule() or to code injection, +that is, to the evaluation of almost arbitrary JavaScript code outside +of the WebAssembly module. + +To address this issue, adopt the same mechanism in createExport() that +createImport() already uses. Add tests for both exports and imports. + +PR-URL: https://github.com/nodejs-private/node-private/pull/461 +Backport-PR-URL: https://github.com/nodejs-private/node-private/pull/490 +Reviewed-By: Rafael Gonzaga +CVE-ID: CVE-2023-39333 +--- + .../modules/esm/create_dynamic_module.js | 14 ++--- + test/es-module/test-esm-wasm.mjs | 50 ++++++++++++++++++ + .../export-name-code-injection.wasm | Bin 0 -> 98 bytes + .../es-modules/export-name-code-injection.wat | 8 +++ + .../es-modules/export-name-syntax-error.wasm | Bin 0 -> 37 bytes + .../es-modules/export-name-syntax-error.wat | 6 +++ + test/fixtures/es-modules/import-name.wasm | Bin 0 -> 237 bytes + test/fixtures/es-modules/import-name.wat | 10 ++++ + 8 files changed, 81 insertions(+), 7 deletions(-) + create mode 100644 test/fixtures/es-modules/export-name-code-injection.wasm + create mode 100644 test/fixtures/es-modules/export-name-code-injection.wat + create mode 100644 test/fixtures/es-modules/export-name-syntax-error.wasm + create mode 100644 test/fixtures/es-modules/export-name-syntax-error.wat + create mode 100644 test/fixtures/es-modules/import-name.wasm + create mode 100644 test/fixtures/es-modules/import-name.wat + +diff --git a/lib/internal/modules/esm/create_dynamic_module.js b/lib/internal/modules/esm/create_dynamic_module.js +index f7c20083b6c91..c99da19d5c827 100644 +--- a/third_party/electron_node/lib/internal/modules/esm/create_dynamic_module.js ++++ b/third_party/electron_node/lib/internal/modules/esm/create_dynamic_module.js +@@ -18,13 +18,13 @@ function createImport(impt, index) { + import.meta.imports[${imptPath}] = $import_${index};`; + } + +-function createExport(expt) { +- const name = `${expt}`; +- return `let $${name}; +-export { $${name} as ${name} }; +-import.meta.exports.${name} = { +- get: () => $${name}, +- set: (v) => $${name} = v, ++function createExport(expt, index) { ++ const nameStringLit = JSONStringify(expt); ++ return `let $export_${index}; ++export { $export_${index} as ${nameStringLit} }; ++import.meta.exports[${nameStringLit}] = { ++ get: () => $export_${index}, ++ set: (v) => $export_${index} = v, + };`; + } + diff --git a/CVE-2023-45143-undici-cookie-leakage.patch b/CVE-2023-45143-undici-cookie-leakage.patch new file mode 100644 index 0000000..49dddd8 --- /dev/null +++ b/CVE-2023-45143-undici-cookie-leakage.patch @@ -0,0 +1,42 @@ +From e041de359221ebeae04c469e8aff4145764e6d76 Mon Sep 17 00:00:00 2001 +From: Khafra +Date: Wed, 11 Oct 2023 14:56:38 -0400 +Subject: [PATCH] Merge pull request from GHSA-wqq4-5wpv-mx2g + +* fix: delete 'cookie' and 'host' headers on cross-origin redirect + +* apply suggestion +--- + lib/fetch/index.js | 4 ++ + test/fetch/redirect-cross-origin-header.js | 48 ++++++++++++++++++++++ + 2 files changed, 52 insertions(+) + create mode 100644 test/fetch/redirect-cross-origin-header.js + +diff --git a/lib/fetch/index.js b/lib/fetch/index.js +index c89c9b7ffc..5323c30abc 100644 +--- a/third_party/electron_node/deps/undici/src/lib/fetch/index.js ++++ b/third_party/electron_node/deps/undici/src/lib/fetch/index.js +@@ -1200,6 +1200,10 @@ async function httpRedirectFetch (fetchParams, response) { + if (!sameOrigin(requestCurrentURL(request), locationURL)) { + // https://fetch.spec.whatwg.org/#cors-non-wildcard-request-header-name + request.headersList.delete('authorization') ++ ++ // "Cookie" and "Host" are forbidden request-headers, which undici doesn't implement. ++ request.headersList.delete('cookie') ++ request.headersList.delete('host') + } + + // 14. If request’s body is non-null, then set request’s body to the first return +--- src/third_party/electron_node/deps/undici/undici.js.orig 2023-10-12 11:05:39.514426000 +0200 ++++ src/third_party/electron_node/deps/undici/undici.js 2023-10-16 19:37:43.239110900 +0200 +@@ -11006,6 +11006,10 @@ var require_fetch = __commonJS({ + } + if (!sameOrigin(requestCurrentURL(request), locationURL)) { + request.headersList.delete("authorization"); ++ ++ // "Cookie" and "Host" are forbidden request-headers, which undici doesn't implement. ++ request.headersList.delete('cookie') ++ request.headersList.delete('host') + } + if (request.body != null) { + assert(request.body.source); diff --git a/create_tarball.sh b/create_tarball.sh index 789d3a6..9df6e87 100644 --- a/create_tarball.sh +++ b/create_tarball.sh @@ -168,7 +168,7 @@ keeplibs=( net/third_party/nss #Derived code, not vendored dependency. net/third_party/quiche #Not available as a shared library yet. An old version is in Factory (google-quiche-source) net/third_party/uri_template #Derived code, not vendored dependency. - third_party/abseil-cpp #15.4 and fc36 too old. + third_party/abseil-cpp #Leap and fc36 too old. third_party/angle # ANGLE is an integral part of chrome and is not available as a shared library. third_party/angle/src/third_party/ceval #not in any distro third_party/angle/src/third_party/libXNVCtrl #Not in 15.4 @@ -286,15 +286,15 @@ keeplibs=( third_party/swiftshader/third_party/astc-encoder #not in rawhide or factory. Debian has it (astc-encoder) third_party/swiftshader/third_party/llvm-subzero #heavily forked version of libLLVM for use in subzero third_party/swiftshader/third_party/marl #not on any distro - third_party/swiftshader/third_party/SPIRV-Headers #FC36 too old - third_party/swiftshader/third_party/SPIRV-Tools #FC36 too old + third_party/swiftshader/third_party/SPIRV-Headers #Leap too old + third_party/swiftshader/third_party/SPIRV-Tools #Leap too old third_party/swiftshader/third_party/subzero #integral part of swiftshader #third_party/tflite #Not used by electron, but chrome needs it. #third_party/tflite/src/third_party/eigen3 #third_party/tflite/src/third_party/fft2d - third_party/vulkan-deps/spirv-headers #FC36 too old - third_party/vulkan-deps/spirv-tools #FC36 too old - third_party/vulkan-deps/vulkan-headers #FC36 too old. CONSIDER UNBUNDLING when all distros have new enough vulkan sdk + third_party/vulkan-deps/spirv-headers #Leap too old + third_party/vulkan-deps/spirv-tools #Leap too old + third_party/vulkan-deps/vulkan-headers #Leap too old. CONSIDER UNBUNDLING when all distros have new enough vulkan sdk third_party/vulkan_memory_allocator #not in any distro third_party/webgpu-cts #Javascript code. Needed even if you're building chrome without webgpu third_party/webrtc #Integral part of chrome diff --git a/nodejs-electron.changes b/nodejs-electron.changes index 2c0dd37..133ba5c 100644 --- a/nodejs-electron.changes +++ b/nodejs-electron.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Mon Oct 16 17:38:38 UTC 2023 - Bruno Pitrus + +- Add backported security patches: + * CVE-2023-38552 bsc#1216272 CVE-2023-38552-node-integrity-checks-according-to-policies.patch + * CVE-2023-39333 bsc#1216273 CVE-2023-39333-node-create_dynamic_module-code-injection.patch + * CVE-2023-45143 bsc#1216205 CVE-2023-45143-undici-cookie-leakage.patch +- Build against Wayland 21 also on Leap 15.4 now that it's available + * drop wayland-WL-SINCE-VERSION.patch + * drop wayland_data_drag_controller-WL_SURFACE_OFFSET_SINCE_VERSION.patch + ------------------------------------------------------------------- Mon Oct 16 08:55:17 UTC 2023 - Bruno Pitrus diff --git a/nodejs-electron.spec b/nodejs-electron.spec index 36371d7..a9bb4c3 100644 --- a/nodejs-electron.spec +++ b/nodejs-electron.spec @@ -115,13 +115,11 @@ BuildArch: i686 %bcond_without system_dav1d %bcond_without system_highway %bcond_without system_nvctrl -%bcond_without wayland_21 %else %bcond_with system_crc32c %bcond_with system_dav1d %bcond_with system_highway %bcond_with system_nvctrl -%bcond_with wayland_21 %endif @@ -231,9 +229,6 @@ Source401: audio_file_reader-ffmpeg-AVFrame-duration.patch # and against harfbuzz 4 Source415: harfbuzz-replace-chromium-scoped-type.patch Source416: harfbuzz-replace-HbScopedPointer.patch -# and against Wayland 1.19 -Source418: wayland-WL-SINCE-VERSION.patch -Source419: wayland_data_drag_controller-WL_SURFACE_OFFSET_SINCE_VERSION.patch #Reverse upstream changes to build against system libavif. @@ -363,6 +358,10 @@ Patch3210: electron_api_app-GetPathConstant-non-constexpr.patch # https://github.com/electron/electron/pull/40032 Patch3211: build-without-extensions.patch Patch3212: swiftshader-llvm17.patch +Patch3213: CVE-2023-38552-node-integrity-checks-according-to-policies.patch +Patch3214: CVE-2023-39333-node-create_dynamic_module-code-injection.patch +Patch3215: CVE-2023-45143-undici-cookie-leakage.patch + %if %{with clang} @@ -464,11 +463,7 @@ BuildRequires: vulkan-headers %if %{with system_vma} BuildRequires: VulkanMemoryAllocator-devel >= 3 %endif -%if %{with wayland_21} BuildRequires: wayland-devel >= 1.20 -%else -BuildRequires: wayland-devel -%endif BuildRequires: zstd %if %{with system_abseil} BuildRequires: pkgconfig(absl_algorithm_container) @@ -715,10 +710,6 @@ patch -R -p1 < %SOURCE416 %endif -%if %{without wayland_21} -patch -R -p1 < %SOURCE418 -patch -R -p1 < %SOURCE419 -%endif # This one depends on an ffmpeg nightly, reverting unconditionally. patch -R -p1 < %SOURCE401 diff --git a/wayland-WL-SINCE-VERSION.patch b/wayland-WL-SINCE-VERSION.patch deleted file mode 100644 index 98f1c9e..0000000 --- a/wayland-WL-SINCE-VERSION.patch +++ /dev/null @@ -1,292 +0,0 @@ -From ce85cd0009fc01aa463db9919c66c5c91eb648ac Mon Sep 17 00:00:00 2001 -From: Max Ihlenfeldt -Date: Mon, 21 Nov 2022 19:24:45 +0000 -Subject: [PATCH] ozone/wayland: remove obsolete `#ifdef ..._SINCE_VERSION` - guards - -Since dropping support for building with `use_system_libwayland=true`, -we always build with the Wayland headers from //third_party. This means -we can remove the #ifdef guards that ensured support for building with -older Wayland header versions (and running these builds without -crashing). - -Fixed: 1385736 -Change-Id: I8083f5e849a6b52233e907e865d3d1766e903c3a -Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4043143 -Reviewed-by: Alexander Dunaev -Commit-Queue: Max Ihlenfeldt -Cr-Commit-Position: refs/heads/main@{#1074142} ---- - .../platform/wayland/host/wayland_output.cc | 14 ++----------- - .../platform/wayland/host/wayland_output.h | 4 ---- - .../platform/wayland/host/wayland_pointer.cc | 9 ++------- - .../platform/wayland/host/wayland_pointer.h | 2 -- - .../platform/wayland/host/wayland_touch.cc | 12 +---------- - .../platform/wayland/host/wayland_touch.h | 4 ---- - .../wayland/host/xdg_toplevel_wrapper_impl.cc | 20 ++++++------------- - .../wayland/host/xdg_toplevel_wrapper_impl.h | 6 ------ - 8 files changed, 11 insertions(+), 60 deletions(-) - -diff --git a/ui/ozone/platform/wayland/host/wayland_output.cc b/ui/ozone/platform/wayland/host/wayland_output.cc -index 715a1da7d962b..6f87fde5fddb1 100644 ---- a/ui/ozone/platform/wayland/host/wayland_output.cc -+++ b/ui/ozone/platform/wayland/host/wayland_output.cc -@@ -118,14 +118,8 @@ void WaylandOutput::Initialize(Delegate* delegate) { - DCHECK(!delegate_); - delegate_ = delegate; - static constexpr wl_output_listener output_listener = { -- &OutputHandleGeometry, &OutputHandleMode, -- &OutputHandleDone, &OutputHandleScale, --#ifdef WL_OUTPUT_NAME_SINCE_VERSION -- &OutputHandleName, --#endif --#ifdef WL_OUTPUT_DESCRIPTION_SINCE_VERSION -- &OutputHandleDescription, --#endif -+ &OutputHandleGeometry, &OutputHandleMode, &OutputHandleDone, -+ &OutputHandleScale, &OutputHandleName, &OutputHandleDescription, - - }; - wl_output_add_listener(output_.get(), &output_listener, this); -@@ -266,7 +260,6 @@ void WaylandOutput::OutputHandleScale(void* data, - wayland_output->scale_factor_ = factor; - } - --#ifdef WL_OUTPUT_NAME_SINCE_VERSION - // static - void WaylandOutput::OutputHandleName(void* data, - struct wl_output* wl_output, -@@ -274,9 +267,7 @@ void WaylandOutput::OutputHandleName(void* data, - if (WaylandOutput* wayland_output = static_cast(data)) - wayland_output->name_ = name ? std::string(name) : std::string{}; - } --#endif - --#ifdef WL_OUTPUT_DESCRIPTION_SINCE_VERSION - // static - void WaylandOutput::OutputHandleDescription(void* data, - struct wl_output* wl_output, -@@ -286,6 +277,5 @@ void WaylandOutput::OutputHandleDescription(void* data, - description ? std::string(description) : std::string{}; - } - } --#endif - - } // namespace ui -diff --git a/ui/ozone/platform/wayland/host/wayland_output.h b/ui/ozone/platform/wayland/host/wayland_output.h -index 8f052fa0e5859..e1b1beec9ddf9 100644 ---- a/ui/ozone/platform/wayland/host/wayland_output.h -+++ b/ui/ozone/platform/wayland/host/wayland_output.h -@@ -154,16 +154,12 @@ class WaylandOutput : public wl::GlobalObjectRegistrar { - static void OutputHandleScale(void* data, - struct wl_output* wl_output, - int32_t factor); --#ifdef WL_OUTPUT_NAME_SINCE_VERSION - static void OutputHandleName(void* data, - struct wl_output* wl_output, - const char* name); --#endif --#ifdef WL_OUTPUT_DESCRIPTION_SINCE_VERSION - static void OutputHandleDescription(void* data, - struct wl_output* wl_output, - const char* description); --#endif - - const Id output_id_ = 0; - wl::Object output_; -diff --git a/ui/ozone/platform/wayland/host/wayland_pointer.cc b/ui/ozone/platform/wayland/host/wayland_pointer.cc -index c8271487beea3..ba9832cd52324 100644 ---- a/ui/ozone/platform/wayland/host/wayland_pointer.cc -+++ b/ui/ozone/platform/wayland/host/wayland_pointer.cc -@@ -37,11 +37,8 @@ WaylandPointer::WaylandPointer(wl_pointer* pointer, - Delegate* delegate) - : obj_(pointer), connection_(connection), delegate_(delegate) { - static constexpr wl_pointer_listener listener = { -- &Enter, &Leave, &Motion, &Button, &Axis, -- &Frame, &AxisSource, &AxisStop, &AxisDiscrete, --#ifdef WL_POINTER_AXIS_VALUE120_SINCE_VERSION -- &AxisValue120, --#endif -+ &Enter, &Leave, &Motion, &Button, &Axis, -+ &Frame, &AxisSource, &AxisStop, &AxisDiscrete, &AxisValue120, - }; - - wl_pointer_add_listener(obj_.get(), &listener, this); -@@ -225,7 +222,6 @@ void WaylandPointer::AxisDiscrete(void* data, - NOTIMPLEMENTED_LOG_ONCE(); - } - --#ifdef WL_POINTER_AXIS_VALUE120_SINCE_VERSION - // --- Version 8 --- - - // static -@@ -237,7 +233,6 @@ void WaylandPointer::AxisValue120(void* data, - // events. - NOTIMPLEMENTED_LOG_ONCE(); - } --#endif - - void WaylandPointer::SetupStylus() { - auto* stylus_v2 = connection_->stylus_v2(); -diff --git a/ui/ozone/platform/wayland/host/wayland_pointer.h b/ui/ozone/platform/wayland/host/wayland_pointer.h -index ec80f29908724..9448d2159662c 100644 ---- a/ui/ozone/platform/wayland/host/wayland_pointer.h -+++ b/ui/ozone/platform/wayland/host/wayland_pointer.h -@@ -82,12 +82,10 @@ class WaylandPointer { - wl_pointer* obj, - uint32_t axis, - int32_t discrete); --#ifdef WL_POINTER_AXIS_VALUE120_SINCE_VERSION - static void AxisValue120(void* data, - wl_pointer* obj, - uint32_t axis, - int32_t value120); --#endif - - void SetupStylus(); - -diff --git a/ui/ozone/platform/wayland/host/wayland_touch.cc b/ui/ozone/platform/wayland/host/wayland_touch.cc -index b3b3664043925..503ef90695405 100644 ---- a/ui/ozone/platform/wayland/host/wayland_touch.cc -+++ b/ui/ozone/platform/wayland/host/wayland_touch.cc -@@ -42,13 +42,7 @@ WaylandTouch::WaylandTouch(wl_touch* touch, - Delegate* delegate) - : obj_(touch), connection_(connection), delegate_(delegate) { - static constexpr wl_touch_listener listener = { -- &Down, &Up, &Motion, &Frame, &Cancel, --#ifdef WL_TOUCH_SHAPE_SINCE_VERSION -- &Shape, --#endif --#ifdef WL_TOUCH_ORIENTATION_SINCE_VERSION -- &Orientation, --#endif -+ &Down, &Up, &Motion, &Frame, &Cancel, &Shape, &Orientation, - }; - - wl_touch_add_listener(obj_.get(), &listener, this); -@@ -122,7 +116,6 @@ void WaylandTouch::Motion(void* data, - EventDispatchPolicyForPlatform()); - } - --#ifdef WL_TOUCH_SHAPE_SINCE_VERSION - // static - void WaylandTouch::Shape(void* data, - wl_touch* obj, -@@ -131,9 +124,7 @@ void WaylandTouch::Shape(void* data, - wl_fixed_t minor) { - NOTIMPLEMENTED_LOG_ONCE(); - } --#endif - --#ifdef WL_TOUCH_ORIENTATION_SINCE_VERSION - // static - void WaylandTouch::Orientation(void* data, - wl_touch* obj, -@@ -141,7 +132,6 @@ void WaylandTouch::Orientation(void* data, - wl_fixed_t orientation) { - NOTIMPLEMENTED_LOG_ONCE(); - } --#endif - - // static - void WaylandTouch::Cancel(void* data, wl_touch* obj) { -diff --git a/ui/ozone/platform/wayland/host/wayland_touch.h b/ui/ozone/platform/wayland/host/wayland_touch.h -index fda7076a0610e..4b8c4b0a5ccba 100644 ---- a/ui/ozone/platform/wayland/host/wayland_touch.h -+++ b/ui/ozone/platform/wayland/host/wayland_touch.h -@@ -59,19 +59,15 @@ class WaylandTouch { - int32_t id, - wl_fixed_t x, - wl_fixed_t y); --#ifdef WL_TOUCH_SHAPE_SINCE_VERSION - static void Shape(void* data, - wl_touch* obj, - int32_t id, - wl_fixed_t major, - wl_fixed_t minor); --#endif --#ifdef WL_TOUCH_ORIENTATION_SINCE_VERSION - static void Orientation(void* data, - wl_touch* obj, - int32_t id, - wl_fixed_t orientation); --#endif - static void Cancel(void* data, wl_touch* obj); - static void Frame(void* data, wl_touch* obj); - -diff --git a/ui/ozone/platform/wayland/host/xdg_toplevel_wrapper_impl.cc b/ui/ozone/platform/wayland/host/xdg_toplevel_wrapper_impl.cc -index e604780b93f9c..9116980aa068a 100644 ---- a/ui/ozone/platform/wayland/host/xdg_toplevel_wrapper_impl.cc -+++ b/ui/ozone/platform/wayland/host/xdg_toplevel_wrapper_impl.cc -@@ -98,16 +98,12 @@ bool XDGToplevelWrapperImpl::Initialize() { - } - - static constexpr xdg_toplevel_listener xdg_toplevel_listener = { -- &ConfigureTopLevel, -- &CloseTopLevel, --#if defined(XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION) -- // Since v4 -- &ConfigureBounds, --#endif --#if defined(XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION) -- // Since v5 -- &WmCapabilities, --#endif -+ &ConfigureTopLevel, -+ &CloseTopLevel, -+ // Since v4 -+ &ConfigureBounds, -+ // Since v5 -+ &WmCapabilities, - }; - - if (!xdg_surface_wrapper_) -@@ -324,7 +320,6 @@ void XDGToplevelWrapperImpl::CloseTopLevel(void* data, - surface->wayland_window_->OnCloseRequest(); - } - --#if defined(XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION) - // static - void XDGToplevelWrapperImpl::ConfigureBounds(void* data, - struct xdg_toplevel* xdg_toplevel, -@@ -332,16 +327,13 @@ void XDGToplevelWrapperImpl::ConfigureBounds(void* data, - int32_t height) { - NOTIMPLEMENTED_LOG_ONCE(); - } --#endif - --#if defined(XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION) - // static - void XDGToplevelWrapperImpl::WmCapabilities(void* data, - struct xdg_toplevel* xdg_toplevel, - struct wl_array* capabilities) { - NOTIMPLEMENTED_LOG_ONCE(); - } --#endif - - void XDGToplevelWrapperImpl::SetTopLevelDecorationMode( - DecorationMode requested_mode) { -diff --git a/ui/ozone/platform/wayland/host/xdg_toplevel_wrapper_impl.h b/ui/ozone/platform/wayland/host/xdg_toplevel_wrapper_impl.h -index 03cbeba08a0f9..a9a0bc1cb6bf7 100644 ---- a/ui/ozone/platform/wayland/host/xdg_toplevel_wrapper_impl.h -+++ b/ui/ozone/platform/wayland/host/xdg_toplevel_wrapper_impl.h -@@ -69,19 +69,13 @@ class XDGToplevelWrapperImpl : public ShellToplevelWrapper { - int32_t height, - struct wl_array* states); - static void CloseTopLevel(void* data, struct xdg_toplevel* xdg_toplevel); -- --#if defined(XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION) - static void ConfigureBounds(void* data, - struct xdg_toplevel* xdg_toplevel, - int32_t width, - int32_t height); --#endif -- --#if defined(XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION) - static void WmCapabilities(void* data, - struct xdg_toplevel* xdg_toplevel, - struct wl_array* capabilities); --#endif - - // zxdg_decoration_listener - static void ConfigureDecoration( diff --git a/wayland_data_drag_controller-WL_SURFACE_OFFSET_SINCE_VERSION.patch b/wayland_data_drag_controller-WL_SURFACE_OFFSET_SINCE_VERSION.patch deleted file mode 100644 index bbfbf5d..0000000 --- a/wayland_data_drag_controller-WL_SURFACE_OFFSET_SINCE_VERSION.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 758dd0a34bec51430123c25a52a2dc14183e5c6a Mon Sep 17 00:00:00 2001 -From: Alexander Dunaev -Date: Wed, 30 Nov 2022 09:26:03 +0000 -Subject: [PATCH] [linux/wayland] Adopted the new way of setting the buffer - offset. - -Since version 5, the Wayland compositor wants the client to use the -dedicated method to set the offset for the buffer when attaching it to -the surface. - -This patch fixes the logic in one place where Chromium uses non-zero -offset, and adds appropriate notes in other places where the offset is -currently zero. - -Bug: 1382126 -Change-Id: Ide0fa3c1cbc9326d6fb25cf177da65a590aafa1c -Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4061548 -Commit-Queue: Alexander Dunaev -Reviewed-by: Maksim Sisov -Cr-Commit-Position: refs/heads/main@{#1077345} ---- - ui/ozone/platform/wayland/host/wayland_cursor.cc | 1 + - .../wayland/host/wayland_data_drag_controller.cc | 9 +++++++-- - ui/ozone/platform/wayland/host/wayland_surface.cc | 1 + - 3 files changed, 9 insertions(+), 2 deletions(-) - -diff --git a/ui/ozone/platform/wayland/host/wayland_cursor.cc b/ui/ozone/platform/wayland/host/wayland_cursor.cc -index 891ca2e5e1f3c..ae10e43d93bfa 100644 ---- a/ui/ozone/platform/wayland/host/wayland_cursor.cc -+++ b/ui/ozone/platform/wayland/host/wayland_cursor.cc -@@ -157,6 +157,7 @@ void WaylandCursor::AttachAndCommit(wl_buffer* buffer, - pointer_surface_.get(), hotspot_x_dip, hotspot_y_dip); - - wl_surface_damage(pointer_surface_.get(), 0, 0, buffer_width, buffer_height); -+ // Note: should the offset be non-zero, use wl_surface_offset() to set it. - wl_surface_attach(pointer_surface_.get(), buffer, 0, 0); - wl_surface_commit(pointer_surface_.get()); - -diff --git a/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc b/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc -index 9fe196023dc18..40b1acd4aab3e 100644 ---- a/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc -+++ b/ui/ozone/platform/wayland/host/wayland_data_drag_controller.cc -@@ -265,9 +265,16 @@ void WaylandDataDragController::DrawIconInternal() { - DVLOG(3) << "Drawing drag icon. size_px=" << size_px.ToString(); - wl::DrawBitmap(*icon_bitmap_, icon_buffer_.get()); - auto* const surface = icon_surface_->surface(); -+ if (wl::get_version_of_object(surface) < WL_SURFACE_OFFSET_SINCE_VERSION) { - wl_surface_attach(surface, icon_buffer_->get(), - pending_icon_offset_.x() - current_icon_offset_.x(), - pending_icon_offset_.y() - current_icon_offset_.y()); -+ } else { -+ wl_surface_attach(surface, icon_buffer_->get(), 0, 0); -+ wl_surface_offset(surface, -+ pending_icon_offset_.x() - current_icon_offset_.x(), -+ pending_icon_offset_.y() - current_icon_offset_.y()); -+ } - if (connection_->UseViewporterSurfaceScaling() && icon_surface_->viewport()) { - wp_viewport_set_destination(icon_surface_->viewport(), size_dip.width(), - size_dip.height()); -diff --git a/ui/ozone/platform/wayland/host/wayland_surface.cc b/ui/ozone/platform/wayland/host/wayland_surface.cc -index c94f30d2f57a0..b0b2701214da3 100644 ---- a/ui/ozone/platform/wayland/host/wayland_surface.cc -+++ b/ui/ozone/platform/wayland/host/wayland_surface.cc -@@ -387,6 +387,7 @@ void WaylandSurface::ApplyPendingState() { - // The logic in DamageBuffer currently relies on attachment coordinates of - // (0, 0). If this changes, then the calculation in DamageBuffer will also - // need to be updated. -+ // Note: should the offset be non-zero, use wl_surface_offset() to set it. - wl_surface_attach(surface_.get(), pending_state_.buffer, 0, 0); - - // Do not call GetOrCreateSurfaceSync() if the buffer management doesn't