From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754439AbbI3QuF (ORCPT ); Wed, 30 Sep 2015 12:50:05 -0400 Received: from mx2.parallels.com ([199.115.105.18]:41813 "EHLO mx2.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932396AbbI3Qtu (ORCPT ); Wed, 30 Sep 2015 12:49:50 -0400 Date: Wed, 30 Sep 2015 19:49:40 +0300 From: Vladimir Davydov To: Andrew Morton CC: Johannes Weiner , Michal Hocko , Tejun Heo , , Subject: Re: [PATCH 2/5] fs: charge pipe buffers to memcg Message-ID: <20150930164940.GB19988@esperanza> References: <94f055dc719129a26149b0f8b22af7c61a3fb4e6.1443262808.git.vdavydov@parallels.com> <20150929155711.3b139dab622848a14af64ca4@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20150929155711.3b139dab622848a14af64ca4@linux-foundation.org> X-ClientProxiedBy: US-EXCH2.sw.swsoft.com (10.255.249.46) To US-EXCH.sw.swsoft.com (10.255.249.47) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 29, 2015 at 03:57:11PM -0700, Andrew Morton wrote: > On Sat, 26 Sep 2015 13:45:54 +0300 Vladimir Davydov wrote: > > > Pipe buffers can be generated unrestrictedly by an unprivileged > > userspace process, so they shouldn't go unaccounted. > > > > ... > > > > --- a/fs/pipe.c > > +++ b/fs/pipe.c > > @@ -400,7 +400,7 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from) > > int copied; > > > > if (!page) { > > - page = alloc_page(GFP_HIGHUSER); > > + page = alloc_kmem_pages(GFP_HIGHUSER, 0); > > if (unlikely(!page)) { > > ret = ret ? : -ENOMEM; > > break; > > This seems broken. We have a page buffer page which has a weird > ->mapcount. Now it gets stolen (generic_pipe_buf_steal()) and spliced > into pagecache. Then the page gets mmapped and MM starts playing with > its ->_mapcount? Right you are! I completely forgot of vmsplice case. Surely, we need to uncharge the page in the ->steal method and clear its PageKmem. Will fix that. Thanks, Vladimir