Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: labbott@redhat.com (Laura Abbott)
To: linux-arm-kernel@lists.infradead.org
Subject: [kernel-hardening][PATCH v2 3/3] arm: mm: dump: add checking for writable and executable pages
Date: Fri, 1 Dec 2017 13:59:48 -0800	[thread overview]
Message-ID: <23def981-3f61-8421-b46d-94f75b293003@redhat.com> (raw)
In-Reply-To: <20171201113447.GA5234@pjb1027-Latitude-E5410>

On 12/01/2017 03:34 AM, Jinbum Park wrote:
> +static inline bool is_prot_ro(struct pg_state *st)
> +{
> +	if (st->level < 4) {
> +	#ifdef CONFIG_ARM_LPAE
> +		if ((st->current_prot &
> +		(L_PMD_SECT_RDONLY | PMD_SECT_AP2)) ==
> +		(L_PMD_SECT_RDONLY | PMD_SECT_AP2))
> +			return true;
> +	#elif __LINUX_ARM_ARCH__ >= 6
> +		if ((st->current_prot &
> +		(PMD_SECT_APX | PMD_SECT_AP_READ | PMD_SECT_AP_WRITE)) ==
> +		(PMD_SECT_APX | PMD_SECT_AP_WRITE))
> +			return true;
> +	#else
> +		if ((st->current_prot &
> +		(PMD_SECT_AP_READ | PMD_SECT_AP_WRITE)) == 0)
> +			return true;
> +	#endif
> +	} else {
> +		if ((st->current_prot & L_PTE_RDONLY) == L_PTE_RDONLY)
> +			return true;
> +	}
> +
> +	return false;
> +}
> +
> +static inline bool is_prot_nx(struct pg_state *st)
> +{
> +	if (st->level < 4) {
> +		if ((st->current_prot & PMD_SECT_XN) == PMD_SECT_XN)
> +			return true;
> +	} else {
> +		if ((st->current_prot & L_PTE_XN) == L_PTE_XN)
> +			return true;
> +	}
> +
> +	return false;
> +}

I know arm64 checks the bits directly, but the arm32 code is a bit
more fiddly and I have mixed feelings about copying and pasting
the checks. It would be cleaner if we could take advantage of
the existing pg_level and bits arrays. I also don't have my heart
set on this so if nobody else objects, the code can stay as is.

Thanks,
Laura

  reply	other threads:[~2017-12-01 21:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-01 11:34 [kernel-hardening][PATCH v2 3/3] arm: mm: dump: add checking for writable and executable pages Jinbum Park
2017-12-01 21:59 ` Laura Abbott [this message]
2017-12-03  2:32   ` park jinbum

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=23def981-3f61-8421-b46d-94f75b293003@redhat.com \
    --to=labbott@redhat.com \
    --cc=linux-arm-kernel@lists.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