Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753412AbbDBPdj (ORCPT ); Thu, 2 Apr 2015 11:33:39 -0400 Received: from mail-db3on0075.outbound.protection.outlook.com ([157.55.234.75]:18730 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751210AbbDBPdf (ORCPT ); Thu, 2 Apr 2015 11:33:35 -0400 X-Greylist: delayed 897 seconds by postgrey-1.27 at vger.kernel.org; Thu, 02 Apr 2015 11:33:34 EDT Authentication-Results: spf=none (sender IP is 193.47.165.134) smtp.mailfrom=mellanox.com; vger.kernel.org; dkim=none (message not signed) header.d=none; Message-ID: <551D5DC8.6070909@mellanox.com> Date: Thu, 2 Apr 2015 18:18:32 +0300 From: Haggai Eran User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Yann Droneaud , Shachar Raindel , Sagi Grimberg CC: "oss-security@lists.openwall.com" , " (linux-rdma@vger.kernel.org)" , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: Re: CVE-2014-8159 kernel: infiniband: uverbs: unprotected physical memory access References: <1427969085.17020.5.camel@opteya.com> <1427981431.22575.21.camel@opteya.com> In-Reply-To: <1427981431.22575.21.camel@opteya.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.0.42.235] X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:193.47.165.134;CTRY:IL;IPV:NLI;EFV:NLI;BMV:1;SFV:NSPM;SFS:(10009020)(6009001)(428002)(24454002)(13464003)(189002)(51704005)(199003)(377454003)(479174004)(101416001)(50466002)(87266999)(86362001)(65816999)(77156002)(77096005)(54356999)(64126003)(46102003)(76176999)(33656002)(83506001)(2950100001)(92566002)(62966003)(19580395003)(47776003)(6806004)(93886004)(87936001)(19580405001)(230783001)(23676002)(80316001)(50986999)(36756003)(105586002)(106466001)(3940600001);DIR:OUT;SFP:1101;SCL:1;SRVR:DB3PR05MB219;H:mtlcas13.mtl.com;FPR:;SPF:None;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB3PR05MB219; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(5002010);SRVR:DB3PR05MB219;BCL:0;PCL:0;RULEID:;SRVR:DB3PR05MB219; X-Forefront-PRVS: 0534947130 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2015 15:18:35.1800 (UTC) X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a652971c-7d2e-4d9b-a6a4-d149256f461b;Ip=[193.47.165.134];Helo=[mtlcas13.mtl.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR05MB219 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2764 Lines: 71 On 02/04/2015 16:30, Yann Droneaud wrote: > Hi, > > Le jeudi 02 avril 2015 à 10:52 +0000, Shachar Raindel a écrit : >>> -----Original Message----- >>> From: Yann Droneaud [mailto:ydroneaud@opteya.com] >>> Sent: Thursday, April 02, 2015 1:05 PM >>> Le mercredi 18 mars 2015 à 17:39 +0000, Shachar Raindel a écrit : > >>>> + /* >>>> + * If the combination of the addr and size requested for this >>> memory >>>> + * region causes an integer overflow, return error. >>>> + */ >>>> + if ((PAGE_ALIGN(addr + size) <= size) || >>>> + (PAGE_ALIGN(addr + size) <= addr)) >>>> + return ERR_PTR(-EINVAL); >>>> + >>> >>> Can access_ok() be used here ? >>> >>> if (!access_ok(writable ? VERIFY_WRITE : VERIFY_READ, >>> addr, size)) >>> return ERR_PTR(-EINVAL); >>> >> >> No, this will break the current ODP semantics. >> >> ODP allows the user to register memory that is not accessible yet. >> This is a critical design feature, as it allows avoiding holding >> a registration cache. Adding this check will break the behavior, >> forcing memory to be all accessible when registering an ODP MR. >> > > Where's the check for the range being in userspace memory space, > especially for the ODP case ? > > For non ODP case (eg. plain old behavior), does get_user_pages() > ensure the requested pages fit in userspace region on all > architectures ? I think so. Yes, get_user_pages will return a smaller amount of pages than requested if it encounters an unmapped region (or a region without write permissions for write requests). If this happens, the loop in ib_umem_get calls get_user_pages again with the next set of pages, and this time if it the first page still cannot be mapped an error is returned. > > In ODP case, I'm not sure such check is ever done ? In ODP, we also call get_user_pages, but only when a page fault occurs (see ib_umem_odp_map_dma_pages()). This allows the user to pre-register a memory region that contains unmapped virtual space, and then mmap different files into that area without needing to re-register. > (Aside, does it take special mesure to protect shared mapping from > being read and/or *written* ?) I'm not sure I understand the question. Shared mappings that the process is allowed to read or write are also allowed for the HCA (specifically, to local and remote operations the same process performs using the HCA), provided the application has registered their virtual address space as a memory region. Regards, Haggai -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/