[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] x86/boot: Restrict directmap permissions for .text/.rodata


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 27 Mar 2023 17:43:29 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UY4KiqS9tzYsjtxXB2qDMvweTjlc6i8zYTxrnAk30u4=; b=M7kbkmUxlZqmrr9lbu0sDG08w3+jj7RJXjE59C5XMzuEvY8lQICk8dhmTD9MvTq+Roa67km7IPR2YfM0LOgFje3IMm1lu/KxghaPUTzx4twwz1quOZhBmAE+rh3IcWdGSvRqDo0/moSo7safKY63oxcbYncgiKIPiwyG2Sv1WwZy7dFAln53iiFclrLhtLTg8MIcD0X6DZLPTCJO7K6tuuDhdJ2TEdFYio1s2vGp6/7EDwNrbHy4fQKJR6jzAKfzIQO2fCsoEo4uJOvBM/PX97mJFt38RK7y+elisfkZKmgvLIxi2xSO9ocqJvd9zmOn68OIThvUr9EtISwb5531dQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JRl4O6wZ11Kjx9jVKw5QN/tqnCiLHUzhXplr7bsR+MDme66Re/L1Rlua9Vd1AL3/VNR6McazksYQw0BKTVNLwtWNjafP/plUKEpf7qgqttO2p+mhukA6WiKOZb8b3SeE/AOFFBMYYwzMr+so7crb6gn1EFJm1rPf/Vye1zcplEjz1RgZu28teDqwqNBfJjcm4qeimYDXc3u8rzT14Ceyhb4GzX3QSSnu+kF4TL6mgpFErT5maWOzCxwqpVJzXo9a1xQZ4yTmbXIJr2FqkGnK+gzmdXwSVG/+kWNC0cbrMAOypoumKbKK2+Hra+981/qHvzUFDNvJvU5R5mdz5pyXjA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 27 Mar 2023 15:43:35 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 24.03.2023 23:08, Andrew Cooper wrote:
> While we've been diligent to ensure that the main text/data/rodata mappings
> have suitable restrictions, their aliases via the directmap were left fully
> read/write.  Worse, we even had pieces of code making use of this as a
> feature.
> 
> Restrict the permissions for .text/rodata, as we have no legitimate need for
> writeability of these areas via the directmap alias.  Note that the
> compile-time allocated pagetables do get written through their directmap
> alias, so need to remain writeable.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>

Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>

> Notes:
>  * The stubs are still have RX via one alias, RW via another, and these need
>    to stay.  We should harden this using PKS (available on SPR and later) to
>    block incidental writes.
>  * Backing memory for livepatch text/rodata needs similar treatment.

Right, but there it's somewhat more involved because upon removal the
attributes also need restoring.

>  * For backporting, this patch depends on c/s e7f147bf4ac7 ("x86/crash: Drop
>    manual hooking of exception_table[]") and c/s e7db635f4428 ("x86/pv-shim:
>    Don't modify the hypercall table").  No compile error will occur from
>    getting these dependencies wrong.

I suppose the latter isn't strictly a prereq, as the modification was done
from an __init function (i.e. before this new code runs).

Iirc we didn't backport prior similar hardening work? So I'm not sure we'd
want/need to do so in this case.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.