From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66F25C433F5 for ; Fri, 30 Sep 2022 01:30:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80D5A8D0002; Thu, 29 Sep 2022 21:29:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 796428D0001; Thu, 29 Sep 2022 21:29:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60F0D8D0002; Thu, 29 Sep 2022 21:29:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4E87E8D0001 for ; Thu, 29 Sep 2022 21:29:59 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 20AE4121484 for ; Fri, 30 Sep 2022 01:29:59 +0000 (UTC) X-FDA: 79967020518.17.476999A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id AF428180008 for ; Fri, 30 Sep 2022 01:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664501398; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=o0qwcHOqcRJEPJox6d6ejyTZ0YHPJhGhid3eXT/4M8s=; b=iBHhzeF6eEZ9js025twCwLwCqL55luxgaQQC/1aU5RkUXOyCOgFD9+uoCsd/ihSKwxGOyZ ZIemzY8sacyGCalHPMVQ/InFyj0YyylNuvAmeDnyDJq41/iOSCOSeJHOXTbUSVDBRi7L1X A3VnkDxBT2UhV4PaL24ODmf4OFmOa7w= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-620-S5PXOp2GM9ySQnz084562A-1; Thu, 29 Sep 2022 21:29:57 -0400 X-MC-Unique: S5PXOp2GM9ySQnz084562A-1 Received: by mail-qk1-f198.google.com with SMTP id bl17-20020a05620a1a9100b006cdf19243acso2645332qkb.4 for ; Thu, 29 Sep 2022 18:29:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=o0qwcHOqcRJEPJox6d6ejyTZ0YHPJhGhid3eXT/4M8s=; b=OrJ4qvRE8mU4ubIKHI2Py+hGwI8MWacVpItR23TUjixQIGAa94Zja4mAAxf+dEt0XB CfFOdlvzFQSODllHbRJoTfa8UAYZWliU0kTxqjSjm1R+5iic0g28zS6jkB+pmi88eMLz mqsqxavI+IZNZLhv2OV3GtcuA1CFIORpbiHUMLLniCGnT4bBye16vCmb1b2ctxyojIdd DypJFocleSdBCF3MWvOJH1r/widNImsUS2uv+R1llnCCe8ZSRmjjIg9G7JoJsHmRRIkI ozacrfwpf2Ypicf2kXaNVPzxMiGarlkPcyVCUiJo4/58ZQuplVuh1TGUG6nuq1hJ0oj6 b7SA== X-Gm-Message-State: ACrzQf0iEDRH62Q7FlXhn2idhRFK/p++IooVlffx40PlebcvenkAWxUE tIw5Cs4OkGra8ocLRiH0bNb7iw9wZwgZvzLV0/8rIGfzgTCLWRygs2UeKrOFhWFRZ05X1iNNb1x R4A1CSWVY0TM= X-Received: by 2002:a05:620a:16b9:b0:6cd:ee77:4223 with SMTP id s25-20020a05620a16b900b006cdee774223mr4452122qkj.114.1664501396708; Thu, 29 Sep 2022 18:29:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4s3EFkkJr/z6Co6lGuauJk3Y11JdFiTHgJ5pNpuAn6mB5jv+A5uo3QGvuI6PK/j5Yj6jEgcg== X-Received: by 2002:a05:620a:16b9:b0:6cd:ee77:4223 with SMTP id s25-20020a05620a16b900b006cdee774223mr4452105qkj.114.1664501396380; Thu, 29 Sep 2022 18:29:56 -0700 (PDT) Received: from xz-m1.local (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id a5-20020ac85b85000000b0035ba7012724sm678681qta.70.2022.09.29.18.29.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Sep 2022 18:29:55 -0700 (PDT) Date: Thu, 29 Sep 2022 21:29:54 -0400 From: Peter Xu To: Mike Kravetz Cc: Hugh Dickins , Axel Rasmussen , Yang Shi , Matthew Wilcox , syzbot , akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, llvm@lists.linux.dev, nathan@kernel.org, ndesaulniers@google.com, songmuchun@bytedance.com, syzkaller-bugs@googlegroups.com, trix@redhat.com Subject: Re: [syzbot] general protection fault in PageHeadHuge Message-ID: References: <0000000000006c300705e95a59db@google.com> <7693a84-bdc2-27b5-2695-d0fe8566571f@google.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iBHhzeF6; spf=pass (imf06.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664501398; a=rsa-sha256; cv=none; b=CQn61KX5HacnkA5lKGWwK0aeLcWxSOZLjLGWZTexIUwczi3aJk4MpT4TZsbTTJv3/H0W/O Yu6/thlpARxsBX+GTcNqMlqMPol+HLPKks+MgEQuKsA3cLaoh9rBXdtLIfGIjs2DjpmCQv 3xeE969wk2ZAFsXYoFaEZpZtYno9518= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664501398; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=o0qwcHOqcRJEPJox6d6ejyTZ0YHPJhGhid3eXT/4M8s=; b=Rz9LqlI4V91/906M9jqWY48j8zEulfdpViXGRAmCoz0KBOD1dwy1zHFF4l+LxN9GWHesQS GHN9uRGlRRa5tnGYx6798paWcCjCWC/4Y/N5o41FziG9zsspc9roGovZMWFd30WK3xpTob yBCXRM25r0OLEltJ0FxWQIbbIaR54gY= X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: AF428180008 X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iBHhzeF6; spf=pass (imf06.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: zgz176ztu9udfnj8hbh4nkusp5i5cjww X-HE-Tag: 1664501398-410902 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi, Mike, On Thu, Sep 29, 2022 at 04:33:53PM -0700, Mike Kravetz wrote: > I added some TLB flushing to hugetlb_mcopy_atomic_pte, but it did not make > any difference. Suggestions would be appreciated as cache/tlb/??? flushing > issues take me a while to figure out. It seems the UFFDIO_COPY for hugetlb is the major issue here, in that for private mappings we don't inject the page cache. I think it makes sense in that e.g. we don't want to allow a private mapping to be able to write to the page cache. But afaict that's not correct because UFFDIO_COPY resolves exactly page faults in page cache layer for file backed memories. So what we should do is inject page cache but mark the page RO, waiting for a coming CoW if needed. I'll attach one patch fix that will start to inject the page into page cache for UFFDIO_COPY+hugetlb even if mapping is private. Another test patch is also added because otherwise the private hugetlb selftest won't work after the fix applied - in the selftest we used to use DONTNEED to drop the private mapping, but IMHO that's not enough, we need to drop the page cache too (after the fix). I've also have the test patch attached. Feel free to try out with the two patches applied. It started to work for me for current issue. I didn't yet post them out yet because after I applied the two patches I found other issues - the reserved pages are messed up and leaked. I'll keep looking tomorrow on the leak issue, but please also let me know if you figured anything suspecious as I know you're definitely must more fluent on the reservation code. And that's not the only issue I found - shmem can have other issues regarding private mappings; shmem does it right on the page cache insertion but not the rest I think.. I'll look into them one by one. It's quite interesting to dig multiple things out of the write check symptons.. -- Peter Xu