Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp393764lqh; Tue, 7 May 2024 02:24:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZxV8mgz9RAEqolTWVobLl6+VWOLK2pVM/EmO0F2cvWRG7jisMVnNAt5rt7/ivQfy0hY1MDj2sWYpy8jyQTdcLUvbmWaWUCCE3V2fFkQ== X-Google-Smtp-Source: AGHT+IEmnxNSIcz15cEyNw1Ehc9cDqvL9iQCBXev4sDdHQzmbR4WftZMTde+dCBj+/nDjS1diZQL X-Received: by 2002:a05:6a21:1508:b0:1aa:92b3:23cb with SMTP id nq8-20020a056a21150800b001aa92b323cbmr14294771pzb.2.1715073896633; Tue, 07 May 2024 02:24:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715073896; cv=pass; d=google.com; s=arc-20160816; b=xitkHqmqVdjYOOgPlSEgFCsBtyBcSfILDSDIO+cr+oVN8KsAFbWlEzjejjhlfh8+zp 8cPj+iixdP8KTuwaF8wbfNrpENkgy5yOGYq80V4oVyQgqxzukM3rQL8PT/GlfRXqpE/G 5iD7r+8KHyjU6kjKBnkeR0I+mTtZA2nSJGtar1lGReqSU7QdgvzIqO1dJdu37ZUltdtM 2MGVjXzncSWZZ3RefN80EHegu0k4tUzIKAH5kw5z8sjcxl7D0F9vKIoHBD0LMo7oL0mg kZ0fxxyQwieaCKn6QWGZcZIatQY6UTB8nxpU/yntKgFrUYJ4iYxYJs/8W6KnEeqGBeFK OYOQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:date :subject:cc:to:from:message-id:dkim-signature; bh=yO/k90JymUOXJTCvLXq3LY5H5yoKY6KSmEgQ9wMKlJc=; fh=f5Mi3csYsk0BNqBTkrhNg60cqsrI3nh2LJLP1iDiM20=; b=R8JUNw0ZmoI3qDS8MqdnXW9uJDqyBWSO4ATCgiDzxdvbnPG+cNHYLDse80pgdA/SHy weaKqy0ovCdvyxwIB/YPN9rJjpNXlBA//2z3ZwLnOoXlqZLe1wSu9B708XBMM96nmbkA aQDnQT9qqAeym1fCJNL4A2G1dsi+M4v5MdFBScCCpZqxSHV+5m1ncUZVoz1x1TmjXKwo O1/4e3B4GJXjtnbFkB0lF6ivBV857iUBESWrf/hnrfxM68s3aVfcz7l12WpHb3KnuFjy Vz3wQjHkdtlpJ+FYxd8+AgGMzzAtX9ymWMFBzQGT27UkHyszY3WpAOWYUT308SNjDX8g IG/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=gVyt63eS; arc=pass (i=1 spf=pass spfdomain=qq.com dkim=pass dkdomain=qq.com dmarc=pass fromdomain=qq.com); spf=pass (google.com: domain of linux-kernel+bounces-170937-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170937-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b5-20020a170902d40500b001eb5bc2d9d0si7178175ple.218.2024.05.07.02.24.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 02:24:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170937-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b=gVyt63eS; arc=pass (i=1 spf=pass spfdomain=qq.com dkim=pass dkdomain=qq.com dmarc=pass fromdomain=qq.com); spf=pass (google.com: domain of linux-kernel+bounces-170937-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170937-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com 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 3151428483C for ; Tue, 7 May 2024 09:24:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7E9014D71F; Tue, 7 May 2024 09:24:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b="gVyt63eS" Received: from out162-62-57-49.mail.qq.com (out162-62-57-49.mail.qq.com [162.62.57.49]) (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 9876414D451; Tue, 7 May 2024 09:24:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=162.62.57.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715073885; cv=none; b=UW/Lv/x8m1wxv0exZoIwvOIuOmGPsxjHU6iZFQ0J8y2VngvF1PmXFADR1LRYAwFKuRUpJlJdrrJmhEG8qFMdYdZVhYgnsi3woPlGjrgFfYuXPuChMoDMGyyvc3CvXWFt1ajOjM90TbhUS0zheEYsTRJ80nv5Ijg/MmWrLvFdGwk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715073885; c=relaxed/simple; bh=+yW59onyXg0Pbvf487LVUARxqJvPaBeg6/Sc/ikl7Nw=; h=Message-ID:From:To:Cc:Subject:Date:In-Reply-To:References: MIME-Version; b=R2M6+5k+KnPvFJaQB6f34jkmFET74+X2NCarso4ka5t6DWyt+fkIkK9dPL4vn1t0UeIOD/Z8TRRtJl0C/aNcyNTX8wEx6AURLE4tcctjOxzhmsdEaMGK0KUh8k006IEHgZMKzi+bNXf64Oow9uC3DPP3eyHUpgxDZSz1ABHrqzU= 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=gVyt63eS; arc=none smtp.client-ip=162.62.57.49 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=1715073576; bh=yO/k90JymUOXJTCvLXq3LY5H5yoKY6KSmEgQ9wMKlJc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gVyt63eSG4URXpc+GaOAIBpWiMDj4in5Tlrb84tjARNEAt0YfDMuD0ZcnQxgb9RYQ iHMJtSdxXJN89EJ58BNxfByWFy5nk+s4yY1bK0UJKbaj5fU9weAGmbrgyeZ8C8PT4C nyokwNbAsBK4WMGYbTQ2kxH9QjcTTKRCsTBvQxlw= Received: from pek-lxu-l1.wrs.com ([111.198.228.153]) by newxmesmtplogicsvrsza15-1.qq.com (NewEsmtp) with SMTP id 4DCB0648; Tue, 07 May 2024 17:19:28 +0800 X-QQ-mid: xmsmtpt1715073568t102emhnj Message-ID: X-QQ-XMAILINFO: MZChPk4K8ikNlT2Eddi9Ggrs0oV4G9NbiHl6MtG6ekOPsfZopI6QIM/z/aIUSO goslJ60GRySBTLq1ngjWjUItTYKOInN+rKDsQj1lXUOaKrAy2xb3k/g7opZJGfA5tS80axKCTdbM FbJCtj93Em7qowzBXjUSDBZVRSa3oTkCmArSaPyAlcrQuOQbIH7XeVR01ecsiBRpH3kEDLeCTOzf UhoOq3XXWJhFkp+KjGlG4yZz301QSR24RQmOqzRGZkunD2iPByVKS3eQRy1U7mYMGwtHGvk78lp/ SVzJdl0iXuJYqknPzgI8EWaz2vCT7z+jHxhtI0ihlzbDXGwnRIoyoGOmVzRQ6tRo7Dg25HcjONW8 /O9rFDYzp/48tIsf1aHg9j4oMnpIKWQ7QxT8BCh5vXkgQ4UcNEO6NYH7BoPpobmRgRywEnPJV4WG czoC30voVF2ILfkwGk4nHFmL9rBH9Qt6Iv9uR1lISK3CIsz59VHPTljSiyUo0U0cclc1ysEBUBwO dlgxxB8SeV5s1tXj+/YzB/dvNJjABSOocMzEHSydcUKhfyEZRfsl3JnI2kSmtQTfJR3PjrYYo9xS CARXLrJKczs85wwFpC4Jf2MyEcfe9iuAACRB6XFf7YjhjDhUEHpyUvwB2oOd3n2u1xg7YUoLXVG/ l1AgzbIZchyLnMmR8SyQ+YUDTptGk+aOGRN6sxZZvdx48aXJOPjDNGFHp1yrj6zfVUugG3Q/oF6g gTuWBrddmh2FSdGuULKPym9/5/jMjBoDRTi8h1Zf6mNFu7MbQTmGJlUDuQTzcyHt9JMmxX+M51zM y7axxD4RjO7MCzBOSMi28IfBqfRIOVY545KEnozNg0At+S5o9d6ugvfrdLbafcMNDj8vJgYooz10 tfVe4iY5WBeO+GxXhjyKTm9SuXUf8GFJgHeEcAt3hE/lhxKTHJMC/IXFPO8TQ5cLvNnNvljJrN X-QQ-XMRINFO: NS+P29fieYNw95Bth2bWPxk= From: Edward Adam Davis To: syzbot+c48865e11e7e893ec4ab@syzkaller.appspotmail.com Cc: bfoster@redhat.com, kent.overstreet@linux.dev, linux-bcachefs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: [PATCH] bcachefs: fix oob in bch2_sb_clean_to_text Date: Tue, 7 May 2024 17:19:29 +0800 X-OQ-MSGID: <20240507091928.2789219-2-eadavis@qq.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <000000000000918c290617b914ba@google.com> References: <000000000000918c290617b914ba@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When got too small clean field, entry will never equal vstruct_end(&clean->field), the dead loop resulted in out of bounds access. Fixes: 12bf93a429c9 ("bcachefs: Add .to_text() methods for all superblock sections") Fixes: a37ad1a3aba9 ("bcachefs: sb-clean.c") Reported-and-tested-by: syzbot+c48865e11e7e893ec4ab@syzkaller.appspotmail.com Signed-off-by: Edward Adam Davis --- fs/bcachefs/sb-clean.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/bcachefs/sb-clean.c b/fs/bcachefs/sb-clean.c index 5980ba2563fe..02101687853e 100644 --- a/fs/bcachefs/sb-clean.c +++ b/fs/bcachefs/sb-clean.c @@ -285,7 +285,7 @@ static void bch2_sb_clean_to_text(struct printbuf *out, struct bch_sb *sb, prt_newline(out); for (entry = clean->start; - entry != vstruct_end(&clean->field); + entry < vstruct_end(&clean->field); entry = vstruct_next(entry)) { if (entry->type == BCH_JSET_ENTRY_btree_keys && !entry->u64s) -- 2.43.0