Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2041767imm; Mon, 16 Jul 2018 00:43:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfsoTKt1HDKhtXsvRj69xjkuiROFyRfgUUWqADBdWd5XkDyaKyE+rg3Cxc2/lQ2ZYLLVjnl X-Received: by 2002:a65:4545:: with SMTP id x5-v6mr14534151pgr.4.1531727024962; Mon, 16 Jul 2018 00:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531727024; cv=none; d=google.com; s=arc-20160816; b=RFcs6rwxoXzTypoBnQW+9fgFRhN0UUxuqfY4lW2qbWh+igsqwsHaO+4LI3qhqlqzDC 6G32ZEaH1g/Ons5m5Rel2ZLLs+f03d661zdGqTfxhQOnEJDE/iQmEDkPGr7OeJa2ztSJ NiDiOceeKh1+rSkavc7F1uElfoL4YoA7oLoHFLyt/06nlKO2SHvpgZedF8Dy6mI3PzQ5 avuWpXuE3tLz5/SYfCA2tBV/GYEh5IRGA7ovRUZnjTP7Cnu4K0weZ5rcQOFMQCOpEUML hQNS1LjZ8FqyRAX/pX01EAr48oYEf2A8N9g/d9FmNgeHdbZpel9NQkUoNyPmUIWNJhNF fxZg== 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=h90ydKkCJAnTmRnzDdioLuHGXrC6TbXnn2rMllp+Mlo=; b=CIPK76rZvlMlRmFt1VEQmob1/i2XAsdFCrbs09mdMOf1WGX8qCaOSGmpaq+mnLVThH s4vilucI8VvmTlKaej7M8ArWEhJaNv9kBlnEaPtL20JQ7ueFwbF50gttKRpOuv0B650u c2VLuSfLj2gXRmKeQR1X4GWZ+8q68qGfWneiX3OASjBHy9D8r3DOcQAVct+7soUWBToc /9glVjnobhlzVP/9pPKRQ8k5bgOXTxDniupQOdFqBu7DD91anu+xjakSZ7hlJ1Cv79tJ 0oMgZnqAawUmHqHgqUt5fxNsAcjAoe6DqDMQSYeS9yktSpGIfNLDsbACdLzQZ+ZnLcxD xnlw== 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 v11-v6si25197926pgl.27.2018.07.16.00.43.30; Mon, 16 Jul 2018 00:43:44 -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 S2388899AbeGPIJA (ORCPT + 99 others); Mon, 16 Jul 2018 04:09:00 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47888 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730161AbeGPIJA (ORCPT ); Mon, 16 Jul 2018 04:09:00 -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 D133CCA1; Mon, 16 Jul 2018 07:42:56 +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.9 21/32] fs, elf: make sure to page align bss in load_elf_library Date: Mon, 16 Jul 2018 09:36:29 +0200 Message-Id: <20180716073507.187864821@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073504.433996952@linuxfoundation.org> References: <20180716073504.433996952@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.9-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 @@ -1217,9 +1217,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)