Bug 250419 - HAL fstab-sync zero-bytes /etc/fstab if / is full.
Summary: HAL fstab-sync zero-bytes /etc/fstab if / is full.
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: hal
Version: 4.5
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: David Zeuthen
QA Contact: desktop-bugs@redhat.com
Depends On:
Blocks: 246627
TreeView+ depends on / blocked
Reported: 2007-08-01 14:18 UTC by Jose Plans
Modified: 2018-10-19 23:18 UTC (History)
2 users (show)

Clone Of:
Last Closed: 2008-07-24 19:58:52 UTC

Attachments (Terms of Use)
Patch from lmacchia@redhat.com (384 bytes, patch)
2007-08-01 14:26 UTC, Jose Plans
no flags Details | Diff

External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2008:0734 normal SHIPPED_LIVE hal bug fix update 2008-07-23 16:47:00 UTC

Description Jose Plans 2007-08-01 14:18:02 UTC
Description of problem:
fstab-sync from hal doesn't detect properly write(2) as the error "-1" is stored
on a signed size_t instead of ssize_t.

This has made some systems to lose their /etc/fstab and therfore provide some
serious impacts on boot.

static boolean
add_udi (const char *udi)
        if (!fs_table_write (fs_table, fd)) <-- fs_table_write will always
return 1 [1]
                goto error;
        if (rename (temp_filename, _PATH_FSTAB) < 0) <- rename will report
ENOSPC but.. it was too late.

[1] return will always be TRUE as size_t is unsigned:

static boolean
fs_table_write (FSTable *table, int fd)
  char *fstab_contents;
-  size_t bytes_written, bytes_to_write;
+  size_t bytes_written, bytes_to_write; <--- signed for error handling on write(2)
  while ((bytes_written = write (fd, fstab_contents + bytes_written,
                                 bytes_to_write)) < bytes_to_write)
      if (bytes_written < 0)             <--- with size_t this will never happen.
  return TRUE; <--- return 1.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
- fill the root partition to 100%
- crash
- system starts
- it mounts all the file system according to fstab
- it runs fstab-sync and NOW corrupts it (as per strace)
Actual results:
/etc/fstab empty.

Expected results:
/etc/fstab not empty.

Additional info:
Patch attached from Leo Macchia <lmacchia@redhat.com>

Comment 1 Jose Plans 2007-08-01 14:26:48 UTC
Created attachment 160416 [details]
Patch from lmacchia@redhat.com

Comment 2 Jose Plans 2007-08-01 14:28:40 UTC
Patched confirmed to work.

Comment 3 Jose Plans 2007-08-01 14:30:26 UTC
Hmm typo on #c0 :
-  size_t bytes_written, bytes_to_write;
+  ssize_t bytes_written, bytes_to_write; <--- signed for error handling on write(2)

Comment 4 RHEL Product and Program Management 2007-11-29 04:16:43 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update

Comment 5 David Zeuthen 2008-02-15 21:16:52 UTC
Looks like something we should fix. Dev ACK.

Comment 7 David Zeuthen 2008-04-10 22:18:29 UTC
Fix is in hal-0.4.2-8.EL4.

Comment 11 errata-xmlrpc 2008-07-24 19:58:52 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.


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