From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.12 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796370453; b=DuNvvhSyd8NiCraqOUgJWpoRgGTQJfmAQLAob+2PD2FOuwulm5tzkZzL+oZRN8DIaCOL JsyS7JqvtjlbKkOOk56lR3QHezza7u1vRdvDsFSPL+72Wyay4Qp2FzuAijof3cr0UsaHT 8857gU3NO93mQRlIokmUnXuUNEtWMb8KQ4Ppn/QzGoXFsd4ty9weBZJ1CRrc+mKkxwOSu 2BNrQLc3WqyxMp6Rp8nyPZEOr2IUBvMVlbmeIZqu/BzlKO/V1CtiyYJaWZfjA2usOtdco FUWYneadR2C2ruI9icOWyEkQDkyk7g/xwNZvwkQWL65MDVTNEaAxAlxwIOKqMF9uQ7w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796370453; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:Content-Language:From:In-Reply-To: Content-Type:Content-Transfer-Encoding; bh=XXc7qwYnhyeBIke/86c7CqqA4sauniJkoCFOudtRq6M=; b=JDZDM97FoZoSmFqJLJfw5KBQ9twpSrtgyhY4ZlmDo9G8Ad94R3YqVIsykf0UiLoGDD4m 2Io/J9g+UtIcGp6vh8c3Dlfwv83Vl9v6SvZApxCxkbPCJ8F+6JCm6dDYuDPtUbU28MQ/U +LEyry/PJbQhpMjCk9hFQ3KwDSox8ttiWgUMNhfh6X6ksR8YT78j65+2TiX5cROTo/OGU i+9J4Io4FlaXTkkyOkdrc2WWCVA/isDypSqJ/jlwMv2lV3ejJ+xMRK6ao/Rmf6sHLYMHg P/VUA+NIUuMKVzJF6SVOSDPsDSdPvJe5gkudAgyMpWVZCbmkooxOB9W/bt+cuzNtyHg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=vbG2Ag0O; arc=none smtp.remote-ip=95.215.58.12 Received: from mta1.migadu.com (out-12.mta1.migadu.com [95.215.58.12]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00ADC606A322 for ; Fri, 4 Dec 2026 07:47:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 00ADC606A322 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=vbG2Ag0O X-Envelope-To: linux-rt-devel@lists.linux.dev DKIM-Signature: a=rsa-sha256; bh=fEUYEBTmD6IAPngtEc8FqAzwQP2UDKipYGqN8ObH+OQ=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796370450; v=1; x=1796975250; b=vbG2Ag0OTx2CFfioVj64pHGecJYEBfKOgrW6wWxRP497UpT5KtbhZJ96RFymQZXrzyG8mNDZ ODUCvPoAw/GZBQ+ISijSc2O6KiNe3obhqMLsNuOZZ+bdk6C2uclbOfEXQxJTUQcOImzuUjqiMps +gcMukhraXJOWuPG3eh6IhAo= X-Envelope-To: linux-rt-devel@lists.linux.dev Received: by smtp.migadu.com with ESMTPS id 37e7b34f30c68384; Fri, 04 Dec 2026 07:47:30 +0000 X-Mizu-Trace-ID: 37e7b34f30c68384 X-Migadu-Flow: FLOW_OUT Message-ID: Date: Fri, 4 Dec 2026 15:47:20 +0800 X-Mailing-List: linux-rt-devel@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/3] alloc_tag: preserve the error when reserving a module tag area fails To: Suren Baghdasaryan Cc: david@kernel.org, liam@infradead.org, vbabka@kernel.org, hannes@cmpxchg.org, brendan.jackman@linux.dev, ziy@nvidia.com, bigeasy@linutronix.de, clrkwllms@kernel.org, rostedt@goodmis.org, pasha.tatashin@soleen.com, pyyjason@gmail.com, usamaarif642@gmail.com, linux-mm@kvack.org, linux-rt-devel@lists.linux.dev, akpm@linux-foundation.org References: <20261204015630.4095988-1-surenb@google.com> <20261204015630.4095988-2-surenb@google.com> Content-Language: en-US From: Hao Ge In-Reply-To: <20261204015630.4095988-2-surenb@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2026/12/4 09:56, Suren Baghdasaryan wrote: > When storing the module area fails after the padding in front of it was > stored, reserve_module_tags() removes the padding with mas_erase() and > only then reads the error from the maple state. mas_erase() walks the > tree and overrides the error stored in mas.node, therefore the correct > error code gets cleared and later treated as area reservation success. > This leaves the same memory area available for allocation to subsequent > modules, causing silent memory corruption of allocation tags. > > Store the error before removing the padding. > > Fixes: 0db6f8d7820a ("alloc_tag: load module tags into separate contiguous memory") > Closes: https://sashiko.dev/#/bug/linux-64e7eab3-9791-43b6-a55e-fc05f931983c > Signed-off-by: Suren Baghdasaryan Reviewed-by: Hao Ge > --- > mm/alloc_tag.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/alloc_tag.c b/mm/alloc_tag.c > index 18bec85b6220..b4e55bbf57f6 100644 > --- a/mm/alloc_tag.c > +++ b/mm/alloc_tag.c > @@ -1010,9 +1010,10 @@ static void *reserve_module_tags(struct module *mod, unsigned long size, > mas.last = offset + size - 1; > mas_store(&mas, mod); > if (mas_is_err(&mas)) { > + /* mas_erase() resets the error in the maple state */ > + ret = ERR_PTR(xa_err(mas.node)); > mas.index = pad_start; > mas_erase(&mas); > - ret = ERR_PTR(xa_err(mas.node)); > } > } else { > mas.last = offset + size - 1;