From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.71 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796349397; b=Zx20K9uosXbhDZ1z/waV4k461795aMKbGl+1AepBqhfF6xjugk2q4rO9cFFcD9gNIeyC qQdyfMYDdkZrIb2g84wWHkz4dQx4YfKWghaJ8YToA6XIcVrlw3T0rwY1wBnhJN5Buw66b L9n8SVmLbwoDZWueG4sjdDvrpLdlmxkoD9L+tzWGhzIlgdYsGVTJA2HpGIWqSpJTJlTiG VKDEvpaeInre5ypICVSg5VwoGg4RDrTQ7Doe1fKSMbyfWvr1rXDj3sKvMM80lGveEwiVT 4THGLgKiS4AOMo/9mGUhwvSfnIB7/1urfUBH6gGjd6xUkNbjTvcRq5j+x0ODuU667Rg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796349397; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=If4EYUHE6q6kgCk7kEs+fZYQnQSKCzOIA+bSRLgKgcE=; b=RUvwwgVZhcgyeObTFwQkiIFiYyJQWZ5rS1MG4TnfY/8/sK6WU331lBrFsNi3ziYoHDZh FATd5Ef+PbA1ERziHO/q9w/lzt7mGS0Yral420z9xBhFHrKQLMmZXnCn139AYbuDktcn7 W64xwA/nWFuvKbgkLPuIUBnn80mQjeg8f1PUHuddgaquodvlOt+6C7IEaEWmMkKckyuid s6mU6U+rnqNlonzz4rtQyC/XkDbZMDf1ExxawBYOr9PJcIVJcczKT6s02MncM4v5hpC+v Tm5AxaVPR9pMmoAPGiDKCPHMxMTurszVMtQ6BVzmkAQlxzv3O3LWaAZu9VvDJqQGW/g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Zhe9jjb9; arc=none smtp.remote-ip=74.125.82.71 Received: from mail-dl1-f71.google.com (mail-dl1-f71.google.com [74.125.82.71]) (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 08B1B606A32D for ; Fri, 4 Dec 2026 01:56:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 08B1B606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--surenb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Zhe9jjb9 Received: by mail-dl1-f71.google.com with SMTP id a92af1059eb24-1b588e4bd7fso417724c88.0 for ; Thu, 03 Dec 2026 17:56:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796349396; x=1796954196; darn=lists.linux.dev; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=If4EYUHE6q6kgCk7kEs+fZYQnQSKCzOIA+bSRLgKgcE=; b=Zhe9jjb9EWCjYX+7Atx/OiR2pWjQ4PbXuQhGQzB9pcuneJjkz4aM6gfXYK1GPjbaFf pO6883IsqqaP4024iNZ6y3CLJzL0ylIq8Wb0fydOKYhD4hhLG417/8nvxR862asRant1 fhFobuOJHcgQoq5UOZNY3Pyorfw2jSoyMM6a2H+nguBBaeWN+EWq2hU7PS8N0sgH32Wk UHnGRxOpQPa1OuWVi64dBRjA7DMglkZz1G6zy3zjPK7W36Q6QmWHULz/V2+8IpBViGjC 8kuHH0ZOaKqzAs6Ln1Krke6tzh5dZLIxvliwP6Mur3yKbc/BDJ0vtBNMliTgWEuQF8fy P4tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796349396; x=1796954196; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=If4EYUHE6q6kgCk7kEs+fZYQnQSKCzOIA+bSRLgKgcE=; b=BjG5KBYD5qxTdS9tQ9DAcJtcGfGuLi58nsWjEmglBK/gzUmxpcRyLUq0l+6JwYo9pA 8AGGAPnC7m9fCRbT0SLJrEG1H570sF1g2bYJ1IbzKVARRKGbYP71v/50Jgjz+9s+b2Hz tJUU45ORnqDd7W5jqft5uk2OR8S6lICkz8Tq+k87fTS8MoMVFDALG1oRurOlPfaeJjHe oTYxfCZ5oeNXdsklT7jpEvmT72f4quCCMM7bICTnpIZ6v+B+fO5opoNw+UC5SW+gPiap DgK9N2iSaNT++7R6mDnmkUw9HdG+PglXfeCaNqCdKa6ubVT2wZT1VrwRPXcuvA2w0DxW ZvDw== X-Forwarded-Encrypted: i=1; AL+hErFL5/uijQbjUZf18lEIpqYi4bKN13p2D4H5N5vw6IEl3r3ZDELnzUqL4Pwep6N3PPgBxiCK1EDfvRbLxqNk1Q==@lists.linux.dev X-Gm-Message-State: APuU4Z8vV40TuJRxaCKyXMI0TcVucO6T+CxAgDSweRPwZOyg1utVLORy YSVVBKNQlH8ZRLYruaU5aIr9DyffhDRkyrbvsGvJxdSop2YfCgLKNnVr4ysE1xAuVPFhaepk33r foksaRw== X-Received: from dlgo29-n2.prod.google.com ([2002:a05:7022:b1dd:20b0:195:d59a:94bc]) (user=surenb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:2610:b0:1b5:1005:682b with SMTP id a92af1059eb24-1b5d710671dmr584195c88.7.1796349395774; Thu, 03 Dec 2026 17:56:35 -0800 (PST) Date: Thu, 3 Dec 2026 17:56:28 -0800 In-Reply-To: <20261204015630.4095988-1-surenb@google.com> 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 References: <20261204015630.4095988-1-surenb@google.com> X-Mailer: git-send-email 2.56.1.987.g2ec0ab4260-goog Message-ID: <20261204015630.4095988-2-surenb@google.com> Subject: [PATCH 1/3] alloc_tag: preserve the error when reserving a module tag area fails From: Suren Baghdasaryan To: akpm@linux-foundation.org Cc: david@kernel.org, hao.ge@linux.dev, 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, surenb@google.com, linux-mm@kvack.org, linux-rt-devel@lists.linux.dev Content-Type: text/plain; charset="UTF-8" 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 --- 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; -- 2.56.1.987.g2ec0ab4260-goog