Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3333135imu; Sun, 11 Nov 2018 12:34:58 -0800 (PST) X-Google-Smtp-Source: AJdET5dSOjkE8bdQgkkUKrpd2p0fbxBHJJZPnfpTu1QGDKW5tqONjrNkD89MtklVQWD2Dl7h8+mN X-Received: by 2002:a63:df13:: with SMTP id u19mr15162855pgg.294.1541968498164; Sun, 11 Nov 2018 12:34:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968498; cv=none; d=google.com; s=arc-20160816; b=rYUzmA1jvzt1WKpm25fsfbudF74xT32c3nvYgiFkrAsk4dxxUfYreImXfGtWEaPLHS X/6cd2ILJpPp56YdNv9k+G5S5mlKAWUkqe1JTJ2qydCFWU/jml88Anl8h5FyQd8WHcw3 RwhFq63Z/osMD7Gn0XZoxjrmKk355DR1M9VYMC6Ej03SYf0SNKw2QsUS7XYzlNZTkxvk Pt1F5TtgP1soRwdLltlTYCtf8oZDC42206iL9qmLDVVwIcPYeMmKpFHkT01UKvEDbvSG nIi4RtRNZva3/kM+Gfp1pc7tDJWxgngFA1D/y/odxARaN8gWBF06QnR54zJPq1DVx7JF gK+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=FLpuD/5ChRNyO8Cww6rF8rTM0bIayNZmk4+RrronZ0E=; b=sxUU86KrKFvs25HjsLdyW+87TQyrBvjm4y/Pt3+1MtQN0BfL2VD64ItX4H28Z4jTZz MpThycMwJQP1DpF7lDrYRZEVRCxxmaF1t9p2jFyyhP1A4LRB6hupNI+aIeP94RaxQtAu uW+gvU0Cd6B+Le5tcFG0CETamTD6SG3FVPHYNxeU1cBlrrNBkWFjI/++S8zPDtJdDKLC 52G1rjXDmGB30V9M/arQ4a7r6fSBcJX/mVQ1vb4HUMAsktxuOkGW8bacgP45x4wPEOpg I3PSo55Sccak710F+EBOGRYQqAWqHl9nEqZnJrqZh+qN8Gura88OgQFZzv8JJEuwuZFh mjWA== ARC-Authentication-Results: i=1; mx.google.com; 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 22si14313852pgr.356.2018.11.11.12.34.42; Sun, 11 Nov 2018 12:34:58 -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; 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 S1730247AbeKLFsP (ORCPT + 99 others); Mon, 12 Nov 2018 00:48:15 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49890 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730182AbeKLFsN (ORCPT ); Mon, 12 Nov 2018 00:48:13 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsZ-0000oF-24; Sun, 11 Nov 2018 19:58:43 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsW-0001jD-HO; Sun, 11 Nov 2018 19:58:40 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Michal Hocko" , "Oscar Salvador" , "Nicolas Pitre" , "Linus Torvalds" , syzbot+5dcb560fe12aa5091c06@syzkaller.appspotmail.com, "Kees Cook" , "Tetsuo Handa" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 253/366] fs, elf: make sure to page align bss in load_elf_library In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Oscar Salvador commit 24962af7e1041b7e50c1bc71d8d10dc678c556b5 upstream. The current code does not make sure to page align bss before calling vm_brk(), and this can lead to a VM_BUG_ON() in __mm_populate() due to the requested lenght not being correctly aligned. Let us make sure to align it properly. Kees: only applicable to CONFIG_USELIB kernels: 32-bit and configured for libc5. Link: http://lkml.kernel.org/r/20180705145539.9627-1-osalvador@techadventures.net Signed-off-by: Oscar Salvador Reported-by: syzbot+5dcb560fe12aa5091c06@syzkaller.appspotmail.com Tested-by: Tetsuo Handa Acked-by: Kees Cook Cc: Michal Hocko Cc: Nicolas Pitre Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Ben Hutchings --- fs/binfmt_elf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1083,9 +1083,8 @@ static int load_elf_library(struct file goto out_free_ph; } - len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr + - ELF_MIN_ALIGN - 1); - bss = eppnt->p_memsz + eppnt->p_vaddr; + len = ELF_PAGEALIGN(eppnt->p_filesz + eppnt->p_vaddr); + bss = ELF_PAGEALIGN(eppnt->p_memsz + eppnt->p_vaddr); if (bss > len) { error = vm_brk(len, bss - len); if (BAD_ADDR(error))