From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751975AbbI2W5O (ORCPT ); Tue, 29 Sep 2015 18:57:14 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37709 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750810AbbI2W5M (ORCPT ); Tue, 29 Sep 2015 18:57:12 -0400 Date: Tue, 29 Sep 2015 15:57:11 -0700 From: Andrew Morton To: Vladimir Davydov Cc: Johannes Weiner , Michal Hocko , Tejun Heo , , Subject: Re: [PATCH 2/5] fs: charge pipe buffers to memcg Message-Id: <20150929155711.3b139dab622848a14af64ca4@linux-foundation.org> In-Reply-To: <94f055dc719129a26149b0f8b22af7c61a3fb4e6.1443262808.git.vdavydov@parallels.com> References: <94f055dc719129a26149b0f8b22af7c61a3fb4e6.1443262808.git.vdavydov@parallels.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?