Title: Segmentation Fault in pthread_getcpuclockid function in time module · Issue #115378 · python/cpython · GitHub
Open Graph Title: Segmentation Fault in pthread_getcpuclockid function in time module · Issue #115378 · python/cpython
X Title: Segmentation Fault in pthread_getcpuclockid function in time module · Issue #115378 · python/cpython
Description: What happened? Version Python 3.13.0a3+ (heads/main:b3f0b698da, Feb 12 2024, 03:56:25) [GCC 11.4.0] bisect from commit e14679c Root Cause the time_pthread_getcpuclockid function retrieves an element from the user input. but improper vali...
Open Graph Description: What happened? Version Python 3.13.0a3+ (heads/main:b3f0b698da, Feb 12 2024, 03:56:25) [GCC 11.4.0] bisect from commit e14679c Root Cause the time_pthread_getcpuclockid function retrieves an elemen...
X Description: What happened? Version Python 3.13.0a3+ (heads/main:b3f0b698da, Feb 12 2024, 03:56:25) [GCC 11.4.0] bisect from commit e14679c Root Cause the time_pthread_getcpuclockid function retrieves an elemen...
Opengraph URL: https://github.com/python/cpython/issues/115378
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Segmentation Fault in pthread_getcpuclockid function in time module","articleBody":"### What happened?\r\n\r\n### Version\r\nPython 3.13.0a3+ (heads/main:b3f0b698da, Feb 12 2024, 03:56:25) [GCC 11.4.0]\r\nbisect from commit e14679c78464d1e0e16786c2a0e9bcebe49e842b\r\n\r\n### Root Cause\r\n\r\nthe time_pthread_getcpuclockid function retrieves an element from the user input. but improper validation of the thread id trigger segmentation fault\r\n\r\n\r\n```c\r\ntime_pthread_getcpuclockid(PyObject *self, PyObject *args)\r\n{\r\n unsigned long thread_id;\r\n int err;\r\n clockid_t clk_id;\r\n if (!PyArg_ParseTuple(args, \"k:pthread_getcpuclockid\", \u0026thread_id)) {\r\n return NULL;\r\n }\r\n err = pthread_getcpuclockid((pthread_t)thread_id, \u0026clk_id); // \u003c-- thread_id from args\r\n if (err) {\r\n errno = err;\r\n PyErr_SetFromErrno(PyExc_OSError);\r\n return NULL;\r\n }\r\n#ifdef _Py_MEMORY_SANITIZER\r\n __msan_unpoison(\u0026clk_id, sizeof(clk_id));\r\n#endif\r\n return PyLong_FromLong(clk_id);\r\n}\r\n```\r\n\r\n### POC\r\n\r\nimport time\r\ntime.pthread_getcpuclockid(-1)\r\n\r\n\r\n\u003cdetails\u003e\r\n \u003csummary\u003easan\u003c/summary\u003e\r\n\r\n```\r\nAddressSanitizer:DEADLYSIGNAL\r\n=================================================================\r\n==9985==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000002ce (pc 0x7f5176af3159 bp 0x7ffcb8437230 sp 0x7ffcb8437178 T0)\r\n==9985==The signal is caused by a READ memory access.\r\n==9985==Hint: address points to the zero page.\r\n #0 0x7f5176af3159 in __pthread_getcpuclockid nptl/pthread_getcpuclockid.c:32\r\n #1 0x564afa3983a1 in time_pthread_getcpuclockid Modules/timemodule.c:380\r\n #2 0x564af9eafacf in cfunction_call Objects/methodobject.c:551\r\n #3 0x564af9dc0393 in _PyObject_MakeTpCall Objects/call.c:242\r\n #4 0x564af9dc0a94 in _PyObject_VectorcallTstate Include/internal/pycore_call.h:166\r\n #5 0x564af9dc0ac0 in PyObject_Vectorcall Objects/call.c:327\r\n #6 0x564afa0cd313 in _PyEval_EvalFrameDefault Python/generated_cases.c.h:815\r\n #7 0x564afa11a855 in _PyEval_EvalFrame Include/internal/pycore_ceval.h:115\r\n #8 0x564afa11a855 in _PyEval_Vector Python/ceval.c:1788\r\n #9 0x564afa11aa76 in PyEval_EvalCode Python/ceval.c:592\r\n #10 0x564afa2245d9 in run_eval_code_obj Python/pythonrun.c:1294\r\n #11 0x564afa227522 in run_mod Python/pythonrun.c:1379\r\n #12 0x564afa228302 in pyrun_file Python/pythonrun.c:1215\r\n #13 0x564afa22a8f0 in _PyRun_SimpleFileObject Python/pythonrun.c:464\r\n #14 0x564afa22ac8c in _PyRun_AnyFileObject Python/pythonrun.c:77\r\n #15 0x564afa2872c0 in pymain_run_file_obj Modules/main.c:357\r\n #16 0x564afa289a71 in pymain_run_file Modules/main.c:376\r\n #17 0x564afa28a682 in pymain_run_python Modules/main.c:628\r\n #18 0x564afa28a812 in Py_RunMain Modules/main.c:707\r\n #19 0x564afa28a9f9 in pymain_main Modules/main.c:737\r\n #20 0x564afa28ad71 in Py_BytesMain Modules/main.c:761\r\n #21 0x564af9c24b05 in main Programs/python.c:15\r\n #22 0x7f5176a86d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58\r\n #23 0x7f5176a86e3f in __libc_start_main_impl ../csu/libc-start.c:392\r\n #24 0x564af9c24a34 in _start (/cpython/python+0x26fa34)\r\n\r\nAddressSanitizer can not provide additional info.\r\nSUMMARY: AddressSanitizer: SEGV nptl/pthread_getcpuclockid.c:32 in __pthread_getcpuclockid\r\n==9985==ABORTING\r\n```\r\n\r\n\r\n\u003c/details\u003e\r\n\r\n\r\n### CPython versions tested on:\r\n\r\nCPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\r\n\r\n### Output from running 'python -VV' on the command line:\r\n\r\nPython 3.13.0a3+ (heads/main:b3f0b698da, Feb 12 2024, 03:56:25) [GCC 11.4.0]","author":{"url":"https://github.com/kcatss","@type":"Person","name":"kcatss"},"datePublished":"2024-02-12T22:36:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/115378/cpython/issues/115378"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:9823535a-5c6b-cd6b-92ca-2d17a6613e92 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 97D6:225E33:838A00:B177C9:6969792B |
| html-safe-nonce | 17345331357d972fd5ec36766710cdaf003c3a40f748a5551f8c93327384c52d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5N0Q2OjIyNUUzMzo4MzhBMDA6QjE3N0M5OjY5Njk3OTJCIiwidmlzaXRvcl9pZCI6IjQ4NTA5MzcxNjkxMjQ2MjA1ODciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8c979a2b8d6257fc96b2f9b0f48431ca2212b127bdf7633edb1f118f3d15e94f |
| hovercard-subject-tag | issue:2131108087 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/115378/issue_layout |
| twitter:image | https://opengraph.githubassets.com/970da1d44aad38b94f6d4c6744d3b8b79f6c93b966f521d20ff904d49b4d37c2/python/cpython/issues/115378 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/970da1d44aad38b94f6d4c6744d3b8b79f6c93b966f521d20ff904d49b4d37c2/python/cpython/issues/115378 |
| og:image:alt | What happened? Version Python 3.13.0a3+ (heads/main:b3f0b698da, Feb 12 2024, 03:56:25) [GCC 11.4.0] bisect from commit e14679c Root Cause the time_pthread_getcpuclockid function retrieves an elemen... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kcatss |
| hostname | github.com |
| expected-hostname | github.com |
| None | c6f193beb8ff08443adc07685d75302ab8aaf0a135f6e251c3ff3112c8deb881 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 212e3e3d3298bf5b313830edfd2399e869f7ea76 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width