From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796452652; b=vvuYnFwd0yCxeDdCoPB0UW0sr9hHk/0HUVCXVD8dqbJzEEHOthFYhYqeaUUt26nQ9lOh eA+VxLcuudwInBnbOrPPKP5TnWEuefyEn9Wd30Hnae48BMP83PUB59sWte9lbyEuZTPvF xgw3GOsVV3k1UxglLPbve4z0Ll0UiUTnDxHSNcKKdy4i8gudM2vEeFSOKC9oT3s+xliqb M8quIRRS90oyuNb0935yjm0e/M0wZxsteLO8MmpfGAQKxV2xRmJNn0hSyxcFiv0KrgldK Ou0bDqTT/uYbItg5YsGEBINtWZO5dU+nncKNcCUi4yBsMFbmiZ6Y9heCnDwuAMf0V8Q== 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=DvUJZSy2T4xlRl1pBAPAZeQYq8I8DNdEcpgpwH1QAOqFP92usIMtJnZxv2lfCF6kDtv1 nlZ76V0Kv1OkVUShy1LMbFZXi8/ZxuepAi3wgFMrrF7K8HjbpZzbK708YUsNcfQLcEXRl Oc2W/amRVKEzdGdcJlPqaByyWSTDuRqFOS81mnseoe2r2nLA96ldP0huVyJTXGGiNDFnh e1R5DfVr8UZ2mi9lpgCFwdm2pjOCvc/YAjL4djp9Q1rZ1NZ0YAsNIGSD4AAsKLZlVIM9L JhVQobVyOSZzP75i1kU5eKaCf+NhI8ImZ7HWyMaH2H54PRsqEavGs2ilJrVIkZOOQYw== 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.51 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (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 429CF606A322 for ; Sat, 5 Dec 2026 06:37:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 429CF606A322 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-f51.google.com with SMTP id a92af1059eb24-1b5d5f9938cso1933342c88.1 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=WfijYHweieXHEg51xF8p+wfiNcI7ZGuqO4JBRNWQOhDt6C3GaNrCiVujozlLePaKVE X9qKtnyOBQqIBrKYXM7yIgbwoNzSYog1rRao9Rxxew21VfwFGniCtas2GAeT4m6kLM2t tU1QFmibY+tZ0r4abFQVWceE3tTBw2sBEAKx48hS9lOAuSu1i7gNao9wHvWnIEPq5j19 EBUFixXm3sQkG5IIltp5nr7YcHI0TnCrH1sN/QxRIcB83Q/iHWVmQyBsDGaAgkU3P1ZN S11J/b43tRD+hHZzsOGWqh9Nn0+6KHAMpdw1wwWhAYGpmgVNzpJA9CR7PS9Yf0QFnp6o Fn/w== X-Forwarded-Encrypted: i=1; AL+hErHuSJavZq8rWCwpgNjZdNu5adZFPf5ipxyVQZJQRge0X2ZHZC8nXeUMfnZHaezD5DXVa8t1d0U=@vger.kernel.org X-Gm-Message-State: APuU4Z9KxB1zMJ6FxcMGeCb+3LaWF9ro/Cxj0xlDSDgkD3uB6Oe68O6O /+hKZ5TYOuDKHyq0o2N0uwqma7RQH2WXIPDdj5cTcJxXh7GuWwMrRjSn X-Gm-Gg: AZFdTZcJM1Oi0GXUihw8UwnM5TV9rYRyuioxrNOoX0L5yEveopb45sBO+QJoADFPoWT ocn5k/kMF8cvChEsd+54pUQIrUsMGXsDBqqNqDe9QQZ+HmnvdnMK9se/JXt1Yu6lNd4COW8uTf8 lZfDegIXUPXZ5pTZf6rhd8orItSD0BP1L4slofytboUMe2Id31U/1A8rF4X5XNENhRsAXkrO2BW KKfNhpr54pzLu8XLWlxOChzfPJCphn69Q92jXu5Q39NZjC+lFsECQepd7wRouB+6smoq+0J8KjH q3UifLUPHc/BN/q0F+6IC6WlQM8v496Z/LWabrvalW3V3Axw7qOqzrJdYSPaLh5bvEHC6691u9A EayBpsIB9jS+yWt7SCaD4Uvrn8ombgwxmTWb6uuSCEaRwCUVo1IFH9PatjHnue9FlXOVOfmTBtv ciLGhsMVSAFogYjVeZWaWHopaaQCSeIIYia1D2iY9CKjKiicqsiTnJStl1PgmcD6vRnSiU8mHfI s+eiW3XUPRy37q0pCLxsruupWsX7CIxoQwUi82wTJ6G9dOJAEs04z7sfc4ZNXIMDqwxcjsgzWk9 8Y/9tqN0Mk84EwGlu7UEHaOsJ7nw4FZasKslDgxJQqzHih2SsCy1haOxPHa4P38IcHA= 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: stable@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