Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1795201lqe; Mon, 8 Apr 2024 23:41:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVkf0IPNyCNVX0b6X0U8ijYcZC+4qIftCSj8xgRkRTyPBC1DHr2O9pg5mPcGmPPSZEVWc/IWKX8IeXQVOL9n3B/21KxCtgeO1XqxLRRWA== X-Google-Smtp-Source: AGHT+IFDOmoU0iItyeyFjpVrCs4xN21sWz8EPrB/tCsSfaCgocpacunukG4332ftKpnrNLdWYsp/ X-Received: by 2002:a81:73d4:0:b0:615:7899:65cb with SMTP id o203-20020a8173d4000000b00615789965cbmr9164405ywc.36.1712644909505; Mon, 08 Apr 2024 23:41:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712644909; cv=pass; d=google.com; s=arc-20160816; b=Hq9bGwnjQrzKyBQfg4ohfYiiorRMfBlnuTC4gnxPDL90gUht+iDXRZPxcfNUZzZ6Hy 55a1bYl99qunLooiY6PJ1pgVenKQOxgsqkEk909ylTjUxPgyfvipR0r+5gelsj+ipXJe XlwNMpg42NFYRiOSP7L0KLkDzBTBiuXdaTp5CxQCfuQNJ0f2NbVP/ZPo3yPHYCNLQZuT VADhVtPvmSXjpNiwn09MAEAD3tYINvVWkvLtErVbxo8oyF0eZ7uEnxqGqnw2MUSmd34/ Jy2dWVV57+uB5DxXKTGJCqCcVyQchfKDf/Ga5H+K3hfWNilBbltP6IE2BGQMLUAck1D9 6Hpg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Oe7RFp+BwBZoK6hQUNiwVYCnvZd3pMjzXOyJ9JrbiaU=; fh=8/tshs6WhvWRRVkj1SSjxdeR4nBmaI9n4XRnmaUe/SQ=; b=pNfFUpjP0zC62GSYrwoKiPgS0mGNg+hEXypHv+fm5wgfY5ETKkGrig08rCxBc7oRS5 oJUCIlVy7SYVT6fVN5vfyEBcFlVBjWimPmXa0WMaM11nnfSuuB+x3GwmghZJaemDxR2e xl/StTfkj4s5OWRL/r/Ehzpo3EZgxzz5eZ8TOJYj0PP7IrUGTR+HsT8dxBW/blCKu8om x0+1NkhBHOeUSt2giV19CGC0pzxDupUOKO2B/sTShq7LcrKHo2EyQFFt5rcxN0NNoFf0 hLwpqzkyQ8IEpSgNPzqIGVb07KHpze/FFmL+lIwcGyRU+xviEkMP8DUJzntFcjZceW9i D8lQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=fYI4zuGn; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-136314-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p10-20020a05622a13ca00b00430b3a87b41si9964927qtk.757.2024.04.08.23.41.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 23:41:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136314-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=fYI4zuGn; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-136314-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 3BE431C21462 for ; Tue, 9 Apr 2024 06:41:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF1C2762DA; Tue, 9 Apr 2024 06:41:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="fYI4zuGn" Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) (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 D434743AA0; Tue, 9 Apr 2024 06:41:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.196 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712644895; cv=none; b=imj0OaYIfZ7x/yv4nUfAowXllMHqZeae1rl6NiD4ZZo/RX9KPewLZdnbAyAmMCQZCzL+hWMvffyzng2UjDt3gff8fil8BitlzaVEd+M31MzuCfa7tcR7qy9RzQcqp/EJkDTNUvE/wN6q5NCN5/QDOe3oSg2FCL6zLvIqKtxW+rk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712644895; c=relaxed/simple; bh=hxeo5rb2iQBEwCq5OE7G7hH2PBbVJx1koBtju/YhOjQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W7zn9phMn/f5VaShHJvGlNPVRvm9uAd33NAasZpS2AYtX9SMPEdKfRQVkA/sUcnmP8zAx31LiwcE+tKt6m9uE+XsGjxcIN0iG4rJD/bGr3RrYrbYgERA1fslDa9MLXldetjHwJfIRMe1gCDCH0BvgqeQ0KwR7N9U1h1aa39qcrQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=fYI4zuGn; arc=none smtp.client-ip=217.70.183.196 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 609D9E0004; Tue, 9 Apr 2024 06:41:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712644890; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oe7RFp+BwBZoK6hQUNiwVYCnvZd3pMjzXOyJ9JrbiaU=; b=fYI4zuGnf6GcgsRjKcnjOxuKk6eZPkxJTiBAAJNyeAI1vg629CeJxfSh3Xjp0iyLYXAX1q MNmozJ0hcpa3MrnPNWQiTnZR5VwHhYsWTFUsjJcIbtk6FtytGQqmdB3LXzwC3SPn5oQWex RTi62PX4vWdPRkuf/WOxzSXVZ4fLSJSzYRlym7GNOUmdv0E8a4aLD92RSysQPGPGDE3KIL FCxZ9NGNAyCXw+ZEKhK2PFyCKaBcquQqmjs8g5dW9FZV6R7uSOhpMNgxYrRPYnhz/grtQS bfVu4WjB1h2gVBqVBhe0KfhCMCSM9PWaSD8NA6pmcTUE/B4Z2nOSsv+xxVAGwg== From: Miquel Raynal To: Arnd Bergmann , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: Arnd Bergmann , stable@vger.kernel.org, Dinghao Liu , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mtd: diskonchip: work around ubsan link failure Date: Tue, 9 Apr 2024 08:41:27 +0200 Message-Id: <20240409064128.91899-1-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240405143015.717429-1-arnd@kernel.org> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-linux-mtd-patch-notification: thanks X-linux-mtd-patch-commit: b'21c9fb611c25d5cd038f6fe485232e7884bb0b3d' Content-Transfer-Encoding: 8bit X-GND-Sasl: miquel.raynal@bootlin.com On Fri, 2024-04-05 at 14:30:04 UTC, Arnd Bergmann wrote: > From: Arnd Bergmann > > I ran into a randconfig build failure with UBSAN using gcc-13.2: > > arm-linux-gnueabi-ld: error: unplaced orphan section `.bss..Lubsan_data31' from `drivers/mtd/nand/raw/diskonchip.o' > > I'm not entirely sure what is going on here, but I suspect this has something > to do with the check for the end of the doc_locations[] array that contains > an (unsigned long)0xffffffff element, which is compared against the signed > (int)0xffffffff. If this is the case, we should get a runtime check for > undefined behavior, but we instead get an unexpected build-time error. > > I would have expected this to work fine on 32-bit architectures despite the > signed integer overflow, though on 64-bit architectures this likely won't > ever work. > > Changing the contition to instead check for the size of the array makes the > code safe everywhere and avoids the ubsan check that leads to the link > error. The loop code goes back to before 2.6.12. > > Cc: stable@vger.kernel.org > Signed-off-by: Arnd Bergmann Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/fixes, thanks. Miquel