Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp730718pxm; Fri, 25 Feb 2022 18:34:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJympKyrU0cL1B8dIhLjRiGbRTsqt2kgF5uPlJd1f05iMlo/tB6GKcWgDj36/80gSwfvOOh2 X-Received: by 2002:a17:903:24d:b0:14f:84dd:babb with SMTP id j13-20020a170903024d00b0014f84ddbabbmr9909677plh.47.1645842852507; Fri, 25 Feb 2022 18:34:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1645842852; cv=pass; d=google.com; s=arc-20160816; b=mWATfb/I/zASEEM/+aDkm2+9yE7D3QAmsNDdNdG2Z+CeuRZiMYpQPhySy3q5nb2D1s +qub+c6iykBkJcow1dR1azCRrJsQpTE9O0mGGSQObaCPPrTZDoHtpxT8TGLlou2it8Hq 3NYzXdy6VS6++Mn9fH0Q6TBTJixUwYP3kczQn1u/tS79x3yMCFUbYEaE1rCPlEY+rdYL O6fKQs/QKtWs9I+ArD1CvN6YV7T/g7vbfVJQjx/ISxKyal1vqgxxkDRvVfs5ly9amuof LdNmQYbkLLVenIgMUovNE6BhmCOM/Em3zUxY52b6QebtaKF6uMY2m+CkuZrODhPXGux0 lViA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=uVSC/PMTzsHigsiGIHK23BY5jCZtKVlO5wz9TlMqa3k=; b=FHAvKNAcdCvzaV6780NjRwPkhYjxh0YB4Iid/VpLr76SrKbz8hcCKey+cLlkiTanDQ Zj2QMi9EVd+RuIFAtayrYs9pLR+4+SGZ2MUIwJt1C+8MD99zkdmo0on4Bj+0vUBHgdfQ MNSyDZeNjYF9ZbRsQ3wt+T5I46X7L67XnK0Kn+J3JpAg//u/dDZe7fueYg6hP/+cAyMQ Mot9dFXfn4ShW/fF3QQOlL1rRVxvKVvMZJXsOmBcgpIT2dHOzbjx1EHsY7bvzU7G4+Lo sdGMjeIvtAWzLCAtMUWVzjFGye53Zxx1aztQ3eyhTHfxTw/U0hpAhHClTkESyZ6Bvq4T lRLg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=kDffCMT8; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=softfail (google.com: domain of transitioning linux-ext4-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q19-20020a056a00089300b004e16ac631bbsi3285977pfj.381.2022.02.25.18.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 18:34:12 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-ext4-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=kDffCMT8; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=softfail (google.com: domain of transitioning linux-ext4-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D699929C3FD; Fri, 25 Feb 2022 18:00:23 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231862AbiBYVeN (ORCPT + 99 others); Fri, 25 Feb 2022 16:34:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229595AbiBYVeM (ORCPT ); Fri, 25 Feb 2022 16:34:12 -0500 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam08on2052.outbound.protection.outlook.com [40.107.102.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 21274210D75; Fri, 25 Feb 2022 13:33:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CHwnO7uyXO//pUXbN4sOrns6PJXT1/RtlA+Iz7c/s5IYNqCqhd/IGQOlBMsV1861nuGGTA3zOB5yz6qVlmInTZ3XjmO0Vw+cFvZ5rxghHIBN1Zr2/3yMKDEzpAsUoKXh+Hd/pDVnokO6AZ0TzjruwLR7v3uVnjedrfNhqB6Wgp2MnfLe2GkFYX24V5VyaVPr6aHCNdBL7/qfMMUEkLUpv3SKv3KTyzNEond1ukZMCM24UR5r9em+IfCsp9cvDOdpZLOLgcZrrdCu/MTTiEqUecNB86wYlJrZwWnZGhlxtVLBWz5oUUERr9BnagTBYTahEAm0PpKf9up8o+V4MrCpKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uVSC/PMTzsHigsiGIHK23BY5jCZtKVlO5wz9TlMqa3k=; b=LPD3dd/UBzmvv1QBOhc2jOl6Jo2LnRdIRrX7bEQyVHzsUm8Iyu9yMkrtUp9C6AZdpm4FU6LisUICv1+C1micUmwpS2WW26DIF/85jh6k+KtSD8ORt0/ss7VkHq3maGFhudsWCDtKzLYplPu5cOWucw2gnFlCM1e9mgeg5ACf9Xh3QG2WegiWHVsYMQG0362nAtuTQ3L97wMyBNrWxT/VkP0zffNj7NTpPj3qfoE39azonrr/G1lBp+gFNZZ8OAMvUNo7onUoNOPx+u9Oe6ka52CCc5qYb4dMC5oim8K6URxPZKep6XY0Uq0XgpID2Aa1Eq1RP9h/SOZnTS9xJSFT/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uVSC/PMTzsHigsiGIHK23BY5jCZtKVlO5wz9TlMqa3k=; b=kDffCMT8Sypk2SSWZ9oO8Qj9PualVPiSyTbWMBLzQXZph2dTNaUhF7fqD5c0Cqcgt/g15fuYg/9A51ILQJwORw3qlvjJgESFqymdYE6S7QHqDSgbNeGRRhMcQQlfg5/D9qYgEfPUhF55eNiSx4PbyCsxMIGUr8ijd/NEhcp7Bkr+F9h4ujQgjJzzOP7j4kMemyI4rH5bzCazFnJKOA/06KrZiWPb9JqQp+fjs7wTM3KY9XZH5bEC3eO09wB0HBio+1px8c6bBo6JF5EF4/U51YXLdPQOSZs3Hucj98LqZUvdSzF7DJpmSgXIoFZvVYfh03J6E3bUqhGDL6BCh12SHg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) by BN6PR12MB1153.namprd12.prod.outlook.com (2603:10b6:404:19::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.22; Fri, 25 Feb 2022 21:33:37 +0000 Received: from BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::498:6469:148a:49c7]) by BY5PR12MB4130.namprd12.prod.outlook.com ([fe80::498:6469:148a:49c7%7]) with mapi id 15.20.5017.026; Fri, 25 Feb 2022 21:33:37 +0000 Message-ID: <2f9933b3-a574-23e1-e632-72fc29e582cf@nvidia.com> Date: Fri, 25 Feb 2022 13:33:33 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH -v3] ext4: don't BUG if kernel subsystems dirty pages without asking ext4 first Content-Language: en-US To: Theodore Ts'o , Eric Biggers Cc: Lee Jones , linux-ext4@vger.kernel.org, Christoph Hellwig , Dave Chinner , Goldwyn Rodrigues , "Darrick J . Wong" , Bob Peterson , Damien Le Moal , Andreas Gruenbacher , Ritesh Harjani , Greg Kroah-Hartman , Johannes Thumshirn , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, cluster-devel@redhat.com, linux-kernel@vger.kernel.org References: From: John Hubbard In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: BY3PR05CA0024.namprd05.prod.outlook.com (2603:10b6:a03:254::29) To BY5PR12MB4130.namprd12.prod.outlook.com (2603:10b6:a03:20b::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 506e02e4-d65b-477b-5be8-08d9f8a67b7d X-MS-TrafficTypeDiagnostic: BN6PR12MB1153:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WTHDBf3Z/mNTIYmrUcyuntsOhEUDWGH0N+I0VaspBEQ+TsnKxm3CtL4dg7onddNKUjQ48/x/yCi8TsE0LYDqMqQG31UYZ/+picbn2s7L3YDi5Mp8NjQMMG7bcfVlUz2MMRu0nuuURuQ3ovGphdKQ4IPiJRyz0MjT7vCuNqUFshdhnxN0XXuqes3bHApwEThvMQ/Q68yBYWm/vW+6tbdagmhQZarPK3FIin8OxcwVnFY6pkSAQe5mlrEnEjtRsAbM8DxqLf7tYzr17nEoRo86uBYifNp4VINceLsIKyvd6Dh21oOBgM6iPfC2EMiJjZTMidB6b3VjaorXmrodZ9+3D08PYKu5ujOyCowslwHCLKB/RswBEO492hOtaJV6vs7V4GLW5sMj9PojMc/4RLyvpDdJlElDvxpP2LauZoDWzXyERWELFcuK/HwWZjGsGUBgSV8J5INNhmXVmAAQyDQJW+VnJ5zjUDboLVp+2zEONEu4uRPrvNfYRcaNBK2lFYx+WruFHc485xBpXiv/YAhRGZl4HyCDpFNL83Hx59xN+T/cx9P484hp8uvSSHk0FqrBioRk6KeC2B9ypDtgJ/aY23XUXrHzAdF1Oxb2j77OCjD8yqhbKu/gSQNDNU86EaDbCM52mXr2/Et9BSVxTpHTcpNuihnE7OFQQAQGZfCkJMvXrcHUxlYmHF1yVDx59z9JE3ePDmkrgGLKMB/Hi5UW73fIuGBDNDGZ8FuOoDd0N9Vs2bnujuWVkYov2Fyy13nzJ/LMS8BaJui2nLOSSjnoXwR3IZHWULjm1k22mUBsTadZAHlJZv3X6j4wUW6IzkJ2i2oM0Xt7pXuiYkJ+1DUBNP6RovXNkgxZXc4OVJujAY3Y8wVaBT0Qis/j8izE6Wt+IP1MNaTxWyowVvDWVSbZaQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR12MB4130.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(6486002)(66946007)(66476007)(8676002)(86362001)(966005)(83380400001)(6506007)(66556008)(6666004)(508600001)(4326008)(6512007)(2616005)(31696002)(53546011)(110136005)(26005)(54906003)(186003)(316002)(38100700002)(36756003)(2906002)(8936002)(31686004)(5660300002)(7416002)(14143004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?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3UWxH?= =?utf-8?B?bnNWTEsyTitPRmNWcHBCZWU0bzhIeGdBekJlZURDR3lBWUg5RzFmNEFvMERI?= =?utf-8?B?ZXJmQnVrMTJWckk4Wlp4YmszcDU3L0FHd1cxRkhoWnAxVlVvSmlBcmFhekcx?= =?utf-8?B?QlQ3OHJXdnZ2cmtKYllGZ1pIejFRVVdvUkJ1dDgwM3ZWcWx0WUtqanVHMXR5?= =?utf-8?B?akxqZVUrSStSRHA5K0hXSS9BMERZNndyVlluZ0lxTXI4TUxkYWJHeDVCSXQ1?= =?utf-8?B?ZXMrTG5jMDBuVFloTkZDRTFmNFlVaUJGVDZvSjJKVE1TNWUrVmpicEh2MnVN?= =?utf-8?B?cW5KY1NOcnpaeFFvMFNpVnBFN1kxSGJ4cjBTZmo0K2lWK2ZkTG5VSTR0Vk1R?= =?utf-8?Q?5P6fwexbWxX5gL9qU1d9PkY=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 506e02e4-d65b-477b-5be8-08d9f8a67b7d X-MS-Exchange-CrossTenant-AuthSource: BY5PR12MB4130.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Feb 2022 21:33:37.0958 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 01V3pwCNaEB80XWkEiegMaAafngjOoFR3nYM0eKejkwnh30yc5+xOa/ojSfmrza5RfhyQaVlo6GWnZcSYJmZcQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1153 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 2/25/22 13:23, Theodore Ts'o wrote: > [un]pin_user_pages_remote is dirtying pages without properly warning > the file system in advance. This was noted by Jan Kara in 2018[1] and In 2018, [un]pin_user_pages_remote did not exist. And so what Jan reported was actually that dio_bio_complete() was calling set_page_dirty_lock() on pages that were not (any longer) set up for that. > more recently has resulted in bug reports by Syzbot in various Android > kernels[2]. > > This is technically a bug in mm/gup.c, but arguably ext4 is fragile in Is it, really? unpin_user_pages_dirty_lock() moved the set_page_dirty_lock() call into mm/gup.c, but that merely refactored things. The callers are all over the kernel, and those callers are what need changing in order to fix this. thanks, -- John Hubbard NVIDIA > that a buggy kernel subsystem which dirty pages without properly > notifying the file system causes ext4 to BUG, while other file systems > are not (although user data likely will be lost). I suspect in real > life it is rare that people are using RDMA into file-backed memory, > which is why no one has complained to ext4 developers except fuzzing > programs. > > So instead of crashing with a BUG, issue a warning (since there may be > potential data loss) and just mark the page as clean to avoid > unprivileged denial of service attacks until the problem can be > properly fixed. More discussion and background can be found in the > thread starting at [2]. > > [1] https://lore.kernel.org/linux-mm/20180103100430.GE4911@quack2.suse.cz > [2] https://lore.kernel.org/r/Yg0m6IjcNmfaSokM@google.com > > Reported-by: syzbot+d59332e2db681cf18f0318a06e994ebbb529a8db@syzkaller.appspotmail.com > Reported-by: Lee Jones > Signed-off-by: Theodore Ts'o > --- > fs/ext4/inode.c | 27 ++++++++++++++++++++++++++- > 1 file changed, 26 insertions(+), 1 deletion(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 01c9e4f743ba..008fe8750109 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -1993,6 +1993,15 @@ static int ext4_writepage(struct page *page, > else > len = PAGE_SIZE; > > + /* Should never happen but for bugs in other kernel subsystems */ > + if (!page_has_buffers(page)) { > + ext4_warning_inode(inode, > + "page %lu does not have buffers attached", page->index); > + ClearPageDirty(page); > + unlock_page(page); > + return 0; > + } > + > page_bufs = page_buffers(page); > /* > * We cannot do block allocation or other extent handling in this > @@ -2588,12 +2597,28 @@ static int mpage_prepare_extent_to_map(struct mpage_da_data *mpd) > (mpd->wbc->sync_mode == WB_SYNC_NONE)) || > unlikely(page->mapping != mapping)) { > unlock_page(page); > - continue; > + goto out; > } > > wait_on_page_writeback(page); > BUG_ON(PageWriteback(page)); > > + /* > + * Should never happen but for buggy code in > + * other subsystems that call > + * set_page_dirty() without properly warning > + * the file system first. See [1] for more > + * information. > + * > + * [1] https://lore.kernel.org/linux-mm/20180103100430.GE4911@quack2.suse.cz > + */ > + if (!page_has_buffers(page)) { > + ext4_warning_inode(mpd->inode, "page %lu does not have buffers attached", page->index); > + ClearPageDirty(page); > + unlock_page(page); > + continue; > + } > + > if (mpd->map.m_len == 0) > mpd->first_page = page->index; > mpd->next_page = page->index + 1;