Bug 500354 - syslogd stops writing any messages to /dev/console after an EINTR in syscall
Summary: syslogd stops writing any messages to /dev/console after an EINTR in syscall
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: sysklogd
Version: 4.7
Hardware: All
OS: Linux
urgent
high
Target Milestone: rc
: ---
Assignee: Peter Vrabec
QA Contact: BaseOS QE
URL:
Whiteboard:
Depends On:
Blocks: 485811 506683 618203
TreeView+ depends on / blocked
 
Reported: 2009-05-12 12:27 UTC by Olivier Fourdan
Modified: 2018-10-27 13:52 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: SIGALRM signal is triggered during a writev() (which can happen when writing so a slow console via serial) Consequence: syslogd stops writing messages to /dev/console. Fix: Reschedule the ALARM just prior to call writev(). Recompute iovec when writev() could not write all data to avoid messages being half written to the log Result: syslogd keeps writing messages to /dev/console.
Clone Of:
: 506683 (view as bug list)
Environment:
Last Closed: 2011-02-16 14:07:28 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Proposed patch (1017 bytes, patch)
2009-05-12 12:27 UTC, Olivier Fourdan
no flags Details | Diff
Proposed patch (992 bytes, patch)
2009-06-04 14:48 UTC, Olivier Fourdan
no flags Details | Diff
Proposed patch (3.65 KB, patch)
2009-06-08 13:34 UTC, Olivier Fourdan
no flags Details | Diff
Proposed patch (451 bytes, patch)
2009-06-11 16:45 UTC, Olivier Fourdan
no flags Details | Diff
Proposed patch (3.48 KB, patch)
2009-06-11 17:11 UTC, Olivier Fourdan
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:0225 0 normal SHIPPED_LIVE sysklogd bug fix update 2011-02-15 16:35:26 UTC

Description Olivier Fourdan 2009-05-12 12:27:33 UTC
Created attachment 343579 [details]
Proposed patch

Description of problem:

The fix for bug #140983 makes system calls interruptible with SIGALRM.

But if that signal is triggered during a writev() (which can happen when sriting so a slow console via serial), syslog will print a message "/dev/console: Interrupted system call" and stop logging to console.

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

sysklogd-1.4.1-26_EL

How reproducible:

Just once in the customer's environment. But reproducer provided by our partner.

Steps to Reproduce:

1. Connect the serial console to system.
2. Edit /etc/syslog.conf as follows to have syslogd write many messages to
   /dev/console.

---
[/etc/syslog.conf]
*.debug               /dev/console
---

3. Execute the following example program to log messages continuously to syslog.

8<-------8<-------8<-------8<-------8<-------

#include<stdio.h>
#include<syslog.h>

int main(void)
{
        int i;
        for(i=0;;i++)
                syslog(LOG_DEBUG,"test--%d",i);

        return 0;

}

8<-------8<-------8<-------8<-------8<-------

Actual Results:

syslogd does not write any messages to /dev/console.

Expected Results:

syslogd writes any messages to /dev/console.

Additional info:

I could not reproduce the issue internally using the technique described, however based on the description, I believe the following attached patch might help with the issue.

A test package has been given to our partner, awaiting test results.

Comment 2 Olivier Fourdan 2009-05-15 08:28:20 UTC
Comment on attachment 343579 [details]
Proposed patch

Patch is causing more bad than good.

Comment 6 Olivier Fourdan 2009-06-04 14:48:37 UTC
Created attachment 346544 [details]
Proposed patch

Same patch as previous, except that it repeats the latest writev() call instead of returning.

Comment 9 Olivier Fourdan 2009-06-08 13:34:44 UTC
Created attachment 346869 [details]
Proposed patch

Third version. Now if writev() cannot write all the data to the file descriptor, the iovec is properly updated and another attempt to writev() is done.

This way no data is lost.

Comment 10 Olivier Fourdan 2009-06-11 16:45:36 UTC
Created attachment 347437 [details]
Proposed patch

A different approach to the problem.

This patch simply just reschedules the ALARM signal prior to log the messages.

So if a writev() is blocked and an alarm occurs, the log is closed and syslog keeps going on.

But by rescheduling the alarm just before calling writev() it virtually avoids the signal to be triggered during the writev() by accident.

This approach is preferred by our customer.

Comment 11 Olivier Fourdan 2009-06-11 17:11:18 UTC
Created attachment 347440 [details]
Proposed patch

Well, another patch, hopefully the last one.

This patch is actually a mix of my two previous patches.

  - Reschedule the ALARM just prior to call writev() to make avoid a signal
    coming up during the writev()
  - Still recompute iovec when writev() could not write all data to avoid
    messages being half written to the log.

Comment 20 Florian Nadge 2011-01-19 15:41:46 UTC
Please be so kind and add a few key words to the technical note of this
bugzilla entry using the following structure:

Cause:

Consequence:

Fix:

Result:


For details, see:
https://bugzilla.redhat.com/page.cgi?id=fields.html#cf_release_notes

Thanks

Comment 21 Florian Nadge 2011-01-19 15:41:47 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause:

Consequence:

Fix:

Result:

Comment 22 Peter Vrabec 2011-01-20 16:18:40 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,7 +1,12 @@
 Cause:
+SIGALRM signal is triggered during a writev() (which can happen when writing so a slow console via serial)
 
 Consequence:
+syslogd stops writing messages to /dev/console.
 
 Fix:
+Reschedule the ALARM just prior to call writev().
+Recompute iovec when writev() could not write all data to avoid messages being half written to the log
 
-Result:+Result:
+syslogd keeps writing messages to /dev/console.

Comment 23 errata-xmlrpc 2011-02-16 14:07:28 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.

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


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