diff options
author | Benjamin Peterson <benjamin@python.org> | 2012-02-21 02:44:56 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2012-02-21 02:44:56 (GMT) |
commit | aee9dfba4a9230f2832dd69d67e92f8e0490a163 (patch) | |
tree | 27a9896969ac7ff79dc75017cff121a077c3eb6e /Doc | |
parent | 34b345b8885e5db8ab6627c081ca86a8b78b6989 (diff) | |
parent | b19fb2462eac776746f6cb40cc84b0587c83b9bc (diff) | |
download | cpython-aee9dfba4a9230f2832dd69d67e92f8e0490a163.zip cpython-aee9dfba4a9230f2832dd69d67e92f8e0490a163.tar.gz cpython-aee9dfba4a9230f2832dd69d67e92f8e0490a163.tar.bz2 |
merge 2.6 with hash randomization fix
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/sys.rst | 1 | ||||
-rw-r--r-- | Doc/reference/datamodel.rst | 2 | ||||
-rw-r--r-- | Doc/using/cmdline.rst | 46 |
3 files changed, 48 insertions, 1 deletions
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst index a52b0d6..3873eb8 100644 --- a/Doc/library/sys.rst +++ b/Doc/library/sys.rst @@ -286,6 +286,7 @@ always available. :const:`verbose` :option:`-v` :const:`unicode` :option:`-U` :const:`bytes_warning` :option:`-b` + :const:`hash_randomization` :option:`-R` ============================= =================================== .. versionadded:: 2.6 diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 0cd4c62..0d87873 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1282,6 +1282,8 @@ Basic customization modules are still available at the time when the :meth:`__del__` method is called. + See also the :option:`-R` command-line option. + .. method:: object.__repr__(self) diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst index 29d249f..0d2924d 100644 --- a/Doc/using/cmdline.rst +++ b/Doc/using/cmdline.rst @@ -24,7 +24,7 @@ Command line When invoking Python, you may specify any of these options:: - python [-BdEiOQsStuUvVWxX3?] [-c command | -m module-name | script | - ] [args] + python [-BdEiOQsRStuUvVWxX3?] [-c command | -m module-name | script | - ] [args] The most common use case is, of course, a simple invocation of a script:: @@ -253,6 +253,29 @@ Miscellaneous options :pep:`238` -- Changing the division operator +.. cmdoption:: -R + + Turn on hash randomization, so that the :meth:`__hash__` values of str, + bytes and datetime objects are "salted" with an unpredictable random value. + Although they remain constant within an individual Python process, they are + not predictable between repeated invocations of Python. + + This is intended to provide protection against a denial-of-service caused by + carefully-chosen inputs that exploit the worst case performance of a dict + insertion, O(n^2) complexity. See + http://www.ocert.org/advisories/ocert-2011-003.html for details. + + Changing hash values affects the order in which keys are retrieved from a + dict. Although Python has never made guarantees about this ordering (and it + typically varies between 32-bit and 64-bit builds), enough real-world code + implicitly relies on this non-guaranteed behavior that the randomization is + disabled by default. + + See also :envvar:`PYTHONHASHSEED`. + + .. versionadded:: 2.6.8 + + .. cmdoption:: -s Don't add the :data:`user site-packages directory <site.USER_SITE>` to @@ -522,6 +545,27 @@ These environment variables influence Python's behavior. .. versionadded:: 2.6 +.. envvar:: PYTHONHASHSEED + + If this variable is set to ``random``, the effect is the same as specifying + the :option:`-R` option: a random value is used to seed the hashes of str, + bytes and datetime objects. + + If :envvar:`PYTHONHASHSEED` is set to an integer value, it is used as a + fixed seed for generating the hash() of the types covered by the hash + randomization. + + Its purpose is to allow repeatable hashing, such as for selftests for the + interpreter itself, or to allow a cluster of python processes to share hash + values. + + The integer must be a decimal number in the range [0,4294967295]. + Specifying the value 0 will lead to the same hash values as when hash + randomization is disabled. + + .. versionadded:: 2.6.8 + + .. envvar:: PYTHONIOENCODING Overrides the encoding used for stdin/stdout/stderr, in the syntax |