Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2270444imm; Mon, 28 May 2018 05:08:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrP14FFzWSA/Utca+/cVQBXDRt1rskPgb33YirLJkLNoySNZXXa5FgiAXTNylA1cSRiJhg1 X-Received: by 2002:a17:902:31a4:: with SMTP id x33-v6mr13511854plb.355.1527509305795; Mon, 28 May 2018 05:08:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527509305; cv=none; d=google.com; s=arc-20160816; b=JiSThzunV2Q1LVqlwNLOQXRAkbs+vR0h42BB6kZKuPxhGfyYTIrcz8WEVXReIEjwqX 4nZ+q0sk+ZOxFMBQwiQo3nZnE2yoUmbi/sDChcF2jLZJKr93TkhAYTGaI8D69O1ZSI01 UZZxP66N6CPqxlCKPlmBI39BoGNUxjaZl6jBeLGCTKwlrtB+ZRXP3dYtvPfQLxPMsQwD LS+fCCnLYjT9QUPSTK7elS2Ega1uBfxmVzB2PADp6TbC+XKjNBkC794TqfTQK/D6hZd2 3pIXRhzJKMu4/lV1MQPrXk8Jh3KpIZIfxaEA0JEjo5Ir42lNjfsOy52A4g/Cs7ukZxpY 2YZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=F0hTtuuTdHnTLIs2t+6luNEXuj9eckU2wdwvX0+iHb4=; b=oum3V3uP8NzLsOB/YmnxY6lEJQdHTPWTlG+EDhtg/qcb5hdr+Z4h1dMBQPxofCkKCo 48Dl2+dcmS2JKJZ8m4G4GV3Y0nsVj9wXNJ7EzZbIzeEMo0vstWacDewR4U78C2LpINZq pVVWNNl2iWNiAmqyZPOZosbRpYZm+IeA+1tL4F2X4mX6SlLzfZCp8OSCIq2Wi7S3Xx5Q g5yJJKLderD0+lf/0oIEifF9IWdpzU5WQMWMYeRnaa3a/NkKoFhi0vIEEg25XRTHnzQl z/CexeC5hsFIVfiZTJzgUaPZL4IgCaGtxBqccpqtAWWp20Dw6FqmOLlrWMSLqoNuoOlI DcOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=psISfSx6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e63-v6si30113733pfd.261.2018.05.28.05.08.09; Mon, 28 May 2018 05:08:25 -0700 (PDT) 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=@kernel.org header.s=default header.b=psISfSx6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423114AbeE1MHT (ORCPT + 99 others); Mon, 28 May 2018 08:07:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:52392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423107AbeE1LFU (ORCPT ); Mon, 28 May 2018 07:05:20 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 970F62087E; Mon, 28 May 2018 11:05:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505520; bh=Th1Hl+j05fo3LAKyzYnSwFydWDt2QnLZrsV1jZnL0wI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=psISfSx6XRIaeyxcV3NjZXA/o4tGaROoAEs+9LZrWD9Xm5rh2gTutjTLYZn9oAs8Y xbRiKJTOLE4VKcZdsV1Inmt0KsZSSkextPllPHCXZqkvEFzEXZRe4tn3Vq/U7rih/U zb8v8HsQsa3msC1jnx431las/ZlrqF38dvVPwa/E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Davidlohr Bueso , Joe Lawrence , Andrea Arcangeli , Manfred Spraul , Andrew Morton , Linus Torvalds Subject: [PATCH 4.16 032/272] Revert "ipc/shm: Fix shmat mmap nil-page protection" Date: Mon, 28 May 2018 12:01:05 +0200 Message-Id: <20180528100243.418439638@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100240.256525891@linuxfoundation.org> References: <20180528100240.256525891@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Davidlohr Bueso commit a73ab244f0dad8fffb3291b905f73e2d3eaa7c00 upstream. Patch series "ipc/shm: shmat() fixes around nil-page". These patches fix two issues reported[1] a while back by Joe and Andrea around how shmat(2) behaves with nil-page. The first reverts a commit that it was incorrectly thought that mapping nil-page (address=0) was a no no with MAP_FIXED. This is not the case, with the exception of SHM_REMAP; which is address in the second patch. I chose two patches because it is easier to backport and it explicitly reverts bogus behaviour. Both patches ought to be in -stable and ltp testcases need updated (the added testcase around the cve can be modified to just test for SHM_RND|SHM_REMAP). [1] lkml.kernel.org/r/20180430172152.nfa564pvgpk3ut7p@linux-n805 This patch (of 2): Commit 95e91b831f87 ("ipc/shm: Fix shmat mmap nil-page protection") worked on the idea that we should not be mapping as root addr=0 and MAP_FIXED. However, it was reported that this scenario is in fact valid, thus making the patch both bogus and breaks userspace as well. For example X11's libint10.so relies on shmat(1, SHM_RND) for lowmem initialization[1]. [1] https://cgit.freedesktop.org/xorg/xserver/tree/hw/xfree86/os-support/linux/int10/linux.c#n347 Link: http://lkml.kernel.org/r/20180503203243.15045-2-dave@stgolabs.net Fixes: 95e91b831f87 ("ipc/shm: Fix shmat mmap nil-page protection") Signed-off-by: Davidlohr Bueso Reported-by: Joe Lawrence Reported-by: Andrea Arcangeli Cc: Manfred Spraul Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- ipc/shm.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) --- a/ipc/shm.c +++ b/ipc/shm.c @@ -1320,13 +1320,8 @@ long do_shmat(int shmid, char __user *sh if (addr) { if (addr & (shmlba - 1)) { - /* - * Round down to the nearest multiple of shmlba. - * For sane do_mmap_pgoff() parameters, avoid - * round downs that trigger nil-page and MAP_FIXED. - */ - if ((shmflg & SHM_RND) && addr >= shmlba) - addr &= ~(shmlba - 1); + if (shmflg & SHM_RND) + addr &= ~(shmlba - 1); /* round down */ else #ifndef __ARCH_FORCE_SHMLBA if (addr & ~PAGE_MASK)