lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 05 Nov 2014 15:35:50 +0800
From:	"Li, ZhenHua" <zhen-hual@...com>
To:	joro@...tes.org
CC:	"Li, Zhen-Hua" <zhen-hual@...com>,
	iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org,
	dwmw2@...radead.org
Subject: Re: [PATCH 1/1] x86/iommu: fix incorrect bit operations in setting
 values

Hi Joerg,

While debugging Bill's patches, I found this problem:
When copying iommu data from old kernel to the kdump kernel, the 
original function context_set_address_root() may cause kdump kernel 
using incorrect address root value.

So I created this patch to fix it.

Zhenhua

On 11/05/2014 03:30 PM, Li, Zhen-Hua wrote:
> The function context_set_address_root() and set_root_value are setting new
> address in a wrong way, and this patch is trying to fix this problem.
>
> According to Intel Vt-d specs(Feb 2011, Revision 1.3), Chapter 9.1 and 9.2,
> field ctp in root entry is using bits 12:63, field asr in context entry is
> using bits 12:63.
>
> To set these fields, the following functions are used:
> static inline void context_set_address_root(struct context_entry *context,
>          unsigned long value);
> and
> static inline void set_root_value(struct root_entry *root, unsigned long value)
>
> But they are using an invalid method to set these fields, in current code, only
> a '|' operator is used to set it. This will not set the asr to the expected
> value if it has an old value.
>
> For example:
> Before calling this function,
> 	context->lo = 0x3456789012111;
> 	value = 0x123456789abcef12;
>
> After we call context_set_address_root(context, value), expected result is
> 	context->lo == 0x123456789abce111;
>
> But the actual result is:
> 	context->lo == 0x1237577f9bbde111;
>
> So we need to clear bits 12:63 before setting the new value, this will fix
> this problem.
>
> Signed-off-by: Li, Zhen-Hua <zhen-hual@...com>
> ---
>   drivers/iommu/intel-iommu.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index a27d6cb..11ac47b 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -195,6 +195,7 @@ static inline void set_root_present(struct root_entry *root)
>   }
>   static inline void set_root_value(struct root_entry *root, unsigned long value)
>   {
> +	root->val &= ~VTD_PAGE_MASK;
>   	root->val |= value & VTD_PAGE_MASK;
>   }
>
> @@ -247,6 +248,7 @@ static inline void context_set_translation_type(struct context_entry *context,
>   static inline void context_set_address_root(struct context_entry *context,
>   					    unsigned long value)
>   {
> +	context->lo &= ~VTD_PAGE_MASK;
>   	context->lo |= value & VTD_PAGE_MASK;
>   }
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ