Skip to content

extmod/modbtree: Add checks for already-closed database. #12949

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

Merged
merged 1 commit into from
Jul 22, 2024

Conversation

BottleRocketeer
Copy link
Contributor

Fixes use-after-free when accessing the database after it is closed
with btree_close. btree_close always succeeds when called with
an already-closed database.

Fixes issue #12543.

Copy link

github-actions bot commented Nov 12, 2023

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:  +176 +0.021% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS

Copy link

codecov bot commented Nov 12, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.42%. Comparing base (8159dcc) to head (6db91df).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #12949   +/-   ##
=======================================
  Coverage   98.42%   98.42%           
=======================================
  Files         161      161           
  Lines       21252    21266   +14     
=======================================
+ Hits        20918    20932   +14     
  Misses        334      334           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stinos
Copy link
Contributor

stinos commented Nov 12, 2023

Can you add a test showing this check works?

@dpgeorge dpgeorge added the extmod Relates to extmod/ directory in source label Feb 14, 2024
@projectgus
Copy link
Contributor

This is an automated heads-up that we've just merged a Pull Request
that removes the STATIC macro from MicroPython's C API.

See #13763

A search suggests this PR might apply the STATIC macro to some C code. If it
does, then next time you rebase the PR (or merge from master) then you should
please replace all the STATIC keywords with static.

Although this is an automated message, feel free to @-reply to me directly if
you have any questions about this.

Fixes use-after-free when accessing the database after it is closed with
`btree_close`.  `btree_close` always succeeds when called with an
already-closed database.

The new test checks that operations that access the underlying database
(get, set, flush, seq) fail with a `ValueError` when the btree is already
closed.  It also checks that closing and printing the btree succeed when
the btree is already closed.

Fixes issue micropython#12543.

Signed-off-by: Michael Vornovitsky <michaelvornovitskiy@outlook.com>
@dpgeorge dpgeorge force-pushed the btree-use-after-free branch from f2f58a5 to 6db91df Compare July 22, 2024 00:43
@dpgeorge dpgeorge merged commit 6db91df into micropython:master Jul 22, 2024
62 checks passed
@dpgeorge
Copy link
Member

Thanks for adding the test, it looks good.

Rebased and merged.

@dpgeorge dpgeorge mentioned this pull request Sep 16, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extmod Relates to extmod/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants