Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4270456pxu; Wed, 9 Dec 2020 12:38:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxu4Kp927t64vxSgDOV5BYbz1ecxlsRXltBv5eWd6jTUNG9HSIAWrxsbA2laGW1J8GM0I23 X-Received: by 2002:a17:906:3b8b:: with SMTP id u11mr3501516ejf.489.1607546322281; Wed, 09 Dec 2020 12:38:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607546322; cv=none; d=google.com; s=arc-20160816; b=yVMWXgTJ8j7Vt3duJv9WLy3yooboQZvsF1LtvM5o1Um4bIeiMl3wIGNqVuXme9w/b8 J+DGFPLluLMLy3KeqWJVPBZVzfBfD++sTAODOjc1U3Ip3UoBiSnNI7ouujgzqeddcTUb D4hQiOHFIr13WqyLSq+Usur0HA5PQRQwc0IN2YzBBP9kCVW7av6BiiA1DYVw8qXS0Lt/ bWpYKKSCKCx38HcDYPnzZbmDeFpZ6k50RwPh3MP5Luj8d1dWBgcM4rcDfxfvn/Cf1p/o gsS839xdcZBUOYsibuUaBCCNvfBjkgSarPKlmQtxiA1VN3GK4gs1jL/O9P/e9S+9lJCf KaaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=dsll6aprTPCbO5sTOq3PqZayd/y4SfYjxDP+csUrtX4=; b=XiAdGieneMcMdwbHYJbSNjWWc10+acRm3uswq5rgt4gnvxb+3qFUBucr4ZoKAjI83X r66R5sAZd23D/iNN3owvhTz7p0sLqsU6ij25yXM95Pe1eXmvJMBN4y3SVgoKnPJ2TyrH CQx8jT/FfOdN/RJ4fLVqrNnN2W+V4pqc29DV9cqUUgWmeUqnTGJN17pMeii9leZfNPvm P9QAB9VEVDzH3Wkrs3nGvaXcgio3N3Wj5TCkR+c3iWgECixMtiWpBhOjB3OAeyPNwC5P GCoiTsfkeQZqahSbus04O0PdmE3FJOi/9x1t29hSgCUHi5wzI89vhgFXATiiFXeixfvc paOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=06AsXUG6; 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 r9si1359205ejr.645.2020.12.09.12.38.19; Wed, 09 Dec 2020 12:38:42 -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=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b=06AsXUG6; 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 S1728508AbgLITs6 (ORCPT + 99 others); Wed, 9 Dec 2020 14:48:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727848AbgLITsk (ORCPT ); Wed, 9 Dec 2020 14:48:40 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16436C0613CF for ; Wed, 9 Dec 2020 11:48:00 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id f23so3902433ejk.2 for ; Wed, 09 Dec 2020 11:48:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dsll6aprTPCbO5sTOq3PqZayd/y4SfYjxDP+csUrtX4=; b=06AsXUG6DFkUZdeym5IUJf5akhsWQWaGOarJsg3OZdNkLNQSeAcU8oTGFenI+cm8au tEirEk7bmHNQCIqJOK5J0Z20mWnml6/IsYhAoVEJJN4+yekg90X398kci4VxdZi83Tst RTD6NL9bNQFQUsxvTFRbjMzTDltf1rL1FmCuQf9cURXgbdKD825/Rkcd9Dc8OTyrJh21 ijoF//0UdWodetZLQCVANlUGfGa2Izs4VDPKYZ8sEeEelkk+ZjaM9pKDn/XzYBRfWRkQ 2/W79SnraP4NANLAixBmzv9g7e6INw8FcRHbhILTDKrxI3aGXSVWxQwsufRZgQknhv+k wvoA== 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=dsll6aprTPCbO5sTOq3PqZayd/y4SfYjxDP+csUrtX4=; b=pdxwaYqkO0F9uNN+mUgvLJQJUyYv3xOr4Tiyw4mWVdyob7WXyfBZC3Fbu08ZsmZrcP 4SS4gVpd4XgVlehAucQ5ECnn+p+QY+DnSruyoAoQWL1f3ErjV6k801g83/kscYMAWkOB u6mDj3egD/7UQAChl9MpJHkqzaMt5JuInYfHN9+R2dyg/znuVCzvxL8SkflsvY/TeNEu ppWQWqpc447zk1nQ2aL5hF4TJnkOhZ4nQOKE9bdJ1iseWCBzoHc/D35cXus/V0s2qClF wryGRapGgS+faztPqvHFLBQ4cuZ2DKr9ciHNpCLx4DHctko0l0sbRQHIPS1rHkm6S8l8 p5bg== X-Gm-Message-State: AOAM533Tjkvl9HiW2UkQo/WF1/VVhPKd61Zvvj7j96jAHg5Sd5XoCOrQ zTvwZCpNCWuFjAWwjq0hKCC9t1SRSYewsHfRSM/JJw== X-Received: by 2002:a17:906:518a:: with SMTP id y10mr3497106ejk.323.1607543278769; Wed, 09 Dec 2020 11:47:58 -0800 (PST) MIME-Version: 1.0 References: <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> <20201209022250.GP1563847@iweiny-DESK2.sc.intel.com> <20201209040312.GN7338@casper.infradead.org> In-Reply-To: <20201209040312.GN7338@casper.infradead.org> From: Dan Williams Date: Wed, 9 Dec 2020 11:47:56 -0800 Message-ID: Subject: Re: [PATCH V2 2/2] mm/highmem: Lift memcpy_[to|from]_page to core To: Matthew Wilcox Cc: Ira Weiny , "Darrick J. Wong" , Thomas Gleixner , Andrew Morton , Dave Hansen , Christoph Hellwig , Al Viro , Eric Biggers , Joonas Lahtinen , Linux Kernel Mailing List , linux-fsdevel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 8, 2020 at 8:03 PM Matthew Wilcox wrote: > > On Tue, Dec 08, 2020 at 06:22:50PM -0800, Ira Weiny wrote: > > 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(). > > Erm, those functions operate on the entire PAGE_SIZE. There's nothing > for them to check. > > > 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. > > Oh good, then this BUG_ON won't trigger. > > > 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. > > Silent data corruption is for ever. Are you absolutely sure nobody has > done: > > page = alloc_pages(GFP_HIGHUSER_MOVABLE, 3); > memcpy_to_page(page, PAGE_SIZE * 2, p, PAGE_SIZE * 2); > > because that will work fine if the pages come from ZONE_NORMAL and fail > miserably if they came from ZONE_HIGHMEM. ...and violently regress with the BUG_ON. The question to me is: which is more likely that any bad usages have been covered up by being limited to ZONE_NORMAL / 64-bit only, or that silent data corruption has been occurring with no ill effects? > > 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] > > BUG() is our only option here. Both limiting how much we copy or > copying the requested amount result in data corruption or leaking > information to a process that isn't supposed to see it. At a minimum I think this should be debated in a follow on patch to add assertion checking where there was none before. There is no evidence of a page being overrun in the audit Ira performed.