From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tejun Heo Subject: Re: [PATCH] kernfs: fix memleak in kernel_ops_readdir() Date: Wed, 7 Aug 2019 11:45:18 -0700 Message-ID: <20190807184518.GP136335@devbig004.ftw2.facebook.com> References: <20190805173404.GF136335@devbig004.ftw2.facebook.com> <20190807132928.GD5443@atomide.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <20190807132928.GD5443@atomide.com> Sender: linux-kernel-owner@vger.kernel.org To: Tony Lindgren , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Andrea Arcangeli , Russell King , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org List-Id: linux-omap@vger.kernel.org Hello, On Wed, Aug 07, 2019 at 06:29:28AM -0700, Tony Lindgren wrote: > Hi, > > * Tejun Heo [691231 23:00]: > > From: Andrea Arcangeli > > > > If getdents64 is killed or hits on segfault, it'll leave cgroups > > directories in sysfs pinned leaking memory because the kernfs node > > won't be freed on rmdir and the parent neither. > > Somehow this causes a regression in Linux next for me where I'm seeing > lots of sysfs entries now missing under /sys/bus/platform/devices. > > For example, I now only see one .serial entry show up in sysfs. > Things work again if I revert commit cc798c83898e ("kernfs: fix memleak > inkernel_ops_readdir()"). Any ideas why that would be? > > Below is a diff -u of ls /sys/bus/platform/devices for reference > showing the missing entries with cc798c83898e. Ugh, you're right. It can get double-put cuz ctx->pos is put by release too. Greg, sorry about the noise but can you please revert the patch? I'll look into why this looked like memory leak from slabinfo side. Thanks. -- tejun From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB13CC32751 for ; Wed, 7 Aug 2019 18:45:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BE0F22229C for ; Wed, 7 Aug 2019 18:45:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KqG6XLCP"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MZtM6ZBG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE0F22229C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EslWcHo9AztG3XyiVsQCWfg5y9ymA/B2/AwanXAeB+U=; b=KqG6XLCPUHUtQt suQqfZ0IhXrUklrZHyvVXVv5MPEp0t3etV48AtY+97dvO4wGCe9LxpdHN7lZcYV7daHC0tB/BlnOj vv5NR3XFNOwEC7DIsG2TP8MuFZxp0RR+BRGm0ggaCl4so68pmrhLYtSLAUKvY8AKrIYhhz2eNORgr BWPaZpBxCJ0AFtL5zB82HTZOay8lf7NdiUM0sVSb4R1C/FDJo20FbolwawYmg9jp3/1xjgbL4bO6p Am4jAml8kqYtppCyXh8hrvXeo8IzrbEMJjD0cU4R1jdz1WO46o+bSH+Ga9x0XGjWlYb2MrClToHt7 Fco2h/eayBqVNOQOOiKg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hvQwC-0000YT-Ql; Wed, 07 Aug 2019 18:45:29 +0000 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hvQw7-0000XY-1F for linux-arm-kernel@lists.infradead.org; Wed, 07 Aug 2019 18:45:24 +0000 Received: by mail-qt1-x844.google.com with SMTP id n11so89395383qtl.5 for ; Wed, 07 Aug 2019 11:45:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=3FBU1u876RL78FpNPM+fEUZZ2hjnifBWtf0De88VGZE=; b=MZtM6ZBGFwE33KRflR0oa3CBb23tUJNibReW2z8hV+PFQvDLcROCi2gyRBPe9ee6oq pZn6TbSj3r0ODQteFDkF1CSI4mKykNPbAiajIshMY8VzAliNvgcPXBUUGCREQt6+8Z1V uoq1tMl4l0ZO9Kp2qY9IGoOwb+odrfNXSq6RIRLRaR+Rg1xVi42LEnwRIXgobluBY2Yl qiqvH8jUFJ6YLAtQc4zO3xuLwE0Qe/iGGtjDSRfnAaXDmDRDsf69FDSYnm7CaH8JdJOZ HtIY+f05nKmGpuO8XMPOf0z13FI4w4jOLVqdzAzcRSRKvZyv4TNu/S1mM4sV1EBmg3u2 tB/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=3FBU1u876RL78FpNPM+fEUZZ2hjnifBWtf0De88VGZE=; b=gQkgde1RCzr/3vbjqtBOyr40rckfpPmpos1BhpGQkIRUAsqrkaU89vJbiVJiiYZqvN Ww0+kxmy4Zz53rTjllilGI/Rqw77wJh+wEXowBgMybyq35dQl5Ow8pcaJHa9aZ61O1vQ AZ0wfo9wWHijp7kZxMPkdmYA7y0T42u8S/Dim/UcQcH7fBlwuWKly2c4LDCgN8Y1IgsV AOonWs7fDZxraIRfvGz5e+FebkNxsDXIlwny6kYJFQVYADPbjitU8rzsZhFHQsZMUb3I v7xHVbA/MnX6mWDZ4V22P3KOxdeU9/aR1KNN3tBTMaIiYCgz8/RHZaaBLzHD62eKYf6g 0zAw== X-Gm-Message-State: APjAAAXRNYOkJ2iW5nmjHDg82yaElR3a5FtfQBWZW9/IA+FoESVzQLUl L94LDabYDHCmmebqSsTKy9E= X-Google-Smtp-Source: APXvYqwWf1dv6Cff16aig8tua7PcpEKLMe7WcVox4dHzStZsHVQ+QYcKczlV2ADG8SaLlMn6NYeznw== X-Received: by 2002:a0c:8705:: with SMTP id 5mr9434765qvh.32.1565203520357; Wed, 07 Aug 2019 11:45:20 -0700 (PDT) Received: from localhost ([2620:10d:c091:500::6ac7]) by smtp.gmail.com with ESMTPSA id d123sm41665368qkb.94.2019.08.07.11.45.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Aug 2019 11:45:19 -0700 (PDT) Date: Wed, 7 Aug 2019 11:45:18 -0700 From: Tejun Heo To: Tony Lindgren , Greg Kroah-Hartman Subject: Re: [PATCH] kernfs: fix memleak in kernel_ops_readdir() Message-ID: <20190807184518.GP136335@devbig004.ftw2.facebook.com> References: <20190805173404.GF136335@devbig004.ftw2.facebook.com> <20190807132928.GD5443@atomide.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190807132928.GD5443@atomide.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190807_114523_080686_59828AC6 X-CRM114-Status: GOOD ( 13.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrea Arcangeli , Russell King , linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hello, On Wed, Aug 07, 2019 at 06:29:28AM -0700, Tony Lindgren wrote: > Hi, > > * Tejun Heo [691231 23:00]: > > From: Andrea Arcangeli > > > > If getdents64 is killed or hits on segfault, it'll leave cgroups > > directories in sysfs pinned leaking memory because the kernfs node > > won't be freed on rmdir and the parent neither. > > Somehow this causes a regression in Linux next for me where I'm seeing > lots of sysfs entries now missing under /sys/bus/platform/devices. > > For example, I now only see one .serial entry show up in sysfs. > Things work again if I revert commit cc798c83898e ("kernfs: fix memleak > inkernel_ops_readdir()"). Any ideas why that would be? > > Below is a diff -u of ls /sys/bus/platform/devices for reference > showing the missing entries with cc798c83898e. Ugh, you're right. It can get double-put cuz ctx->pos is put by release too. Greg, sorry about the noise but can you please revert the patch? I'll look into why this looked like memory leak from slabinfo side. Thanks. -- tejun _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel