Received: by 2002:a05:7412:4082:b0:f3:10fb:27e3 with SMTP id c2csp1316289rda; Wed, 22 Nov 2023 15:57:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNyUHX2i2kk9EeGLdGW2ZOnOJCXlchW88D7TuG9gAzCr4R7tM5BEUnFvMGJ5NyrhSbJ3h5 X-Received: by 2002:a05:6a00:478a:b0:6c9:af71:1de7 with SMTP id dh10-20020a056a00478a00b006c9af711de7mr1242116pfb.11.1700697467498; Wed, 22 Nov 2023 15:57:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700697467; cv=none; d=google.com; s=arc-20160816; b=f1py5vchoD+qs8WAYz6OvAez+gfev67jHr3lV7qRe2GV7R4wP2SJqb3GvxAoykwzq0 hGgUDeP7tLoFNSoAo0hlNoVYN/m7DDgPEFQjMW98gzpW6G9KR6qwaj4s99vFO7bY/ErU o68ov/1X+WBSYb8yje3qKzaP/k+p1l/jBGZv1ni2OWk9N3xHwGCHq0mZOaXjvd0NRedM jg8SPLvaLuGyPxoncHFogEQtPqMSkzZA/sdLQS+qpUGdqXXqLs6WMIF1Kdoh+2UkwyiG Jo2QyUQRXgfHSck2IddlWKLV/tOYfpr1dP6tk5j14gXlyPsacEqLg8OLSL5IgKLf8RdZ R9yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=1ZPhv1Y4mad8pc6Sp3pH+gIGSK/MlW2XI6tHY4Xxt8w=; fh=enLqCybeBsufpAEudVOvNeFFRzGUNPw6LyjwoApl+ew=; b=Zsxwdv3/TxwlOUuuHBIK3cFKiVGLdWXg4VK9iBCZqw3Hy/xUJeUuNDP4ilspTcuI2c PL3hI3FSUkaI8m/e7iZMoU0D9VQIXxu7e37TsHAcoxx5pIXlGmNFk+X48umtZzcEbCJT QPbmVomY+9e0NOiQdGgpLEeghanyEvVCnaRmXtwIXiLnBF6Y8RWTolBW9ZV19mVTPkVJ Nb5l54X23NbH9ovVx4vKgC7CRjRMPd1t9XKV69XoYNOJ5R0qDMSgmv/NV7lSoig9Zcvp fXwcVjpRJsttQMslu+osuBeNGjmn4JdlHTduwWywluAuIynIhRON2vGqKxmKnhI3qlVh 3g1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Ism3Y9NB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id p67-20020a625b46000000b00690204af234si84436pfb.378.2023.11.22.15.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 15:57:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Ism3Y9NB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 7E168815CD92; Wed, 22 Nov 2023 15:57:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344255AbjKVX5e (ORCPT + 99 others); Wed, 22 Nov 2023 18:57:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344054AbjKVX5d (ORCPT ); Wed, 22 Nov 2023 18:57:33 -0500 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [IPv6:2001:41d0:1004:224b::b1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DECFE110 for ; Wed, 22 Nov 2023 15:57:29 -0800 (PST) Date: Wed, 22 Nov 2023 18:57:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700697448; 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=1ZPhv1Y4mad8pc6Sp3pH+gIGSK/MlW2XI6tHY4Xxt8w=; b=Ism3Y9NBJBn4HNWS4hpsESFKy/rFrGOE8+evdNB9lbSC3EW4417UqfABLGmGbP90JIjflL yJJ8ht//Oi9oH7PUduBsN8brbXkJ+Z3qdqvkx+MGg7H872urew6utALcBEkaW1ZPvMSGdT hQ6//Lp5UcVHXbPI/u4BUG6I5ysMfpA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Peter Zijlstra Cc: Mark Rutland , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , linux-kernel@vger.kernel.org Subject: Re: lockdep + kasan bug? Message-ID: <20231122235725.m6nwjrwjr2fr2hpa@moria.home.lan> References: <20231120233659.e36txv3fedbjn4sx@moria.home.lan> <20231121103614.GG8262@noisy.programming.kicks-ass.net> <20231121114126.GH8262@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231121114126.GH8262@noisy.programming.kicks-ass.net> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 22 Nov 2023 15:57:40 -0800 (PST) On Tue, Nov 21, 2023 at 12:41:26PM +0100, Peter Zijlstra wrote: > > I suspect the dodgy access is to chain_block_buckets[-1], which hits the last 4 > > bytes of the redzone and gets (incorrectly/misleadingly) attributed to > > nr_large_chain_blocks. > > That would mean @size == 0, at which point size_to_bucket() returns -1 > and the above happens. > > alloc_chain_hlocks() has 'size - req', for the first with the > precondition 'size >= rq', which allows the 0. > > The second is an iteration with the condition size > req, which does not > allow the 0 case. > > So the first, thing, IIRC, this is trying to split a block, > del_chain_block() takes what we need, and add_chain_block() puts back > the remainder, except in the above case the remainder is 0 sized and > things go sideways or so. > > Does the below help? > > --- > diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c > index e85b5ad3e206..151bd3de5936 100644 > --- a/kernel/locking/lockdep.c > +++ b/kernel/locking/lockdep.c > @@ -3497,7 +3497,8 @@ static int alloc_chain_hlocks(int req) > size = chain_block_size(curr); > if (likely(size >= req)) { > del_chain_block(0, size, chain_block_next(curr)); > - add_chain_block(curr + req, size - req); > + if (size > req) > + add_chain_block(curr + req, size - req); > return curr; > } > } > Yep, no kasan splats with that patch