pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15312: Possible access to unintended variable in "postgres/src/backend/postmaster/pgstat.c" line 2698
3+ messages / 3 participants
[nested] [flat]

* BUG #15312: Possible access to unintended variable in "postgres/src/backend/postmaster/pgstat.c" line 2698
@ 2018-08-07 10:52  PG Bug reporting form <noreply@postgresql.org>
  0 siblings, 2 replies; 3+ messages in thread

From: PG Bug reporting form @ 2018-08-07 10:52 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: petrum@gmail.com

The following bug has been logged on the website:

Bug reference:      15312
Logged by:          Petru-Florin Mihancea
Email address:      petrum@gmail.com
PostgreSQL version: Unsupported/Unknown
Operating system:   Macosx
Description:        

While experimenting with a CodeSonar plugin we develop, we noticed a
potential bug in file "postgres/src/backend/postmaster/pgstat.c" line 2698
function CreateSharedBackendStatus.

/* Create or attach to the shared activity buffer */
BackendActivityBufferSize = mul_size(pgstat_track_activity_query_size,
									 NumBackendStatSlots);
BackendActivityBuffer = (char *)
	ShmemInitStruct("Backend Activity Buffer",
					BackendActivityBufferSize,
					&found);
if (!found)
{
	MemSet(BackendActivityBuffer, 0, size); //HERE

	/* Initialize st_activity pointers. */
	buffer = BackendActivityBuffer;
	for (i = 0; i < NumBackendStatSlots; i++)
	{
		BackendStatusArray[i].st_activity_raw = buffer;
		buffer += pgstat_track_activity_query_size;
	}
}

Shouldn't BackendActivityBufferSize be accessed in the marked line instead
of size? 

Thanks,
Petru Florin Mihancea



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #15312: Possible access to unintended variable in "postgres/src/backend/postmaster/pgstat.c" line 2698
@ 2018-08-07 15:31  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 0 replies; 3+ messages in thread

From: Alvaro Herrera @ 2018-08-07 15:31 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: petrum@gmail.com, Robert Haas <robertmhaas@gmail.com>; Marti Raudsepp <marti@juffo.org>

On 2018-Aug-07, PG Bug reporting form wrote:

> While experimenting with a CodeSonar plugin we develop, we noticed a
> potential bug in file "postgres/src/backend/postmaster/pgstat.c" line 2698
> function CreateSharedBackendStatus.

Hmm, yeah this is a bug, introduced by commit c8e8b5a6e20b AFAICS.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: BUG #15312: Possible access to unintended variable in "postgres/src/backend/postmaster/pgstat.c" line 2698
@ 2018-08-07 18:45  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Bug reporting form <noreply@postgresql.org>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2018-08-07 18:45 UTC (permalink / raw)
  To: petrum@gmail.com; +Cc: pgsql-bugs@lists.postgresql.org

=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> 	MemSet(BackendActivityBuffer, 0, size); //HERE

> Shouldn't BackendActivityBufferSize be accessed in the marked line instead
> of size? 

Yeah, I think you're right --- looks like a pretty obvious copy-and-paste
oversight.  It's probably harmless as long as
pgstat_track_activity_query_size is at least NAMEDATALEN, but it's
not good.

Thanks for reporting that!

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2018-08-07 18:45 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-07 10:52 BUG #15312: Possible access to unintended variable in "postgres/src/backend/postmaster/pgstat.c" line 2698 PG Bug reporting form <noreply@postgresql.org>
2018-08-07 15:31 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2018-08-07 18:45 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox