Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3643337pxu; Tue, 8 Dec 2020 18:27:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXmSWdkc8MSYI86WQBlkUToAa1N+FnbsotWVxS9yUKRlW6/UoD6eadfXDZag7m5cHSra+3 X-Received: by 2002:a17:906:7f13:: with SMTP id d19mr276593ejr.54.1607480839007; Tue, 08 Dec 2020 18:27:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607480839; cv=none; d=google.com; s=arc-20160816; b=EYoycXSW4VYa9SCobkvrkoLCBpVtSh7iPvhft0uAYpKL30KYfK/q6xT2BGluDHiHow HL9lBkXhjkkIaGUUbMpIpkbtz3S3pzH8II4fNkHA2AGurs8cLhMbsbCQHBgXLcPDwWY1 54d4IK41jcRUr5MhPAw7WWmZfBULBTvz/UArZuUWS1jvREydUra9Zt6JZgKvTSeAtHgo zOfLWmYO9gNO9qdk/Yt9FsOs+UW7NWzKdjj60dhPXozum+EKnYDXJgAZ6bHnJoa4Hswp 0V9yYJdAWUgmYKhBMMkxmSLtejUYuRq1uVuxTM/r7Q66TIzsQS+dQi19ncRk/z2L5zAF DPuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=lQ8mT/pCMSv0ymhWw//1/XPnET8l0Y0Ir6PV4fg1hEQ=; b=S9NvrTtnWmGS9oqz6NM3UNWkbCNhyV+zYQn4jfajdHsPw2J4rG+lX9jmMb60W5ujpP 180dKSFqjU1L36cREYQ5rLc72IACdyv8PJIhayPvguF7C09csCCVOh3l5PlEwiJyddQr YGlCsD37TIwIHYXjLbNSgbrS3bpaF4CB9uAlawzAUXF9oBRjHBtJGiBABPj82tCBHaOf NmvntdWtEjIDGIXQJ2gcAcc5LZAM09EukL/6orRkkDnoRiag3qdULRtJ/vCiPBYqFGvh GqugLQjRWGZBU8GbKbvPqwOoWVeDdp6clqW+Cluu2FDPLsiqBWAl9Q/YSeR/7V9bMUWY 1yGQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f8si79849edc.529.2020.12.08.18.26.56; Tue, 08 Dec 2020 18:27:18 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726413AbgLICXb (ORCPT + 99 others); Tue, 8 Dec 2020 21:23:31 -0500 Received: from mga09.intel.com ([134.134.136.24]:48066 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725789AbgLICXb (ORCPT ); Tue, 8 Dec 2020 21:23:31 -0500 IronPort-SDR: uHvzLIC6jXf6pie8/ZcfVVV4zW0ilI3XeAdBTyjlqwsdUZT0LIXonUlht0vluLImeJoqByE42Y jZMSO13CObtQ== X-IronPort-AV: E=McAfee;i="6000,8403,9829"; a="174153825" X-IronPort-AV: E=Sophos;i="5.78,404,1599548400"; d="scan'208";a="174153825" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2020 18:22:50 -0800 IronPort-SDR: X7OpOgvlReRxSkhPvZFRfdFT0of14sphAk2JsWUHlrfeXmh5ht8zdLca5zdU6Bj+/aeLsroT/U NwCxfiwMznXg== X-IronPort-AV: E=Sophos;i="5.78,404,1599548400"; d="scan'208";a="363934735" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Dec 2020 18:22:50 -0800 Date: Tue, 8 Dec 2020 18:22:50 -0800 From: Ira Weiny To: Dan Williams Cc: "Darrick J. Wong" , Matthew Wilcox , Thomas Gleixner , Andrew Morton , Dave Hansen , Christoph Hellwig , Al Viro , Eric Biggers , Joonas Lahtinen , Linux Kernel Mailing List , linux-fsdevel Subject: Re: [PATCH V2 2/2] mm/highmem: Lift memcpy_[to|from]_page to core Message-ID: <20201209022250.GP1563847@iweiny-DESK2.sc.intel.com> References: <20201207232649.GD7338@casper.infradead.org> <20201207234008.GE7338@casper.infradead.org> <20201208213255.GO1563847@iweiny-DESK2.sc.intel.com> <20201208215028.GK7338@casper.infradead.org> <20201208223234.GL7338@casper.infradead.org> <20201208224555.GA605321@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1 (2018-12-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 08, 2020 at 03:40:52PM -0800, Dan Williams wrote: > On Tue, Dec 8, 2020 at 2:49 PM Darrick J. Wong wrote: > [..] > > > So what's your preferred poison? > > > > > > 1. Corrupt random data in whatever's been mapped into the next page (which > > > is what the helpers currently do) > > > > Please no. > > My assertion is that the kernel can't know it's corruption, it can > only know that the driver is abusing the API. So over-copy and WARN > seems better than violently regress by crashing what might have been > working silently before. Right now we have a mixed bag. zero_user() [and it's variants, circa 2008] does a BUG_ON.[0] While the other ones do nothing; clear_highpage(), clear_user_highpage(), copy_user_highpage(), and copy_highpage(). While continuing to audit the code I don't see any users who would violating the API with a simple conversion of the code. The calls which I have worked on [which is many at this point] all have checks in place which are well aware of page boundaries. Therefore, I tend to agree with Dan that if anything is to be done it should be a WARN_ON() which is only going to throw an error that something has probably been wrong all along and should be fixed but continue running as before. BUG_ON() is a very big hammer. And I don't think that Linus is going to appreciate a BUG_ON here.[1] Callers of this API should be well aware that they are operating on a page and that specifying parameters beyond the bounds of a page are going to have bad consequences... Furthermore, I'm still leery of adding the WARN_ON's because Greg KH says many people will be converting them to BUG_ON's via panic-on-warn anyway. But at least that is their choice. FWIW I think this is a 'bad BUG_ON' use because we are "checking something that we know we might be getting wrong".[1] And because, "BUG() is only good for something that never happens and that we really have no other option for".[2] IMO, These calls are like memcpy/memmove. memcpy/memmove don't validate bounds and developers have lived with those constructs for a long time. Ira [0] BTW, After writing this email, with various URL research, I think this BUG_ON() is also probably wrong... [1] ... It's [BUG_ON] not a "let's check that everybody did things right", it's a "this is a major design rule in this core code". ... -- Linus (https://lkml.org/lkml/2016/10/4/337) [2] https://yarchive.net/comp/linux/BUG.html