Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751614Ab1CIFWK (ORCPT ); Wed, 9 Mar 2011 00:22:10 -0500 Received: from fgwmail5.fujitsu.co.jp ([192.51.44.35]:53305 "EHLO fgwmail5.fujitsu.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751240Ab1CIFWF (ORCPT ); Wed, 9 Mar 2011 00:22:05 -0500 X-SecurityPolicyCheck-FJ: OK by FujitsuOutboundMailChecker v1.3.1 From: KOSAKI Motohiro To: Stephen Wilson Subject: Re: [PATCH 4/6] proc: disable mem_write after exec Cc: kosaki.motohiro@jp.fujitsu.com, linux-mm@kvack.org, Andrew Morton , Alexander Viro , Rik van Riel , Roland McGrath , Matt Mackall , David Rientjes , Nick Piggin , Andrea Arcangeli , Mel Gorman , Ingo Molnar , Michel Lespinasse , Hugh Dickins , linux-kernel@vger.kernel.org In-Reply-To: <1299631343-4499-5-git-send-email-wilsons@start.ca> References: <1299631343-4499-1-git-send-email-wilsons@start.ca> <1299631343-4499-5-git-send-email-wilsons@start.ca> Message-Id: <20110309142107.03FA.A69D9226@jp.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Becky! ver. 2.50.07 [ja] Date: Wed, 9 Mar 2011 14:22:03 +0900 (JST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1138 Lines: 33 > This change makes mem_write() observe the same constraints as mem_read(). This > is particularly important for mem_write as an accidental leak of the fd across > an exec could result in arbitrary modification of the target process' memory. > IOW, /proc/pid/mem is implicitly close-on-exec. > > Signed-off-by: Stephen Wilson > --- > fs/proc/base.c | 4 ++++ > 1 files changed, 4 insertions(+), 0 deletions(-) > > diff --git a/fs/proc/base.c b/fs/proc/base.c > index 9d096e8..e52702d 100644 > --- a/fs/proc/base.c > +++ b/fs/proc/base.c > @@ -848,6 +848,10 @@ static ssize_t mem_write(struct file * file, const char __user *buf, > if (check_mem_permission(task)) > goto out; > > + copied = -EIO; > + if (file->private_data != (void *)((long)current->self_exec_id)) > + goto out; > + I agree. Reviewed-by: KOSAKI Motohiro -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/