All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Mike Snitzer <snitzer@redhat.com>,
	Jilin Yuan <yuanjilin@cdjrlc.com>,
	Nikos Tsironis <ntsironis@arrikto.com>,
	Shaomin Deng <dengshaomin@cdjrlc.com>,
	Mike Snitzer <snitzer@kernel.org>,
	Nathan Huckleberry <nhuck@google.com>,
	linux-block@vger.kernel.org, dm-devel@redhat.com,
	Genjian Zhang <zhanggenjian@kylinos.cn>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Milan Broz <gmazyland@gmail.com>,
	Alasdair G Kergon <agk@redhat.com>,
	Jiangshan Yi <yijiangshan@kylinos.cn>
Subject: Re: [dm-devel] [git pull] device mapper changes for 6.1
Date: Thu, 20 Oct 2022 07:44:14 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LRH.2.21.2210200731150.25125@file01.intranet.prod.int.rdu2.redhat.com> (raw)
In-Reply-To: <Y1EDxZvjEi47iWUN@infradead.org>



On Thu, 20 Oct 2022, Christoph Hellwig wrote:

> On Tue, Oct 18, 2022 at 02:48:01PM -0400, Mike Snitzer wrote:
> > > That really does not sound like a good idea at all.  And it does not
> > > seem to have any MM or core maintainer signoffs.
> > 
> > Sorry, I should've solicited proper review more loudly.
> > 
> > But if you have a specific concern with how DM is looking to use
> > is_vmalloc_or_module_addr() please say what that is.
> 
> If I understand the patch correct it tries to use it to detect if
> a string is a string global.  Besides being nasty API abuse I can't
> see how this would even work if DM is built in.

It works for built-in DM.

You have "kfree_const" that detects if the string points to to .rodata 
with "is_kernel_rodata". Unfortunatelly, is_kernel_rodata doesn't detect 
if the string points to some modules's rodata, so we need an extra check 
for that.

So, the logic is:
if (!is_vmalloc_or_module_addr(ptr) && !is_kernel_rodata(ptr)) kfree(ptr);

I thought about modifying is_kernel_rodata to detect module's rodata as 
well, but it wouldn't work because kstrdup_const uses it and there would 
be crash possibility:
ptr = kstrdup_const(modules_rodata); unload_module(); use "ptr";

Mikulas


WARNING: multiple messages have this Message-ID (diff)
From: Mikulas Patocka <mpatocka@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Shaomin Deng <dengshaomin@cdjrlc.com>,
	Nikos Tsironis <ntsironis@arrikto.com>,
	Mike Snitzer <snitzer@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	Nathan Huckleberry <nhuck@google.com>,
	linux-block@vger.kernel.org, dm-devel@redhat.com,
	Genjian Zhang <zhanggenjian@kylinos.cn>,
	Jilin Yuan <yuanjilin@cdjrlc.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Milan Broz <gmazyland@gmail.com>,
	Alasdair G Kergon <agk@redhat.com>,
	Jiangshan Yi <yijiangshan@kylinos.cn>
Subject: Re: [dm-devel] [git pull] device mapper changes for 6.1
Date: Thu, 20 Oct 2022 07:44:14 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LRH.2.21.2210200731150.25125@file01.intranet.prod.int.rdu2.redhat.com> (raw)
In-Reply-To: <Y1EDxZvjEi47iWUN@infradead.org>



On Thu, 20 Oct 2022, Christoph Hellwig wrote:

> On Tue, Oct 18, 2022 at 02:48:01PM -0400, Mike Snitzer wrote:
> > > That really does not sound like a good idea at all.  And it does not
> > > seem to have any MM or core maintainer signoffs.
> > 
> > Sorry, I should've solicited proper review more loudly.
> > 
> > But if you have a specific concern with how DM is looking to use
> > is_vmalloc_or_module_addr() please say what that is.
> 
> If I understand the patch correct it tries to use it to detect if
> a string is a string global.  Besides being nasty API abuse I can't
> see how this would even work if DM is built in.

It works for built-in DM.

You have "kfree_const" that detects if the string points to to .rodata 
with "is_kernel_rodata". Unfortunatelly, is_kernel_rodata doesn't detect 
if the string points to some modules's rodata, so we need an extra check 
for that.

So, the logic is:
if (!is_vmalloc_or_module_addr(ptr) && !is_kernel_rodata(ptr)) kfree(ptr);

I thought about modifying is_kernel_rodata to detect module's rodata as 
well, but it wouldn't work because kstrdup_const uses it and there would 
be crash possibility:
ptr = kstrdup_const(modules_rodata); unload_module(); use "ptr";

Mikulas
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  reply	other threads:[~2022-10-20 11:44 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18 16:20 [git pull] device mapper changes for 6.1 Mike Snitzer
2022-10-18 16:20 ` [dm-devel] " Mike Snitzer
2022-10-18 18:17 ` Christoph Hellwig
2022-10-18 18:17   ` [dm-devel] " Christoph Hellwig
2022-10-18 18:48   ` Mike Snitzer
2022-10-18 18:48     ` [dm-devel] " Mike Snitzer
2022-10-20  8:16     ` Christoph Hellwig
2022-10-20  8:16       ` Christoph Hellwig
2022-10-20 11:44       ` Mikulas Patocka [this message]
2022-10-20 11:44         ` Mikulas Patocka
2022-10-18 18:54   ` Linus Torvalds
2022-10-18 18:54     ` [dm-devel] " Linus Torvalds
2022-10-18 19:19     ` Linus Torvalds
2022-10-18 19:19       ` [dm-devel] " Linus Torvalds
2022-10-18 21:13       ` Mike Snitzer
2022-10-18 21:13         ` [dm-devel] " Mike Snitzer
2022-10-18 22:11         ` Milan Broz
2022-10-18 22:11           ` [dm-devel] " Milan Broz
2022-10-18 22:18           ` Linus Torvalds
2022-10-18 22:18             ` [dm-devel] " Linus Torvalds
2022-10-18 20:28     ` Mikulas Patocka
2022-10-18 20:28       ` [dm-devel] " Mikulas Patocka
2022-10-18 22:17       ` Linus Torvalds
2022-10-18 22:17         ` [dm-devel] " Linus Torvalds
2022-10-19  6:18     ` Jason A. Donenfeld
2022-10-19  6:18       ` [dm-devel] " Jason A. Donenfeld
2022-10-20  8:17     ` Christoph Hellwig
2022-10-20  8:17       ` Christoph Hellwig

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=alpine.LRH.2.21.2210200731150.25125@file01.intranet.prod.int.rdu2.redhat.com \
    --to=mpatocka@redhat.com \
    --cc=agk@redhat.com \
    --cc=dengshaomin@cdjrlc.com \
    --cc=dm-devel@redhat.com \
    --cc=gmazyland@gmail.com \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=nhuck@google.com \
    --cc=ntsironis@arrikto.com \
    --cc=snitzer@kernel.org \
    --cc=snitzer@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=yijiangshan@kylinos.cn \
    --cc=yuanjilin@cdjrlc.com \
    --cc=zhanggenjian@kylinos.cn \
    /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 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.