Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4981005pxu; Tue, 22 Dec 2020 05:46:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwn5XCOZ0ifkhKymJPIdNS3Cipl1npZC3v3yeyz5NndIs2N+mSvGzBsU4EXwrGaYVamFbk X-Received: by 2002:a17:906:3712:: with SMTP id d18mr20364868ejc.178.1608644803934; Tue, 22 Dec 2020 05:46:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608644803; cv=none; d=google.com; s=arc-20160816; b=tGQx6Z2RCt7Tn3j71PYfA4XJhAer+RznHmPlLq9sPln2kLmuD7gXqfkDV4GUdF2fiS pj++DUnHD5KGdQL71Qw+SsLvdk9QkFRO2r8+xQrgLSW0eBfBIITR9IRgjcx0fqLuHCbP 0SmzoPZBc3/j0TkPrXsP6Hokzx25+kCpTYBf9j11iP7Yh05F2Td8sHbuuBB/WCEE4o3t jcsKalT77nJqZ4cf+So/PwdII+c94C1sYoRD6cZ9je0B1j4y2Q/BSJAbod8GhBKOQDuo OEsAW/TI10fv1R4v21YmmDeQSo2xulzYymazMESgBFf1LXEbHuA2QaeCYF54/ADiPxSA Ku6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eXSyGreQyqo1MSmMoq/qMuV3OWCVLUj1olxIkYhTkl0=; b=hKJgmz+Pa+kyqcF8zgAV0EmYBfVp06gpbFJWtdxGgqkn+bMRpklZaAuS94A39L3uMZ DKU4VIv1sJxTAyLVUp0SyM6q5MGrfSkkbkXG6/FvpBQDoT7z98JxBsKwCqNrO2tGdk+3 Mm300TzrY7mVCWSIvggCCFKAtEF8s1fE+8BKYwW70VwDk854kz51/kFbcIOVhaIyxd59 JPYb58IrNmv4BImEDTRhwibYNUr0GDlIJC8KPxk5uxcz1MSR5pa+i8zXOcNMmO9o6ZQk 1xS1PFmKmIcC2MvjiGqpezR+jWJi9z7OeI3KnrovOA2UOzgyeh55kM4wMMOINx+Ms+X+ qfnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Ix8mJC38; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp20si10153368ejc.620.2020.12.22.05.46.20; Tue, 22 Dec 2020 05:46:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Ix8mJC38; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727168AbgLVNpi (ORCPT + 99 others); Tue, 22 Dec 2020 08:45:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727062AbgLVNph (ORCPT ); Tue, 22 Dec 2020 08:45:37 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 423A5C0613D3; Tue, 22 Dec 2020 05:44:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=eXSyGreQyqo1MSmMoq/qMuV3OWCVLUj1olxIkYhTkl0=; b=Ix8mJC38mYvh+lNbE2zOg73S2V aW8+bJnapCtY5yvKkPflK2jIdDa2nZaR3ghWYIzq0sfRZ02qOCAZfEHG/mQxOfcyk+/5GLm05CZQ9 1//PIsYFfsPOM9YnsFc0MK/+cW401LKBSC2npcgsbbVx1H8rIZUUCGQvsW/j3gF48T2Ea/CWgFu1O I9Naeba9H0I76TnpqQ+UlimvfzMahfalNYx17Dgwpb1XFwQw7Ul9big6pvyPf8LViAJOc/g7sy+8P nJ0DkW1OpNbL/pl3rC86J8zT2uhv7RCpK+zUzX7Ig0Fjcsl47jE82uuldUA8ToZjHCcGMET5UW5we NmGAkx3g==; Received: from hch by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1krhxu-0002DJ-GS; Tue, 22 Dec 2020 13:44:38 +0000 Date: Tue, 22 Dec 2020 13:44:38 +0000 From: Christoph Hellwig To: Jann Horn Cc: Minchan Kim , Christoph Hellwig , Suren Baghdasaryan , Andrew Morton , Michal Hocko , Michal Hocko , David Rientjes , Matthew Wilcox , Johannes Weiner , Roman Gushchin , Rik van Riel , Christian Brauner , Oleg Nesterov , Tim Murray , Linux API , Linux-MM , kernel list , kernel-team Subject: Re: [PATCH 1/2] mm/madvise: allow process_madvise operations on entire memory range Message-ID: <20201222134438.GA7170@infradead.org> References: <20201124053943.1684874-1-surenb@google.com> <20201124053943.1684874-2-surenb@google.com> <20201125231322.GF1484898@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 11, 2020 at 09:27:46PM +0100, Jann Horn wrote: > > Can we just use one element in iovec to indicate entire address rather > > than using up the reserved flags? > > > > struct iovec { > > .iov_base = NULL, > > .iov_len = (~(size_t)0), > > }; > > In addition to Suren's objections, I think it's also worth considering > how this looks in terms of compat API. If a compat process does > process_madvise() on another compat process, it would be specifying > the maximum 32-bit number, rather than the maximum 64-bit number, so > you'd need special code to catch that case, which would be ugly. > > And when a compat process uses this API on a non-compat process, it > semantically gets really weird: The actual address range covered would > be larger than the address range specified. > > And if we want different access checks for the two flavors in the > future, gating that different behavior on special values in the iovec > would feel too magical to me. > > And the length value SIZE_MAX doesn't really make sense anyway because > the length of the whole address space would be SIZE_MAX+1, which you > can't express. > > So I'm in favor of a new flag, and strongly against using SIZE_MAX as > a magic number here. Yes, using SIZE_MAX is a horrible interface in this case. I'm not a huge fan of a flag either. What is the use case for the madvise to all of a processes address space anyway?