Skip to content

gh-103295: fix stack overwrite on 32-bit in perf map test harness - #104811

Merged
carljm merged 1 commit into
python:mainfrom
carljm:fixperfmaptest
May 23, 2023
Merged

gh-103295: fix stack overwrite on 32-bit in perf map test harness#104811
carljm merged 1 commit into
python:mainfrom
carljm:fixperfmaptest

Conversation

@carljm

@carljm carljm commented May 23, 2023

Copy link
Copy Markdown
Member

We can't use K format specifier in PyArg_ParseTuple to write to a void *; it always writes 64 bits, so writes too much on 32-bit systems. Use O instead and an explicit call to PyLong_AsVoidPtr to get the pointer value.

Also fix the error check so it detects either error code (-1 or -2) and raises a more informative error using errno. I verified this error handling by temporarily changing the perf map file path to a nonexistent directory, and the test raised FileNotFoundError as expected.

Also simplify the return value to just use PyLong_FromLong; we don't need to go through Py_BuildValue for such a simple case.

@carljm
carljm marked this pull request as ready for review May 23, 2023 19:40
@carljm
carljm requested a review from pablogsal May 23, 2023 19:41
@hroncok

ghost commented May 23, 2023

Copy link
Copy Markdown
Contributor

A Fedora build with this patch applied on top of 3.12.0b1 tarball.

https://koji.fedoraproject.org/koji/taskinfo?taskID=101500963

It is hopefully set up not to terminate the build immediately when one architecture fails. Let's see.

@carljm carljm added the needs backport to 3.12 only security fixes label May 23, 2023
@carljm

ghost commented May 23, 2023

Copy link
Copy Markdown
Member Author

Looks like the builds all succeeded 🎉

@hroncok

ghost commented May 23, 2023

Copy link
Copy Markdown
Contributor

A Fedora build with this patch applied on top of 3.12.0b1 tarball.

https://koji.fedoraproject.org/koji/taskinfo?taskID=101500963

All architectures built, tests have passed.

@carljm

ghost commented May 23, 2023

Copy link
Copy Markdown
Member Author

I'm going to go ahead and merge this to help unblock the Fedora builds, since this PR only touches test harness and the test signal is all good (including the Fedora build signal on multiple platforms, including 32-bit.)

If there are any concerns with anything here, I'll be happy to do a follow-up PR to address comments.

@carljm
carljm merged commit e0b3078 into python:main May 23, 2023
@miss-islington

ghost commented May 23, 2023

Copy link
Copy Markdown
Contributor

Thanks @carljm for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@carljm
carljm deleted the fixperfmaptest branch May 23, 2023 22:04
@bedevere-bot

ghost commented May 23, 2023

Copy link
Copy Markdown

GH-104823 is a backport of this pull request to the 3.12 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants