NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/38888: cnputc() has no locking



>Number:         38888
>Category:       kern
>Synopsis:       cnputc() has no locking
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 08 12:55:00 +0000 2008
>Originator:     Andrew Doran
>Release:        4.99.64
>Organization:
The NetBSD Project
>Environment:
n/a
>Description:
cnputc() calls into tty drivers and beyond the printf mutex, no locking
is done.
>How-To-Repeat:
Code inspection.
>Fix:
Something like this maybe? In subr_prf.c:putchar():

if ((flags & TOCONS) && constty == NULL && c != '\0') {
    if (!mutex_tryenter(&tty_lock)) {
         /* queue character and defer to soft interrupt */;
    } else {
        (*v_putc)(c);
        mutex_exit(&tty_lock);
    }
}

We would also need to block out high-level pseudo-dma interrupts
from serial devices. I'm hoping to introduce a pdma_lock to cover
those.

.. also, we would need to avoid taking the locks if in DDB, or if
the system is going down in flames.



Home | Main Index | Thread Index | Old Index