Re: [PATCH -next v2] unix stream: Fix use-after-free crashes
flat view
From: Tim Chen <hidden>
Date: 2011-09-06 19:30:44
On Tue, 2011-09-06 at 21:01 +0200, Eric Dumazet wrote:
quoted
All the skbs put on the list does have proper reference on pid/scm. In the example you give, the first skb got the reference at this line: err = unix_scm_to_skb(siocb->scm, skb, !fds_sent, fds_sent);This is the current code. We know its buggy. I was discussing of things after proposed patch, not current net-next.
I think we are on the same page.
My approach would basically revert the 7361c36c commit too :(
I think so. I was not fond of commit 7361c36c as it caused a 90% regression in threaded case of hackbench that we noticed back in 2.6.36 days. If there's some way to undo its evil, I'm all for it.
I am sorry, but the only way to avoid too many pid/cred references is to lock the socket [aka unix_state_lock(other);] for the whole send() duration.
Yes, I think locking the sendmsg for the entire duration of unix_stream_sendmsg makes a lot of sense. It simplifies the logic a lot more. I'll try to cook something up in the next couple of days.
This way, you can really increment the pid/cred reference on the last pushed skb, because no reader can 'catch first skb' As soon as unix_state_unlock(other) is called, everything can happen, so skb must be self contained, as I stated in my earlier mail.
Thanks. Tim