Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp211548lqo; Tue, 7 May 2024 18:21:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX1QGYpgngZ8iCivF2hnwsX1FlrLdBVgx2I2mabQ9bMmO2xQBnbWKzZiTSq7v0tQQw4FVlHj9AHTpXpiNmW1bjk6T4XYhi/RhCoXHGFKg== X-Google-Smtp-Source: AGHT+IEdYhQkRhx6FjmfxSI1Zuprfif3gPmnnQ2MHLTTeZe2lEDMmq55VixaqHs58laghQ7GISSw X-Received: by 2002:a17:902:da85:b0:1ec:2977:d934 with SMTP id d9443c01a7336-1eeb079739fmr13637285ad.62.1715131310976; Tue, 07 May 2024 18:21:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715131310; cv=pass; d=google.com; s=arc-20160816; b=ig02MKHD6+Ut5DGE3SQaG4E8AqhKrahdYlhiQI0QOuYMyfRUvbwatoUzWV1ION9cVK OBcuX6K27nY4Svj/zJE4J/PZaY4jO4OAZL7hLmh0cI1G45QSjwHOPaeOx+OP1I19iO1g ZqUrVbw/NbuTeUf5sf/dJejeAF5TszwPqBNp+TMoMDIECGizLSCNCIZxqoFB48CT7QfJ GwSocPBqn1rYbz9D1ikx50WCRuHMbzMh0RZemGxBTowrIit8ONVyun2ry+ZotX4sqhR1 wHCEstkQ7qYZKSB8Tqy/UKKsLcwUf05A9FT+gcRrmU+gx/if7M6DVm34ML5XetAgrpWe uLnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:dkim-signature:date; bh=omz2Z73asoBCYFW4lWbzGyZDJr0g0ILH5q94fOP8bB8=; fh=ZbcJgOIj31NLWRSZZioNngDXdsUDhUAxt7sbcVNd43s=; b=AH/0Am5KH65a5TULY3vDlNbwVucC7u8qwBGrb2CJT5G5tqXTz/UKtPvGWBpF7ivj7N lAhgq5EtODLlDycQZ8worlGJTI3hJzbVFzpilh8IHSHzjGL6eUGWbkyE7lVLtPfkgkkH nGKR3plcJdsCoJniON5Ya6ulIoaMXMftth8b8i10F8bFA1USlHCCSS7VXInUOno1kcV/ TGgqwaE+uPQiahQ+71k6+1XhaVhzaCVEiSjuqDDN+reOV8qRjWZAzJL7JEwl2/zWQ9i3 mH2LbCPuoQixDg5A2F7SUAdmpheiQNQnnmt+d3EpZ6KyBSDLT0ufN511patZkWHArL6S kk7w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=ZzgEY+aj; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-172587-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172587-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a4-20020a170902ee8400b001e43376415esi10863447pld.327.2024.05.07.18.21.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 18:21:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172587-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=@linux.dev header.s=key1 header.b=ZzgEY+aj; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-172587-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172587-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 BCC67286030 for ; Wed, 8 May 2024 01:21:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2295DD266; Wed, 8 May 2024 01:21:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ZzgEY+aj" Received: from out-175.mta0.migadu.com (out-175.mta0.migadu.com [91.218.175.175]) (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 3785DBA2D for ; Wed, 8 May 2024 01:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715131285; cv=none; b=o81vmcCcKPdAL3vf86bcJ1m+usJdidZr5hFIhO9IkBWrw/LAFurl+q1oQ8nKgasBYNxDDnFk79O0C+C5jFPPseD0DYzBau2y3HmXTpGZvVSIpbLKFl0RYu3OWwdjBLhZHDAx4bQ9v0+wpUmzuvoUMKyD/LHvZdVCHHCXKP+/utI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715131285; c=relaxed/simple; bh=swmvHkWAt6mZSEzNdM50W50K8sKA0Y3zZvFwBOp25EA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=izIdBGyqeqsPmzLRpk5WN/vyZYGn58BWRWcsbIaWbGRSksz1ki7JsooS4KYKbGUDuJdaI5ZGz/UTsd0ZWSy2sgWFLoj/mQNxKarnKqNTAVEYq1qv5yV/vy7RKbV8gr7ZcVtsS/VvHIRWteRXRuKIL8sFcI5PtljLmowZL0Q8ngo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ZzgEY+aj; arc=none smtp.client-ip=91.218.175.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Date: Tue, 7 May 2024 21:21:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715131280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=omz2Z73asoBCYFW4lWbzGyZDJr0g0ILH5q94fOP8bB8=; b=ZzgEY+ajY/O6dd9ouTT8PqTLRZjQ6r4TGs7v5oyAmyIuV3YudOg9lxxadNV5uyJJH25EoV Unwm/9+JV+nf2VPBdA/jfGPvHPROxj4yYEEjWb4KD2M9YdI5dqargs8tdE3Y5mKfkaZwRK 4X7AhvZscFOt5D8KBgbrasUaI+Rmpsc= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Edward Adam Davis Cc: bfoster@redhat.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 Message-ID: References: <7chwa5h2y2eotafxfnapxn754n7y3zpze2sm5dif3zyx7hkxcc@2zu6pskc7fbo> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT On Wed, May 08, 2024 at 09:11:37AM +0800, Edward Adam Davis wrote: > 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)); > You sure you're not inebriated?