platform/surface: aggregator_tabletsw: accept zero-padded source-list responses - #173
Open
zR-JB wants to merge 1 commit into
Open
platform/surface: aggregator_tabletsw: accept zero-padded source-list responses#173zR-JB wants to merge 1 commit into
zR-JB wants to merge 1 commit into
Conversation
zR-JB
marked this pull request as ready for review
August 12, 2026 21:13
… responses Some Surface firmware returns a fixed-size POS source-list response with unused bytes zero-filled instead of returning only the bytes described by the source count. On the Surface Pro 12 Intel, the POS source-list command returns 24 bytes with count 1, source ID 0 for the Type Cover, and all remaining 16 bytes set to zero. The current parser only provides 20 bytes of response capacity and requires the response length to exactly match 4 + count * 4, so the POS tablet-mode client fails to probe. Provide space for the observed additional trailing word and allow trailing response data only when it is entirely zero. Also validate the source count against the fixed source array before calculating the expected payload size. Exact-length responses remain accepted unchanged. Short responses, source counts larger than the available array, and non-zero trailing data continue to fail with -EPROTO. This allows the Surface Pro 12 POS tablet-mode client to bind while keeping the parser bounded and rejecting unexpected response data. Link: linux-surface/linux-surface#2144 (comment) Signed-off-by: Jan Baisch <jan.baisch@protonmail.com> Link: linux-surface#173 Patchset: surface-sam
zR-JB
force-pushed
the
ssam-pos-zero-padding
branch
from
August 12, 2026 21:37
45513b6 to
51b3d8d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow the Surface Aggregator POS source-list parser to accept bounded, zero-filled trailing response data.
The Surface Pro 12 for Business Intel provides a reproducer (In combination with Flex Keyboard). Its POS source-list command returns a 24-byte response:
This describes one Type-Cover posture source. The additional bytes are zero-filled trailing data, not additional posture sources.
The current driver requires the response length to exactly equal:
and its source-list response buffer is only 20 bytes.
As a result, the POS/tablet-mode client fails to probe on the SP12.
Proposed handling
This PR:
four-entry source array;
The resulting validation is effectively:
So this does not generally relax response validation.
The following continue to be rejected:
count;Existing exact-length responses continue to be accepted unchanged.
Why add four bytes to the response structure?
The existing structure contains:
and is also used directly as the response buffer:
The SP12 returns 24 bytes, so validating trailing data alone is not sufficient: the response buffer must first be large enough to receive the complete response.
An additional four-byte padding field raises the maximum accepted response size to 24 bytes.
For the observed SP12 response with
count = 1, the semantic payload is 8 bytes and all 16 bytes after it are verified to be zero.Surface Pro 12 reproducer
Tested on:
Before this change the SSAM POS/tablet-mode client failed during probe.
The SP12 firmware response was observed as:
With this patch:
surface_aggregator_tabletswbinds normally at boot;Microsoft Surface POS Tablet Mode Switchis created;EV_SW/SW_TABLET_MODE.Physical testing produced:
The full SP12 investigation is documented here:
linux-surface/linux-surface#2144 (comment)
Testing / review scope
The exact patch in this PR has already been runtime-tested on the SP12.
It has also been compile-tested against
v6.19-surface-develusing the current linux-surface Arch kernel configuration.Because this changes the generic SSAM POS source-list parser rather than adding an SP12-specific device quirk, testing on other devices using the POS tablet-mode implementation would be useful.
In particular I would like to confirm that existing exact-length responses continue to behave unchanged.
Surface Pro 12 enablement
This is one independently reviewable part of the broader Surface Pro 12
Intel enablement work:
linux-surface/linux-surface#2144
Related draft PRs: