Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp104467lqo; Wed, 15 May 2024 08:53:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUeMb6nhQgpuGzmUn1DT3C6A2unzldnONtbpghfNTolInRESYsUD9kW0qfKENuxTDM5l6vLMRt0m1GTLShFR9e2uaTw6zVSWfX8KycL7w== X-Google-Smtp-Source: AGHT+IG7LG4aCEREIEnFHAoeiPWhA1UKrUadB6SADIHlwfIoyYPkCnjVhgdnt8K6t6inKjcmVKLB X-Received: by 2002:a92:c56a:0:b0:36d:b851:c529 with SMTP id e9e14a558f8ab-36db851c717mr21894715ab.2.1715788391632; Wed, 15 May 2024 08:53:11 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-65705abe5b4si644121a12.777.2024.05.15.08.53.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 08:53:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180093-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UGTt9ovX; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-180093-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180093-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id F2DAEB2255C for ; Wed, 15 May 2024 15:53:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED04F156242; Wed, 15 May 2024 15:52:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="UGTt9ovX" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95646155723; Wed, 15 May 2024 15:52:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=198.175.65.19 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715788376; cv=fail; b=Cjp0bszjWpC6qRVpv6LVSl25110H7ZxS4VLfeAJWLpvA66jb9fQH2SKZQKrwb1blYp8pcF0mA0G4G4ADtReh9f83B5x1ZiCh2VgSh52fs9z4wJu/dvs0WHG038bdLlaJIwsLSUkcf/GAUmh8qoU9oVaXYqhOyQftYLXP7CcuDi4= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715788376; c=relaxed/simple; bh=OJD4K7NglkEa3Td/4Gf40sFYQvrker8T22zHFwjJIzY=; h=Message-ID:Date:Subject:To:CC:References:From:In-Reply-To: Content-Type:MIME-Version; b=C9M72IiPuidkwLEPCzKjpf10OmYb32IqEU/qffVFrq9AWYMYDqerU0y8phnVVrQgAcoX7dwAHwCJC8AqkaiqucyQoIv6+VjVeVw8wS1KfWW9eMLfYTYmuVE7rYz5kmyUVctMxSBEBokmSVMzhT6Uh2X51ki+Tb1dcMRnR9AFo20= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=UGTt9ovX; arc=fail smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1715788375; x=1747324375; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=OJD4K7NglkEa3Td/4Gf40sFYQvrker8T22zHFwjJIzY=; b=UGTt9ovXT/cWtN3ddz0NjMYU4JZT+9Jt+Ua7SN3iXwhd1NhJUQqIV7tp cM4ypZFNBlCIl2ubULrCNsMYFIC9r49LGBAt42kxyrl+cPllG8sg293WU dsohFlGnz2Fm3/4ErFLsx3hmfpTrqkYobOEBVfjpwsIblMqXoYhvkJK5+ ooYDUKDtL+gFqdoKY98PApcFMno+RR32ctuNiu4Z9X1mb46eOYDs52mPi LqJhlwKrcY4QfbcTWwJPxiqsGKhn0dY+LiOUg2c2LqDurT0sycRLui1jy /es/XU2/13nJy4Jv/zhgvwuAFlLcLbjDhb5xi8qb0GYk733GeetFQbGjz A==; X-CSE-ConnectionGUID: h2i5LiUnRHmHOSFgdMEz0w== X-CSE-MsgGUID: rbwkA9h7TTuuyotz+jmEMA== X-IronPort-AV: E=McAfee;i="6600,9927,11074"; a="11703868" X-IronPort-AV: E=Sophos;i="6.08,162,1712646000"; d="scan'208";a="11703868" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 May 2024 08:52:39 -0700 X-CSE-ConnectionGUID: Lo/ndSV2Qq+SMFaIYnEFBw== X-CSE-MsgGUID: cHSffqHsQEah1BJtrnwwRQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,162,1712646000"; d="scan'208";a="31233744" Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by orviesa009.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 15 May 2024 08:52:39 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 15 May 2024 08:52:38 -0700 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39 via Frontend Transport; Wed, 15 May 2024 08:52:38 -0700 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (104.47.57.41) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 15 May 2024 08:52:38 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eVDba8P4ab7AwLEAWMOQ77k8DnoYTbDDQZNHSP/BaBd6bzPbT5/kwBttPvhV188VTlFxe1DOvbyOPPpk4vbAMH0dfVSqsTFz5FilOD55+V6s5e7gXngwhrFMt/p538RB5wisViuCHMf/D4U0e15UDR871vm8XR9kH1B3TwmuuoT+IPHKrlmnR5yVnOzXdYdDfS7VrcCwZPsHbu7lOI7ROo97kaGaMEo5TKbkhZuuRaU9h1za6G+2EsglN3fJER75n7D6i2LxZq/mcdbGbbYZuSaDVD8+sswSCAwW/FReIL0yrx5F8GDT2S8JvGzDPEx2HOWz3z7KZLNn3uPCbJRzWA== 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=qbBPBoWNanTm1jveWrzXb2HenDjQDbXdbViCwNMr2eU=; b=oQEfMI4PiMPgy39VibRkWVXps6yRsILHDRsVxQ5UqCnwUSr6Jp313iSeKcvFOvQcftX9jtBqizxCJrgGW+4KRii7/JrdOlWg8KLqeDEwmjLuUuNYJ8Vp8HZeZE2y6sOxCoV/V7kH+oKdRWWVEJhAGfhaQmKPI+e8E7ZbybSQeN00ejR4EL3MEVdMxeLPPDIVUMkOXQJkljYO10gjanKcLk326XxWpFB3MCsNpv9SstzfoWbxhksVZBRUbkduGiPXEAVEbJs5GTz9pB84Cdh9b+GfAY7zng2+QO+au8PB9QMYwSo4gbODkBbIEWQJxf+kcn5QEWyxWvCs+Uw/jos4VA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from SJ2PR11MB7573.namprd11.prod.outlook.com (2603:10b6:a03:4d2::10) by PH7PR11MB6546.namprd11.prod.outlook.com (2603:10b6:510:212::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Wed, 15 May 2024 15:52:36 +0000 Received: from SJ2PR11MB7573.namprd11.prod.outlook.com ([fe80::b394:287f:b57e:2519]) by SJ2PR11MB7573.namprd11.prod.outlook.com ([fe80::b394:287f:b57e:2519%4]) with mapi id 15.20.7544.052; Wed, 15 May 2024 15:52:36 +0000 Message-ID: Date: Wed, 15 May 2024 08:52:33 -0700 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 2/2] x86/sgx: Resolve EREMOVE page vs EAUG page data race To: Dmitrii Kuvaiskii , , , , , , CC: , , References: <20240515131240.1304824-1-dmitrii.kuvaiskii@intel.com> <20240515131240.1304824-3-dmitrii.kuvaiskii@intel.com> Content-Language: en-US From: Reinette Chatre In-Reply-To: <20240515131240.1304824-3-dmitrii.kuvaiskii@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MW2PR2101CA0030.namprd21.prod.outlook.com (2603:10b6:302:1::43) To SJ2PR11MB7573.namprd11.prod.outlook.com (2603:10b6:a03:4d2::10) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ2PR11MB7573:EE_|PH7PR11MB6546:EE_ X-MS-Office365-Filtering-Correlation-Id: 2150a8d3-2baa-4eda-7ebd-08dc74f70a5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015; X-Microsoft-Antispam-Message-Info: =?utf-8?B?ODl5Q3BXNE5EdHphSkFUNVNVNy9ydWM2QzhWUkdONUwrRnk3aHp0SEMxR2pq?= =?utf-8?B?c0hoWkVwdmlXYVlOMTlWYW9rWDJTSFBoMUdjaTZVeFFaZ21wRmtlRVR6S2VV?= =?utf-8?B?WHJ4RmhHQ0lkWGJPUE44YzJSYTA2d2FEb1hpTWNlUjJXWCttTUFNOU9KZWhV?= =?utf-8?B?VFM1bFNWdVlONW9FUXJXTkphaGsrNkw2d2NSSVlFLzNTdit5WCtWYzhLLzdq?= =?utf-8?B?Vk1VOXBUL2VrMHA5VHJJajVRWFk2M2NoU3RWNmNVbTVERFE1NkR6WWxWNE40?= =?utf-8?B?Ky8ybXR2aDEzbTlzOG5sUC9CcDJYZTFQYk9QV1hQS2pwdHIvSGorcVIzM2RP?= =?utf-8?B?SjNOTHBGd0dVSmhaSkJxYWpYbDQrMEgzb3lUNzBoUjFkQnZtbU53VGlpQy9h?= =?utf-8?B?WkVicnJUZ05XSDlnell3eHJsaW0wZ05QVW0rY3VzRkdFaldOdVh2ejNsTmF6?= =?utf-8?B?YkkyZWlnU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jRySjN5Rmlw?= =?utf-8?B?b1VHUU1Hall6bVJLNWJiYnRveDVrK3gvMXpPUUFaSElxelMybDU3RlhHeG5u?= =?utf-8?B?WDlOdS9KSThmRS9jTmc1Q2grd0o1ZU94cldYNUpVZDJrV1J5c0FBZXdub3lM?= =?utf-8?B?eDF2b0RoNkRuYzkwb3NFd2d2bkxvcnlubXNWQUhWMlhLSXZEb0llcE01Y01N?= =?utf-8?B?U04yK2ZqTVYvN2c5bzNPVnl0d3RLZlJ1MjF0aXdlZXZPaFJuTmt2V1FDM3Jp?= =?utf-8?B?eUtBK25KTU0wajNCdE00WEdSRFNJQzBQVU9mU2I3ZGNEaVBzclJvSjdIemZ3?= =?utf-8?B?ZzZuekFGZSs4TDNNZkJGVFZRY2hUbmFCOW92N0xJSmNwNXE2VHRGMUpBPT0=?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ2PR11MB7573.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(1800799015);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?T0V3OEdoWFk1eWhXUUtOeXVpVUVYSk84bnJ0RndUdnBLL1RhTG1sa0M3NFJx?= =?utf-8?B?TWlMOXZrNzJ2NEF2czhLcXZHUDliVkpGVW8zMG1mYnZ0NThSbWNSVFJQTG1u?= =?utf-8?B?QldCOE9tdUNOSkNpd2diUGF1dlNtTTFTeFlFRFNKSllrWmVPQnZxaGw4RXVX?= =?utf-8?B?NVNnVGt2dkhqZFZnUE9kT3A4bjhLWUtZU1FkZHhPS2pUL0dmU09SalQ0dFZQ?= =?utf-8?B?TXloQnZNbFFvUWJlRjJodzJmeW9Mc1FKL2ltYlhGRE5DUFIvMXhxaTV0ck5Z?= =?utf-8?B?OEpFbmZhQVFrbVp3dEE5TThlZ214Z1ArL3gyczV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em5LZXdnWThQZWtqL2YxdFpDdy9VRnJWN0twRlQxUUtSV3U4bWRqazVj?= =?utf-8?B?SXc9PQ==?= X-MS-Exchange-CrossTenant-Network-Message-Id: 2150a8d3-2baa-4eda-7ebd-08dc74f70a5c X-MS-Exchange-CrossTenant-AuthSource: SJ2PR11MB7573.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 May 2024 15:52:36.0851 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ABuHYFGlE425hzDrtqGPa2Np3sqDY0CDg4FUYDOVNIR6A/4KJFL2Yb5Ocqd8ok6wXW1yVgxE8AVP4bYUxdlRD5H036RL0e+m558HjExvu0g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB6546 X-OriginatorOrg: intel.com Hi Dmitrii, On 5/15/2024 6:12 AM, Dmitrii Kuvaiskii wrote: > Two enclave threads may try to add and remove the same enclave page > simultaneously (e.g., if the SGX runtime supports both lazy allocation > and MADV_DONTNEED semantics). Consider some enclave page added to the > enclave. User space decides to temporarily remove this page (e.g., > emulating the MADV_DONTNEED semantics) on CPU1. At the same time, user > space performs a memory access on the same page on CPU2, which results > in a #PF and ultimately in sgx_vma_fault(). Scenario proceeds as > follows: > > /* > * CPU1: User space performs > * ioctl(SGX_IOC_ENCLAVE_REMOVE_PAGES) > * on enclave page X > */ > sgx_encl_remove_pages() { > > mutex_lock(&encl->lock); > > entry = sgx_encl_load_page(encl); > /* > * verify that page is > * trimmed and accepted > */ > > mutex_unlock(&encl->lock); > > /* > * remove PTE entry; cannot > * be performed under lock > */ > sgx_zap_enclave_ptes(encl); > /* > * Fault on CPU2 on same page X > */ > sgx_vma_fault() { > /* > * PTE entry was removed, but the > * page is still in enclave's xarray > */ > xa_load(&encl->page_array) != NULL -> > /* > * SGX driver thinks that this page > * was swapped out and loads it > */ > mutex_lock(&encl->lock); > /* > * this is effectively a no-op > */ > entry = sgx_encl_load_page_in_vma(); > /* > * add PTE entry > * > * *BUG*: a PTE is installed for a > * page in process of being removed > */ > vmf_insert_pfn(...); > > mutex_unlock(&encl->lock); > return VM_FAULT_NOPAGE; > } > /* > * continue with page removal > */ > mutex_lock(&encl->lock); > > sgx_encl_free_epc_page(epc_page) { > /* > * remove page via EREMOVE > */ > /* > * free EPC page > */ > sgx_free_epc_page(epc_page); > } > > xa_erase(&encl->page_array); > > mutex_unlock(&encl->lock); > } > > Here, CPU1 removed the page. However CPU2 installed the PTE entry on the > same page. This enclave page becomes perpetually inaccessible (until > another SGX_IOC_ENCLAVE_REMOVE_PAGES ioctl). This is because the page is > marked accessible in the PTE entry but is not EAUGed, and any subsequent > access to this page raises a fault: with the kernel believing there to > be a valid VMA, the unlikely error code X86_PF_SGX encountered by code > path do_user_addr_fault() -> access_error() causes the SGX driver's > sgx_vma_fault() to be skipped and user space receives a SIGSEGV instead. > The userspace SIGSEGV handler cannot perform EACCEPT because the page > was not EAUGed. Thus, the user space is stuck with the inaccessible > page. > > Fix this race by forcing the fault handler on CPU2 to back off if the > page is currently being removed (on CPU1). This is achieved by > introducing a new flag SGX_ENCL_PAGE_BEING_REMOVED, which is unset by > default and set only right-before the first mutex_unlock() in > sgx_encl_remove_pages(). Upon loading the page, CPU2 checks whether this > page is being removed, and if yes then CPU2 backs off and waits until > the page is completely removed. After that, any memory access to this > page results in a normal "allocate and EAUG a page on #PF" flow. > > Fixes: 9849bb27152c ("x86/sgx: Support complete page removal") > Cc: stable@vger.kernel.org > Signed-off-by: Dmitrii Kuvaiskii > --- > arch/x86/kernel/cpu/sgx/encl.c | 3 ++- > arch/x86/kernel/cpu/sgx/encl.h | 3 +++ > arch/x86/kernel/cpu/sgx/ioctl.c | 1 + > 3 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/cpu/sgx/encl.c b/arch/x86/kernel/cpu/sgx/encl.c > index 41f14b1a3025..7ccd8b2fce5f 100644 > --- a/arch/x86/kernel/cpu/sgx/encl.c > +++ b/arch/x86/kernel/cpu/sgx/encl.c > @@ -257,7 +257,8 @@ static struct sgx_encl_page *__sgx_encl_load_page(struct sgx_encl *encl, > > /* Entry successfully located. */ > if (entry->epc_page) { > - if (entry->desc & SGX_ENCL_PAGE_BEING_RECLAIMED) > + if (entry->desc & (SGX_ENCL_PAGE_BEING_RECLAIMED | > + SGX_ENCL_PAGE_BEING_REMOVED)) > return ERR_PTR(-EBUSY); > > return entry; > diff --git a/arch/x86/kernel/cpu/sgx/encl.h b/arch/x86/kernel/cpu/sgx/encl.h > index f94ff14c9486..fff5f2293ae7 100644 > --- a/arch/x86/kernel/cpu/sgx/encl.h > +++ b/arch/x86/kernel/cpu/sgx/encl.h > @@ -25,6 +25,9 @@ > /* 'desc' bit marking that the page is being reclaimed. */ > #define SGX_ENCL_PAGE_BEING_RECLAIMED BIT(3) > > +/* 'desc' bit marking that the page is being removed. */ > +#define SGX_ENCL_PAGE_BEING_REMOVED BIT(2) > + > struct sgx_encl_page { > unsigned long desc; > unsigned long vm_max_prot_bits:8; > diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c > index b65ab214bdf5..c542d4dd3e64 100644 > --- a/arch/x86/kernel/cpu/sgx/ioctl.c > +++ b/arch/x86/kernel/cpu/sgx/ioctl.c > @@ -1142,6 +1142,7 @@ static long sgx_encl_remove_pages(struct sgx_encl *encl, > * Do not keep encl->lock because of dependency on > * mmap_lock acquired in sgx_zap_enclave_ptes(). > */ > + entry->desc |= SGX_ENCL_PAGE_BEING_REMOVED; > mutex_unlock(&encl->lock); > > sgx_zap_enclave_ptes(encl, addr); Thank you very much for tracking down and fixing this issue. Acked-by: Reinette Chatre Reinette