Re: [PATCH -next v2] unix stream: Fix use-after-free crashes
flat view
From: Eric Dumazet <hidden>
Date: 2011-09-07 05:08:34
Le mercredi 07 septembre 2011 à 12:36 +0800, Yan, Zheng a écrit :
I guess you misunderstood this code. Set scm_ref to false means skb will inherit sender's reference. Then we call unix_scm_to_skb() with parameter 'ref' == false. So it doesn't get additional reference. I admit my patch is confusing, but I think Tim's new patch is OK. (even in the case of fail skb allocation or user->kernel copy)
I want to be able to review the code now, and in two or three years too,
without spending hours and hours.
Could you _please_ guys send a patch, with :
1) A good changelog : In this confusing area, this is probably more
important than actual code.
2) right logic and right variable names
I am sorry, but this is not good :
+ /* encode scm in skb and use the scm ref */
+ ref_avail = false;
+ if (sent + size < len) {
+ /* Only send the fds in the first buffer */
+ /* get additional ref if more skbs will be created */
+ err = unix_scm_to_skb(siocb->scm, skb, !fds_sent, true);
+ ref_avail = true;
+ } else
+ err = unix_scm_to_skb(siocb->scm, skb, !fds_sent, false);