Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753147Ab1DLTAL (ORCPT ); Tue, 12 Apr 2011 15:00:11 -0400 Received: from smtp1.linux-foundation.org ([140.211.169.13]:50101 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751699Ab1DLTAI (ORCPT ); Tue, 12 Apr 2011 15:00:08 -0400 MIME-Version: 1.0 In-Reply-To: References: From: Linus Torvalds Date: Tue, 12 Apr 2011 11:59:18 -0700 Message-ID: Subject: Re: [PATCH] mm: fix possible cause of a page_mapped BUG To: =?UTF-8?B?Um9iZXJ0IMWad2nEmWNraQ==?= Cc: Hugh Dickins , Andrew Morton , Miklos Szeredi , Michel Lespinasse , "Eric W. Biederman" , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Peter Zijlstra , Rik van Riel Content-Type: multipart/mixed; boundary=0015176f0d283cb13b04a0bd4b62 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5165 Lines: 85 --0015176f0d283cb13b04a0bd4b62 Content-Type: text/plain; charset=ISO-8859-1 On Tue, Apr 12, 2011 at 10:19 AM, Linus Torvalds wrote: > > THIS IS A HACKY AND UNTESTED PATCH! .. and here is a rather less hacky, but still equally untested patch. It moves the stack guard page handling into __get_user_pages() itself, and thus avoids the whole problem. This one I could easily see myself committing. Assuming I get some ack's and testing.. Comments? Linus --0015176f0d283cb13b04a0bd4b62 Content-Type: text/x-patch; charset=US-ASCII; name="patch.diff" Content-Disposition: attachment; filename="patch.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gmf6z1cm1 IG1tL21lbW9yeS5jIHwgICAyNiArKysrKysrKysrKysrKysrKystLS0tLS0tLQogbW0vbWxvY2su YyAgfCAgIDEzIC0tLS0tLS0tLS0tLS0KIDIgZmlsZXMgY2hhbmdlZCwgMTggaW5zZXJ0aW9ucygr KSwgMjEgZGVsZXRpb25zKC0pCgp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zICYgVk1fR1JPV1NET1dO KSAmJgotCQkodm1hLT52bV9zdGFydCA9PSBhZGRyKSAmJgotCQkhdm1hX3N0YWNrX2NvbnRpbnVl KHZtYS0+dm1fcHJldiwgYWRkcik7Ci19Ci0KIC8qKgogICogX19tbG9ja192bWFfcGFnZXNfcmFu Z2UoKSAtICBtbG9jayBhIHJhbmdlIG9mIHBhZ2VzIGluIHRoZSB2bWEuCiAgKiBAdm1hOiAgIHRh cmdldCB2bWEKQEAgLTE4OCwxMiArMTgxLDYgQEAgc3RhdGljIGxvbmcgX19tbG9ja192bWFfcGFn ZXNfcmFuZ2Uoc3RydWN0IHZtX2FyZWFfc3RydWN0ICp2bWEsCiAJaWYgKHZtYS0+dm1fZmxhZ3Mg JiBWTV9MT0NLRUQpCiAJCWd1cF9mbGFncyB8PSBGT0xMX01MT0NLOwogCi0JLyogV2UgZG9uJ3Qg dHJ5IHRvIGFjY2VzcyB0aGUgZ3VhcmQgcGFnZSBvZiBhIHN0YWNrIHZtYSAqLwotCWlmIChzdGFj a19ndWFyZF9wYWdlKHZtYSwgc3RhcnQpKSB7Ci0JCWFkZHIgKz0gUEFHRV9TSVpFOwotCQlucl9w YWdlcy0tOwotCX0KLQogCXJldHVybiBfX2dldF91c2VyX3BhZ2VzKGN1cnJlbnQsIG1tLCBhZGRy LCBucl9wYWdlcywgZ3VwX2ZsYWdzLAogCQkJCU5VTEwsIE5VTEwsIG5vbmJsb2NraW5nKTsKIH0K --0015176f0d283cb13b04a0bd4b62-- -- 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/