Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp175493lqn; Thu, 11 Apr 2024 19:04:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVY32M4QaC/wEgoydl+EvPFamD/iH+ooOpZh9UTuLn7vk4/w6CvH2rtUN/RmNTSsdhHqzblrAiV0sCL5igbuTsI792saqQXP9NKwzsEZg== X-Google-Smtp-Source: AGHT+IGjc1wEItdiHpM/giSoWU84II1FBD6MhXYVHtGofi0QzrTqBLlZ/QPNpbzHqiB7hEG2SclE X-Received: by 2002:a17:906:2c59:b0:a50:9190:b751 with SMTP id f25-20020a1709062c5900b00a509190b751mr822332ejh.10.1712887482348; Thu, 11 Apr 2024 19:04:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712887482; cv=pass; d=google.com; s=arc-20160816; b=BRxTeOfiYAO9V4Rr0jOJdbLM7ZVmmdXNbJKp9979r1HwNZEQLpOqsdVSQjaW+drGKC TdWjuvoXPkSTdkJQ4XhoO/Z8u1U96kktBaRH9oxs4AGfF5TZtRCBPk/t4ty6WaPwJidp n+42Ar4hEAi/o6UcW9TBliLBi0LngRhFePBB5weIHJtSMw8FmqcVbv1agCGBzSR0KX+J Dp77BVgmU/9AAURq9r8ymG1FPBVcQ10HzWjHSV+6SP/6ilsarSurXfjbyf28UqEkyRjl MI9J9rp/Q4hNeObN6rl+F9OCL2BwgjQey64uTFvkFwhwGrJcraAgAzN4rPHUvG20JNOK 4F/g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:subject:cc:to:from:date:dkim-signature; bh=DcuE7f9X1W1goW9Rw0CyhmG355kPpq2Gqbq8MdMXHsQ=; fh=sErTEhMmy5HHeficVZoLW1jj9A5Ugg/kFGo1M8kaAM0=; b=FLt4lyrv7aqSUEBZFcCKEVfqiFWQPseEX1xIvOj1xlT1xz2Vif13JE9mRNZlT7cRTH OFuzK0u6m6fdvEdY22994PmaDc52wSzghPbJmIw47QiNFzDHKNf7gjuuT5N+7W19+r9J 3n0xPHoCsUasO8TlrzYWVA5zOUeRY0fffHwBmZ2rLgnrf0dt2GzTWoerBN1Ypz+CUaFL ovdRKrItGhfoze7ImptkNrz/6Ul2vM6Ve56xPFxzPj30iWElJiJsv9KD5L2IRnn01xAT 07BEFupy2ep3iiRYBwGSuuJFM6mw+TKV9PR5hdBO+kmP+WIg3WW9g5XgmMWF+Z5sn4wI nXmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@canb.auug.org.au header.s=201702 header.b=EJQwDDOn; arc=pass (i=1 spf=pass spfdomain=canb.auug.org.au dkim=pass dkdomain=canb.auug.org.au dmarc=pass fromdomain=canb.auug.org.au); spf=pass (google.com: domain of linux-kernel+bounces-141799-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141799-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canb.auug.org.au Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kv23-20020a17090778d700b00a5197312ca1si1226237ejc.29.2024.04.11.19.04.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 19:04:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-141799-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@canb.auug.org.au header.s=201702 header.b=EJQwDDOn; arc=pass (i=1 spf=pass spfdomain=canb.auug.org.au dkim=pass dkdomain=canb.auug.org.au dmarc=pass fromdomain=canb.auug.org.au); spf=pass (google.com: domain of linux-kernel+bounces-141799-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-141799-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canb.auug.org.au Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DA0F61F22432 for ; Fri, 12 Apr 2024 02:04:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 57B90D53E; Fri, 12 Apr 2024 02:04:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canb.auug.org.au header.i=@canb.auug.org.au header.b="EJQwDDOn" Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B48738801; Fri, 12 Apr 2024 02:04:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=150.107.74.76 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712887471; cv=none; b=XnTBb6MxBX295Tt2zFw5f6AX25AKQ+l+7sOgf+ICCOfNtaPWOpFidw9oKf/tF2RL848DijuTuif+aW519EQk3QTSZEiLrdXHW7h8g1mME1N7ve9DXbPE2jSsseTUVe8EgC9CUJjI1AZ/kdL5vh3CLnv065Nl1mTVDL5itJRpdbo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712887471; c=relaxed/simple; bh=t9q+otk2Tc6NmYmjxqB1BgWWDc81IAO4Z0aG6aI6KQk=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type; b=kiMh4erJ2TPJ6S3pyKVf93Mb/k2Qgtkxlc/UWY4bthfhBbyOMswUHiJfgZ4fsnf7LfI83bxm5DgvgaY7wYHMUfyRRAdaaZKocdbiohgXLZ69ovFudSMGGW+XxX8yWLQ3ehGzFFCCyzWH9VSMujkapMek/iBaw5iatOmZ02nBTMI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canb.auug.org.au; spf=pass smtp.mailfrom=canb.auug.org.au; dkim=pass (2048-bit key) header.d=canb.auug.org.au header.i=@canb.auug.org.au header.b=EJQwDDOn; arc=none smtp.client-ip=150.107.74.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canb.auug.org.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canb.auug.org.au DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canb.auug.org.au; s=201702; t=1712887465; bh=DcuE7f9X1W1goW9Rw0CyhmG355kPpq2Gqbq8MdMXHsQ=; h=Date:From:To:Cc:Subject:From; b=EJQwDDOnAZZkWlKU+6Arj+Knp7t9fK9UCymNq/MT2dvBfs2T8aon9qUFF1+SBewY1 TrDJiV8LpBztvSgxVzEokRjGOW8QuMIw7Ph3Lb7SbB1nJ5OZP8tjKxla8ln1OMcNE6 BR+OK/x8cr4hKkc2O7VI1OEy2tOEaWmLAMF5r4U2GjOPuXKpFaOozisQxbNtPyz+oT pa8GkCo23I3GouQ4mJm568eeVZwVNz/KtGg05Y7WT2W7wGSyPky2XJ6UGcsVZLcb07 B24R2neuwvmdmkRQgmzfRolDX3b698y0fweU3ySaPNFy+ER5Dv6IWSAhr7M4Cq1hcy qb6TNYe3/PK4g== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4VG0HX6P8hz4wb2; Fri, 12 Apr 2024 12:04:24 +1000 (AEST) Date: Fri, 12 Apr 2024 12:04:21 +1000 From: Stephen Rothwell To: Luis Chamberlain , Andrew Morton Cc: Linux Kernel Mailing List , Linux Next Mailing List , "Mike Rapoport (IBM)" , Suren Baghdasaryan Subject: linux-next: manual merge of the modules tree with the mm tree Message-ID: <20240412120421.27d86c34@canb.auug.org.au> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/nVmWy2XDg2rYoS268/+W7Xr"; protocol="application/pgp-signature"; micalg=pgp-sha256 --Sig_/nVmWy2XDg2rYoS268/+W7Xr Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi all, Today's linux-next merge of the modules tree got a conflict in: kernel/module/main.c between commit: 58782d7a7ccd ("lib: prevent module unloading if memory is not freed") from the mm-unstable branch of the mm tree and commit: a4ee8c9b86bd ("module: make module_memory_{alloc,free} more self-containe= d") from the modules tree. I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts. --=20 Cheers, Stephen Rothwell diff --cc kernel/module/main.c index 2d25eebc549d,d56b7df0cbb6..000000000000 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@@ -56,8 -56,8 +56,9 @@@ #include #include #include +#include #include + #include #include #include "internal.h" =20 @@@ -1204,26 -1194,51 +1195,55 @@@ static bool mod_mem_use_vmalloc(enum mo mod_mem_type_is_core_data(type); } =20 - static void *module_memory_alloc(unsigned int size, enum mod_mem_type typ= e) + static int module_memory_alloc(struct module *mod, enum mod_mem_type type) { + unsigned int size =3D PAGE_ALIGN(mod->mem[type].size); + void *ptr; +=20 + mod->mem[type].size =3D size; +=20 if (mod_mem_use_vmalloc(type)) - return vzalloc(size); - return module_alloc(size); + ptr =3D vmalloc(size); + else + ptr =3D execmem_alloc(EXECMEM_MODULE_TEXT, size); +=20 + if (!ptr) + return -ENOMEM; +=20 + /* + * The pointer to these blocks of memory are stored on the module + * structure and we keep that around so long as the module is + * around. We only free that memory when we unload the module. + * Just mark them as not being a leak then. The .init* ELF + * sections *do* get freed after boot so we *could* treat them + * slightly differently with kmemleak_ignore() and only grey + * them out as they work as typical memory allocations which + * *do* eventually get freed, but let's just keep things simple + * and avoid *any* false positives. + */ + kmemleak_not_leak(ptr); +=20 + memset(ptr, 0, size); + mod->mem[type].base =3D ptr; +=20 + return 0; } =20 - static void module_memory_free(void *ptr, enum mod_mem_type type, -static void module_memory_free(struct module *mod, enum mod_mem_type type) ++static void module_memory_free(struct module *mod, enum mod_mem_type type, + bool unload_codetags) { + void *ptr =3D mod->mem[type].base; +=20 + if (!unload_codetags && mod_mem_type_is_core_data(type)) + return; + if (mod_mem_use_vmalloc(type)) vfree(ptr); else - module_memfree(ptr); + execmem_free(ptr); } =20 -static void free_mod_mem(struct module *mod) +static void free_mod_mem(struct module *mod, bool unload_codetags) { for_each_mod_mem_type(type) { struct module_memory *mod_mem =3D &mod->mem[type]; @@@ -1234,13 -1249,12 +1254,13 @@@ /* Free lock-classes; relies on the preceding sync_rcu(). */ lockdep_free_key_range(mod_mem->base, mod_mem->size); if (mod_mem->size) - module_memory_free(mod_mem->base, type, - module_memory_free(mod, type); ++ module_memory_free(mod, type, + unload_codetags); } =20 /* MOD_DATA hosts mod, so free it at last */ lockdep_free_key_range(mod->mem[MOD_DATA].base, mod->mem[MOD_DATA].size); - module_memory_free(mod->mem[MOD_DATA].base, MOD_DATA, unload_codetags); - module_memory_free(mod, MOD_DATA); ++ module_memory_free(mod, MOD_DATA, unload_codetags); } =20 /* Free a module, remove from lists, etc. */ @@@ -2309,7 -2301,7 +2314,7 @@@ static int move_module(struct module *m return 0; out_enomem: for (t--; t >=3D 0; t--) - module_memory_free(mod->mem[t].base, t, true); - module_memory_free(mod, t); ++ module_memory_free(mod, t, true); return ret; } =20 --Sig_/nVmWy2XDg2rYoS268/+W7Xr Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEENIC96giZ81tWdLgKAVBC80lX0GwFAmYYlqUACgkQAVBC80lX 0GxJqgf/YhyeAFTIWqGU0sA/nEexDdRUO7eO2SyZMYL2wq97P1eW1PoDfWq2OM+0 ESyjDL71qFdZNEyL49W2w5WQKfCBdxVaTUZo9x9Z+sSsF0frki7MUTyc5ggQP5yU 8Ya8Ww9ERg4jsQPqSYQliKRkwdR+ppjRAKKImxUp6/UVNd3qWLfmNspC+f3K+kmc xZHs8aEgV3TjWLicYG5hSH0dka3zBDyq8HUVO4SqKm5Pa5TTZHBSEMg+4CX4pyN0 7HtV5kO/14Rq1vK5DcmrQAXM/zrICesPF8TbF+mU8//nWxW96cSGR+uHaon4ictP HuZiOSvduv8/LO84DTrtuwlJ0G/L0g== =JSMi -----END PGP SIGNATURE----- --Sig_/nVmWy2XDg2rYoS268/+W7Xr--