mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Chung-Yih Wang (王崇懿)" <cywang@google.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] crypto/scatterwalk.c to skip unnecessary flush_dcache_page()  calls which may cause kernel panic
Date: Fri, 20 Mar 2009 16:15:16 +0800	[thread overview]
Message-ID: <9c0b8b730903200115i7ae4512di97418958e05f6a0e@mail.gmail.com> (raw)

I am developing the ipsec tools on ARM platform. When I turn the
 CONFIG_DEBUG_VM on, the ipsec traffic triggers the kernel panic
which is caused by the VM_DEBUG_ON(PageSlab(page)) of
page_mapping() in the call of flush_dcache_page().

The root cause is that ipsec/esp intends to encrypt the original
data and dynamically allocate cache memory in socket buffer for
this purpose. However, all the cache memory pages dynamically
allocated in socket buffer will be flagged as PG_slab by
__SetPageSlab(). That's the reason it asserts on
VM_BUG_ON(PageSlab(page)) in flush_dcache_page(). Since the
flush_dcache_page() is to ensure the cache coherency between
kernel mapping and userspace mapping. The kernel cache memory
created in socket buffer for encrypting ipsec traffic does not
need to call this function at all since it is all kernel space
data.

Below is my patch for fixing this bug for  CONFIG_DEBUG_VM=y.

Chung-yih


diff --git a/crypto/scatterwalk.c b/crypto/scatterwalk.c
index 9aeeb52..3de89a4 100644
--- a/crypto/scatterwalk.c
+++ b/crypto/scatterwalk.c
@@ -54,7 +54,8 @@ static void scatterwalk_pagedone(struct scatter_walk
*walk, int out,
                struct page *page;

                page = sg_page(walk->sg) + ((walk->offset - 1) >> PAGE_SHIFT);
-               flush_dcache_page(page);
+               if (!PageSlab(page))
+                       flush_dcache_page(page);
        }

        if (more) {

             reply	other threads:[~2009-03-20  8:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-20  8:15 Chung-Yih Wang (王崇懿) [this message]
2009-03-20  8:20 ` David Miller
2009-03-20  8:29   ` Chung-Yih Wang (王崇懿)

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=9c0b8b730903200115i7ae4512di97418958e05f6a0e@mail.gmail.com \
    --to=cywang@google.com \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®