Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750979AbbD3NLg (ORCPT ); Thu, 30 Apr 2015 09:11:36 -0400 Received: from mail-la0-f45.google.com ([209.85.215.45]:32868 "EHLO mail-la0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750719AbbD3NLd (ORCPT ); Thu, 30 Apr 2015 09:11:33 -0400 MIME-Version: 1.0 In-Reply-To: References: <20150429193622.GA11892@node.dhcp.inet.fi> Date: Thu, 30 Apr 2015 16:11:30 +0300 Message-ID: Subject: Re: Regression: Requiring CAP_SYS_ADMIN for /proc//pagemap causes application-level breakage From: Konstantin Khlebnikov To: Linus Torvalds Cc: "Kirill A. Shutemov" , Mark Williamson , Mark Seaborn , kernel list , "Kirill A. Shutemov" , Pavel Emelyanov , Andrew Morton , Andy Lutomirski , Linux API , Finn Grimwood , Daniel James Content-Type: multipart/mixed; boundary=001a11c2707e8de7290514f0d53d Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6272 Lines: 100 --001a11c2707e8de7290514f0d53d Content-Type: text/plain; charset=UTF-8 On Thu, Apr 30, 2015 at 2:43 PM, Konstantin Khlebnikov wrote: > On Thu, Apr 30, 2015 at 12:02 AM, Linus Torvalds > wrote: >> On Wed, Apr 29, 2015 at 1:44 PM, Konstantin Khlebnikov wrote: >>> >>> This's no longer true. After recent fixes for "anon_vma endless growing" new vma >>> might reuse old anon_vma from grandparent vma. >> >> Oh well. I guess that was too simple. >> >> If Mark is ok with the rule that "it's not reliably if you have two >> nested forks" (ie it only works if you exec for every fork you do), it >> should still work, right? It sounds like Mark doesn't necessarily need >> to handle the *generic* case. > > What about exposing shared/exclusive bit in pagemap == 1 if > page_mapcount() > 1, otherwise 0 (or vise versa). > > Seems like this should work for detecting CoWed pages in child mm. Something like this (see patch in attachment) --001a11c2707e8de7290514f0d53d Content-Type: application/octet-stream; name=pagemap-add-mmap-shared-bit-for-marking-pages-mapped-multiple-times Content-Disposition: attachment; filename=pagemap-add-mmap-shared-bit-for-marking-pages-mapped-multiple-times Content-Transfer-Encoding: base64 X-Attachment-Id: f_i946wfnx0 cGFnZW1hcDogYWRkIG1tYXAtc2hhcmVkIGJpdCBmb3IgbWFya2luZyBwYWdlcyBtYXBwZWQgbXVs dGlwbGUgdGltZXMKCkZyb206IEtvbnN0YW50aW4gS2hsZWJuaWtvdiA8a2hsZWJuaWtvdkB5YW5k ZXgtdGVhbS5ydT4KClRoaXMgcGF0Y2ggc2V0cyBiaXQgNTYgaW4gcGFnZW1hcCBpZiB0aGlzIHBh Z2UgaXMgbWFwcGVkIG1vcmUgdGhhbiBvbmNlLgpJdCBhbGxvd3MgdG8gZGV0ZWN0IHNoYXJlZCBm aWxlIGFuZCBDb1dlZCBhbm9uIHBhZ2VzIHdpdGhvdXQgZXhwb3NpbmcgUEZOLgoKU2lnbmVkLW9m Zi1ieTogS29uc3RhbnRpbiBLaGxlYm5pa292IDxraGxlYm5pa292QHlhbmRleC10ZWFtLnJ1Pgot LS0KIERvY3VtZW50YXRpb24vdm0vcGFnZW1hcC50eHQgfCAgICAzICsrLQogZnMvcHJvYy90YXNr X21tdS5jICAgICAgICAgICB8ICAgIDMgKysrCiB0b29scy92bS9NYWtlZmlsZSAgICAgICAgICAg IHwgICAgMiArLQogdG9vbHMvdm0vcGFnZS10eXBlcy5jICAgICAgICB8ICAgIDYgKysrKysrCiA0 IGZpbGVzIGNoYW5nZWQsIDEyIGluc2VydGlvbnMoKyksIDIgZGVsZXRpb25zKC0pCgpkaWZmIC0t Z2l0IGEvRG9jdW1lbnRhdGlvbi92bS9wYWdlbWFwLnR4dCBiL0RvY3VtZW50YXRpb24vdm0vcGFn ZW1hcC50eHQKaW5kZXggNmJmYmMxNzJjZGI5Li40MzViMTRjMTNmYjkgMTAwNjQ0Ci0tLSBhL0Rv Y3VtZW50YXRpb24vdm0vcGFnZW1hcC50eHQKKysrIGIvRG9jdW1lbnRh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LAogCVtLUEZfU0xVQl9ERUJVR10JPSAiRTpzbHViX2RlYnVnIiwKKwlbS1BGX01N QVBfU0hBUkVEXQk9ICI1Om1tYXBfc2hhcmVkIiwKIH07CiAKIApAQCAtNDUyLDYgKzQ1Niw4IEBA IHN0YXRpYyB1aW50NjRfdCBleHBhbmRfb3ZlcmxvYWRlZF9mbGFncyh1aW50NjRfdCBmbGFncywg dWludDY0X3QgcG1lKQogCiAJaWYgKHBtZSAmIFBNX1NPRlRfRElSVFkpCiAJCWZsYWdzIHw9IEJJ VChTT0ZURElSVFkpOworCWlmIChwbWUgJiBQTV9NTUFQX1NIQVJFRCkKKwkJZmxhZ3MgfD0gQklU KE1NQVBfU0hBUkVEKTsKIAogCXJldHVybiBmbGFnczsKIH0K --001a11c2707e8de7290514f0d53d-- -- 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/