[iOS] WebGL leaks exact GPU type
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2018 21:12:55 +0000 (21:12 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Nov 2018 21:12:55 +0000 (21:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191393
Source/WebCore:

Reviewed by Tim Horton.

The fully exposed renderer info shouldn't be necessary
on iOS, where the GPUs and drivers are consistent
enough that people shouldn't need to write code specifically
for them. Reduce the ability to fingerprint by simply
returning "Apple GPU".

The other option would have been to disable the extension,
but I think it might still be useful to know you're on
an iOS device.

Test: fast/canvas/webgl/hide-some-renderer-info.html

* html/canvas/WebGL2RenderingContext.cpp: Return "Apple GPU"
on iOS.
(WebCore::WebGL2RenderingContext::getParameter):
* html/canvas/WebGLRenderingContext.cpp: Ditto.
(WebCore::WebGLRenderingContext::getParameter):

LayoutTests:

<rdar://problem/45788297>

Reviewed by Tim Horton.

A test that checks that when the GPU vendor is Apple we're
returning a generic renderer name.

* fast/canvas/webgl/hide-some-renderer-info-expected.txt: Added.
* fast/canvas/webgl/hide-some-renderer-info.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237940 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/canvas/webgl/hide-some-renderer-info-expected.txt [new file with mode: 0644]
LayoutTests/fast/canvas/webgl/hide-some-renderer-info.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/html/canvas/WebGL2RenderingContext.cpp
Source/WebCore/html/canvas/WebGLRenderingContext.cpp

index 2e06d1a..38e6b37 100644 (file)
@@ -1,3 +1,17 @@
+2018-11-07  Dean Jackson  <dino@apple.com>
+
+        [iOS] WebGL leaks exact GPU type
+        https://bugs.webkit.org/show_bug.cgi?id=191393
+        <rdar://problem/45788297>
+
+        Reviewed by Tim Horton.
+
+        A test that checks that when the GPU vendor is Apple we're
+        returning a generic renderer name.
+
+        * fast/canvas/webgl/hide-some-renderer-info-expected.txt: Added.
+        * fast/canvas/webgl/hide-some-renderer-info.html: Added.
+
 2018-11-07  Ali Juma  <ajuma@chromium.org>
 
         IntersectionObserver GC-dependent tests are flaky
diff --git a/LayoutTests/fast/canvas/webgl/hide-some-renderer-info-expected.txt b/LayoutTests/fast/canvas/webgl/hide-some-renderer-info-expected.txt
new file mode 100644 (file)
index 0000000..9f6dd61
--- /dev/null
@@ -0,0 +1,3 @@
+PASS: Renderer was appropriately hidden for WebGL 1.
+PASS: Renderer was appropriately hidden for WebGL 2.
+
diff --git a/LayoutTests/fast/canvas/webgl/hide-some-renderer-info.html b/LayoutTests/fast/canvas/webgl/hide-some-renderer-info.html
new file mode 100644 (file)
index 0000000..054a132
--- /dev/null
@@ -0,0 +1,57 @@
+<!DOCTYPE html><!-- webkit-test-runner [ experimental:WebGL2Enabled=true ] -->
+<html>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+const debug = (msg) => {
+    const p = document.querySelector("p");
+    p.appendChild(document.createTextNode(msg));
+    p.appendChild(document.createElement("br"));
+}
+
+window.addEventListener("load", () => {
+    let canvas = document.createElement("canvas");
+    let gl = canvas.getContext("webgl");
+
+    let ext = gl.getExtension("WEBGL_debug_renderer_info");
+
+    if (!ext) {
+        debug("WebGL1: WEBGL_debug_renderer_info not available");
+        return;
+    }
+
+    let vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
+    let renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
+    if (vendor.includes("Apple") && renderer != "Apple GPU")
+        debug("FAIL: Renderer was not appropriately hidden for WebGL 1.")
+     else
+        debug("PASS: Renderer was appropriately hidden for WebGL 1.")
+
+    canvas = document.createElement("canvas");
+    gl = canvas.getContext("webgl2");
+
+    if (!gl) {
+        debug("WebGL2: Not available");
+        return;
+    }
+
+    ext = gl.getExtension("WEBGL_debug_renderer_info");
+
+    if (!ext) {
+        debug("WebGL2: WEBGL_debug_renderer_info not available");
+        return;
+    }
+
+    vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
+    renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
+    if (vendor.includes("Apple") && renderer != "Apple GPU")
+        debug("FAIL: Renderer was not appropriately hidden for WebGL 2.")
+     else
+        debug("PASS: Renderer was appropriately hidden for WebGL 2.")
+
+}, false);
+</script>
+<p>
+</p>
+</html>
\ No newline at end of file
index fbe4fd8..427c498 100644 (file)
@@ -1,3 +1,28 @@
+2018-11-07  Dean Jackson  <dino@apple.com>
+
+        [iOS] WebGL leaks exact GPU type
+        https://bugs.webkit.org/show_bug.cgi?id=191393
+
+        Reviewed by Tim Horton.
+
+        The fully exposed renderer info shouldn't be necessary
+        on iOS, where the GPUs and drivers are consistent
+        enough that people shouldn't need to write code specifically
+        for them. Reduce the ability to fingerprint by simply
+        returning "Apple GPU".
+
+        The other option would have been to disable the extension,
+        but I think it might still be useful to know you're on
+        an iOS device.
+
+        Test: fast/canvas/webgl/hide-some-renderer-info.html
+
+        * html/canvas/WebGL2RenderingContext.cpp: Return "Apple GPU"
+        on iOS.
+        (WebCore::WebGL2RenderingContext::getParameter):
+        * html/canvas/WebGLRenderingContext.cpp: Ditto.
+        (WebCore::WebGLRenderingContext::getParameter):
+
 2018-11-07  Daniel Bates  <dabates@apple.com>
 
         Override +[UIKeyboard isInHardwareKeyboardMode] in WebKitTestRunner and DumpRenderTree
index 48c31bc..b56eca5 100644 (file)
@@ -1936,14 +1936,19 @@ WebGLAny WebGL2RenderingContext::getParameter(GC3Denum pname)
     case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL:
         return m_unpackColorspaceConversion;
     case GraphicsContext3D::VENDOR:
-        return String { "WebKit"_s };
+        return String { "WebKit" };
     case GraphicsContext3D::VERSION:
         return String { "WebGL 2.0" };
     case GraphicsContext3D::VIEWPORT:
         return getWebGLIntArrayParameter(pname);
     case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL:
-        if (m_webglDebugRendererInfo)
+        if (m_webglDebugRendererInfo) {
+#if PLATFORM(IOS_FAMILY)
+            return String { "Apple GPU" };
+#else
             return m_context->getString(GraphicsContext3D::RENDERER);
+#endif
+        }
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "invalid parameter name, WEBGL_debug_renderer_info not enabled");
         return nullptr;
     case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL:
index daab79e..fbcc663 100644 (file)
@@ -586,7 +586,7 @@ WebGLAny WebGLRenderingContext::getParameter(GC3Denum pname)
     case GraphicsContext3D::UNPACK_COLORSPACE_CONVERSION_WEBGL:
         return m_unpackColorspaceConversion;
     case GraphicsContext3D::VENDOR:
-        return String { "WebKit"_s };
+        return String { "WebKit" };
     case GraphicsContext3D::VERSION:
         return String { "WebGL 1.0" };
     case GraphicsContext3D::VIEWPORT:
@@ -597,8 +597,13 @@ WebGLAny WebGLRenderingContext::getParameter(GC3Denum pname)
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "invalid parameter name, OES_standard_derivatives not enabled");
         return nullptr;
     case WebGLDebugRendererInfo::UNMASKED_RENDERER_WEBGL:
-        if (m_webglDebugRendererInfo)
+        if (m_webglDebugRendererInfo) {
+#if PLATFORM(IOS_FAMILY)
+            return String { "Apple GPU" };
+#else
             return m_context->getString(GraphicsContext3D::RENDERER);
+#endif
+        }
         synthesizeGLError(GraphicsContext3D::INVALID_ENUM, "getParameter", "invalid parameter name, WEBGL_debug_renderer_info not enabled");
         return nullptr;
     case WebGLDebugRendererInfo::UNMASKED_VENDOR_WEBGL: