1. 18 Feb, 2014 3 commits
    • Tom Lane's avatar
      Remove broken code that tried to handle OVERLAPS with a single argument. · a222f7fd
      Tom Lane authored
      The SQL standard says that OVERLAPS should have a two-element row
      constructor on each side.  The original coding of OVERLAPS support in
      our grammar attempted to extend that by allowing a single-element row
      constructor, which it internally duplicated ... or tried to, anyway.
      But that code has certainly not worked since our List infrastructure was
      rewritten in 2004, and I'm none too sure it worked before that.  As it
      stands, it ends up building a List that includes itself, leading to
      assorted undesirable behaviors later in the parser.
      
      Even if it worked as intended, it'd be a bit evil because of the
      possibility of duplicate evaluation of a volatile function that the user
      had written only once.  Given the lack of documentation, test cases, or
      complaints, let's just get rid of the idea and only support the standard
      syntax.
      
      While we're at it, improve the error cursor positioning for the
      wrong-number-of-arguments errors, and inline the makeOverlaps() function
      since it's only called in one place anyway.
      
      Per bug #9227 from Joshua Yanovski.  Initial patch by Joshua Yanovski,
      extended a bit by me.
      a222f7fd
    • Magnus Hagander's avatar
      Disable RandomizedBaseAddress on MSVC builds · 7f3e17b4
      Magnus Hagander authored
      The ASLR in Windows 8/Windows 2012 can break PostgreSQL's shared memory. It
      doesn't fail every time (which is explained by the Random part in ASLR), but
      can fail with errors abut failing to reserve shared memory region.
      
      MauMau, reviewed by Craig Ringer
      7f3e17b4
    • Heikki Linnakangas's avatar
  2. 17 Feb, 2014 14 commits
    • Tom Lane's avatar
      Last-minute updates for release notes. · 7b1fab3f
      Tom Lane authored
      Add entries for security issues.
      
      Security: CVE-2014-0060 through CVE-2014-0067
      7b1fab3f
    • Robert Haas's avatar
      Fix capitalization in README. · 876f78d5
      Robert Haas authored
      Vik Fearing
      876f78d5
    • Tom Lane's avatar
      Improve documentation about multixact IDs. · e7f40975
      Tom Lane authored
      Per gripe from Josh Berkus.
      e7f40975
    • Tom Lane's avatar
      Document risks of "make check" in the regression testing instructions. · 6ef32542
      Tom Lane authored
      Since the temporary server started by "make check" uses "trust"
      authentication, another user on the same machine could connect to it
      as database superuser, and then potentially exploit the privileges of
      the operating-system user who started the tests.  We should change
      the testing procedures to prevent this risk; but discussion is required
      about the best way to do that, as well as more testing than is practical
      for an undisclosed security problem.  Besides, the same issue probably
      affects some user-written test harnesses.  So for the moment, we'll just
      warn people against using "make check" when there are untrusted users on
      the same machine.
      
      In passing, remove some ancient advice that suggested making the
      regression testing subtree world-writable if you'd built as root.
      That looks dangerously insecure in modern contexts, and anyway we
      should not be encouraging people to build Postgres as root.
      
      Security: CVE-2014-0067
      6ef32542
    • Tom Lane's avatar
      Prevent potential overruns of fixed-size buffers. · 01824385
      Tom Lane authored
      Coverity identified a number of places in which it couldn't prove that a
      string being copied into a fixed-size buffer would fit.  We believe that
      most, perhaps all of these are in fact safe, or are copying data that is
      coming from a trusted source so that any overrun is not really a security
      issue.  Nonetheless it seems prudent to forestall any risk by using
      strlcpy() and similar functions.
      
      Fixes by Peter Eisentraut and Jozef Mlich based on Coverity reports.
      
      In addition, fix a potential null-pointer-dereference crash in
      contrib/chkpass.  The crypt(3) function is defined to return NULL on
      failure, but chkpass.c didn't check for that before using the result.
      The main practical case in which this could be an issue is if libc is
      configured to refuse to execute unapproved hashing algorithms (e.g.,
      "FIPS mode").  This ideally should've been a separate commit, but
      since it touches code adjacent to one of the buffer overrun changes,
      I included it in this commit to avoid last-minute merge issues.
      This issue was reported by Honza Horak.
      
      Security: CVE-2014-0065 for buffer overruns, CVE-2014-0066 for crypt()
      01824385
    • Noah Misch's avatar
      Predict integer overflow to avoid buffer overruns. · 31400a67
      Noah Misch authored
      Several functions, mostly type input functions, calculated an allocation
      size such that the calculation wrapped to a small positive value when
      arguments implied a sufficiently-large requirement.  Writes past the end
      of the inadvertent small allocation followed shortly thereafter.
      Coverity identified the path_in() vulnerability; code inspection led to
      the rest.  In passing, add check_stack_depth() to prevent stack overflow
      in related functions.
      
      Back-patch to 8.4 (all supported versions).  The non-comment hstore
      changes touch code that did not exist in 8.4, so that part stops at 9.0.
      
      Noah Misch and Heikki Linnakangas, reviewed by Tom Lane.
      
      Security: CVE-2014-0064
      31400a67
    • Noah Misch's avatar
      Fix handling of wide datetime input/output. · 4318daec
      Noah Misch authored
      Many server functions use the MAXDATELEN constant to size a buffer for
      parsing or displaying a datetime value.  It was much too small for the
      longest possible interval output and slightly too small for certain
      valid timestamp input, particularly input with a long timezone name.
      The long input was rejected needlessly; the long output caused
      interval_out() to overrun its buffer.  ECPG's pgtypes library has a copy
      of the vulnerable functions, which bore the same vulnerabilities along
      with some of its own.  In contrast to the server, certain long inputs
      caused stack overflow rather than failing cleanly.  Back-patch to 8.4
      (all supported versions).
      
      Reported by Daniel Schüssler, reviewed by Tom Lane.
      
      Security: CVE-2014-0063
      4318daec
    • Robert Haas's avatar
      Avoid repeated name lookups during table and index DDL. · 5f173040
      Robert Haas authored
      If the name lookups come to different conclusions due to concurrent
      activity, we might perform some parts of the DDL on a different table
      than other parts.  At least in the case of CREATE INDEX, this can be
      used to cause the permissions checks to be performed against a
      different table than the index creation, allowing for a privilege
      escalation attack.
      
      This changes the calling convention for DefineIndex, CreateTrigger,
      transformIndexStmt, transformAlterTableStmt, CheckIndexCompatible
      (in 9.2 and newer), and AlterTable (in 9.1 and older).  In addition,
      CheckRelationOwnership is removed in 9.2 and newer and the calling
      convention is changed in older branches.  A field has also been added
      to the Constraint node (FkConstraint in 8.4).  Third-party code calling
      these functions or using the Constraint node will require updating.
      
      Report by Andres Freund.  Patch by Robert Haas and Andres Freund,
      reviewed by Tom Lane.
      
      Security: CVE-2014-0062
      5f173040
    • Noah Misch's avatar
      Document security implications of check_function_bodies. · 540b4e5b
      Noah Misch authored
      Back-patch to 8.4 (all supported versions).
      540b4e5b
    • Noah Misch's avatar
      Prevent privilege escalation in explicit calls to PL validators. · 537cbd35
      Noah Misch authored
      The primary role of PL validators is to be called implicitly during
      CREATE FUNCTION, but they are also normal functions that a user can call
      explicitly.  Add a permissions check to each validator to ensure that a
      user cannot use explicit validator calls to achieve things he could not
      otherwise achieve.  Back-patch to 8.4 (all supported versions).
      Non-core procedural language extensions ought to make the same two-line
      change to their own validators.
      
      Andres Freund, reviewed by Tom Lane and Noah Misch.
      
      Security: CVE-2014-0061
      537cbd35
    • Noah Misch's avatar
      Shore up ADMIN OPTION restrictions. · fea164a7
      Noah Misch authored
      Granting a role without ADMIN OPTION is supposed to prevent the grantee
      from adding or removing members from the granted role.  Issuing SET ROLE
      before the GRANT bypassed that, because the role itself had an implicit
      right to add or remove members.  Plug that hole by recognizing that
      implicit right only when the session user matches the current role.
      Additionally, do not recognize it during a security-restricted operation
      or during execution of a SECURITY DEFINER function.  The restriction on
      SECURITY DEFINER is not security-critical.  However, it seems best for a
      user testing his own SECURITY DEFINER function to see the same behavior
      others will see.  Back-patch to 8.4 (all supported versions).
      
      The SQL standards do not conflate roles and users as PostgreSQL does;
      only SQL roles have members, and only SQL users initiate sessions.  An
      application using PostgreSQL users and roles as SQL users and roles will
      never attempt to grant membership in the role that is the session user,
      so the implicit right to add or remove members will never arise.
      
      The security impact was mostly that a role member could revoke access
      from others, contrary to the wishes of his own grantor.  Unapproved role
      member additions are less notable, because the member can still largely
      achieve that by creating a view or a SECURITY DEFINER function.
      
      Reviewed by Andres Freund and Tom Lane.  Reported, independently, by
      Jonas Sundman and Noah Misch.
      
      Security: CVE-2014-0060
      fea164a7
    • Tom Lane's avatar
      0983315b
    • Tom Lane's avatar
      PGDLLIMPORT-ify MainLWLockArray, ProcDiePending, proc_exit_inprogress. · fa1f0d78
      Tom Lane authored
      These are needed in HEAD to make assorted contrib modules build on Windows.
      Now that all the MSVC and Mingw buildfarm members seem to be on the same
      page about the need for them, we can have some confidence that future
      problems of this ilk will be detected promptly; there seems nothing more
      to be learned by delaying this fix further.
      
      I chose to mark QueryCancelPending as well, since it's easy to imagine code
      that wants to touch ProcDiePending also caring about QueryCancelPending.
      fa1f0d78
    • Tom Lane's avatar
      Fix unportable coding in tarCreateHeader(). · a1c80271
      Tom Lane authored
      uid_t and gid_t might be wider than int on some platforms.
      Per buildfarm member brolga.
      a1c80271
  3. 16 Feb, 2014 6 commits
    • Tom Lane's avatar
      Revert to using --enable-auto-import in Cygwin builds. · 8d6e2d4a
      Tom Lane authored
      Disabling auto-import requires that all libraries we use be careful about
      declspecs for exported variables; and it seems they aren't.  This means
      that Cygwin will not give us useful info about missing PGDLLIMPORT markers;
      but it's probably sufficient that MSVC and Mingw builds do.
      8d6e2d4a
    • Tom Lane's avatar
      Further wordsmithing on 9.3.3 release notes. · 734ff84b
      Tom Lane authored
      No substantive changes, but reorder some items and improve some
      descriptions.
      734ff84b
    • Tom Lane's avatar
      PGDLLIMPORT'ify DateStyle and IntervalStyle. · a5cf6068
      Tom Lane authored
      This is needed on Windows to support contrib/postgres_fdw.  Although it's
      been broken since last March, we didn't notice until recently because there
      were no active buildfarm members that complained about missing PGDLLIMPORT
      marking.  Efforts are underway to improve that situation, in support of
      which we're delaying fixing some other cases of global variables that
      should be marked PGDLLIMPORT.  However, this case affects 9.3, so we
      can't wait any longer to fix it.
      
      I chose to mark DateOrder as well, though it's not strictly necessary
      for postgres_fdw.
      a5cf6068
    • Tom Lane's avatar
      Improve release notes per comments from Andres Freund. · 8fd994e4
      Tom Lane authored
      Make a bit more noise about the timeout-interrupt bug.  Also, remove the
      release note entry for commit 423e1211; that patch fixed a problem
      introduced post-9.3.2, so there's no need to document it in the release
      notes.
      8fd994e4
    • Tom Lane's avatar
      On Windows, expect to find Tcl DLL in bin directory not lib directory. · 56caaf19
      Tom Lane authored
      Still another step in the continuing saga of trying to get
      --disable-auto-import to work.
      
      Hiroshi Inoue
      56caaf19
    • Tom Lane's avatar
      First-draft release notes for 9.3.3. · cefd3e50
      Tom Lane authored
      As usual, the release notes for older branches will be made by cutting
      these down, but put them up for community review first.
      cefd3e50
  4. 15 Feb, 2014 7 commits
  5. 14 Feb, 2014 9 commits
    • Tom Lane's avatar
      Fix fat-fingered makefile changes for pltcl. · 638b153f
      Tom Lane authored
      I put the OBJS assignments in the wrong order.  Per buildfarm.
      638b153f
    • Tom Lane's avatar
      Update regression testing instructions. · 2128c52f
      Tom Lane authored
      This documentation never got the word about the existence of check-world or
      installcheck-world.  Revise to recommend use of those, and document all the
      subsidiary test suites.  Do some minor wordsmithing elsewhere, too.
      
      In passing, remove markup related to generation of plain-text regression
      test instructions, since we don't do that anymore.
      
      Back-patch to 9.1 where check-world was added.  (installcheck-world exists
      in 9.0; but since check-world doesn't, this patch would need additional
      work to cover that branch, and it doesn't seem worth the effort.)
      2128c52f
    • Tom Lane's avatar
      In mingw builds, make our own import library for libtcl, too. · dcbf3977
      Tom Lane authored
      Per buildfarm results.
      dcbf3977
    • Tom Lane's avatar
      Suggest shell here-documents instead of psql -c for multiple commands. · 1ea081bb
      Tom Lane authored
      The documentation suggested using "echo | psql", but not the often-superior
      alternative of a here-document.  Also, be more direct about suggesting
      that people avoid -c for multiple commands.  Per discussion.
      1ea081bb
    • Tom Lane's avatar
      In mingw builds, make our own import library for libperl. · 02b61dd0
      Tom Lane authored
      Borrow the method already used by plpython.  This is pretty ugly, but
      it might fix the build failure exhibited by buildfarm member narwhal
      since commit 846e91e0.
      
      Hiroshi Inoue
      02b61dd0
    • Tom Lane's avatar
      Cosmetic improvements in plpython's make rule for libpython import library. · a7983e98
      Tom Lane authored
      This build technique is remarkably ugly, but that doesn't mean it has
      to be unreadable too.  Be a bit more liberal with the vertical whitespace,
      and give the .def file a proper dependency, just in case.
      a7983e98
    • Heikki Linnakangas's avatar
      Change the order that pg_xlog and WAL archive are polled for WAL segments. · 4d894b41
      Heikki Linnakangas authored
      If there is a WAL segment with same ID but different TLI present in both
      the WAL archive and pg_xlog, prefer the one with higher TLI. Before this
      patch, the archive was polled first, for all expected TLIs, and only if no
      file was found was pg_xlog scanned. This was a change in behavior from 9.3,
      which first scanned archive and pg_xlog for the highest TLI, then archive
      and pg_xlog for the next highest TLI and so forth. This patch reverts the
      behavior back to what it was in 9.2.
      
      The reason for this is that if for example you try to do archive recovery
      to timeline 2, which branched off timeline 1, but the WAL for timeline 2 is
      not archived yet, we would replay past the timeline switch point on
      timeline 1 using the archived files, before even looking timeline 2's files
      in pg_xlog
      
      Report and patch by Kyotaro Horiguchi. Backpatch to 9.3 where the behavior
      was changed.
      4d894b41
    • Peter Eisentraut's avatar
      Fix typo · 0f2ca007
      Peter Eisentraut authored
      Stefan Kaltenbrunner
      0f2ca007
    • Bruce Momjian's avatar
      9c57d11f
  6. 13 Feb, 2014 1 commit
    • Tom Lane's avatar
      Clean up error cases in psql's COPY TO STDOUT/FROM STDIN code. · b8f00a46
      Tom Lane authored
      Adjust handleCopyOut() to stop trying to write data once it's failed
      one time.  For typical cases such as out-of-disk-space or broken-pipe,
      additional attempts aren't going to do anything but waste time, and
      in any case clean truncation of the output seems like a better behavior
      than randomly dropping blocks in the middle.
      
      Also remove dubious (and misleadingly documented) attempt to force our way
      out of COPY_OUT state if libpq didn't do that.  If we did have a situation
      like that, it'd be a bug in libpq and would be better fixed there, IMO.
      We can hope that commit fa4440f5 took care
      of any such problems, anyway.
      
      Also fix longstanding bug in handleCopyIn(): PQputCopyEnd() only supports
      a non-null errormsg parameter in protocol version 3, and will actively
      fail if one is passed in version 2.  This would've made our attempts
      to get out of COPY_IN state after a failure into infinite loops when
      talking to pre-7.4 servers.
      
      Back-patch the COPY_OUT state change business back to 9.2 where it was
      introduced, and the other two fixes into all supported branches.
      b8f00a46