From: Oleg Drokin Subject: Re: Leak in nlmsvc_testlock for async GETFL case Date: Fri, 11 Jan 2008 21:57:35 -0500 Message-ID: <71BCABE5-52AD-4573-8DC0-5C57152A397B@Sun.COM> References: <48611B2F-1587-48C5-9F30-8DCFA1121CF6@Sun.COM> <20071129190848.GA17907@fieldses.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Boundary_(ID_hMCl3775jpGKVFBUcp3wug)" Cc: linux-fsdevel@vger.kernel.org To: "J. Bruce Fields" Return-path: Received: from brmea-mail-2.Sun.COM ([192.18.98.43]:38864 "EHLO brmea-mail-2.sun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757274AbYALDFE (ORCPT ); Fri, 11 Jan 2008 22:05:04 -0500 Received: from fe-amer-10.sun.com ([192.18.109.80]) by brmea-mail-2.sun.com (8.13.6+Sun/8.12.9) with ESMTP id m0C2vbDP014978 for ; Sat, 12 Jan 2008 02:57:37 GMT Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0JUI00701G21IE00@mail-amer.sun.com> (original mail from Oleg.Drokin@Sun.COM) for linux-fsdevel@vger.kernel.org; Fri, 11 Jan 2008 19:57:37 -0700 (MST) In-reply-to: <20071129190848.GA17907@fieldses.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: --Boundary_(ID_hMCl3775jpGKVFBUcp3wug) Content-type: text/plain; delsp=yes; format=flowed; charset=US-ASCII Content-transfer-encoding: 7BIT Hello! On Nov 29, 2007, at 2:08 PM, J. Bruce Fields wrote: > On Thu, Nov 29, 2007 at 01:46:04PM -0500, Oleg Drokin wrote: >> Hello! >> >> Per our discussion, I am resending this patch that fixes a leak in >> nlmsvc_testlock. It is addition to another leak fixing patch you >> already have. Without the patch, there is a leakage of nlmblock >> structure refcount that holds a reference nlmfile structure, that >> holds a reference to struct file, when async GETFL is used >> (-EINPROGRESS return from file_ops->lock()), and also in some error >> cases > Thanks for the fix! Looks right to me. Yes, somehow I missed this > one > when you sent it privately. Applied and pushed out to > git://linux-nfs.org/~bfields/linux.git nfs-server-stable > and I'll submit it for 2.6.25. After playing around that code a bit more, I figured out the leak was not completely fixed by that first patch, the case where there is conflicting lock passed in by callback still leaks block reference. This simple incremental fix (against your current tree) takes care of that. Signed-off-by: Oleg Drokin I guess there is no way to safely include patches in messages in apple mail, so the patch is still attached. --Boundary_(ID_hMCl3775jpGKVFBUcp3wug) Content-type: application/octet-stream; name=nlmblock-leak_fix-2-incr.diff; x-unix-mode=0644 Content-transfer-encoding: BASE64 Content-disposition: attachment; filename=nlmblock-leak_fix-2-incr.diff Rml4IG5sbV9ibG9jayBsZWFrIGZvciB0aGUgY2FzZSBvZiBzdXBwbGllZCBibG9j a2luZyBsb2NrIGluZm8uDQpTaWduZWQtb2ZmLWJ5OiBPbGVnIERyb2tpbiA8Z3Jl ZW5AbGludXhoYWNrZXIucnU+DQoNCi0tLSAvdG1wL3N2Y2xvY2suYwkyMDA4LTAx LTExIDIxOjQwOjM5LjAwMDAwMDAwMCAtMDUwMA0KKysrIGxpbnV4LTIuNi4yMi9m cy9sb2NrZC9zdmNsb2NrLmMJMjAwOC0wMS0xMSAyMTo0MTo1NC4wMDAwMDAwMDAg LTA1MDANCkBAIC01MDUsMTIgKzUwMSwxMiBAQCBubG1zdmNfdGVzdGxvY2soc3Ry dWN0IHN2Y19ycXN0ICpycXN0cCwgDQogCQkJZ290byBvdXQ7DQogCQl9DQogCQlp ZiAoYmxvY2stPmJfZmxhZ3MgJiBCX0dPVF9DQUxMQkFDSykgew0KKwkJCW5sbXN2 Y191bmxpbmtfYmxvY2soYmxvY2spOw0KIAkJCWlmIChibG9jay0+Yl9mbCAhPSBO VUxMDQogCQkJCQkmJiBibG9jay0+Yl9mbC0+ZmxfdHlwZSAhPSBGX1VOTENLKSB7 DQogCQkJCWxvY2stPmZsID0gKmJsb2NrLT5iX2ZsOw0KIAkJCQlnb3RvIGNvbmZf bG9jazsNCiAJCQl9IGVsc2Ugew0KLQkJCQlubG1zdmNfdW5saW5rX2Jsb2NrKGJs b2NrKTsNCiAJCQkJcmV0ID0gbmxtX2dyYW50ZWQ7DQogCQkJCWdvdG8gb3V0Ow0K IAkJCX0NCg== --Boundary_(ID_hMCl3775jpGKVFBUcp3wug) Content-type: text/plain; format=flowed; charset=US-ASCII Content-transfer-encoding: 7BIT --Boundary_(ID_hMCl3775jpGKVFBUcp3wug)--