8000 GH-85724: Ignore the MAC from the Touch Bar interface on macOS in uuid by ronaldoussoren · Pull Request #99717 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-85724: Ignore the MAC from the Touch Ba 8000 r interface on macOS in uuid #99717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ronaldoussoren
Copy link
Contributor
@ronaldoussoren ronaldoussoren commented Nov 23, 2022

All Intel MacBook Pro devices with a Touch Bar have a network interface connected to a controller for that device that has the same MAC address for all MacBooks.

Ignore these MAC adresses in the UUID library.

…in uuid

All Intel MacBook Pro devices with a Touch Bar have a network
interface connected to a controller for that device that has
the same MAC address for all MacBooks.

Ignore these MAC adresses in the UUID library.
@ronaldoussoren
Copy link
Contributor Author

One thing I haven't seriously looked into yet is how to include tests for my changes, other than a trivial change to test_uuid that will ensure tests fail on an affected device without the changes to uuid.py.

I have manually checked that uuid.uuid1() does not use the MAC address for the Touch Bar interface on an affected device.

@ronaldoussoren ronaldoussoren requested review from vstinner and a team November 23, 2022 10:41
1. Remove the "BLACKLIST" variable as it is both lazy naming
   not necessary

2. Be more explicit in tests

3. Add test that checks that the mac touchbar mac is
   actually ignored.
@@ -581,6 +589,18 @@ def _netbios_getnode():
_generate_time_safe = getattr(_uuid, "generate_time_safe", None)
_UuidCreate = getattr(_uuid, "UuidCreate", None)
_has_uuid_generate_time_safe = _uuid.has_uuid_generate_time_safe

if sys.platform == "darwin" and _generate_time_safe is not None:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure about this test, and in particular not about the test for "darwin".

There are people running Linux on Apple hardware and I don't know if those could be affected by this issue, in particular if there is a driver that exposes a ethernet-like interface to the Touch Bar hardware.

_x = _generate_time_safe()[0]
if _x.endswith(bytes.fromhex(_MACOS_TOUCHBAR_MAC.replace(":", ""))):
_has_uuid_generate_time_safe = False
_generate_time_safe = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense/be possible to implement this test directly in the _uuid module: remove the function if it returns this address?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... Possible yes, sensible maybe not.

The implementation of _uuid.generate_time_safe has 3 or 4 variants (depending on how you count) and because of that an implementation in C mirrors the Python code above but is more verbose and likely not faster than the Python implementation.

I have a patch, but haven't tested it on a device with a Touch Bar yet. That patch adds 49 lines of code to _uuidmodule.c and removes the 4 lines of python code above.

@hugovk hugovk removed the needs backport to 3.10 only security fixes label Apr 7, 2023
@serhiy-storchaka serhiy-storchaka added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes and removed needs backport to 3.11 only security fixes labels May 9, 2024
@serhiy-storchaka serhiy-storchaka added the needs backport to 3.14 bugs and security fixes label May 8, 2025
@ZeroIntensity ZeroIntensity removed the needs backport to 3.12 only security fixes label May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0