Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1129559lqd; Thu, 25 Apr 2024 06:56:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUqd83cEt2mhKrLljy/zyQOtWNolDjXbgtACmoLxETGPIdCUc498iCuOgHte9aQh4ri3cK0R+HQw61BsEc7Qcm+QNe1inZA+7qs+JXeaA== X-Google-Smtp-Source: AGHT+IEpSi0xDpALVUupQNwiRtHdrSXFApaRuJgMht2JfkiULRJRIGki5HkR9q4pklXIVhw8Z6l9 X-Received: by 2002:a50:f684:0:b0:56f:e4f7:fbd9 with SMTP id d4-20020a50f684000000b0056fe4f7fbd9mr3852414edn.20.1714053371703; Thu, 25 Apr 2024 06:56:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714053371; cv=pass; d=google.com; s=arc-20160816; b=qXzG1XJ5YVAQXtqo1DH6PV6bI+NT7PQF75CpEEwdVz6Yfu3AC0Zm0nKt7Re0CIMFEh 4qqXlspDmJsdUSX+uZ5X4Sia0HIOK/Dz0hBkkivjETw/gkXyHmZG9vpwwq/JIXtGeP8f KAFPip12m2nZzJ7smb5Kh21fg4p0otx/qxZbvCIAyUcMMBMWXal31gjrkG/y+Ecp102l syKpWNiS2CiPVuBTWXIFiC8w3NIQVm+GcexNdH8aG1RwncEg+ZAz8l2PoyHRNNe9pktq oZ5e6iq6AKdaMaiTg9FRkpaC0UY8FS3/A3g8yllmk7nISf+dj3AF6xWLqEg+5lpFyT5r GMtg== 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:date:dkim-signature; bh=SIrQNZSOyGumQ4W9WyC3jnI0g+lXhd8s1D7EZMPy8ok=; fh=lwrWORmwGhDftVCCBtsTR7uq4/dHNGoURXaQZ0RPgLY=; b=M7vQ7zw0+371zp8LOPT56x16n8QXSj5YpeaubqqIIU08POxWS8OZ3ISlZJrMSWnuLw lWwDYdbDL6HYXjhyVVaCsQuMyrZVI7fRslnjzZb7wC4ppHDYQe6LvolLkBq8G8Oo9pDp Epm3cJ3dGXxW8Ppqw+EF6/une9JSLpvuga/LyxN6puEhoQ2ILNQ2Qa+bQSn1aXUd3uBl kSoLYlDv62PjQGZdGK+MhT8NWasE9xXMBRxTnDzQewqNt1C6e8tTbR43VFNpjYjxbb3t XHyil7RQaYUwh4XEcoZ6PeZWsIqzJ7KqtXPwwlHx7q3JqBVQMAumoE90aqp2sHwoA7b2 99Rw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NXzcqdVf; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-158628-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158628-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k22-20020aa7c056000000b0057247beb085si271386edo.409.2024.04.25.06.56.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 06:56:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158628-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NXzcqdVf; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-158628-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158628-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6EE861F22537 for ; Thu, 25 Apr 2024 13:56:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BC2D149E08; Thu, 25 Apr 2024 13:55:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NXzcqdVf" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 BF3EF1494D2 for ; Thu, 25 Apr 2024 13:55:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714053349; cv=none; b=D/odUhHV1yrKQrarm9uBLa+1l38oWK83S4F/0sLqr4wI2MevmjXs3EEoTZIEvPm2fHbOiZLXGJj+m984Ymv1QTNTEEeXFqZ3BKW8Rw6PQjikxcQF94ukJjp9czxkX6cw58exTA4fXANLMYq+8ZRz2LWJsIQLklT5G7RqirLuokg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714053349; c=relaxed/simple; bh=0gOGWX754Dme5o75hzHeRnF10h1sIbteWYGixJF88Zo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=GQTrudu7074kz+GfpLgt/cAeAmJuFmEOtXcj9NiUTxXbCCbeeWRhU3FPwZk8Stdjq4SBLNKsoHwyTkcmd4JgHeL0nn1vPUiPTr6UmnMEXoAf5FhiPDz5Fjlkk+hUyZPGF+xK0BwBgL3gRL13lQIiEdj7/73mpssrva3EW/skq08= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NXzcqdVf; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714053346; 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=SIrQNZSOyGumQ4W9WyC3jnI0g+lXhd8s1D7EZMPy8ok=; b=NXzcqdVffiHt64vMyfUbOK2s1qDvJuvE7RWuGPRinoCD05KNWh2NcIXehdc8b9hsXH5fKn BqC/JbQWn3g18clYILOR8/aHBQgxjNfm7zXcOGTSJKhLkBU4POABhTFrRMlJUzemIJ4zFC yMbEVWs+yVSCGPY5ZhHmR8txU1Pp9UY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-274-Aqd1LsKTOJ6ER0lihQRU_Q-1; Thu, 25 Apr 2024 09:55:40 -0400 X-MC-Unique: Aqd1LsKTOJ6ER0lihQRU_Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C8D481827141; Thu, 25 Apr 2024 13:55:38 +0000 (UTC) Received: from bfoster (unknown [10.22.16.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7127DEC686; Thu, 25 Apr 2024 13:55:38 +0000 (UTC) Date: Thu, 25 Apr 2024 09:57:54 -0400 From: Brian Foster To: Christoph Hellwig Cc: Sam Sun , linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, djwong@kernel.org, chandan.babu@oracle.com, syzkaller-bugs@googlegroups.com, xrivendell7@gmail.com Subject: Re: [Linux kernel bug] KASAN: slab-out-of-bounds Read in xlog_cksum Message-ID: References: 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-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 On Thu, Apr 25, 2024 at 06:12:23AM -0700, Christoph Hellwig wrote: > This triggers the workaround for really old xfsprogs putting in a > bogus h_size: > > [ 12.101992] XFS (loop0): invalid iclog size (0 bytes), using lsunit (65536 bytes) > > but then calculates the log recovery buffer size based on the actual > on-disk h_size value. The patch below open codes xlog_logrec_hblks and > fixes this particular reproducer. But I wonder if we should limit the > workaround. Brian, you don't happpen to remember how old xfsprogs had > to be to require your workaround (commit a70f9fe52daa8)? > No, but a little digging turns up xfsprogs commit 20fbd4593ff2 ("libxfs: format the log with valid log record headers"), which I think is what you're looking for..? That went in around v4.5 or so, so I suppose anything earlier than that is affected. Brian > diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c > index b445e8ce4a7d21..b3ea546508dc93 100644 > --- a/fs/xfs/xfs_log_recover.c > +++ b/fs/xfs/xfs_log_recover.c > @@ -2999,7 +2999,7 @@ xlog_do_recovery_pass( > int error = 0, h_size, h_len; > int error2 = 0; > int bblks, split_bblks; > - int hblks, split_hblks, wrapped_hblks; > + int hblks = 1, split_hblks, wrapped_hblks; > int i; > struct hlist_head rhash[XLOG_RHASH_SIZE]; > LIST_HEAD (buffer_list); > @@ -3055,14 +3055,16 @@ xlog_do_recovery_pass( > if (error) > goto bread_err1; > > - hblks = xlog_logrec_hblks(log, rhead); > - if (hblks != 1) { > - kvfree(hbp); > - hbp = xlog_alloc_buffer(log, hblks); > + if ((rhead->h_version & cpu_to_be32(XLOG_VERSION_2)) && > + h_size > XLOG_HEADER_CYCLE_SIZE) { > + hblks = DIV_ROUND_UP(h_size, XLOG_HEADER_CYCLE_SIZE); > + if (hblks > 1) { > + kvfree(hbp); > + hbp = xlog_alloc_buffer(log, hblks); > + } > } > } else { > ASSERT(log->l_sectBBsize == 1); > - hblks = 1; > hbp = xlog_alloc_buffer(log, 1); > h_size = XLOG_BIG_RECORD_BSIZE; > } >