From patchwork Wed Jan 31 12:04:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Edward Adam Davis X-Patchwork-Id: 1893464 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=gpwVmNbX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=sb/o=jj=vger.kernel.org=linux-ext4+bounces-1044-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TQ11P37xvz23dQ for ; Wed, 31 Jan 2024 23:04:41 +1100 (AEDT) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4TQ11P2fDLz4xGP for ; Wed, 31 Jan 2024 23:04:41 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4TQ11P2Q62z4xM1; Wed, 31 Jan 2024 23:04:41 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=gpwVmNbX; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-ext4+bounces-1044-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4TQ11P08dhz4xGP for ; Wed, 31 Jan 2024 23:04:41 +1100 (AEDT) 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 C3F8E291721 for ; Wed, 31 Jan 2024 12:04:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7386476C85; Wed, 31 Jan 2024 12:04:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b="gpwVmNbX" X-Original-To: linux-ext4@vger.kernel.org Received: from out203-205-221-205.mail.qq.com (out203-205-221-205.mail.qq.com [203.205.221.205]) (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 4A2F67866C; Wed, 31 Jan 2024 12:04:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.205.221.205 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706702675; cv=none; b=JIzOX3o3nCHpjoLz3iKxi+JjQMiBT+nqBOUgFOk0HyP1GrDYtm8SsITkjClxIqp6uCQ1/6Lht2U0Kf7lBT42jIy+ubp9u/Sbw9w4lVMpLbD81dzGfN7djhsiztZ3znQw1si1bBQXEhiQtlAPfy48Ve8N0zdL1Kr24FpnlS5awEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706702675; c=relaxed/simple; bh=F+KoyRFtfnsgTzITPD6Uvzz6cJDqE0m6fF2NfXjS3LQ=; h=Message-ID:From:To:Cc:Subject:Date:In-Reply-To:References: MIME-Version; b=u39f1ODfm94IvorN4Uq4vQ9PUgW2fCDwIcHp9XrOkyVDqGTkBRsUTlaOqNsRc3SW/m3wZamR0yTz2wfOL3mlvTUIFRvCRifpAwnz4UZDF1wMIo9t++cb6J1zrwojoy+j/paBrQ5pmwHQ5NqpDRf8G5Ze4mqVL3iRbsKeqm/HjtU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com; spf=pass smtp.mailfrom=qq.com; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b=gpwVmNbX; arc=none smtp.client-ip=203.205.221.205 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=qq.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=qq.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1706702669; bh=OcZp1rMol08Z2WnpIQmEJuPhzfQf6La7Ry56I2aCSsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gpwVmNbXAfM4HjLrVX8m0DwgrXVHwxM1nuqcFibTpkSFKbMMwGlHoYCrKkE/+jvSn ln7ROO//5hE+V/MnBzbemmx3MnkH4qqvNsXL5QAUeXtOCENFHRnJ11mrtQpGcaPf9T Cgacs6g7BLoSDldyPbpUeVICnlTULcYCDq+5hflQ= Received: from pek-lxu-l1.wrs.com ([111.198.225.215]) by newxmesmtplogicsvrsza7-0.qq.com (NewEsmtp) with SMTP id 11AB34D7; Wed, 31 Jan 2024 20:04:26 +0800 X-QQ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j//9VHAxr69bL5MkOOs= From: Edward Adam Davis To: syzbot+cdee56dbcdf0096ef605@syzkaller.appspotmail.com Cc: adilger.kernel@dilger.ca, chandan.babu@oracle.com, jack@suse.com, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, syzkaller-bugs@googlegroups.com, tytso@mit.edu Subject: [PATCH] jbd2: user-memory-access in jbd2__journal_start Date: Wed, 31 Jan 2024 20:04:27 +0800 X-OQ-MSGID: <20240131120426.1278044-2-eadavis@qq.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <000000000000d6e06d06102ae80b@google.com> References: <000000000000d6e06d06102ae80b@google.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Before reusing the handle, it is necessary to confirm that the transaction is ready. Reported-and-tested-by: syzbot+cdee56dbcdf0096ef605@syzkaller.appspotmail.com Signed-off-by: Edward Adam Davis --- fs/jbd2/transaction.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index cb0b8d6fc0c6..702312cd5392 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -493,6 +493,9 @@ handle_t *jbd2__journal_start(journal_t *journal, int nblocks, int rsv_blocks, return ERR_PTR(-EROFS); if (handle) { + if (handle->saved_alloc_context & ~PF_MEMALLOC_NOFS) + return ERR_PTR(-EBUSY); + J_ASSERT(handle->h_transaction->t_journal == journal); handle->h_ref++; return handle;