Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796286389; b=sWWCul09eTxjzbiUHnqVh18ro9gmE5eF7FUXBKmRSj/ZVStOH/W70TzPS6knLSvYxIkz M2O/9pJskQGgiYSpoNMee79mPDJIqEzagrF8hL6+4Dhj8EOkOTS+irB4Cy/nlG3w2PXVY x7HoyZ7YtgyGQvs6nFuAO12QrgRc1Hebkk0CULBMKKZZIQZFRInrcNRQfiOXK4aauUxSa Dc2wca1+nzAzus36U0WKhsndK73YkD49uqSJ3lGwrWkJFXlPxn4xKzXhI9NUY5ddbRaoc aFSxQ5vagOgHVdCmqFLGnetOE+rUYCyZpCbPeRL1qGiheReTKzN2a1njES7mNjrK67A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796286389; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=B09zDhjYzpmW+2pOkifaksArgfOzr1X8iNHt4mHASyE=; b=0zDNDj+R51koUsrMOxW7RGIfTv7lhH1KNZ8cTer4Zzz215JFiP2yiI689wUn0ihnici7 kbApX4oWZNU2rtsObXzpleOMTOUReAkE86k5FONYgdrrSPKQ0L71a62sUmNUl2koWoUKo HRRgTuoZrjOUQ9NJxyhC9Ew5SAOWDLHjllw8SCbNJ3mWr3bx0Fllkt1SiRygCGeADFBED VfCBY4gRXVO4vFuNZXEVUeubWp9h31jnFLtDnD5/pVF1iPQl0M0DwtdkIlA/LJmSJXeH8 DENbHpySF660LyFj/2wydWMjZNzhRDj2EmsWjY+7s5gnORAptvGactkh1UxoK9fVMGQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Nq9x5IhN; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24068606A68B; Thu, 3 Dec 2026 08:26:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Nq9x5IhN Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECBED1F00926; Thu, 3 Dec 2026 08:26:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796286389; bh=B09zDhjYzpmW+2pOkifaksArgfOzr1X8iNHt4mHASyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Nq9x5IhN75tIW2kecHow6hUrOY1zgUOd0NMzzmVNt30+jxHnubOPnc6kqFpKwtTva yCr+z2hJJXDEC9bhUVBv5+vVwJZ6h1bVaCbIhy4KLH+KhfY3xDoJNGSV7MD1mmmiVo U6Ndh3ZOWH5xYAJqaQYNoMnIm7tZ+XCl3FatHaNSlm5Ee6Y+DQtWc/HwK273BMxs+F +ErMHR4UDHRBzvmMtE0qCwlqOPuTw7tAu/l5D/Fxc/0qSmfkguy8oyEqrqFFhJhKfd I6QdE4wX/X4x0C6ha76gE/YifugAhtWHQi1joXRMhzF1Kl8EbsU7aIO7v1eF1F+u9X 4IOZD8Sv9Pi8g== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Anatolij Gustschin , Greg Kroah-Hartman , Srinivas Kandagatla Subject: [PATCH 06/10] nvmem: eeprom_93xx46: Reject unaligned writes on 16-bit devices Date: Thu, 3 Dec 2026 08:26:07 +0000 Message-ID: X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog In-Reply-To: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit eeprom_93xx46_probe() hardcodes nvmem_config.word_size to 1 even for 16-bit (EE_ADDR16) devices, while eeprom_93xx46_write() silently masks off the low bit of count and returns 0 on success. A 1-byte write therefore silently writes nothing and reports success, and an odd offset is shifted down by eeprom_93xx46_write_word(), overwriting the adjacent byte. Set nvmem_config.word_size to 2 for EE_ADDR16 devices and reject odd offsets or byte counts in eeprom_93xx46_write() with -EINVAL. Fixes: a8ab316ab125 ("nvmem: 93xx46: remove nvmem regmap dependency") Closes: https://sashiko.dev/#/bug/linux-2aded405-6835-472f-bb94-d76d40cc2d96 Cc: stable@vger.kernel.org Signed-off-by: Lee Jones --- Cc: Anatolij Gustschin Cc: Greg Kroah-Hartman Cc: Srinivas Kandagatla drivers/nvmem/eeprom_93xx46.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/nvmem/eeprom_93xx46.c b/drivers/nvmem/eeprom_93xx46.c index f9c3ab52c2f9..6b159d5fa08e 100644 --- a/drivers/nvmem/eeprom_93xx46.c +++ b/drivers/nvmem/eeprom_93xx46.c @@ -282,10 +282,11 @@ static int eeprom_93xx46_write(void *priv, unsigned int off, if (unlikely(!count)) return count; - /* only write even number of bytes on 16-bit devices */ + /* only write even offsets and counts on 16-bit devices */ if (edev->pdata->flags & EE_ADDR16) { + if ((off & 1) || (count & 1)) + return -EINVAL; step = 2; - count &= ~1; } /* erase/write enable */ @@ -513,7 +514,7 @@ static int eeprom_93xx46_probe(struct spi_device *spi) edev->nvmem_config.reg_write = eeprom_93xx46_write; edev->nvmem_config.priv = edev; edev->nvmem_config.stride = 4; - edev->nvmem_config.word_size = 1; + edev->nvmem_config.word_size = (pd->flags & EE_ADDR16) ? 2 : 1; edev->nvmem_config.size = edev->size; edev->nvmem = devm_nvmem_register(&spi->dev, &edev->nvmem_config); -- 2.56.1.911.g883d8bcb20-goog