Re: [PATCH v4 0/4] Application Data Integrity feature introduced by SPARC M7

From: Khalid Aziz
Date: Wed Jan 11 2017 - 19:24:42 EST


On 01/11/2017 12:11 PM, Dave Hansen wrote:
On 01/11/2017 10:50 AM, Khalid Aziz wrote:
On 01/11/2017 11:13 AM, Dave Hansen wrote:
On 01/11/2017 08:56 AM, Khalid Aziz wrote:
For memory shared by two different processes, do they have to agree on
what the tags are, or can they differ?

The two processes have to agree on the tag. This is part of the security
design to prevent other processes from accessing pages belonging to
another process unless they know the tag set on those pages.

So what do you do with static data, say from a shared executable? You
need to ensure that two different processes from two different privilege
domains can't set different tags on the same physical memory. That
would seem to mean that you must not allow tags to be set of memory
unless you have write access to it. Or, you have to ensure that any
file that you might want to use this feature on is entirely unreadable
(well, un-mmap()-able really) by anybody that you are not coordinating with.

All of the tag coordination can happen in userspace. Once a process sets a tag on a physical page mapped in its address space, another process that has mapped the same physical page in its address space can only set the tag to exact same value. Attempts to set a different tag are caught by memory controller and result in MCD trap and kernel sends SIGSEGV to the process trying to set a different tag.


If you want to use it on copy-on-write'able data, you've got to ensure
that you've got entirely private copies. I'm not sure we even have an
interface to guarantee that. How could this work after a fork() on
un-COW'd, but COW'able data?

On COW, kernel maps the the source and destination pages with kmap_atomic() and copies the data over to the new page and the new page wouldn't be ADI protected unless the child process chooses to do so. This wouldn't change with ADI as far as private copies are concerned. Please do correct me if I get something wrong here. Quick tests with COW data show everything working as expected but your asking about COW has raised a few questions in my own mind. I am researching through docs and running experiments to validate my thinking and I will give you more definite information on whether COW would mess ADI up.

Thanks,
Khalid