Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp294326rdb; Mon, 29 Jan 2024 02:28:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHv1Xu5OdHwN7DkHHEIFvIgYx5gHVohWf0D1fZZyb7uH2tfIQ9jFvpq5n4JVTCDutKCxx+B X-Received: by 2002:a05:6a20:5194:b0:19c:9ba6:4c21 with SMTP id j20-20020a056a20519400b0019c9ba64c21mr3707212pzf.24.1706524089070; Mon, 29 Jan 2024 02:28:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706524089; cv=pass; d=google.com; s=arc-20160816; b=VrnkttCKfRaijCkCF8rsgrkHPoktO+nghc1LtvScW/+IiR9eP/P7HZAwWGhPAdnrRM ORBWZizOXfsDAkhua5RIAzEpMrfqTNG/9px4imWEpRp9kdF/RmFd7F7Yk95wwkVGjaRp cyF7TeUYO/spQwAUe11T4jJjqSeqApBSlIj5ZDEoticJOoUYcJiI95LhrIQYeZojE1xp Wy3jyahQ7DEhj7bv/FlJPjuuU1jMCs4W9CCnt+L2iEMBUzOWsIhlQfwzeWKQibuaD9tO XMKuTb1xFhAvWVEHN+SyXgDFdrJP+iRswPaECNbu4GQMG2btKf5LNUp2Kb52hQINnIN9 3rkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=NoBtbWBG+b1qUxuU3QxEjVwcHZileZtHD/xiFangzVk=; fh=ttb1mjfS5MhgZXbiX3GddienybLawXvEiMfsU6kwbl0=; b=WYxM68Z25n0R1DkjMfidAITn7KhEn2jQUNUcQFqK1WeoEqicInuphr3Rs577XTmXuk XJIG94xnOxnPvQY2e7ppUEnZWBkK8wo3fYTCr9PfZeKIm7lnZbtv9N07udh4hp1xmFoW kAQVg3Sm8+dvYRBBkeBO9jf53IABEDszmTb3Na3Z3o9jFU+rJeW8+tZEpgFqV8cjbAJD GleWOPCUhsdLGsgUChlsjD1KAnYsDoDdLR4eGc58k0Spi7ZJoOMgRtmN2Wqmj+T7pGVv sqDNImy1rJ/T0Sij14G72zrktUKsNjXDikBzAn7YBhJmsk08KcM8ICjHbabZb0MPK9fS YqJA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qJ6H4eTW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-42537-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42537-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id gx11-20020a056a001e0b00b006dbd45663b4si5457929pfb.228.2024.01.29.02.28.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 02:28:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-42537-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qJ6H4eTW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-42537-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-42537-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1879F2850F1 for ; Mon, 29 Jan 2024 10:28:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3E84C5730C; Mon, 29 Jan 2024 10:27:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qJ6H4eTW" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 63AFB5647A for ; Mon, 29 Jan 2024 10:27:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706524066; cv=none; b=A4zyqZTiRtAezAsQHyyEL60MBY0tM3DecrByx5TkIEiYMqston0h1KDTfzbhWJJ5h/Cp03tKlBpZjlxIQnoPPhRzZGRIGfdE8/Js1E0Sn6duC/eAE9gLcDb8S0DFsj/SPluCP3ZXcdg0sDkmK5asYsV0ZFvVtZLu2IT5VOjnlUM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706524066; c=relaxed/simple; bh=dJ3bS5oGG9PHms+736cFAZX/JO0z5fQy3JzWxPCMyqc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Y80DSbMtAEvtl7WNdNsI/VU7Ld0vZ7JCQgyMQ0WLd0JSpzxRLxzWkkW7iesiVCdYuMnAWagiXgRKsqaD52Fp1pscXY7OBg2jKjkbr84EbyE/b63k2Ou5rZOVY5aDNhMLhKZkeiPOkUSQE1HzF+FK+3ztDQx7LD3OXx9tZJYuq/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qJ6H4eTW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01ABAC43390; Mon, 29 Jan 2024 10:27:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706524065; bh=dJ3bS5oGG9PHms+736cFAZX/JO0z5fQy3JzWxPCMyqc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=qJ6H4eTWCM1WSFpRsizOIHNUQefYGhckq73mSh80dT/GCCrPohIBd/BZx+8MvPhsX Ue74dpfnWa2meEEYCbKyugyVLUwDszjvrJfgtp4xHfD+aJKlnLvJfoniYMMgtADO73 xk/810eY/grQ3XUkPY2G9WwTiUUj88VXkgV7eIPIv8jh6xGy7yQ1+M3HutW8fLndsw 9YymWyTvOywHyNpTmJg8Q4rDBojS0F5cf+Vbci4SgNQ8cX28DwvIMrhTl73M+wjY0C u5nU48uBa/pfIs405Q7rL+akEn86Tv3WUQybJ0IGJqff2yPfevc/Ms2eKbzT2Tjslo qHoxhRyLbmBkA== Message-ID: Date: Mon, 29 Jan 2024 18:27:39 +0800 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 v1] f2fs: fix NULL pointer dereference in f2fs_submit_page_write() To: Wenjie Qi , jaegeuk@kernel.org Cc: hustqwj@hust.edu.cn, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org References: <20240116141138.1245-1-qwjhust@gmail.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20240116141138.1245-1-qwjhust@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/1/16 22:11, Wenjie Qi wrote: > BUG: kernel NULL pointer dereference, address: 0000000000000014 > RIP: 0010:f2fs_submit_page_write+0x6cf/0x780 [f2fs] > Call Trace: > > ? show_regs+0x6e/0x80 > ? __die+0x29/0x70 > ? page_fault_oops+0x154/0x4a0 > ? prb_read_valid+0x20/0x30 > ? __irq_work_queue_local+0x39/0xd0 > ? irq_work_queue+0x36/0x70 > ? do_user_addr_fault+0x314/0x6c0 > ? exc_page_fault+0x7d/0x190 > ? asm_exc_page_fault+0x2b/0x30 > ? f2fs_submit_page_write+0x6cf/0x780 [f2fs] > ? f2fs_submit_page_write+0x736/0x780 [f2fs] > do_write_page+0x50/0x170 [f2fs] > f2fs_outplace_write_data+0x61/0xb0 [f2fs] > f2fs_do_write_data_page+0x3f8/0x660 [f2fs] > f2fs_write_single_data_page+0x5bb/0x7a0 [f2fs] > f2fs_write_cache_pages+0x3da/0xbe0 [f2fs] > ... > It is possible that other threads have added this fio to io->bio > and submitted the io->bio before entering f2fs_submit_page_write(). > At this point io->bio = NULL. > If is_end_zone_blkaddr(sbi, fio->new_blkaddr) of this fio is true, > then an NULL pointer dereference error occurs at bio_get(io->bio). > The original code for determining zone end was after "out:", > which would have missed some fio who is zone end. I've moved > this code before "skip:" to make sure it's done for each fio. > > Signed-off-by: Wenjie Qi Reviewed-by: Chao Yu Thanks,