Received: by 10.223.185.116 with SMTP id b49csp894746wrg; Wed, 14 Feb 2018 08:32:39 -0800 (PST) X-Google-Smtp-Source: AH8x227LaAuZGv6WUprPQ5//CqQ9M32/hqWG9wmvqUGyaC4ToQnp6BAthP7qOfKkd9Na0Xnk18vt X-Received: by 10.99.110.137 with SMTP id j131mr2807006pgc.85.1518625959145; Wed, 14 Feb 2018 08:32:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518625959; cv=none; d=google.com; s=arc-20160816; b=NkpGA8vJH2V5an30EZvlqjAaFKiBvLY58lwmt0UGESGYYwhpdCkl1L46teinq5i0bs XaOQJ+7nygFA/62saAsD5GDNfh0+JTFEVzjpv75I/fo0jbAq3k9Nr71waTRjJQD+7wQC 4JOzdJCLWqM7+iM/+TIY4xjtSHSXQbPYnqsMMgJq6WsucKBFH4eNjyE973qEdNtEDqTC 1Mnlpcx6cn0iCrVScbkkpENauek/VigEt/w0pfw59+fWk/3CZRo2sZuLSJUNZkJmAzGQ 34UY5bFv7iZOEk31hvoZak00zcNFz1+c4KZZ2SAFS6UngOQFJdBN1Byxpke7asC/hYKk Fthw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=nsxvOnI0cWiZnqPrMTuKbcRpeeZi5MeGL0YSflISwvc=; b=KLKlXJqL6qGs8cQ75BKj8oJfvbq6N0qTvv5cF2IeDnIeRfDLQ4/mEsYqQ9wayBzHWE 3ybzBuuLN5ROR4kUve2fIZXNafdRJesGrGk5Z1RLN/HSbqwps7X4Lc4/GjQ17ZnRqFX7 wm7pn41Lwl+PDVrY1unkD3FKCflab2yri/tmTI5nC4BW8b/WE0RSmkVPvjr5Dx3i8TPv s2YoVJa47jBVHG3o8F70fZfJkDQuHOEO0RQrdDQ/J+JHmE17Mtm/lIWI0+8pJxuWGmFK CCyzUDoRoB7pccpxk0pfI19ODz52oevRyyoru/w41kjE2YjaZqjUpvaXf/Jaqn7GsA5Y tpGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=bJzEIWOM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m66si1373410pfi.23.2018.02.14.08.32.06; Wed, 14 Feb 2018 08:32:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=bJzEIWOM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1032588AbeBNQaj (ORCPT + 99 others); Wed, 14 Feb 2018 11:30:39 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:43738 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1032397AbeBNQah (ORCPT ); Wed, 14 Feb 2018 11:30:37 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1EGQu9Y181398; Wed, 14 Feb 2018 16:30:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=corp-2017-10-26; bh=nsxvOnI0cWiZnqPrMTuKbcRpeeZi5MeGL0YSflISwvc=; b=bJzEIWOMtKsc+ifXuPlke+rqlV1WUACmUH4XLoT95vj+Lah7R6nXpcL+HF1Xj+JVJJNj l8824p/nUiTH8sPpusc9FliZ+hie6ayLqvSOTbPzQImcPIAd6RKgg5XKzZOO+KQAjfmx 8LEVmJvTQP7iWl2ogAhK66PlYn3//kgtFRT4KsAPls63AWTeTXWPdqVC0K6vrHmMd54+ 1Zrlhm+DipruKDurbJqtJCvBgZ4lPmv/dzeqBc09bzCmVB7pNd8YjQDs1E/1zSlqzuBv fvH2V70k+KzOUzr/v3DLuioNLwh9iCmxPL3/fZfDlD1UZ51yt2GK4jxaB0+u8ZgUalqi rg== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2g4puq0rj5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Feb 2018 16:30:22 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w1EGUM4o032681 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 14 Feb 2018 16:30:22 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w1EGUKle026324; Wed, 14 Feb 2018 16:30:21 GMT Received: from concerto (/24.9.64.241) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 14 Feb 2018 08:30:20 -0800 Message-ID: <1518625818.24026.2.camel@oracle.com> Subject: Re: [RFC PATCH] elf: enforce MAP_FIXED on overlaying elf segments (was: Re: ppc elf_map breakage with MAP_FIXED_NOREPLACE) From: Khalid Aziz To: Michal Hocko , Kees Cook Cc: Anshuman Khandual , Michael Ellerman , "akpm@linux-foundation.org" , mm-commits@vger.kernel.org, LKML , Linux-MM , "linux-fsdevel@vger.kernel.org" , Linux-Next , Stephen Rothwell , Mark Brown , Linus Torvalds Date: Wed, 14 Feb 2018 09:30:18 -0700 In-Reply-To: <20180213100440.GM3443@dhcp22.suse.cz> References: <6db9b33d-fd46-c529-b357-3397926f0733@linux.vnet.ibm.com> <20180129132235.GE21609@dhcp22.suse.cz> <87k1w081e7.fsf@concordia.ellerman.id.au> <20180130094205.GS21609@dhcp22.suse.cz> <5eccdc1b-6a10-b48a-c63f-295f69473d97@linux.vnet.ibm.com> <20180131131937.GA6740@dhcp22.suse.cz> <20180201131007.GJ21609@dhcp22.suse.cz> <20180201134026.GK21609@dhcp22.suse.cz> <20180213100440.GM3443@dhcp22.suse.cz> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8804 signatures=668670 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802140195 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-02-13 at 11:04 +0100, Michal Hocko wrote: >=20 > From 97e7355a6dc31a73005fa806566a57eb5c38032b Mon Sep 17 00:00:00 > 2001 > From: Michal Hocko > Date: Tue, 13 Feb 2018 10:50:53 +0100 > Subject: [PATCH] elf: enforce MAP_FIXED on overlaying elf segments >=20 > Anshuman has reported that some ELF binaries in his environment fail > to > start with > =C2=A0[=C2=A0=C2=A0=C2=A023.423642] 9148 (sed): Uhuuh, elf segment at 000= 0000010030000 > requested but the memory is mapped already > =C2=A0[=C2=A0=C2=A0=C2=A023.423706] requested [10030000, 10040000] mapped= [10030000, > 10040000] 100073 anon >=20 > The reason is that the above binary has overlapping elf segments: > =C2=A0 LOAD=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A00x0000000000000000 0x0000000010000000 > 0x0000000010000000 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A00x0000000000013a8c 0x0000000000013a8c=C2=A0= =C2=A0R E=C2=A0=C2=A0=C2=A0=C2=A010000 > =C2=A0 LOAD=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A00x000000000001fd40 0x000000001002fd40 > 0x000000001002fd40 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A00x00000000000002c0 0x00000000000005e8=C2=A0= =C2=A0RW=C2=A0=C2=A0=C2=A0=C2=A0=C2=A010000 > =C2=A0 LOAD=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A00x0000000000020328 0x0000000010030328 > 0x0000000010030328 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A00x0000000000000384 0x00000000000094a0=C2=A0= =C2=A0RW=C2=A0=C2=A0=C2=A0=C2=A0=C2=A010000 >=20 > That binary has two RW LOAD segments, the first crosses a page border > into the second >=20 > 0x1002fd40 (LOAD2-vaddr) + 0x5e8 (LOAD2-memlen) =3D=3D 0x10030328 (LOAD3- > vaddr) >=20 > Handle this situation by enforcing MAP_FIXED when we establish a > temporary brk VMA to handle overlapping segments. All other mappings > will still use MAP_FIXED_NOREPLACE. >=20 > Fixes: fs, elf: drop MAP_FIXED usage from elf_map > Reported-by: Anshuman Khandual > Signed-off-by: Michal Hocko > --- >=20 Looks reasonable to me. Reviewed-by: Khalid Aziz