Re: Assert in pageinspect with NULL pages
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Daria Lepikhova <d.lepikhova@postgrespro.ru>, pgsql-hackers@postgresql.org
Date: 2022-03-15T09:32:44Z
Lists: pgsql-hackers
Attachments
- 0001-Fixes-for-pageinspect-with-page-sizes.patch (text/x-diff) patch 0001
On Thu, Feb 17, 2022 at 09:00:20PM -0600, Justin Pryzby wrote: > BRIN can also crash if passed a non-brin index. > > I've been sitting on this one for awhile. Feel free to include it in your > patchset. So, I have begun a close lookup of this thread, and the problem you are reporting here is worth fixing on its own, before we do something for new pages as reported originally. There is more that caught my attention than the brin AM not being check properly, because a couple of code paths are fuzzy with the checks on the page sizes. My impression of the whole thing is that we'd better generalize the use of get_page_from_raw(), improving the code on many sides when the user can provide a raw page in input (also I'd like to think that it is a better practice anyway as any of those functions may finish to look 8-byte fields, but the current coding would silently break in alignment-picky environments): - Some code paths (hash, btree) would trigger elog(ERROR) but we cannot use that for errors that can be triggered by the user. - bt_page_items_bytea(), page_header() and fsm_page_contents() were fuzzy on the page size check, so it was rather easy to generate garbage with random data. - page_checksum_internal() used a PageHeader, where I would have expected a Page. - More consistency in the error strings, meaning less contents to translate in the long-term. This first batch leads me to the attached, with tests to stress all that for all the functions taking raw pages in input. -- Michael
Commits
-
pageinspect: Fix handling of all-zero pages
- 12d32b7bc151 10.21 landed
- 79fed072ba5f 11.16 landed
- 5378d55cb2f3 12.11 landed
- 2275d044d084 13.7 landed
- df6bbe73b86c 14.3 landed
- cd4868a5700f 15.0 landed
-
pageinspect: Add more sanity checks to prevent out-of-bound reads
- ab80b0fbbbc4 10.21 landed
- 1a2fdf86aae8 11.16 landed
- 5ca2aa2f26ea 12.11 landed
- 3d4d6dee0777 13.7 landed
- 27d384441851 14.3 landed
- 291e517a4dc9 15.0 landed
-
pageinspect: Fix handling of page sizes and AM types
- c42b88932b9d 10.21 landed
- 2389ee8dd800 11.16 landed
- af8a8eb54245 12.11 landed
- d3a9b83c30b6 13.7 landed
- b61e6214cfac 14.3 landed
- 076f4d9539e9 15.0 landed
-
Teach pageinspect about nbtree deduplication.
- 93ee38eade1b 13.0 cited