Linux-NFS Archive on
 help / color / Atom feed
From: Al Viro <>
To: Christoph Hellwig <>
Cc: Andrew Morton <>,
	Sami Tolvanen <>,
	Kees Cook <>,
	Nick Desaulniers <>,,,,
Subject: Re: [PATCH 3/4] jffs2: pass the correct prototype to read_cache_page
Date: Tue, 18 Jun 2019 21:27:21 +0100
Message-ID: <> (raw)
In-Reply-To: <>

On Mon, May 20, 2019 at 07:57:30AM +0200, Christoph Hellwig wrote:
> Fix the callback jffs2 passes to read_cache_page to actually have the
> proper type expected.  Casting around function pointers can easily
> hide typing bugs, and defeats control flow protection.

FWIW, this
unsigned char *jffs2_gc_fetch_page(struct jffs2_sb_info *c,
                                   struct jffs2_inode_info *f,
                                   unsigned long offset,
                                   unsigned long *priv)
        struct inode *inode = OFNI_EDONI_2SFFJ(f);
        struct page *pg;

        pg = read_cache_page(inode->i_mapping, offset >> PAGE_SHIFT,
                             (void *)jffs2_do_readpage_unlock, inode);
        if (IS_ERR(pg))
                return (void *)pg;

        *priv = (unsigned long)pg;
        return kmap(pg);
looks like crap.  And so does this:
void jffs2_gc_release_page(struct jffs2_sb_info *c,
                           unsigned char *ptr,
                           unsigned long *priv)
        struct page *pg = (void *)*priv;


	First of all, there's only one caller for each of those, and both
are direct calls.  So passing struct page * around that way is ridiculous.
What's more, there is no reason not to do kmap() in caller (i.e. in
jffs2_garbage_collect_dnode()).  That way jffs2_gc_fetch_page() would
simply be return read_cache_page(....), and in the caller we'd have

        struct page *pg;
        unsigned char *pg_ptr;
        pg = jffs2_gc_fetch_page(c, f, start);
        if (IS_ERR(pg)) {
                pr_warn("read_cache_page() returned error: %ld\n", PTR_ERR(pg));
                return PTR_ERR(pg);
	pg_ptr = kmap(pg);

and that's it, preserving the current locking and with saner types...

  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20  5:57 fix filler_t callback type mismatches v2 Christoph Hellwig
2019-05-20  5:57 ` [PATCH 1/4] mm: fix an overly long line in read_cache_page Christoph Hellwig
2019-05-20  5:57 ` [PATCH 2/4] mm: don't cast ->readpage to filler_t for do_read_cache_page Christoph Hellwig
2019-05-20  5:57 ` [PATCH 3/4] jffs2: pass the correct prototype to read_cache_page Christoph Hellwig
2019-06-18 20:27   ` Al Viro [this message]
2019-05-20  5:57 ` [PATCH 4/4] 9p: " Christoph Hellwig

Reply instructions:

You may reply publically 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:

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

  git send-email \ \ \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-NFS Archive on

Archives are clonable:
	git clone --mirror linux-nfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-nfs linux-nfs/ \
	public-inbox-index linux-nfs

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone public-inbox