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 AE683C25B06 for ; Thu, 4 Aug 2022 15:03:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0907D6B0071; Thu, 4 Aug 2022 11:03:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 03D436B0072; Thu, 4 Aug 2022 11:03:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1F938E0001; Thu, 4 Aug 2022 11:03:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id D0E656B0071 for ; Thu, 4 Aug 2022 11:03:12 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AB3D5C1723 for ; Thu, 4 Aug 2022 15:03:12 +0000 (UTC) X-FDA: 79762228224.26.C45AF6C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 135B2A013E for ; Thu, 4 Aug 2022 15:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659625385; 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=pekLGGTwGU134kB3IB43TJmHr3pL+ZOzWfhqhMa54MU=; b=IKbpTwL3IOeK8jlmJ6gXaE9IzwSErBbOo1M0/msetnSR3oavcr8jt6ajzmzmZ+SYGo09nO /fKEeEj8zriRkZKf1JkBZ0V8xVAqyb6bLQoVudI/ib/8dlbYD8h8geubi6r6komQ4Yx2CP fvBsb2JJVaq8KkqwrIrEZTuVmOTMbro= 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-168-dMn3qFAJO-KsXpFpjYVa6Q-1; Thu, 04 Aug 2022 11:03:03 -0400 X-MC-Unique: dMn3qFAJO-KsXpFpjYVa6Q-1 Received: by mail-qk1-f198.google.com with SMTP id l15-20020a05620a28cf00b006b46997c070so16277669qkp.20 for ; Thu, 04 Aug 2022 08:03:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=pekLGGTwGU134kB3IB43TJmHr3pL+ZOzWfhqhMa54MU=; b=2NMbN2upl2XUWPi2L/SyT9vDAQd1CY8h+mO8bxJDkS8FY0/bs1Cp3j75YX+lJWKlfx jooh9ZViiINrKEoFewOqykgsx5SO7OUGXthmDUFEsO1Zmhl7MnQXHUDkJATq5OQYAmUl vEjd7IciQqK+Ss7QBQmUUfc/jExz3GQp5DtpqfPXkod+chorn9dn4SkotqBYCOaC3nUe ueaDs1FuBRxfYhm4xBQNsNrzqNEzs+nAPbzble+mjYc2SU0zZEEwGT/FTzdmsmwD2DDE UBC6SJHWBoqcYuraD0c0BzDzi7bg9IY8k/JSIZbpTCjwIjFcNxAVa8QnVpcIatUvNO86 YbPA== X-Gm-Message-State: ACgBeo2mrWvXtp1S7yxjzHBSvfApf5mHATyvx2eqj3OZKfgGCbB1zG0R YHa+WYiQWqcAZ1RHat5DK2iELcwEOVmJyXsmDDi32H5W3AWyqiJu+7j58MsmMPUspG4yix51wXo T6cj4EjjFerk= X-Received: by 2002:a05:620a:4154:b0:6b6:145:6c28 with SMTP id k20-20020a05620a415400b006b601456c28mr1624627qko.573.1659625381896; Thu, 04 Aug 2022 08:03:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR4SnRw3zx1frfS9MHDCpUTfs75xGTCUxzJocWdjVHyndB+Ww02uUX4aInm8ap5i4tebIDZbDg== X-Received: by 2002:a05:620a:4154:b0:6b6:145:6c28 with SMTP id k20-20020a05620a415400b006b601456c28mr1624591qko.573.1659625381443; Thu, 04 Aug 2022 08:03:01 -0700 (PDT) Received: from xz-m1.local (bras-base-aurron9127w-grc-35-70-27-3-10.dsl.bell.ca. [70.27.3.10]) by smtp.gmail.com with ESMTPSA id u13-20020a37ab0d000000b006b90c318dfdsm491961qke.88.2022.08.04.08.02.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Aug 2022 08:03:00 -0700 (PDT) Date: Thu, 4 Aug 2022 11:02:59 -0400 From: Peter Xu To: Dmitry Vyukov Cc: Mike Kravetz , 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] WARNING in hugetlb_change_protection Message-ID: References: <000000000000098a0105e557f130@google.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 1 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1659625389; a=rsa-sha256; cv=none; b=m+TAArcJ98mm8edHsyuhqjdqOE1yDtQmcTs2T2X6deHBzNIQvGpwGYtr1QszeTMkKo9F/J TpBObG9auOCWqejvmwOWGtaTgeNFcp7kxXi2c0BozeojdThCJdQm9eWLuXVQGfmqpktlyV 2y5xjv0YVOLf0BEGk7KTOWRyn6USYKA= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IKbpTwL3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1659625389; 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=pekLGGTwGU134kB3IB43TJmHr3pL+ZOzWfhqhMa54MU=; b=IIWOboOHKiXQhoG8yUcHPgxvs2OahmoBdfWycjfLUojEcZWYOQpoA//20sBYbVcTNnQ9ve EKdSFsnlwRSFJ1aF/yui1EYlLlU9PG6bFZOwfm3E/775QIOD2Pbj0cs5HSfmhneWs+jMWG pmpQS5H5RaiTkmwlWpXJfOsjv8SkkCY= Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IKbpTwL3; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf15.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 135B2A013E X-Rspam-User: X-Stat-Signature: f1z7fwux5jd4jrw3jbc3odxo48183ygb X-HE-Tag: 1659625385-672679 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: On Thu, Aug 04, 2022 at 07:29:56AM +0200, Dmitry Vyukov wrote: > ,On Wed, 3 Aug 2022 at 23:03, Peter Xu wrote: > > > > Hi, Mike, > > > > Thanks for forwarding. > > > > On Wed, Aug 03, 2022 at 10:02:37AM -0700, Mike Kravetz wrote: > > > I'll start looking at this, but adding Peter this may be related to his > > > recent changes. > > > -- > > > Mike Kravetz > > > > > > On 08/03/22 08:32, syzbot wrote: > > > > Hello, > > > > > > > > syzbot found the following issue on: > > > > > > > > HEAD commit: e65c6a46df94 Merge tag 'drm-fixes-2022-07-30' of git://ano.. > > > > git tree: upstream > > > > console output: https://syzkaller.appspot.com/x/log.txt?x=139cc282080000 > > > > kernel config: https://syzkaller.appspot.com/x/.config?x=26034e6fe0075dad > > > > dashboard link: https://syzkaller.appspot.com/bug?extid=824e71311e757a9689ff > > > > compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2 > > > > userspace arch: i386 > > > > > > > > Unfortunately, I don't have any reproducer for this issue yet. > > > > > > > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > > > > Reported-by: syzbot+824e71311e757a9689ff@syzkaller.appspotmail.com > > > > > > > > ------------[ cut here ]------------ > > > > WARNING: CPU: 1 PID: 28745 at include/linux/swapops.h:319 make_pte_marker_entry include/linux/swapops.h:319 [inline] > > > > This is the warning code I added to make sure pte marker won't be created > > if not configured at all: > > > > static inline swp_entry_t make_pte_marker_entry(pte_marker marker) > > { > > /* This should never be called if !CONFIG_PTE_MARKER */ > > WARN_ON_ONCE(1); > > return swp_entry(0, 0); > > } > > > > The stack below comes from a UFFDIO_WRITEPROTECT, however logically it > > shouldn't really reach there - if with !PTE_MARKER then it must be with > > !PTE_MARKER_UFFD_WP, then we should have returned "false" if hugetlb wanted > > to register with uffd-wp: > > > > static inline bool vma_can_userfault(struct vm_area_struct *vma, > > unsigned long vm_flags) > > { > > if (vm_flags & VM_UFFD_MINOR) > > return is_vm_hugetlb_page(vma) || vma_is_shmem(vma); > > > > #ifndef CONFIG_PTE_MARKER_UFFD_WP > > /* > > * If user requested uffd-wp but not enabled pte markers for > > * uffd-wp, then shmem & hugetlbfs are not supported but only > > * anonymous. > > */ > > if ((vm_flags & VM_UFFD_WP) && !vma_is_anonymous(vma)) > > return false; > > #endif > > return vma_is_anonymous(vma) || is_vm_hugetlb_page(vma) || > > vma_is_shmem(vma); > > } > > > > Then the UFFDIO_WRITEPROTECT should have failed already.. at: > > > > if (!userfaultfd_wp(dst_vma)) > > goto out_unlock; > > > > in mwriteprotect_range(). > > > > I still have no idea how the bot managed to trigger a real wr-protect upon > > this vma (which I don't think should have registered with uffd-wp but maybe > > it can be worked around somehow..). However to make this even safer we can > > also guard the pte marker callers with CONFIG_PTE_MARKER_UFFD_WP. Patch > > attached for that, but since this seems to have no reproducer yet maybe no > > easy way to verify it. > > > > At the meantime, I'd also like to double check the kernel config to make > > sure CONFIG_PTE_MARKER_UFFD_WP will always be unset when CONFIG_PTE_MARKER=n. > > Anyone knows where I can fetch the config somewhere? > > Hi Peter, > > If you mean the kernel config for the kernel that produces the > WARNING, it's in the report above under the "kernel config" link. Thanks Dmitry. That was a stupid question and Mike helped me to figure it out.. Somehow I had an impression that config was normally attached to the end of the email so I didn't try looking upwards. :( > > Note that so far it was triggered only once: > https://syzkaller.appspot.com/bug?extid=824e71311e757a9689ff > which may suggest a very narrow race condition. I found that the config is as expected (PTE_MARKER_UFFD_WP not defined), so far I still don't know how the race has happened, so maybe the patch attachd can at least help avoid the warning. It'll be interesting to know the race if hopefully it can have a reproducer somehow. Thanks, -- Peter Xu