From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94DDD3C5552 for ; Tue, 17 Mar 2026 12:51:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773751865; cv=none; b=pGIZ7zzGuuKPaGsLvr0T5cIWSe/QF2airErdRI3orTRe8pm+SpfQNWEzd3lKJ1L5EVH9tX2auD2Fv9v4gc3dkB52KoW2erHY2ccfVrH/C4pvduTds1XGATOo6XXDT2a09y7OkdYK02UHxjQ8HLvqBwZEznT+rT1DuMOseRKtO2Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773751865; c=relaxed/simple; bh=9x4rSJQhtKV4SnOioksCqGOgd6yo22HmDkvguE0dioE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TfuKdroDJAHvRoEU73kfgXXxpObNyr6SfWVyPkFwNYZroffxrigh7DQ5j2DLgmpCFULZu+nSZUcTc4qYybX0RtqohTqXOSVDzxZUI3asiJthWTT9X7iZoYNKWITh+qwSfGG0UUtILlb6obj15c19hEhe5Bd7Zm0mbir252kG2BM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=ZwDWtvNn; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="ZwDWtvNn" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-482f454be5bso7570005e9.0 for ; Tue, 17 Mar 2026 05:51:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1773751861; x=1774356661; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=z9FF3jptzwdTviK++wQdCMhUD9QB9yKDmCDYs1F27lA=; b=ZwDWtvNn7cEEFWUmjhJPSKp/7PwWA/UpqoKksqEcLxVkRQhF3fUOKxNHCGI91TWuBU rcTo0m40iwDc1Dbh1AZkafj6St6fFrjqAA5wJXM/u9ZNvgw2u7x66JG6JZAHz9oly75W FSYXKGw1fVvscn6GPGiz+r7yWNxTZ8/1E7Cf8kQXQaEFP9Na0xN5FE5cQWwHLWrRaAeA Jf0/seGTY38yD0U9Cj++TIlUm6nBNAwvwmEgn9BZ5fhXM1tOr8DpJeipGI5MDuPw1KXA NGFJ60JGvRaqdzxsriCsOJ2Ep84yRG/pFXHgAAMXS8LmR/rmFgFjrwL7fc9ebMSuK9SE AuSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773751861; x=1774356661; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=z9FF3jptzwdTviK++wQdCMhUD9QB9yKDmCDYs1F27lA=; b=LaOS5ATx9eOVT/GFVvDD5wfJm+RB3ss28aioHhK62qbgGwFE7xj0ShGENF+lEpi42Q 1bZzDEYp35ZTgzXsjRep8xNfJ7f/EYo63xeq7FqMplDgQk5k4g3Fa42oiAkdLYwnSDyS Ve7iZJqvof+py1ff5drJ7NKDZIowmI5rSVXE9V8XE4z8Qa04WOpJYVWc04vGL7WTYnZw JqhPatUuAJO1D3ATiVm13iOzEST9vFuk2Stc1O9VmiPGD6cmqrZ7OzKXVZcKxXcMFW9U WorfY5ErqukKMggcatpnq41UByCyd9he9JHC2E0bNrs9inuQWpg7s3AqF7L0QXzRvnPw BduA== X-Forwarded-Encrypted: i=1; AJvYcCUF3/Z7UHFywDKfhAMTjjXoHREQdbKxn/MsBLsIAa+Unfwp5y9ss1KJr6r6TNk3LOLHv4hNK848rqwPhI0=@vger.kernel.org X-Gm-Message-State: AOJu0YywIatugOF+qonfsL8NdZaXqCBwJb99muaMZNTUeMoNNBo69Mo2 PIObtURD9KRLAWAqhPhsMCGVZNPYYV+d8t3Yn+KlE4iccMPt5e180KxSsuPfD4VFK8M= X-Gm-Gg: ATEYQzxEwLoEFVXDhobpPDQ6LsI1F5oXrl0/kvYwW/l5L9SysAuolM/CphyirPlqRtf JJmK8WDAkg4rpDUvA+psE1mr4YI4Age8kGOx/fcYiHJTce08Pmb46pCOu1VvRTbLsQW1Zzb3EhV GIb/X4nCdjz7h3pB8/xdFXffIqSGqrX2sP88piUuUmXNCAVl3HFLqQ++hluVmDswcg7SQwpJnNl XNzJuo6MvgySVdemeGXOxEAAjdnRT+Cj8QSLsfFFO73V/d5vye5ZLDoPBM7+XbCpkgy+ziQWTCq SEEGI0RjleXerJe/I7FcT46JYsJm/Epx0RImcW1blau4ve/8RwsPvIhUiM3Huh2+CvDiNn6ZAuC S4D4MZtOSrkgb+1zk6GpCP1zBxK0kZduZb5qOIch7RCHk1lfRrDB0DtNir6GuNC38TX1DSfcGfb omvazZnxwJcRVZAprEEsXdL1m+Z1IqXfRd4ZrI1bWVAhAHBCRxK6DYzmg= X-Received: by 2002:a05:600c:8488:b0:479:13e9:3d64 with SMTP id 5b1f17b1804b1-4856eadba01mr53496405e9.15.1773751860635; Tue, 17 Mar 2026 05:51:00 -0700 (PDT) Received: from [10.100.51.209] (nat2.prg.suse.com. [195.250.132.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48634a7ac2csm32740025e9.1.2026.03.17.05.50.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Mar 2026 05:51:00 -0700 (PDT) Message-ID: Date: Tue, 17 Mar 2026 13:50:59 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] module: remove MODULE_VERSION() To: Greg Kroah-Hartman Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Chamberlain , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Shyam Saini , Kees Cook , Thorsten Blum , Christoph Hellwig References: <2026031341-evolve-repeater-987b@gregkh> <2026031630-linseed-powdered-a0d1@gregkh> Content-Language: en-US From: Petr Pavlu In-Reply-To: <2026031630-linseed-powdered-a0d1@gregkh> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/16/26 11:03 AM, Greg Kroah-Hartman wrote: > On Mon, Mar 16, 2026 at 10:37:38AM +0100, Petr Pavlu wrote: >> On 3/13/26 3:20 PM, Greg Kroah-Hartman wrote: >>> Module "versions" do not make sense as the kernel is built all at once, >>> the "version" is the overall kernel version number, so modules can not >>> really be described as having a unique version given that they rely on >>> the infrastructure of the whole kernel. >>> >>> For now, just make this an "empty" define, to keep existing code >>> building properly as the tree is slowly purged of the use of this over >>> time. >>> >>> This macro will be removed entirely in the future when there are no >>> in-tree users. >> >> I share a similar sentiment that module versions set by MODULE_VERSION() >> are not particularly useful for in-tree modules and the macro is often >> used unnecessarily. However, I don't think this patch takes the best >> approach to phase it out. >> >> The file Documentation/ABI/stable/sysfs-module documents >> /sys/module//version as a stable ABI. Searching for >> '^MODULE_VERSION' in v7.0-rc4 shows 600 uses of the macro. My concern is >> that if any of these modules has a userspace part that checks the >> version, this patch could potentially break users' systems. > > sysfs use is ALWAYS "if the file is not there, the userspace tool should > keep working". How would userspace every do something different if a > module version flag is not there, that is not how a kernel driver should > ever be attempting to communicate with userspace as to what the api is, > or is not. > > And as the module version does not even work for any stable kernel > release, it's kind of proof that userspace does not rely on this. Makes sense. I have now also reviewed updates of MODULE_VERSION() invocations going back 5 years and my impression is that removing this macro should be generally safe. New instances of MODULE_VERSION() are typically introduced when a new driver is added to the codebase. There were numerous commits where MODULE_VERSION() is removed with the argument that it is unnecessary for in-tree modules and that the main kernel version should be used instead. This suggest that there is already a broader consensus that module versions are not particularly useful, at least not for in-tree modules. There was a limited number of cases where a per-module version is actually updated. Examples: ea7af9454815 ("platform/x86: dell_rbu: Bump version") 93d09773d1a5 ("xz: add RISC-V BCJ filter") 98d5b61ef5fa ("coda: bump module version to 7.2") 8cb5d216ab33 ("char: xillybus: Move class-related functions to new xillybus_class.c") 74f46a0524f8 ("scsi: fnic: Turn off FDMI ACTIVE flags on link down") 6cd379f75f42 ("ata: pata_hpt3x2n: pass base DPLL frequency to hpt3x2n_pci_clock()") 47adef20e67d ("pata: ixp4xx: Rewrite to use device tree") (The last three commits are indirect updates, where the module contains MODULE_VERSION(DRV_VERSION); and DRV_VERSION is updated.) Most of these version bumps do not seem particularly noteworthy. Only commit 98d5b61ef5fa appears somewhat interesting with the description: coda: bump module version to 7.2 Helps with tracking which patches have been propagated upstream and if users are running the latest known version. > >> I believe it would be safer to start by removing individual uses of >> MODULE_VERSION(). That way, we can also learn if we're missing any use >> cases for having module versions. > > Sure, I'll make up a patch to drop all 700 uses, but how is that much > different? :) The end result is ultimately the same. The kernel will no longer have any uses of MODULE_VERSION() or its implementation. The difference is that by removing the uses of MODULE_VERSION() first, the maintainers of the relevant code will be properly informed about this change, rather than being told afterwards, when they will no longer have a chance to provide any feedback. Another aspect is that MODULE_VERSION() still appears useful for external modules. Sure, we won't keep this macro if all uses in the kernel are removed and these external modules will need to replace it with a different mechanism. However, changing MODULE_VERSION() now to only a dummy implementation can silently break version tracking for these modules, which is not ideal. If I end up being the only one who prefers removing the invocations of this macro first, then please at least CC a few more lists on v2 of the patch, such as driver-core and netdev, as well as the authors of the recent version-bump commits that I identified above. > >> The original patch "Add a MODULE_VERSION macro" [1] from 2004 doesn't >> say much about the motivation for adding module versions, but it does >> mention that they should be accessible via sysfs. > > That was because we were just exporting all of the module information in > sysfs, not due to us attempting to do anything special with that info in > userspace other than "hey we have an attribute, let's export it!" > >> That was implemented >> a year later in commit c988d2b28454 ("[PATCH] modules: add version and >> srcversion to sysfs") [2], which primarily discusses use cases related >> to DKMS, and to administrators + tech support needing to know what is >> actually loaded on the system. For the latter, I believe srcversion (or >> something similar) should be sufficient. > > And does dkms actually do anything with this sysfs value? At quick > glance, I couldn't see anything. I'm not familiar with DKMS. From a quick look, it parses both the version and srcversion, although it calls modinfo and doesn't read the values from sysfs. See get_module_verinfo() and compare_module_version() in dkms.in [1]. [1] https://github.com/dkms-project/dkms/blob/2c35ae1d32eb6377ef8e8dd7e15427d56b63828d/dkms.in#L983 -- Thanks, Petr