Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452652; b=KYlXkYGpRXLzx5dj3KPfYT6vPLmWopeK/eqh4R5ZM0BjV/723RIpT0NmZ5uIzfGGYH32 QqlLGraJYPrRvgZCtefMTUekCxmvVger2jmppnXdqG46vd/n6Ms2UGxF2tiKYncBFPRXS fzQZKPz84inaxuuRKv70PYRVSJ/cz5U6pLKQte7vmKqm47gblZOnm75JPLZptIQVKP3j1 y4rXB5gXEOVf+za6lb1VD+HVQtBlqKXrRc5reKlMU68UJ0wiOaLHx6WdVLeEGi+FKiMM8 u5t217kg+DUem7D+HOuZ8/qvUdUpuSVKDBdQSXU6q8T2R8qqdINXHja/eLeKZZYY9Hw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796452652; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=i1X3DP1txvqKlyWAxOuLJ0I0oHZScT1ILC9/dj57ZjE=; b=uCXEv0fxquN1LUfSsEMd5dOWQ5t5EzSJhMFSsp8hzvINm4IEwEbSxIyknJ7KbcpY66o0 F61uqh+qhLgq6O65SZgSBejrNmhKQGJYyYtAysgeB4+D/1hGstQ8UEEpJNTVFHc4Au6rF O71oNHocDZe3UBPf9RC0NFaniZfAoCrL5sd9JZlxGSRhlNKlCNNwceKbWP1P1cdAxJO30 HnPxfaZ+3/dctFgoYv8wk8vgORk5m6CGDBQ58xZOLKlhAc8+QmAMd3lUMrfeAXUF4EYAw N1VEMX9tUstrK+BeX8xl01Qfoi3Rv2yr7nL1hVFzftNK2nklY3XhHFPsnWi7PNmrPMA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=G1jJsRyq; arc=none smtp.remote-ip=74.125.82.41 Received: from mail-dl1-f41.google.com (mail-dl1-f41.google.com [74.125.82.41]) (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 4B569606A32F for ; Sat, 5 Dec 2026 06:37:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4B569606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=G1jJsRyq Received: by mail-dl1-f41.google.com with SMTP id a92af1059eb24-1a3c08d6928so2534350c88.0 for ; Fri, 04 Dec 2026 22:37:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796452651; x=1797057451; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=i1X3DP1txvqKlyWAxOuLJ0I0oHZScT1ILC9/dj57ZjE=; b=G1jJsRyq2sNH7mmJ9II0q1IbzjQFFkMwuzn7/hiTixmDmcM7bZSygT8iHD7bZeSHZD vIe4PceJJiKcm+jA2opcFFnWQVbTTzyvZR3+C8bEova3EcIx4SVlzIj9Ujgm5cc/T6v9 K7gmO1Fgz5CT2vrhU9unHyaoNyFuno6fTOR2bK0lEv3FctgApKM1x+LD3kYeoMKkVyIM AFZwKPt8f2bvKuL/suqKZ+0DgLArGSS6j7TdGd+jQKuE8RRg72Jd2iOvo2SvK1zdrL3h xDf0OnLRXBv4uF2TPq4OqeIfvzS1OAszp5F+/0QyBYg7UMiRGhMzryKzIvjcqPSBaOry MOwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796452651; x=1797057451; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=i1X3DP1txvqKlyWAxOuLJ0I0oHZScT1ILC9/dj57ZjE=; b=XBLFdKQ3VC/TWki9ZKLVHKiqArRcuEO5lvOy0TBbtEKfH6HYwcDdANpO/PF0FC4HP2 9WcWJo+AEy21Vur/xAWHZ5pA34ma6GL4/jl4ayWIZ554yS9Dcq3SWGqt5IdRzbQ7JO3+ e2cedFFaNUTOzYxv7uvnXfayyV6YZ2fIDkvtuQn//Z2vJxMY1c3OfSgibJ+wjFJ2nz+6 9GKWWqGAxCoWafERItL/wzFRtpJnCLY0a2OJQh5e97v/pmqv4dzC6PcMdblzCu3yqO0q H+RRfLucu2k9IhrV0t/Kvy/z7cpAEfgELPp7F1lAu8gnfNpHefnR2weki8ArVB6mNtdN /KJQ== X-Forwarded-Encrypted: i=1; AL+hErGWEaHBGiWn8Au0YUyOfrGU6Chj/IPmSFMuQ8lXJAeFJBMY5VPKmwy84DkoEVx9eX1VM90IJdHXfDkiArk=@vger.kernel.org X-Gm-Message-State: APuU4Z9vMDCyzOgjHcKG9FeJaB4xYFHhZV0Eou1YWJi/qTjASA7f5MKZ cHqnBAodB/SaomMWF8+7l0438NuOx3cdgemmqS3tLpolVjJywDsjILzw X-Gm-Gg: AZFdTZeeOHema/VdVNq3j9OVG2LQ316HbbQqraj9gK0y+U4LtxYfvQt67suJg7BKwip PH3MW/pFqryXiHQoxkj++4ZiA7+GandusoI6PAwxeT1VbcjEaDVTEKd4kAtM3DrYucI9Ea28xQo xS2ieDywlnqmArgNrX9KEemz/tucS48TL77cXHeWxbApABKMrIyAJ2gBIgddEUXVIRmJ8/wQ5K0 FjYGEXhAvgZgk3svyeqbUtshVmh1mIQGhukXCToMHLkTlZ1ljH087SyNqBT+LRAu+q7U9inOBXr 1JRnCNU55t7jUALThNhzLacldDlgqDk7mHYehNFl1/YpepSqNk3h2HkF/fpy0HBOGBodzVlJ/m9 HfXYrdhDLe46wnzC5cwg9SLyzAAVwfpH7ZrqnTtYTb+gKzAE8h6bQfFGn8IAKM67z4693M+6S2m 9lKgq4FMcPAiSpVNQUh+/NnvYUUhfdYi6mrRDZJMqrrrrYxk0XOI6WzJTadsLuD/fFF2X0UUU5t aQ1yQeoLzIgXtzi2hzQD3/cQbWdrX55WU0QK2i1J6wnYKxm0k4BJRFRj2bdLsG7zj2YFDBo1Ir8 UYco5pFu4Uoxvd4gG+dgXKgogw6eXLYiUGoVZgMwPzLlbfSo5z4wGjZmkX1f/erX+k4= X-Received: by 2002:a05:701b:42c9:20b0:191:a5b2:ef4a with SMTP id a92af1059eb24-1b5d7239171mr4097117c88.28.1796452651394; Fri, 04 Dec 2026 22:37:31 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b5d642f101sm13633752c88.5.2026.12.04.22.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 22:37:30 -0800 (PST) From: Praneeth Balasubramanian To: Vineet Gupta Cc: Praneeth Balasubramanian , stable@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] ARC: unwind: Serialize module unwind table updates Date: Fri, 4 Dec 2026 22:37:20 -0800 Message-Id: <20261205063720.2523881-1-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 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-Transfer-Encoding: 8bit unwind_add_table() and unwind_remove_table() say they must be called with module_mutex held. Since commit 75676500f8298 ("module: make locking more fine-grained."), the module loader calls module_finalize() and module_arch_cleanup() without it. So the updates of root_table.link and last_table are not serialized. Two module loads at the same time can link their tables to the same last table, so one table drops out of the list while last_table may still point to it. When that module is removed, its table is freed, and the next load writes through last_table into freed memory. Concurrent removals can likewise unlink a table through one that another removal has freed. Serialize the list updates and the frees with a private mutex. Both callers run in process context. This was found by an LLM-based audit that checks code against the rules stated in kernel comments. Fixes: 75676500f829 ("module: make locking more fine-grained.") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by an LLM-based audit, part of research at UCSB SecLab. An LLM turned a kernel comment into a rule, and three LLM votes checked the code against it. The fix and changelog were drafted with GLM-5.3, then checked against the source and partly rewritten with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (arc haps_hs_smp_defconfig, GCC 14.2). checkpatch.pl is clean. Not runtime- tested, and there is no reproducer. I do not have this hardware. arch/arc/kernel/unwind.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/arc/kernel/unwind.c b/arch/arc/kernel/unwind.c index 6fdc751f906e..f2aff90fb811 100644 --- a/arch/arc/kernel/unwind.c +++ b/arch/arc/kernel/unwind.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -354,8 +355,8 @@ static void *unw_hdr_alloc(unsigned long sz) } static struct unwind_table *last_table; +static DEFINE_MUTEX(unwind_mutex); -/* Must be called with module_mutex held. */ void *unwind_add_table(struct module *module, const void *table_start, unsigned long table_size) { @@ -382,11 +383,13 @@ void *unwind_add_table(struct module *module, const void *table_start, unw_debug("Table added for [%s] %lx %lx\n", module->name, table->core.pc, table->core.range); #endif + mutex_lock(&unwind_mutex); if (last_table) last_table->link = table; else root_table.link = table; last_table = table; + mutex_unlock(&unwind_mutex); return table; } @@ -421,7 +424,6 @@ static int unlink_table(void *arg) return 0; } -/* Must be called with module_mutex held. */ void unwind_remove_table(void *handle, int init_only) { struct unwind_table *table = handle; @@ -430,18 +432,21 @@ void unwind_remove_table(void *handle, int init_only) if (!table || table == &root_table) return; + mutex_lock(&unwind_mutex); if (init_only && table == last_table) { table->init.pc = 0; table->init.range = 0; + mutex_unlock(&unwind_mutex); return; } info.table = table; info.init_only = init_only; - unlink_table(&info); /* XXX: SMP */ + unlink_table(&info); kfree(table->header); kfree(table); + mutex_unlock(&unwind_mutex); } #endif /* CONFIG_MODULES */ base-commit: 29beb21c21ada7207692b2d69fc58dcd15dab6e9 -- 2.25.1