Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2039077imm; Mon, 16 Jul 2018 00:39:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgperk2fc1S87Up8EvZRE/0oPfjQdNmmWEJ6HgmXn01EbUbHSu29ElZrb+xqWqbh8OXLRs7G0 X-Received: by 2002:a17:902:e3:: with SMTP id a90-v6mr15921407pla.227.1531726792365; Mon, 16 Jul 2018 00:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531726792; cv=none; d=google.com; s=arc-20160816; b=Og/ktrW5iOmnFyRbUlhVE3I9+Iq29Z4lwJScw2RW1Ys77NR7Gx9nlfX8u9VvNz/G3A PYAiGUPqSrW7zMN8Yd1eWttKhHrdgjxv75aNMSVXgrxXpfJSj9ocjqmTQ+1KVeujH3GP BE29SHNmFw1LB2yt0Yt5zoNkBjHLg0kElpqaRE2zNIn2zwXqwUay4s3EdyiNTO+4SrLQ Y5hJoy9ICGkvKZs2PQXoDLJ2fppK1nIynT/gT5fbK4GRIr5oR8J6bg787ue5YcEmJ8Eo 2bp5h7uWnnqcp+9krPSkTbEKDDAyMJz0iO5V2J5rvpQE8//aseML85Pe1fT/WtK5Fsk2 zUDA== 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 :arc-authentication-results; bh=JqGe3FGYTIumqE7Ir8eyu5ZhRFQfTWKbLT9O1X/olgE=; b=aGVObr47P/CLBYg1gY1lT755t8AQxwTRoBgY6O/jZ0lr+wJpDtu531Cpqx+u6afE+u Ar8aoOtIS/UD/XLFe8wQgxmGFvu8BcnWtP/y/xEe8RVtY6QNmKh8Jfy6TqZ9/HgwZIlN wQL14mUQSiARS/YRcofIQKT59oXonGmhXBUYdWf+mQk5urB5slar/+yV/ayV/nqr9jxt S+UvN3VrnYo8MibZVSF4aXvUKdTS+c9a40JB4nHgeeyieQ4jxWARuTDMbv00i7nwYE3X /kBxifSgpZ1wKMgI9AUrrRsR0yTQojOm0LILvjOKjeSwDrkOJ1GMxLPb0RRW6q5UjPBC Jq2w== 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 x5-v6si28207603pgb.399.2018.07.16.00.39.37; Mon, 16 Jul 2018 00:39:52 -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; 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 S1733128AbeGPIEk (ORCPT + 99 others); Mon, 16 Jul 2018 04:04:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46956 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729611AbeGPIEj (ORCPT ); Mon, 16 Jul 2018 04:04:39 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3BD9BC03; Mon, 16 Jul 2018 07:38:37 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oscar Salvador , syzbot+5dcb560fe12aa5091c06@syzkaller.appspotmail.com, Tetsuo Handa , Kees Cook , Michal Hocko , Nicolas Pitre , Andrew Morton , Linus Torvalds Subject: [PATCH 4.17 38/67] fs, elf: make sure to page align bss in load_elf_library Date: Mon, 16 Jul 2018 09:35:07 +0200 Message-Id: <20180716073449.137646736@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073443.294323458@linuxfoundation.org> References: <20180716073443.294323458@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.17-stable 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 Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- fs/binfmt_elf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1259,9 +1259,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 (error)