Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp210374lqo; Tue, 7 May 2024 18:18:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVGJjkb77dLY/WJ58kOAAoySAo/e6+1jjUnk6SfiAlP+hPuFGl6GjEiLyCmfItxYMqFRH2hVm6TjDDVy7gzRmf9nW2SJyWXZVFgo1WmHw== X-Google-Smtp-Source: AGHT+IGZapnCq5ismatyxFBiR/8kI+EYJV3TX4jcA9wqDRWeBcjckKzgkoWlfgHIZ2Z2AFVWBK1u X-Received: by 2002:a05:6102:2137:b0:47e:f54c:4ba6 with SMTP id ada2fe7eead31-47f3c371519mr1097236137.27.1715131093699; Tue, 07 May 2024 18:18:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715131093; cv=pass; d=google.com; s=arc-20160816; b=IceS3+PsanRGX1UgvG57QHXHCvlXpr5nTMkMTF0fXRYPVpxQA6JYyi4GguHRbx1FhB /x0Wnvknkan7PEA+5Y4glFfRtChiWBcFOYLD4Fd3oFVmjQVyNI7mxLAl2+sEzt5a3ZSZ U0lvunaP4GNp4U/gxOv90KECN7NIbLavo3VF9Ai3dOOkWVRhtiiF+TMfMtWToj4dFpVe zy0GtIPFcQeReZNeMaRg3ep9KEArscJJ4OW4jE7cfeZuo0ukTrG4gykieoEM6J86mWaQ Gy0iGsCGq09j1q/EgyMGaK4JUcwTgiw971L2oQlGqQiW1hIYU0dtcJl6nPaFMwFe1Bsm MXfw== 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=bXCqxOHnXGAR0rzdG4ht0Yt67x9bWfQlWK66zskQZqM=; fh=RmKYhalX0OxqEiYy+BfB1a+8lZIwgUVFA8AMXFOf63Q=; b=d6mUSgxC5q6lk1a46zjwJkn15ieBJdghmxH04SzlAwbUA01Z05XOVBB8jx4DdTCZpD NCpPlTfBIW5e+ycnowyKyx9DiP1N6/nTg9fl2tcGvQiSPB9ghTF+Pq+hjKriwo0Ellsx KEAas1e0sNET0i5tcicf3JOIVdLMZgJzm4Lq/CvStzV0yVDya4y1oAc5XJiVBaeYOG3q qxlMIkQeTSDI/Lr/IDb9mG2Bqz4JEE5jMTPZxfzYA2LDjB1mdtK9ycxg/ZjYgpFBY1tq 5qSkA7v9aCFdKLpgzHds/K8KaYni1fMTQ6IxwvM3VqzmXgd38kRvkQ0t7WBzZN/r51jK BSjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b="jYonm/yn"; 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-172582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172582-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=qq.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id f12-20020a056214076c00b00699438ef744si12948463qvz.178.2024.05.07.18.18.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 18:18:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@qq.com header.s=s201512 header.b="jYonm/yn"; 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-172582-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172582-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 596271C20B74 for ; Wed, 8 May 2024 01:18:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D875AD52; Wed, 8 May 2024 01:18:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=qq.com header.i=@qq.com header.b="jYonm/yn" 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 9469179EA; Wed, 8 May 2024 01:17:58 +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=1715131081; cv=none; b=LC5xvg67Yn4vpYKsgtnxdWg5zwGftxDXoZvK3WQk/Lt7VPcLsOjyj05ghoobPnVZK+PLSmG5sNmous/Dva3IS109m7JK0hMZbGrV77D/MXYAM4+Sy1y8ggZQ8LTwkMMbE3LJuGkBC4yy24TWfSVUKT/ss70vQl/D4TAXOEFPj5w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715131081; c=relaxed/simple; bh=jj2KQP2ub0sVi3xfQLP9yZsNYDR+0zm8HmKQaeY8O48=; h=Message-ID:From:To:Cc:Subject:Date:In-Reply-To:References: MIME-Version; b=OIQkB64FgbLdd6sLPjtNReYJLagGXKrLaaWzHYM6qJNfUy1Slim4t+bOvXOU72l5OdLYVILt/yhv2kU6uSt/IuOzHAJmrYC6lXDyg8jv6VR/39YkeQ/IjL5hRZiNGkRZKstAj3rIXt4/hFEvaB9fqMLONAAAAH3wnlPhulVz8QY= 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=jYonm/yn; 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=1715131069; bh=bXCqxOHnXGAR0rzdG4ht0Yt67x9bWfQlWK66zskQZqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jYonm/ynl8I+nvGyIi68cgjeUrXiNx8rpFbas+Yi7licRAKKCKLCVZdtZ7ZUFKqrz AYArmsgtPNCEojicaLjE3O+ytnYRwmGnnfWU1QvDaOyAEKsmf1olL32GbTvNkVlEtr hTPth5lJgvLVKEoLBSFtJfxgq3bhepPceWaKwEOQ= Received: from pek-lxu-l1.wrs.com ([111.198.228.153]) by newxmesmtplogicsvrszc19-0.qq.com (NewEsmtp) with SMTP id 2E4340E6; Wed, 08 May 2024 09:11:36 +0800 X-QQ-mid: xmsmtpt1715130696tuynpi050 Message-ID: X-QQ-XMAILINFO: NhpLzBn2I3Xw/Mobo9iGIOo/qTBimLx0Fery84U2qt+xe6wOTv+10vngPKcjAI IqW1+gezsbiVQYJCRmH7WU9LN0jI4i5k9XEySZ3h1cs3xlUABCpOsjcUL5q3y0FOQy3W7QEjadTi h/V3x6xxUTJaXiWgvBlMLdGD+waeX/5UpdyXjEECwt+Yqz7y5zSOVQlabIeA8hY0IYT+cUbh3iAZ 7Xn8LDwvy/YCA+9tGqVS7JRjQMtWILKfGrHCp9+iIMU+4NEDz3/nV2I3r5TXzKw0Y18unRavguK9 AUKmTXN5lLdVeAGp4R+ZQEE0sJy2jFoEBY9zTWh/Denj4swhfYb6XGfn6qph/4+ANaSwmY2dWirA 5JyoVeeautia6lKtcPiw7yqhBUBiQkUDV21Y4ZPASASe/rm9CX1zmb7YJaU2b+SLFSfWYUdDoomS 3tIVxMF6rTy5EQlfqqxBmv4KEXUrUvuOwQXWZ1i2qEQyeqdUCs1D5zHm8UOsd/uHG79EjS7DGeFN 0EMN867ULqrbV3BtYC3XEH8fAc60csu83MYr5I0QroOeoQXwceQYuy5I5PCjqFwbYAQdAJSQH2PU j2+t4RxoXLQXo4zn3K3KaCmH31XyGUy9knOVFDLyixQMi8YMOniBRWe8oyOuCu9UXj1NclWwoZkz hp2nkDBgP7KNzhBHxvADRsdwCK0swSz3WhWs6yxd5UqXql47ou9zQwq8efNRT5c2pxcl1gKMdhTr +C30+rLU9BHOtvYART3AYPBZ3vFrIPsDF3VBv4HTtM2ibw4IMved6k4mXyPectNEaf+UjG6FeFYe F84HxkAhVISuRZR91FcicIx/ZOxGvDbMRrlwGmPapqZyiAw83wJp0sbQC6ji3G22QYKuGPmKwkul +OrQOsxwPWGvKrgZeLizNu575iZX+wHLFxiq+ThbXSL/WBiYKrKHNii7pFZXGVpo7CbjsYb7M749 EAevEEfno= X-QQ-XMRINFO: OD9hHCdaPRBwq3WW+NvGbIU= From: Edward Adam Davis To: kent.overstreet@linux.dev Cc: bfoster@redhat.com, eadavis@qq.com, linux-bcachefs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+c48865e11e7e893ec4ab@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com Subject: Re: [PATCH] bcachefs: fix oob in bch2_sb_clean_to_text Date: Wed, 8 May 2024 09:11:37 +0800 X-OQ-MSGID: <20240508011136.3227286-2-eadavis@qq.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <7chwa5h2y2eotafxfnapxn754n7y3zpze2sm5dif3zyx7hkxcc@2zu6pskc7fbo> References: <7chwa5h2y2eotafxfnapxn754n7y3zpze2sm5dif3zyx7hkxcc@2zu6pskc7fbo> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Tue, 7 May 2024 20:59:14 -0400, Kent Overstreet wrote: > > > diff --git a/fs/bcachefs/sb-clean.c b/fs/bcachefs/sb-clean.c > > > index 35ca3f138de6..194e55b11137 100644 > > > --- a/fs/bcachefs/sb-clean.c > > > +++ b/fs/bcachefs/sb-clean.c > > > @@ -278,6 +278,17 @@ static int bch2_sb_clean_validate(struct bch_sb *sb, > > > return -BCH_ERR_invalid_sb_clean; > > > } > > > > > > + for (struct jset_entry *entry = clean->start; > > > + entry != vstruct_end(&clean->field); > > > + entry = vstruct_next(entry)) { > > > + if ((void *) vstruct_next(entry) > vstruct_end(&clean->field)) { > > > + prt_str(err, "entry type "); > > > + bch2_prt_jset_entry_type(err, le16_to_cpu(entry->type)); > > > + prt_str(err, " overruns end of section"); > > > + return -BCH_ERR_invalid_sb_clean; > > > + } > > > + } > > > + > > The original judgment here is sufficient, there is no need to add this section of inspection. > > No, we need to be able to print things that failed to validate so that > we see what went wrong. The follow check work fine, why add above check ? 1 if (vstruct_bytes(&clean->field) < sizeof(*clean)) { 268 prt_printf(err, "wrong size (got %zu should be %zu)", 1 vstruct_bytes(&clean->field), sizeof(*clean));