From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751993Ab2ALGnn (ORCPT ); Thu, 12 Jan 2012 01:43:43 -0500 Received: from mail-lpp01m010-f46.google.com ([209.85.215.46]:60721 "EHLO mail-lpp01m010-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751533Ab2ALGnm (ORCPT ); Thu, 12 Jan 2012 01:43:42 -0500 Date: Thu, 12 Jan 2012 08:43:26 +0200 (EET) From: Pekka Enberg X-X-Sender: penberg@tux.localdomain To: David Rientjes cc: Sasha Levin , lizf@cn.fujitsu.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm: Don't warn if memdup_user fails In-Reply-To: Message-ID: References: <1326300636-29233-1-git-send-email-levinsasha928@gmail.com> User-Agent: Alpine 2.02 (LFD 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 11 Jan 2012, Sasha Levin wrote: >> memdup_user() is called when we need to copy data from userspace. This >> means that a user is able to trigger warnings if the kmalloc() inside >> memdup_user() fails. >> >> For example, this is one caused by writing to much data to ecryptdev: >> >> [ 912.739685] ------------[ cut here ]------------ >> [ 912.745080] WARNING: at mm/page_alloc.c:2217 __alloc_pages_nodemask+0x22c/0x910() >> [ 912.746525] Pid: 19977, comm: trinity Not tainted 3.2.0-next-20120110-sasha #120 >> [ 912.747915] Call Trace: >> [ 912.748415] [] ? __alloc_pages_nodemask+0x22c/0x910 >> [ 912.749651] [] warn_slowpath_common+0x75/0xb0 >> [ 912.750756] [] warn_slowpath_null+0x15/0x20 >> [ 912.751831] [] __alloc_pages_nodemask+0x22c/0x910 >> [ 912.754230] [] ? pvclock_clocksource_read+0x55/0xd0 >> [ 912.755484] [] ? kvm_clock_read+0x46/0x80 >> [ 912.756565] [] ? sched_clock_cpu+0xc8/0x140 >> [ 912.757667] [] ? get_parent_ip+0x11/0x50 >> [ 912.758731] [] ? get_parent_ip+0x11/0x50 >> [ 912.759890] [] ? ecryptfs_miscdev_write+0x6b/0x240 >> [ 912.761119] [] alloc_pages_current+0xa0/0x110 >> [ 912.762269] [] __get_free_pages+0xf/0x40 >> [ 912.763347] [] __kmalloc_track_caller+0x172/0x190 >> [ 912.764561] [] memdup_user+0x2b/0x90 >> [ 912.765526] [] ecryptfs_miscdev_write+0x6b/0x240 >> [ 912.766669] [] ? ecryptfs_miscdev_open+0x190/0x190 >> [ 912.767832] [] do_loop_readv_writev+0x50/0x80 >> [ 912.770735] [] do_readv_writev+0x1ce/0x1e0 >> [ 912.773059] [] ? __mutex_unlock_slowpath+0x10c/0x200 >> [ 912.774634] [] ? get_parent_ip+0x11/0x50 >> [ 912.775699] [] ? sub_preempt_count+0x9d/0xd0 >> [ 912.776827] [] ? retint_swapgs+0x13/0x1b >> [ 912.777887] [] vfs_writev+0x48/0x60 >> [ 912.779162] [] sys_writev+0x4f/0xb0 >> [ 912.780152] [] system_call_fastpath+0x16/0x1b >> [ 912.793046] ---[ end trace 50c38c9cdee53379 ]--- >> [ 912.793906] ecryptfs_miscdev_write: memdup_user returned error [-12] >> >> Failing memdup_user() shouldn't be generating warnings, instead it should >> be notifying userspace about the error. >> >> Signed-off-by: Sasha Levin On Wed, 11 Jan 2012, David Rientjes wrote: > Acked-by: David Rientjes Acked-by: Pekka Enberg Sasha, I suppose strndup_user() has the same kind of issue?