Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2072897imu; Sat, 5 Jan 2019 13:56:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN65CwUKndooRpweoxL8Eoc3DFRiL9G3kvdE1Dl+pY+YK8qpoKy3hiGDdbma9UdsELLKs/bZ X-Received: by 2002:a62:e044:: with SMTP id f65mr56941828pfh.208.1546725393718; Sat, 05 Jan 2019 13:56:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546725393; cv=none; d=google.com; s=arc-20160816; b=DnNriMb9wPjbXYGtUh+ybFhPXsAuesoPobr8SPqs9qCMW/uP47LcIQGiNXeEdcxvbJ 3cqaApelrIS9MuS84nunMTnb8y+5bHwFKClbrQ4GPx3bpuFbXEKIm9okR6cq6VaUOgI5 3JJ2Sh/nFGwFRImqeV1ZswmT1VqwxsxdvX1N1uwU13KBHCEdIkBsOE0NbdcxIDEc8dI2 Pdqyr9eezS2CXZ5NAmOT369YPWRhDS9Y20NFX49WD3gzSx2s+FSjLBtduwUzAeufQXCg 8DplRSMdG2CzYYurWV1Y1HewpYNFVThfBZmS4RgXj0gGDCWzYmSgpu21V5WKyZ1UmVIr Qixw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=+1ou9Ablj7aPz54GczAfBZDoTjLzri1LRQMpX+g56pk=; b=vB8kBtKLmUfiJes9NQJprnijwFVb+o97eMKkYb9nhvOczkfBAMZxs8WI0DW5C3eTI6 Huvxx7V3/a+JMCaaqj9ttEutHn9EYS+0QxEVKYErUtS+FUc7UuN0z34v2j4BPBsYU+Pb h9xNC9t2yVpGW+1S1cE2i9L4az22MYYHXyNvjtCFC/StcmOvIgKcBum8aK+quZvm8vxp CM0LBQ2wx8iOqkUZy9LIBBbe1tWWGnp95caUAbPEzgEmHrgQBk6rpb6TRm/hhxlx2GPP 9TWfuxmtT6K53jo54pnjK49hlpdDrvqwc9+6DtGn2qpWzbhJdx7uf2PkBdbK8eN54l0a jZkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=aLv2aXvu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cf16si59884514plb.227.2019.01.05.13.56.16; Sat, 05 Jan 2019 13:56:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=aLv2aXvu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726367AbfAEVyY (ORCPT + 99 others); Sat, 5 Jan 2019 16:54:24 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:47037 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbfAEVyY (ORCPT ); Sat, 5 Jan 2019 16:54:24 -0500 Received: by mail-lf1-f66.google.com with SMTP id y14so8731164lfg.13 for ; Sat, 05 Jan 2019 13:54:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+1ou9Ablj7aPz54GczAfBZDoTjLzri1LRQMpX+g56pk=; b=aLv2aXvuQ2PcnOES4bn3an92ZWFwet2D8xWSCbWkNHh0ScTlLJjUThLCdtqbEwdzdq KwMAljejKSH453sW9kRjuoDOKAO+SJ9pEZzB2L0igqHXwWwGHe0+QdjWIuFF/3H43T1S OQj3p5p+5O3bs8MJLbC8JhX9XV5Puwstpxp0E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+1ou9Ablj7aPz54GczAfBZDoTjLzri1LRQMpX+g56pk=; b=TQ7EShg/hL7j33D7KcnGjIya8+F5AHLKSQdoO60CA22qkzYSU8TdLWtQW4R30RM/P6 bA4+q90TdMgPSHPcWqRMOlqFmMX9/U5+djEY5CZPrwp915z0nez0GaGZ3YDaI3ljYPs5 GgRGJTOEHqiIttf2zrFL/rjhy6ZXHh7i6VEFrzU5RxVyXdLHCXfVLhxfOAsOenucbv1X xTCE0O5iaxy1ZETPPke5ag6uycyjvyHV3xrAeM69+eDJVOZ5PiI+z/ChZ7FEyqgHkTUW X4EYX6a1z8LNekGTcuOdnTuUwOlfWtpwH2tOwPKeJ0gtNroE6vcVVBghF9J18Z0XDzAg d1IQ== X-Gm-Message-State: AA+aEWZgWpi83LEXoFVxatkt/9L7IDvZqz6xUYTRf+fRi5Kd+0MGDMoR Jo8Xa04psrjYMK4pD/uXCEsS+H7LV9Y= X-Received: by 2002:a19:ee08:: with SMTP id g8mr28957882lfb.72.1546725261748; Sat, 05 Jan 2019 13:54:21 -0800 (PST) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com. [209.85.208.180]) by smtp.gmail.com with ESMTPSA id q21-v6sm12936082ljc.5.2019.01.05.13.54.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Jan 2019 13:54:20 -0800 (PST) Received: by mail-lj1-f180.google.com with SMTP id v1-v6so35240530ljd.0 for ; Sat, 05 Jan 2019 13:54:20 -0800 (PST) X-Received: by 2002:a2e:9c7:: with SMTP id 190-v6mr24066633ljj.120.1546725259853; Sat, 05 Jan 2019 13:54:19 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Sat, 5 Jan 2019 13:54:03 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mm/mincore: allow for making sys_mincore() privileged To: Jiri Kosina , Masatake YAMATO Cc: Andrew Morton , Greg KH , Peter Zijlstra , Michal Hocko , linux-mm@kvack.org, Linux List Kernel Mailing , linux-api@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jan 5, 2019 at 12:43 PM Jiri Kosina wrote: > > > Who actually _uses_ mincore()? That's probably the best guide to what > > we should do. Maybe they open the file read-only even if they are the > > owner, and we really should look at file ownership instead. > > Yeah, well > > https://codesearch.debian.net/search?q=mincore > > is a bit too much mess to get some idea quickly I am afraid. Yeah, heh. And the first hit is 'fincore', which probably nobody cares about anyway, but it does fd = open (name, O_RDONLY) .. mmap(window, len, PROT_NONE, MAP_PRIVATE, .. so if we want to keep that working, we'd really need to actually check file ownership rather than just looking at f_mode. But I don't know if anybody *uses* and cares about fincore, and it's particularly questionable for non-root users. And the Android go runtime code seems to oddly use mincore to figure out page size: // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. which is all kinds of odd, but whatever.. Why mincore, rather than something sane and obvious like mmap? Don't ask me... Anyway, the Debian code search just results in mostly non-present stuff. It's sad that google code search is no more. It was great for exactly these kinds of questions. The mono runtime seems to have some mono_pages_not_faulted() function, but I don't know if people use it for file mappings, and I couldn't find any interesting users of it. I didn't find anything that seems to really care, but I gave up after a few pages of really boring stuff. Linus