linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Aaron Tomlin <atomlin@redhat.com>,
	"mcgrof@kernel.org" <mcgrof@kernel.org>
Cc: "linux-modules@vger.kernel.org" <linux-modules@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] module: Show the last unloaded module's taint flag(s)
Date: Tue, 28 Jun 2022 05:54:28 +0000	[thread overview]
Message-ID: <4ddb64da-58f0-a4af-cf57-a870015a0077@csgroup.eu> (raw)
In-Reply-To: <20220627164052.2416485-2-atomlin@redhat.com>



Le 27/06/2022 à 18:40, Aaron Tomlin a écrit :
> For diagnostic purposes, this patch, in addition to keeping a record/or
> track of the last known unloaded module, we now will include the
> module's taint flag(s) too e.g: " [last unloaded: fpga_mgr_mod(OE)]"
> 
> Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
> ---
>   kernel/module/main.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/module/main.c b/kernel/module/main.c
> index dcb83cf18d84..0ca6fd38b903 100644
> --- a/kernel/module/main.c
> +++ b/kernel/module/main.c
> @@ -524,7 +524,12 @@ static struct module_attribute modinfo_##field = {                    \
>   MODINFO_ATTR(version);
>   MODINFO_ATTR(srcversion);
>   
> -static char last_unloaded_module[MODULE_NAME_LEN+1];
> +/*
> + * Maximum number of characters written by module_flags()
> + * without a module's state information.
> + */
> +#define LAST_UNLOADED_MODULE_NAME_LEN (MODULE_NAME_LEN + MODULE_FLAGS_BUF_SIZE - 2 + 1)
> +static char last_unloaded_module[LAST_UNLOADED_MODULE_NAME_LEN];
>   
>   #ifdef CONFIG_MODULE_UNLOAD
>   
> @@ -694,6 +699,7 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
>   {
>   	struct module *mod;
>   	char name[MODULE_NAME_LEN];
> +	char buf[LAST_UNLOADED_MODULE_NAME_LEN];
>   	int ret, forced = 0;
>   
>   	if (!capable(CAP_SYS_MODULE) || modules_disabled)
> @@ -753,8 +759,8 @@ SYSCALL_DEFINE2(delete_module, const char __user *, name_user,
>   
>   	async_synchronize_full();
>   
> -	/* Store the name of the last unloaded module for diagnostic purposes */
>   	strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module));
> +	strcat(last_unloaded_module, module_flags(mod, buf, false));

You replace a bounded string copy by an unbounded strict contat.

Should you use strlcat() instead ?

>   
>   	free_module(mod);
>   	/* someone could wait for the module in add_unformed_module() */

  reply	other threads:[~2022-06-28  5:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-27 16:40 [PATCH 1/2] module: Modify module_flags() to accept show_state argument Aaron Tomlin
2022-06-27 16:40 ` [PATCH 2/2] module: Show the last unloaded module's taint flag(s) Aaron Tomlin
2022-06-28  5:54   ` Christophe Leroy [this message]
2022-06-28  7:47     ` Aaron Tomlin
2022-06-28  8:16       ` Christophe Leroy
2022-06-28  8:23         ` Aaron Tomlin
2022-07-03 14:22       ` Aaron Tomlin
2022-07-06 23:33         ` Luis Chamberlain
2022-07-06 23:37   ` Luis Chamberlain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ddb64da-58f0-a4af-cf57-a870015a0077@csgroup.eu \
    --to=christophe.leroy@csgroup.eu \
    --cc=atomlin@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).