Re: [PATCH] tty_io: fix race in master pty close/slave pty closepath

From: H. Peter Anvin
Date: Thu Feb 22 2007 - 13:11:23 EST

Aristeu Sergio Rozanski Filho wrote:

This normally would only issue a warning on idr_remove() but in case of a
customer's critical application, it's never too simple:

thread1: opens master, gets index X
thread1: begin closing master
thread2: begin opening slave with index X
thread1: finishes closing master, index X released
thread3: opens master, gets index X, just released
thread2: fails opening slave, releases index X <----
thread4: opens master, gets index X, init_dev() then find an already in use
and healthy tty and fails

OK, that's fiendishly subtle, as most races are, of course. I'll try to walk through the codepaths to make sure the proposed patch doesn't introduce a leak, but the concept sounds good.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at