Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3036258lqo; Tue, 14 May 2024 18:50:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDhusYUUOSt+1WH4kN0foS2Kh+1ebRj7AfqiP8Oowes4K8+AJ1oiNyu3+y3ND4zW1uAnLWg2LZLbbD/u1GBubqCUZXN+4hGpMXMLzL9w== X-Google-Smtp-Source: AGHT+IFDjLjecVKFX3qw1TzlA+jnuNzo5DQ06ytjs22WmddpY1C1nLDPCd95QYg+71ubcKgHidvu X-Received: by 2002:a05:6808:1816:b0:3c9:9398:4c7e with SMTP id 5614622812f47-3c9970359d4mr20850869b6e.6.1715737848252; Tue, 14 May 2024 18:50:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715737848; cv=pass; d=google.com; s=arc-20160816; b=CJQ93eDHCWSVXXj4aFVjn39AIzGOd+gpmAHBPSVpkAwvNVdYKewIeMLB02Oy/bQwy1 ovfjrEa3qbi5kD/GzvewtURViKyRbx3Gx1Cctz0Lv1RYZlPK9EJQlzw8S2V3xIK3Bl0C 3O55vvTzPDey1rDID3VFd61QAuKeEvsA63bc4MnSIUBwOyX5wcd6VwMkJx1FN8YDCUUN vCQyrET2KRMWoiZvvGEI3LoIl5aEh5oZKLO9dEjuX3Q5wmX3xLh1wp0Y98NTIyajYMj4 6n7dlEVN+XLZyRvR8uWW6a2tEEBNQ7SK7NDMnYWA3FvCiPntybJs0JNsuk6U3f3A0fC0 OXiw== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=5kQ1NfQplOskT4B5ZqgIky4P0ExeAiR7M84edP4J3wY=; fh=Q8QYUbfKL8ehK52FN5C2/yynbhRxmUgaQ38OW0P4cKU=; b=l5xfGMLZ6X5yqK99FUPUGav3CGWS5E+LA5wJf2mgCLGiBHbOWiBMoXi3GAy63AjTRB IZFoVm0oMujGRB+wYiQeFWK70xwM/klJHS0Y2IfFhpSiRsDl/OduIBv8BYMFZW2MBoU2 Pu7AyUU00rJQ+gI0kvjnXWzumz59Ht8K7eqapTj+QSjvlRt9nznifOaZfWcV9+fO2zpp 8d/LXWjAc4o8OSVEhofUmIyigG5uq+T86bM3fs1YNxRdKGnUyGpWz78bCX0qw2reQzg6 OQkl3a2jh1LvpvwkUPECY5UClA3YgM7hhbc0idkydd1j3b6YnLH+AP1Ackzl/nHHQo8c 6cOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kk9X4Fsz; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-179341-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179341-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-63409e824a8si12568391a12.128.2024.05.14.18.50.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 18:50:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179341-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=@gmail.com header.s=20230601 header.b=kk9X4Fsz; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-179341-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179341-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 D8187282D16 for ; Wed, 15 May 2024 01:50:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9BEBA39FF2; Wed, 15 May 2024 01:49:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kk9X4Fsz" Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA4874F1FE; Wed, 15 May 2024 01:49:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715737779; cv=none; b=mKZpx7qzkfq36EW3JnvvdxEoQvZvUcX20Ce4YfjDiaXa3eNsVWK/vQjqsy46gTH4aKFxFv7t0j2H8ZCDguZMQ70S25h0HhQhWt9hK170PM8Xc7/GVWd/l7xI3lpdTVyvyXBzJSCfrnI1Toiq551VCwMEvZfmZCMkJ+4JoZc7Mjo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715737779; c=relaxed/simple; bh=pvzjn5+bbR0c+haL5/MVAidccpj+9o808LC0Z+cMxlA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Tex4lYlEszIWTCTVI+wzH5xocgkFIWTEGcbiJ9nlBz3+woT4MpjGBH6HjqIs5EFLfG5dtC9mXYcAEiXWJxPGs6rRtr7LKlUGDPTvXFOigop1oxXlguulHf3RnM4So45/a0sypBH/vxTvjydcdGHwaADISMH2A/nqNuYvEeLaYl0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kk9X4Fsz; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1ee0132a6f3so48007805ad.0; Tue, 14 May 2024 18:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715737743; x=1716342543; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5kQ1NfQplOskT4B5ZqgIky4P0ExeAiR7M84edP4J3wY=; b=kk9X4Fszq0tV3IL+k7hTWhXPkHh4ka1Kljqs2c+Lds8YnVEw9tNRobHQ2NU0vpHIdq V+nBJ6R1h1NSt0KTMEIT1DflD8LDCmSNxT4ch+/wT3+lGT4KyWshKLTKRwtK3q5n7mtc mDeFUTc8lxxlhgTyBsh8iC+hQp4Xcdt44agxsCiihMt7Qp05TxHOuuB3fMQCt8YxE4Cq J2v1fxh8BuXokHpR7K0R51MsizMWiZ303+ulKbv8yleGftn1nnoP/u2GE+BoovvJMnmL zJknkt94W1TX1uT3nlhSyzVeQcHbc3X1vJa6SF/TjFJKJiEae1bjWRptI2YNyM6QeAAh lsuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715737743; x=1716342543; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5kQ1NfQplOskT4B5ZqgIky4P0ExeAiR7M84edP4J3wY=; b=czpqkvkef9etExJXPi44akYjMTI2WmpevDwBOTwSQySGLonH943GJVTrXJwP0gwtAn VW25c6JAbTO4M0lfAyfgAi43W0Idok0j/rgDA58FSH5KOHouM4Q8tq5EwKx5JBj1mzZF woIB6pkNVzWIW6wdFYw9eN/7ROn042x/CARlIb9lCdUmCfrk9AOSgvLIZX6rPfuOm88J EP2ZuheLjwSCy9JuSDP7xfByvCltNv02D3VPEtmx4DHAV43wIICpnGT+0n1d+wgMyIAt TQh5A8Fcxt94BK8bGhazfAfJa5cOf0ibmJ4yxPEJmK/fd99LGqAqEv0xO3Rb+G1Q+vnT Juzg== X-Forwarded-Encrypted: i=1; AJvYcCVxJiood5vmHPTpnEhhHNYLYRAHVjTeJ/jr7JkYg7u5J40biI3mkEp4+aDgrpNaPVQRdPlOlS9jMsD8mDZK+RSvHlYBohkS8doELDm8Ptxcdl4osKudzF29g9p/yY+8K0/05DFhib366e4s09E= X-Gm-Message-State: AOJu0Yzh5BLrGxHk5XrKqbpT/EsyeSwrX6JumgIMkwOS2ybm6ySNcrOv RGe8x1vtzIDXyMRxvoINV8QtMzP3aimDQieWKOU0hXemLALECqD6 X-Received: by 2002:a17:902:82c8:b0:1ec:5f1f:364f with SMTP id d9443c01a7336-1ef43d18196mr132940295ad.26.1715737742825; Tue, 14 May 2024 18:49:02 -0700 (PDT) Received: from localhost.localdomain ([190.196.103.34]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c160b1asm105738195ad.275.2024.05.14.18.49.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 18:49:02 -0700 (PDT) From: Camila Alvarez To: Kent Overstreet Cc: Brian Foster , linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org, Camila Alvarez , syzbot+249018ea545364f78d04@syzkaller.appspotmail.com Subject: [PATCH] guard against unknown r->data_type in bch2_sb_dev_has_data() Date: Tue, 14 May 2024 21:47:22 -0400 Message-Id: <20240515014720.2482142-1-cam.alvarez.i@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Shift is perfomed only when the data type makes sense. Fix a missing guard on r->data_type being known. Reported-by: syzbot+249018ea545364f78d04@syzkaller.appspotmail.com Signed-off-by: Camila Alvarez --- fs/bcachefs/replicas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/replicas.c b/fs/bcachefs/replicas.c index 678b9c20e251..0fa91d0bf951 100644 --- a/fs/bcachefs/replicas.c +++ b/fs/bcachefs/replicas.c @@ -1006,14 +1006,14 @@ unsigned bch2_sb_dev_has_data(struct bch_sb *sb, unsigned dev) for_each_replicas_entry(replicas, r) for (i = 0; i < r->nr_devs; i++) - if (r->devs[i] == dev) + if (r->devs[i] == dev && r->data_type < BCH_DATA_NR) data_has |= 1 << r->data_type; } else if (replicas_v0) { struct bch_replicas_entry_v0 *r; for_each_replicas_entry_v0(replicas_v0, r) for (i = 0; i < r->nr_devs; i++) - if (r->devs[i] == dev) + if (r->devs[i] == dev && r->data_type < BCH_DATA_NR) data_has |= 1 << r->data_type; } -- 2.34.1