Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp1402513rdb; Sat, 23 Dec 2023 05:33:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHiYnN3TcoA9G0nb2t472a4dHEI0Aw9IZ5cJAruk1YuRFi4BegXWMljfTk3ia+PPkdSKcPr X-Received: by 2002:a17:902:d584:b0:1d3:b83c:9c35 with SMTP id k4-20020a170902d58400b001d3b83c9c35mr1681174plh.123.1703338438832; Sat, 23 Dec 2023 05:33:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703338438; cv=none; d=google.com; s=arc-20160816; b=iKtCJBCdfiCfUEbFvEyfHtwtOxq8fLLiFkl5JUzSsxwPfaBJF2ZTYgGV5BG3WfBDMd To/SoJL/U1BC4zUbElfRDwkggyBXMZpBFbDBR77n33ZQGMlwYv4ts7+Sb0u1AU5p8OTY Q6mjQsMgjwB/YQYD/kUpTPswQih+7GSggz8jUQlEp0h9XoAQllxUmbANLbtkIc4/Gw3o eAZHq90SH0kFttNlAq9DTjeSLZMyu+gxca3ebMAc79Jz2TibjINwT7/zqxwdeA/QEuu2 hFadD+2fdXtpU09lKYU46eFHpv6wsBVzM6w3jC17sdYyO4atuOCchMfH0ReyR3ZEeCmv jYyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=o9ZOnkQhAirB4ub7Z9b5oIjILmgGUqmGhDmKhenc5gc=; fh=8ixoOU76S8z1XGh40ACb/GHAz7JMbWyURBxYSWRIQYk=; b=XePV/FYtn7tH37m809BahzZPEKxrDZDs05ZiZDqIjXregBYBlG88HSCZuP4Jy3hD0O dkAqCKrh8O8j2JHIwS5000ylzuHXzJcT3/N8jwWz/rx7UPcNBgBA3UjEUKQfdhqXkEpX e/0JrBjZBxZfOuYETMfsXrI6BjDHpcFRrru7RO2j9Px62XZ4/2Dabw6ZOBX6aLilQ0uT jRxxFCNUZbbbXuuiwaYOIzTOwaNDlFd98Bo6AemnaFdXJQFrYeRME6OxyVjLMFRiqCiD eRSGWhyKnp4qd60UzluD48k3PzSzPqSZxuvfBqiUwJpMnYHD41Z6lrwFYYSc56Fpt7/a brQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10419-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10419-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id k3-20020a170902e90300b001d40fba8749si3751501pld.484.2023.12.23.05.33.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Dec 2023 05:33:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10419-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-10419-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10419-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 1DC98B229C8 for ; Sat, 23 Dec 2023 13:33:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A79EDD520; Sat, 23 Dec 2023 13:33:44 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from www262.sakura.ne.jp (www262.sakura.ne.jp [202.181.97.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E64DFD300; Sat, 23 Dec 2023 13:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=I-love.SAKURA.ne.jp Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=I-love.SAKURA.ne.jp Received: from fsav312.sakura.ne.jp (fsav312.sakura.ne.jp [153.120.85.143]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 3BNDXCaO091885; Sat, 23 Dec 2023 22:33:12 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav312.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav312.sakura.ne.jp); Sat, 23 Dec 2023 22:33:12 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav312.sakura.ne.jp) Received: from [192.168.1.6] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 3BNDXB7O091879 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Sat, 23 Dec 2023 22:33:12 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Message-ID: Date: Sat, 23 Dec 2023 22:33:11 +0900 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5/8] fs/ntfs3: Use kvmalloc instead of kmalloc(... __GFP_NOWARN) Content-Language: en-US To: Matthew Wilcox , Konstantin Komarov Cc: ntfs3@lists.linux.dev, Linux Kernel Mailing List , linux-fsdevel@vger.kernel.org References: <890222ac-1bd2-6817-7873-390801c5a172@paragon-software.com> From: Tetsuo Handa In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2023/12/23 13:46, Matthew Wilcox wrote: > On Mon, Jul 03, 2023 at 11:26:36AM +0400, Konstantin Komarov wrote: >> >> Signed-off-by: Konstantin Komarov > > So, um, why? I mean, I know what kvmalloc does, but why do you want to > do it? Also, this is missing changes from kfree() to kvfree() so if > you do end up falling back to vmalloc, you'll hit a bug in kfree(). Right. The first thing we should do is to revert commit fc471e39e38f("fs/ntfs3: Use kvmalloc instead of kmalloc(... __GFP_NOWARN)"), for that commit is horrible. > >> +++ b/fs/ntfs3/attrlist.c >> @@ -52,7 +52,8 @@ int ntfs_load_attr_list(struct ntfs_inode *ni, struct >> ATTRIB *attr) >> >> if (!attr->non_res) { >> lsize = le32_to_cpu(attr->res.data_size); >> - le = kmalloc(al_aligned(lsize), GFP_NOFS | __GFP_NOWARN); >> + /* attr is resident: lsize < record_size (1K or 4K) */ >> + le = kvmalloc(al_aligned(lsize), GFP_KERNEL); syzbot is reporting that /* attr is resident: lsize < record_size (1K or 4K) */ was false at https://syzkaller.appspot.com/bug?extid=f987ceaddc6bcc334cde . Maybe you can fix this report by adding more validations. Please be sure to take into account that the filesystem image is corrupted/crafted. But you can't replace GFP_NOFS with GFP_KERNEL anyway, for syzbot is also reporting GFP_KERNEL allocation with filesystem lock held at https://syzkaller.appspot.com/bug?extid=18f543fc90dd1194c616 . By the way, you might want to add __GFP_RETRY_MAYFAIL when you can't use GFP_KERNEL, for GFP_NOFS memory allocation request cannot trigger OOM killer in order to allocate requested amount of memory, leading to possibility of out-of-memory deadlock. Especially when there is possibility that kvmalloc() needs to allocate so many pages... See https://elixir.bootlin.com/linux/v6.7-rc6/source/mm/page_alloc.c#L3458 .