Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5062156imm; Tue, 26 Jun 2018 05:22:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIOQO4J04RF4ndwdzEoaWjGvrLqdr/zZtH3zj0mMXaLnGdNmeWZ7jZHp3O2QZ5MFzF2akDO X-Received: by 2002:a65:60d2:: with SMTP id r18-v6mr1210050pgv.306.1530015770271; Tue, 26 Jun 2018 05:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530015770; cv=none; d=google.com; s=arc-20160816; b=qRPFKnp2xJ6rW25rBh4NKS9/47H5Zx/lpOt1UAlKnFW3w9D9PmGyP0bj2xBAcThOV/ /Qab65khsRMAvV5IDnYz++1A605rg+TGRqaTIQPdTcEyHLuVhi7cljv1iUH4lyznTSve QT632tS+LNOMe7HuDaC6K/DUIhzBWD9NI2g1Z3naq86MerwLUOyMR74NbNofK322Upqo OnGrz3HhMTO4IEKelMKrRd+YOt/dRpMOsUSBwAucNvutkHISzbXWFKz/yWZ25STg6b1l AiMq0EEgtAb/hlAV3bjjxTRFI7tv/e9EfaFfmWud7J9fYjVRGYeo5Vf4ssArOOkhrbTu NIgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:reply-to:from:date :arc-authentication-results; bh=qIlMNFV+VPtqh3RAHvWJcB2j32Z9LS7FyQxyDwnfCuI=; b=fiE96iZhR0SuUX2Diakp9QE3b0l9f1E3ExxdzAhKh7I2m+OR1Ifw+Asq3dAS6/HImq aBjymSSL1JCCFkc8xhGpmymvTlz6YDaTZAOzxAfql7oODm/uOGxPqVB01w546JG4kkjW /pZMmK6nbZX7TH83RxDFnFK6CyaZ/HA+X5jQsvpz1oZaT6f7MZNUBUH51sKW34WkkTsw zdl1GOSCIJEnNOLPddoXhQzbxvYop/5Ba0Cl/II5YxGFMeYyjhrZsv8w0dZYo25oWI6v oGfBBe5XsKERKALyj/2viKuhpwMsbB4KJLe70f5BCZwEdXs7MBJLeS83y/USJA+w37zy 8fmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a21-v6si1440971pls.237.2018.06.26.05.22.36; Tue, 26 Jun 2018 05:22:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935236AbeFZMU4 (ORCPT + 99 others); Tue, 26 Jun 2018 08:20:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49218 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933823AbeFZMUx (ORCPT ); Tue, 26 Jun 2018 08:20:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3D91430820F4; Tue, 26 Jun 2018 12:20:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2F5FB7EE7C; Tue, 26 Jun 2018 12:20:53 +0000 (UTC) Received: from zmail23.collab.prod.int.phx2.redhat.com (zmail23.collab.prod.int.phx2.redhat.com [10.5.83.28]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A552C4BB78; Tue, 26 Jun 2018 12:20:52 +0000 (UTC) Date: Tue, 26 Jun 2018 08:20:52 -0400 (EDT) From: Chunyu Hu Reply-To: Chunyu Hu To: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, Christoph Hellwig Cc: linux-kernel@vger.kernel.org Message-ID: <1113263100.13594710.1530015652549.JavaMail.zimbra@redhat.com> In-Reply-To: <20180611062354.GA32641@lst.de> References: <1528573884-9133-1-git-send-email-chuhu@redhat.com> <20180611062354.GA32641@lst.de> Subject: Re: [PATCH] proc: add proc_seq_release MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [10.68.5.41, 10.4.195.29] Thread-Topic: proc: add proc_seq_release Thread-Index: vbxOw6lDQSrIXGETAu5l3gKdnHGdHQ== X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 26 Jun 2018 12:20:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- Original Message ----- > From: "Christoph Hellwig" > To: "Chunyu Hu" > Cc: viro@zeniv.linux.org.uk, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org > Sent: Monday, June 11, 2018 2:23:54 PM > Subject: Re: [PATCH] proc: add proc_seq_release > > On Sun, Jun 10, 2018 at 03:51:24AM +0800, Chunyu Hu wrote: > > kmemleak reported some memory leak on reading proc files. After adding > > some debug lines, find that proc_seq_fops is using seq_release as > > release handler, which won't handle the free of 'private' field of > > seq_file, while in fact the open handler proc_seq_open could create > > the private data with __seq_open_private when state_size is greater > > than zero. So after reading files created with proc_create_seq_private, > > such as /proc/timer_list and /proc/vmallocinfo, the private mem of a > > seq_file is not freed. Fix it by adding the paired proc_seq_release > > as the default release handler of proc_seq_ops instead of seq_release. > > Indeed, thanks for the patch. > > Reviewed-by: Christoph Hellwig > What's our plan for this issue? We can still see the leaking in 4.18-RC2. 1) Run 'cat /proc/timer_list' then 2) echo scan > /sys/kernel/debug/kmemleak 3) cat /sys/kernel/debug/kmemleak each time, it leaks 16 bytes. unreferenced object 0xffff880017525120 (size 16): comm "cat", pid 4682, jiffies 4294964743 (age 46.880s) hex dump (first 16 bytes): 04 00 00 00 01 00 00 00 42 00 96 e7 3f 00 00 00 ........B...?... backtrace: [<000000006f6b5d90>] seq_open_private+0x25/0x40 [<00000000d94d91aa>] proc_seq_open+0xca/0x120 [<00000000d5609077>] proc_reg_open+0x1d4/0x5b0 [<0000000036a3d49c>] do_dentry_open+0x7d6/0x1010 [<00000000d4fb0a82>] vfs_open+0x170/0x2b0 [<00000000f3bf21b4>] path_openat+0x760/0x3750 [<00000000b0d4e66c>] do_filp_open+0x1bb/0x2c0 [<0000000063b53236>] do_sys_open+0x2b2/0x490 [<00000000a5249c62>] do_syscall_64+0xd3/0x6e0 [<000000006f9f8436>] entry_SYSCALL_64_after_hwframe+0x49/0xbe [<000000001d702cb2>] 0xffffffffffffffff -- Regards, Chunyu Hu