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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C288FC433EF for ; Sun, 24 Oct 2021 19:54:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2C8A661052 for ; Sun, 24 Oct 2021 19:54:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2C8A661052 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 346FB6B006C; Sun, 24 Oct 2021 15:54:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F67A6B0072; Sun, 24 Oct 2021 15:54:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E5676B0073; Sun, 24 Oct 2021 15:54:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id 0E2B26B006C for ; Sun, 24 Oct 2021 15:54:44 -0400 (EDT) Received: from smtpin33.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B706A181AC9C6 for ; Sun, 24 Oct 2021 19:54:43 +0000 (UTC) X-FDA: 78732383646.33.3876554 Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) by imf03.hostedemail.com (Postfix) with ESMTP id C2A1130000A6 for ; Sun, 24 Oct 2021 19:54:39 +0000 (UTC) Received: by mail-lj1-f182.google.com with SMTP id 65so3863240ljf.9 for ; Sun, 24 Oct 2021 12:54:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1p8rRQhrPJGVMBevG1qLWZZPoZkUrXDNHIGpX/wf4OM=; b=F56m+11Ze+7cbDsWSZYCHd6j4FJGTi3YSon3cDO0lheV/b/uBtdV6+AyJ1Fv4IUrh7 6kcOy52uvMo4FAj1dVIS1uTTSzqh6ExgkD6XYRb2rnbVXtCE3X0o0BKvYwDKJx0T7BwD kMZl6RLbws91GB1Nw/aQKN2Yjyt6S3F52tG+o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1p8rRQhrPJGVMBevG1qLWZZPoZkUrXDNHIGpX/wf4OM=; b=7xI4+hiC4lvCZzjj7pi6yOe/4GoI3jCKARsDGWv/IJgesCS0PH/wQdyY/kUad6cg3R 8sIeR/fGgRbPUbYqmtPBDXo8ZBMfrJVw6AYaRZ/4J/1VdYvSKdYLzQmP8URk8m5kT6Ni 7lVa+etqL4e1uy65Y94XDQEBGt9vrJ8Yk1ONW1O3Ju2TRLPWv3VLupUYCiaO4KBSyVcq L8MR2YaDAmz0lU9btFjVQS22Gyrac/gwLA/pHV6BGZuwqsel7KAaVkvJ9+e/tVL2mFs0 qzTTDHJVM9fmSLTwz2xiV/nUrig90ASIGUrSyKOHXyS9GCO4p28xNIb7iOUB4Ec5PKM+ 1oeg== X-Gm-Message-State: AOAM531A8eny4BGipalzh3gezaoapbF7KqryS8l27aw2xXfz5hf5vFC3 WIDYoN+aHYXLpCHgRV95fd7Wpav+YVivL42/ X-Google-Smtp-Source: ABdhPJzBFuw1MoTllolyj+uWzVazDFDWCPKal5i6CZFGyUjH1tvp6Mxe6fRiuN/l1nVW+1cg5jtC0w== X-Received: by 2002:a05:651c:a09:: with SMTP id k9mr14073014ljq.442.1635105280794; Sun, 24 Oct 2021 12:54:40 -0700 (PDT) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com. [209.85.167.51]) by smtp.gmail.com with ESMTPSA id m6sm458383lfu.82.2021.10.24.12.54.39 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 24 Oct 2021 12:54:39 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id x192so6249471lff.12 for ; Sun, 24 Oct 2021 12:54:39 -0700 (PDT) X-Received: by 2002:a05:6512:10d0:: with SMTP id k16mr12974048lfg.150.1635105279149; Sun, 24 Oct 2021 12:54:39 -0700 (PDT) MIME-Version: 1.0 References: <00000000000064451505cf0a3aa2@google.com> In-Reply-To: <00000000000064451505cf0a3aa2@google.com> From: Linus Torvalds Date: Sun, 24 Oct 2021 09:54:22 -1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [syzbot] WARNING: refcount bug in memfd_secret To: syzbot Cc: Andrew Morton , jordy@jordyzomer.github.io, jordy@pwning.systems, Linux Kernel Mailing List , Linux-MM , syzkaller-bugs Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: C2A1130000A6 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=F56m+11Z; spf=pass (imf03.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.182 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none X-Stat-Signature: bdkhwps16uw4dmgyannfs94jhnakenge X-Rspamd-Server: rspam06 X-HE-Tag: 1635105279-222458 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 Sat, Oct 23, 2021 at 9:35 AM syzbot wrote: > > syzbot found the following issue on: > > HEAD commit: 9c0c4d24ac00 Merge tag 'block-5.15-2021-10-22' of git://gi.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=115a0328b00000 > kernel config: https://syzkaller.appspot.com/x/.config?x=59f3ef2b4077575 > dashboard link: https://syzkaller.appspot.com/bug?extid=75639e6a0331cd61d3e2 > compiler: Debian clang version 11.0.1-2, GNU ld (GNU Binutils for Debian) 2.35.2 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13a035c2b00000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14ae869f300000 > > The issue was bisected to: > > commit 110860541f443f950c1274f217a1a3e298670a33 I think that commit is actually just buggy. "secretmem_users" is not actually a reference count. There's no "magic happens when it goes down to zero". It's purely a count of the number of existing users, and incrementing it from zero is not a probolem at all - it is in fact expected. Sure, zero means "we can hibernate", so zero and overflow are somewhat special, but not special enough to cause these kinds of issues. I have reverted this commit in my tree, because honestly, the whole "try to overflow exactly, and hibernate" threat model just isn't worth this all. If people really care, I can suggest - use "atomic_long_t" instead. Let's face it, 32-bit isn't interesting any more, and 64-bit doesn't overflow. - make up some new "atomic_inc_nooverflow()" thing or whatever. but for now this is just reverted. Linus