Bug 697470 - os.lstat() returns negative values for owner and/or group for huge UID/GIDs on i386
os.lstat() returns negative values for owner and/or group for huge UID/GIDs o...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: python (Show other bugs)
6.0
i386 Unspecified
high Severity high
: rc
: ---
Assigned To: Dave Malcolm
Petr Šplíchal
:
: 697472 (view as bug list)
Depends On:
Blocks: 682670 628730 849988
  Show dependency treegraph
 
Reported: 2011-04-18 07:55 EDT by Eduard Benes
Modified: 2013-04-10 05:15 EDT (History)
5 users (show)

See Also:
Fixed In Version: python-2.6.6-26.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 734844 849988 (view as bug list)
Environment:
Last Closed: 2011-12-06 05:24:10 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Eduard Benes 2011-04-18 07:55:32 EDT
Description of problem:
os.lstat() returns negative values for owner and/or group for users with huge UID/GIDs on i386 arch while on other archs it is positive as expected and on i386 also libuser returns positive values. This is not a regression. 

Version-Release number of selected component (if applicable):
python-2.6.6-20.el6.i686
python-2.6.5-3.el6_0.2.i686

How reproducible:
always

Steps to Reproduce:
1. # adduser -u 4294967293  foo
2. # python
>>> import os
>>> os.lstat('/home/foo/')
3.
  
Actual results:
Negative UID -> st_uid=-3:
>>> os.lstat('/home/foo/')
posix.stat_result(st_mode=16832, st_ino=523265L, st_dev=64770L, st_nlink=4, st_uid=-3, st_gid=506, st_size=4096L, st_atime=1303126993, st_mtime=1303126936, st_ctime=1303126936)

Expected results:
Unchanged UID value ->  st_uid=4294967293:
>>> os.lstat('/home/foo/')
posix.stat_result(st_mode=16832, st_ino=16, st_dev=64771L, st_nlink=2, st_uid=4294967293, st_gid=502, st_size=1024, st_atime=1303126860, st_mtime=1303126860, st_ctime=1303126860)

Additional info:
The issue is causing failures in s-c-users on i386 systems when reproducing bug
https://bugzilla.redhat.com/show_bug.cgi?id=628730 but it might have also other negative implications.
Comment 1 Zbysek MRAZ 2011-04-18 08:16:30 EDT
*** Bug 697472 has been marked as a duplicate of this bug. ***
Comment 2 Dave Malcolm 2011-04-18 13:23:50 EDT
Relevant code is within Modules/posixmodule.c:

  1291  static PyObject*
  1292  _pystat_fromstructstat(STRUCT_STAT *st)
  1293  {
  ...
  1313      PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st->st_uid));
  1314      PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st->st_gid));
  ...

A PyIntObject can only hold a C "long" type, whereas as PyLongObject can hold an arbitrary-sized integer value.

Appears to still affect latest upstream 2.7 maintenance branch.
(Python 3 upstream uses PyLong_FromLong((long)st->st_uid) so may or may not be affected)
Comment 3 Dave Malcolm 2011-04-18 13:26:10 EDT
Looks similar to this upstream bug:
  http://bugs.python.org/issue4591
Comment 28 errata-xmlrpc 2011-12-06 05:24:10 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1564.html

Note You need to log in before you can comment on or make changes to this bug.