All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] fprobe: Add exit_handler support
@ 2022-03-22  6:46 Dan Carpenter
  2022-03-22  7:08 ` Masami Hiramatsu
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-03-22  6:46 UTC (permalink / raw)
  To: mhiramat; +Cc: kernel-janitors

Hello Masami Hiramatsu,

The patch 5b0ab78998e3: "fprobe: Add exit_handler support" from Mar
15, 2022, leads to the following Smatch static checker warning:

	kernel/trace/fprobe.c:155 fprobe_init_rethook()
	warn: struct type mismatch 'rethook_node vs fprobe_rethook_node'

kernel/trace/fprobe.c
    134 static int fprobe_init_rethook(struct fprobe *fp, int num)
    135 {
    136         int i, size;
    137 
    138         if (num < 0)
    139                 return -EINVAL;
    140 
    141         if (!fp->exit_handler) {
    142                 fp->rethook = NULL;
    143                 return 0;
    144         }
    145 
    146         /* Initialize rethook if needed */
    147         size = num * num_possible_cpus() * 2;
    148         if (size < 0)
    149                 return -E2BIG;
    150 
    151         fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler);
    152         for (i = 0; i < size; i++) {
    153                 struct rethook_node *node;
    154 
--> 155                 node = kzalloc(sizeof(struct fprobe_rethook_node), GFP_KERNEL);

It's hard to tell if we're deliberately allocating a larger struct or
whether it's accidental.

    156                 if (!node) {
    157                         rethook_free(fp->rethook);
    158                         fp->rethook = NULL;
    159                         return -ENOMEM;
    160                 }
    161                 rethook_add_node(fp->rethook, node);
    162         }
    163         return 0;
    164 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] fprobe: Add exit_handler support
  2022-03-22  6:46 [bug report] fprobe: Add exit_handler support Dan Carpenter
@ 2022-03-22  7:08 ` Masami Hiramatsu
  0 siblings, 0 replies; 2+ messages in thread
From: Masami Hiramatsu @ 2022-03-22  7:08 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: kernel-janitors

Hi,

On Tue, 22 Mar 2022 09:46:20 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> Hello Masami Hiramatsu,
> 
> The patch 5b0ab78998e3: "fprobe: Add exit_handler support" from Mar
> 15, 2022, leads to the following Smatch static checker warning:
> 
> 	kernel/trace/fprobe.c:155 fprobe_init_rethook()
> 	warn: struct type mismatch 'rethook_node vs fprobe_rethook_node'
> 
> kernel/trace/fprobe.c
>     134 static int fprobe_init_rethook(struct fprobe *fp, int num)
>     135 {
>     136         int i, size;
>     137 
>     138         if (num < 0)
>     139                 return -EINVAL;
>     140 
>     141         if (!fp->exit_handler) {
>     142                 fp->rethook = NULL;
>     143                 return 0;
>     144         }
>     145 
>     146         /* Initialize rethook if needed */
>     147         size = num * num_possible_cpus() * 2;
>     148         if (size < 0)
>     149                 return -E2BIG;
>     150 
>     151         fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler);
>     152         for (i = 0; i < size; i++) {
>     153                 struct rethook_node *node;
>     154 
> --> 155                 node = kzalloc(sizeof(struct fprobe_rethook_node), GFP_KERNEL);
> 
> It's hard to tell if we're deliberately allocating a larger struct or
> whether it's accidental.

Good catch! This does not cause any error, but it should be;

struct fprobe_rethook_node *node;

node = kzalloc(sizeof(*node), GFP_KERNEL);
...
rethook_add_node(fp->rethook, &node->node);

Thank you!

> 
>     156                 if (!node) {
>     157                         rethook_free(fp->rethook);
>     158                         fp->rethook = NULL;
>     159                         return -ENOMEM;
>     160                 }
>     161                 rethook_add_node(fp->rethook, node);
>     162         }
>     163         return 0;
>     164 }
> 
> regards,
> dan carpenter


-- 
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-22  7:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-22  6:46 [bug report] fprobe: Add exit_handler support Dan Carpenter
2022-03-22  7:08 ` Masami Hiramatsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.