Re: [PATCH net-next v3] af_unix: Fix use-after-free crashes
flat view
From: Tim Chen <hidden>
Date: 2011-09-09 17:41:31
On Fri, 2011-09-09 at 08:51 +0200, Eric Dumazet wrote:
Le jeudi 08 septembre 2011 à 01:37 -0700, Tim Chen a écrit :quoted
On Thu, 2011-09-08 at 15:21 +0200, Eric Dumazet wrote:quoted
Le jeudi 08 septembre 2011 à 11:59 +0200, Sedat Dilek a écrit :quoted
I have tested this fixup patch on i386. Can we have a separate patch with corrected descriptive text? Thanks to all involved people.Here it is : [PATCH net-next v3] af_unix: Fix use-after-free crashes Commit 0856a30409 (Scm: Remove unnecessary pid & credential references in Unix socket's send and receive path) introduced an use-after-free bug. We are allowed to steal the references to pid/cred only in the last skb sent from unix_stream_sendmsg(), because first skbs might be consumed by the receiver before we finish our sendmsg() call. Remove scm_release() helper, since its cleaner to clear pid/cred fields in unix_scm_to_skb() when we steal them. Based on prior patches from Yan Zheng and Tim Chen Signed-off-by: Eric Dumazet <redacted> Reported-by: Jiri Slaby <redacted> Tested-by: Sedat Dilek <redacted> Tested-by: Valdis Kletnieks <redacted> ---Thanks. Acked-by: Tim Chen <redacted>Now we have to fix a bug in unix_stream_recvmsg() as well.
Thanks for your careful review to catch the bugs. Wish I had thought about the stream msg case more in my original patch.
consume_skb() call actually releases pid/cred references, and we can use them after their eventual freeing. Keep also in mind that receiver can provides a too short user buffer, and skb can be put back to head of sk_receive_queue Tim, your 0856a304091b33 commit introduced a lot of bugs, I was right asking a revert. If we revert your patch, my litle patch (af_unix: dont send SCM_CREDENTIALS by default) is enough to solve performance problems.
But the regression where we do send SCM_CREDENTIALS is not addressed, right? I don't mind reverting my patch if there's a better solution. Tim