Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1725565pxb; Mon, 22 Feb 2021 09:18:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKeEuRTyxcaIrIJ/RSSh9SGbjGDftuMpBbZrZSAiKhRn10ZX77rXVWwQPJhcQiz01EDlV9 X-Received: by 2002:a17:907:9626:: with SMTP id gb38mr21792405ejc.301.1614014325298; Mon, 22 Feb 2021 09:18:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614014325; cv=none; d=google.com; s=arc-20160816; b=wBE4G7x/ukJtkJTKQOaiuoIArHA2wk87DPNLCeO7yn7UEKcwNwXjSqhBhG4iazYZjb vxP8aM3fDIkPDGuokxGK3yJgvly8c3hC9ZrXLq6icKjECWKzZNw7FM26K9yqfAlrJn06 mZFgxNqmT/HJf3tem5Dq+fAxwxMkzTnBBP6d9GTJAJQrNUBTT6nCRj04r/fgUWpwjhfV pQZqi7kCL+3OjJxfJFWR94hWGluMb00tA1CnhTAtkvyVFexRcWklJNeUiYgk1sFYpNGr R+etjK+G2VabI40sbfyHDjVzs4PIj2epwb0DDi0CPlqCnH5HhSY+0sX9ZrZJL7FGe4a8 nPHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=8Sth/vn+x03IFTs3POGULa11n6BLFesiTB4GWeVu0W0=; b=O0dbDEdeNZOlAaMv6BEmvVdzo3b6oQyMWuhTBOtMHQox5OhpvywDnz6LFmrmbwj1ID d+b7+iBAfMYUs3ahWXwGDV+02mmD95ffvls5n0J7F9MzvyxVrrmzefLnMb6H46z0bWxj R5k8+LXvIqf8N1c0XZruLvTyzpb9gPlQW6DHaEZ/y7iWL74kYLrz4DkQVAF3An6/7LaE FISRRMlW2daY8BFqKdc/h94vBgPjrXl6o5ExgfrnQo9nEj98uMS95HKBo5K1AiD436X1 aV3XOtFqwcBAIRLfGaFMB/W2pDJq0YbvlqSB8UilQKQ3Ph2XQF2TClvh5BkBbBuaffBE VgLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dr22si9811654ejc.303.2021.02.22.09.18.13; Mon, 22 Feb 2021 09:18:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230282AbhBVRRN (ORCPT + 99 others); Mon, 22 Feb 2021 12:17:13 -0500 Received: from mx2.suse.de ([195.135.220.15]:45940 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230213AbhBVRRM (ORCPT ); Mon, 22 Feb 2021 12:17:12 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 29A8FAFD7; Mon, 22 Feb 2021 17:16:30 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id D68121E14ED; Mon, 22 Feb 2021 18:16:29 +0100 (CET) From: Jan Kara To: Ted Tso Cc: , Jan Kara Subject: [PATCH] ext4: Add checks to xattr code that we have appropriate reclaim context Date: Mon, 22 Feb 2021 18:16:26 +0100 Message-Id: <20210222171626.21884-1-jack@suse.cz> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Syzbot is reporting that ext4 can enter fs reclaim from kvmalloc() while the transaction is started like: fs_reclaim_acquire+0x117/0x150 mm/page_alloc.c:4340 might_alloc include/linux/sched/mm.h:193 [inline] slab_pre_alloc_hook mm/slab.h:493 [inline] slab_alloc_node mm/slub.c:2817 [inline] __kmalloc_node+0x5f/0x430 mm/slub.c:4015 kmalloc_node include/linux/slab.h:575 [inline] kvmalloc_node+0x61/0xf0 mm/util.c:587 kvmalloc include/linux/mm.h:781 [inline] ext4_xattr_inode_cache_find fs/ext4/xattr.c:1465 [inline] ext4_xattr_inode_lookup_create fs/ext4/xattr.c:1508 [inline] ext4_xattr_set_entry+0x1ce6/0x3780 fs/ext4/xattr.c:1649 ext4_xattr_ibody_set+0x78/0x2b0 fs/ext4/xattr.c:2224 ext4_xattr_set_handle+0x8f4/0x13e0 fs/ext4/xattr.c:2380 ext4_xattr_set+0x13a/0x340 fs/ext4/xattr.c:2493 This should be impossible since transaction start sets PF_MEMALLOC_NOFS. Add some assertions to the code to catch if something isn't working as expected early. Link: https://lore.kernel.org/linux-ext4/000000000000563a0205bafb7970@google.com/ Signed-off-by: Jan Kara --- fs/ext4/xattr.c | 4 ++++ 1 file changed, 4 insertions(+) Hi Ted! This is the debug patch we talked about on our last ext4 call. I hope we can carry it for some time and see if syzbot hits any of the warnings. Honza diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 372208500f4e..083c95126781 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -1462,6 +1462,9 @@ ext4_xattr_inode_cache_find(struct inode *inode, const void *value, if (!ce) return NULL; + WARN_ON_ONCE(ext4_handle_valid(journal_current_handle()) && + !(current->flags & PF_MEMALLOC_NOFS)); + ea_data = kvmalloc(value_len, GFP_KERNEL); if (!ea_data) { mb_cache_entry_put(ea_inode_cache, ce); @@ -2327,6 +2330,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, error = -ENOSPC; goto cleanup; } + WARN_ON_ONCE(!(current->flags & PF_MEMALLOC_NOFS)); } error = ext4_reserve_inode_write(handle, inode, &is.iloc); -- 2.26.2