linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: Ira Weiny <ira.weiny@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Peter Collingbourne <pcc@google.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] mm/highmem: VM_BUG_ON() if offset + len > PAGE_SIZE
Date: Mon, 25 Apr 2022 03:47:38 +0200	[thread overview]
Message-ID: <8929547.CDJkKcVGEf@leap> (raw)
In-Reply-To: <20220424104806.25396-1-fmdefrancesco@gmail.com>

On domenica 24 aprile 2022 12:48:06 CEST Fabio M. De Francesco wrote:
> Call VM_BUG_ON() if offset + len > PAGE_SIZE.
> 
> This is an RFC patch because I'm not sure if we actually need to 
BUG_ON(),

Actually I considered VM_BUG_ON() for consistency with the other functions 
in highmem.h

What about VM_WARN_ON_ONCE() here and also in memset_page?

Thanks,

Fabio

> so I'd like to know what Maintainers and other developers think about 
this
> proposal.
> 
> Please note that memset_page() uses VM_BUG_ON() to prevent the same 
issue.
> 
> Furthermore, I also cannot understand why memset_page() does not call
> flush_dcache_page() after memset() but I suppose that the different
> implementations of these two functions should be addressed in another 
RFC.
> 
> Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
> ---
>  include/linux/highmem.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/linux/highmem.h b/include/linux/highmem.h
> index c3d562b5f0c1..bdb16d5f8148 100644
> --- a/include/linux/highmem.h
> +++ b/include/linux/highmem.h
> @@ -349,6 +349,8 @@ static inline void memcpy_to_page(struct page *page, 
size_t offset,
>  static inline void memzero_page(struct page *page, size_t offset, size_t 
len)
>  {
>  	char *addr = kmap_local_page(page);
> +
> +	VM_BUG_ON(offset + len > PAGE_SIZE);
>  	memset(addr + offset, 0, len);
>  	flush_dcache_page(page);
>  	kunmap_local(addr);
> -- 
> 2.34.1
> 
> 





  reply	other threads:[~2022-04-25  1:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-24 10:48 [RFC PATCH] mm/highmem: VM_BUG_ON() if offset + len > PAGE_SIZE Fabio M. De Francesco
2022-04-25  1:47 ` Fabio M. De Francesco [this message]
2022-04-25 16:47   ` Ira Weiny
2022-04-25 20:05     ` Fabio M. De Francesco

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=8929547.CDJkKcVGEf@leap \
    --to=fmdefrancesco@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pcc@google.com \
    --cc=will@kernel.org \
    --cc=willy@infradead.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).