Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4718134rdb; Fri, 29 Dec 2023 10:55:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IFLVjLQuN/esj1EwMXK3MXu3UV5YLQfcH9u6jKwAoZuDaYwqb7Ly2Nll8Wf9/eJHEY1q0bk X-Received: by 2002:a17:902:64d0:b0:1d4:8a75:a6d6 with SMTP id y16-20020a17090264d000b001d48a75a6d6mr4055060pli.15.1703876106938; Fri, 29 Dec 2023 10:55:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703876106; cv=none; d=google.com; s=arc-20160816; b=u5+favto+UFTavz6MwvRbwEoyvw7TLreRXNhWg3maVsZFdxYzvrVQ9ttVv9DFessQP 4KjjQDWeUOzJOybod4phC5UIClXRXkg7BzyqOCrJ08Q9kBRmuoblWJxVqjOCCLYhmn9C NyamsFQ/cJnrfO8Xn5ezTZJk7p5r21X/1TJsuiWoN43NNs48eQ7BMCmOimVvBfWWy3km QYZVP2DYhCoSye+bBqJf1QHnBJqop824BLG4FZI9zVFR/RUguakdl1HbO0mpVT6prgYv dSCNL7cskPbskSH9OrKoSv+27rQVAOy92yNRehxatDY6K8kVCtdLAHWQncp6hIRxsAQu 6Z1g== ARC-Message-Signature: i=1; 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=foI3BeWGtWNh75wzfz6IrCcvUtBQLjp/z/XKEKBzVhY=; fh=2h7mtSTI8A3PQ9bXyg3YuJsb796zJygFcs4ZX01wbeQ=; b=mYnNsFhEHxiCWBxUgW2ZCSEPHLYQ9wBs8eCDsIMkgsXBko815rgU1nHNB1bh6Yko8L NbcByfmFkRPGxMKuoFjcvGEp15fxaTYELnfu3bpn2WO/241SxQXxJbirjmWUCCVLbjgC PP7xOZ3bvSk4r+bwMSA+4j620EmU1QyAVtm2D6mRjmWCu5WVsTgY9N/6g/iV7BKdOgjH J3o5x7AGZAiyidOnzjtVWsmKTpRyvpB8U8wiM753AmMTMn26AafsYPbAkoZW43B9dRRK 7RJjYGKSI1Nkem+whMFcMGhMu9Ta/he1lZ35oOHMa9ov6i2lKtMJBaosn3DulFUzgAok XqCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=u0eehce0; spf=pass (google.com: domain of linux-kernel+bounces-13204-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13204-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. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q14-20020a170902788e00b001d3ac497f07si10136569pll.565.2023.12.29.10.55.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 10:55:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13204-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=@linux.dev header.s=key1 header.b=u0eehce0; spf=pass (google.com: domain of linux-kernel+bounces-13204-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13204-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 9CF9B281F42 for ; Fri, 29 Dec 2023 18:55:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 205D612B9F; Fri, 29 Dec 2023 18:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="u0eehce0" X-Original-To: linux-kernel@vger.kernel.org Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (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 EE08612B93 for ; Fri, 29 Dec 2023 18:54:57 +0000 (UTC) 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: Fri, 29 Dec 2023 13:54:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1703876096; 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=foI3BeWGtWNh75wzfz6IrCcvUtBQLjp/z/XKEKBzVhY=; b=u0eehce0bxNGwlmKU/aq20IQw+j5KErIRGrefwyqbpu8QEP7ok4N5q2s6dC3Tf+hZMvJGa pBfraAY7XoVBLi2q+5+LV4p+nrsGyntsMo2CRRF5R1gOVi9jZu/icKilwnvogLpOT9bdKG kv3qc7dmP9OX5vnpmX2uxp4g28ztvOY= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Daniel J Blueman Cc: linux-bcachefs@vger.kernel.org, Linux Kernel Subject: Re: Stack corruption in bch2_nocow_write 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-Migadu-Flow: FLOW_OUT On Fri, Dec 29, 2023 at 07:43:13PM +0800, Daniel J Blueman wrote: > Hi Kent et al, > > On Linux 6.7-rc7 from bcachefs master SHA f3608cbdfd built with UBSAN > [1], with a crafted workload [2] I'm able to trigger stack corruption > in bch2_nocow_write [3]. > > Let me know if you can't reproduce it and I'll check reproducibility > on another platform, and let me know for any patch testing. this should be fixed in the testing branch: commit ab35f724070ccdaa31f6376a1890473e7d031ed0 Author: Kent Overstreet Date: Fri Dec 29 13:54:00 2023 -0500 bcachefs: fix nocow write path when writing to multiple extents Signed-off-by: Kent Overstreet diff --git a/fs/bcachefs/io_write.c b/fs/bcachefs/io_write.c index c5961bac19f0..7c5963cd0b85 100644 --- a/fs/bcachefs/io_write.c +++ b/fs/bcachefs/io_write.c @@ -1316,6 +1316,7 @@ static void bch2_nocow_write(struct bch_write_op *op) closure_get(&op->cl); bch2_submit_wbio_replicas(to_wbio(bio), c, BCH_DATA_user, op->insert_keys.top, true); + nr_buckets = 0; bch2_keylist_push(&op->insert_keys); if (op->flags & BCH_WRITE_DONE)