From patchwork Thu Jul 5 14:55:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10509561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 21C04600F5 for ; Thu, 5 Jul 2018 14:55:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EAC628EA8 for ; Thu, 5 Jul 2018 14:55:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 012582918C; Thu, 5 Jul 2018 14:55:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FE9028EA8 for ; Thu, 5 Jul 2018 14:55:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F51A6B000D; Thu, 5 Jul 2018 10:55:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9A4D16B000E; Thu, 5 Jul 2018 10:55:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86D246B0010; Thu, 5 Jul 2018 10:55:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f69.google.com (mail-wm0-f69.google.com [74.125.82.69]) by kanga.kvack.org (Postfix) with ESMTP id 279246B000D for ; Thu, 5 Jul 2018 10:55:51 -0400 (EDT) Received: by mail-wm0-f69.google.com with SMTP id x18-v6so4801201wmc.7 for ; Thu, 05 Jul 2018 07:55:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=vnynUJRrhmyvbhjWglxVURQkDlJBwYoP1B2qLfca2jo=; b=sgWgYpMmoHIbJL+OdXLBNdHFr2RW96QLp5mSBFSIXxMLR1mWnVcqWzUDmOKlIvFvAC vuhbAjFgzToagrUtM2XkgJnJymGnfDzXLV6PozoFh2Vg1b8C1FZBshPcmrDGqVhgC/pF YbKxDTX/he83+htGDQBSDInQ0iPndkx1uoRfOyFd7kl8PE8Le5e/+qd9u+ToUKK4u3g4 ICTmfXTHIYYx3sGLHGoIM391p0xThoegTUaW2fwztyM/zsZRUlEdETHYRF2G243B5jD1 moLOdqTS0zcu7uuFPPhUABd33AwZqUlk2Gpwp1O401XN9ecKTK9wT6w0D4iGu8VO1fE/ igXQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: APt69E3rpcmHRckfvFzvOMILpAisxO9qxFDhxvn1eRvxo48i9d3HA761 jP+wiszQxK3s/1uZGBmDSnhiRBNpoYJugbTFb1Y1+mxdOGYrxzTjeOc+DYKBYCOg5NWNJ1v1JTK ++kn07J6l7SIFOSpyMkaW1qAPKcdmhvyPXmEffaXslQT4GEiDPV95ixR78U9Z9QkgCWeqXIrvS0 9yxi8z/yRPG2jVFkjpm8P7v7syu94sjXc8XK7nfC/lUTX60xNzChZ/WOX06X7M/b8y4njhEOyU0 CibPqwYbDCv7IxJ1BC15JYetFjwrIY8R+5nN1uyRMQxLpahVk5BZ+SXKcCoNA7QbGuyn8LGrXfB /4o5byzATQVicLZ03QCdjZkxD91a7fuNMwi47AlK/OhkqzjV/MDf3q+ZEN6Io8uiuDfv5inb3w= = X-Received: by 2002:a1c:8291:: with SMTP id e139-v6mr4776074wmd.39.1530802550690; Thu, 05 Jul 2018 07:55:50 -0700 (PDT) X-Received: by 2002:a1c:8291:: with SMTP id e139-v6mr4776037wmd.39.1530802549775; Thu, 05 Jul 2018 07:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530802549; cv=none; d=google.com; s=arc-20160816; b=wa37fE0Xswmq9q0terxnGPUNgnvGiqEqQLBW5ObmIgPeEJQOsKyLqCXGYlxj0zdPIz ZZLJqS/jtLbUT8/5pQpFqpMRwNbt2rW148HepBFc2Mgp9vBPAcYI/ADlRP2yJwecQ7cN upAW5eP/xmhXfx0Z1hrYGGdERb3BM/DGSmZyEcZE83hMIKkQ5ejMDPkZ2kzXoGgHtOn/ 6TWzqZV70Zj3aZ8502N3D6LnGOx71cmyQWXOQ3RXoCIDHrgyimCyBwRzSqKDoy7LGbFc u/AUw5YNI8T7PLYp4OLzH36jTIfIvHoa7UgZVxvU6AW3FuJq9AteY6xWd2hnjBxdlQvR Hkcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=vnynUJRrhmyvbhjWglxVURQkDlJBwYoP1B2qLfca2jo=; b=hwyuGfO0dGyhL4kn2CuoHB5E1jMDlbPM2pRBHmGAX3Gzs7pZfpI5LdI38y5VATkdl+ 7137ztbELZWFQKZULpCRFGUmOUAJyjt89zRbcAu42pWSQ2f2CFygUG8DaXSUySdyMXvT 9rUIk8NxDspLcQmhOYVer/aDxBBBYbwRkBIN+s74I73DKax2ebCuDCjR6N2qETbuDQ6R z3yPA6uAlY3olVNXlOB9MhVWfYgNiBrCYkptP05vfudd+gD/3g49hzMp7GUIZrN4OU6a Jj36Z5pep5GONNeqpewEhsuKAYICRIOsTbiZoTdCxyR6b4T1t35JLVIU6nxB8RlLkOqQ 4I8A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id d11-v6sor3041797wrr.38.2018.07.05.07.55.49 for (Google Transport Security); Thu, 05 Jul 2018 07:55:49 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: AAOMgpcVYxfwfSJTvLtf17u0PGbJDp+VeAt+PCx/Tx6lqnGdIGuqmdRNDx0beQxCqYaIvPaEjkmDNw== X-Received: by 2002:adf:c612:: with SMTP id n18-v6mr4729886wrg.177.1530802549492; Thu, 05 Jul 2018 07:55:49 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id q17-v6sm8845707wrr.7.2018.07.05.07.55.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 07:55:48 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 0878D123BDA; Thu, 5 Jul 2018 16:55:48 +0200 (CEST) From: osalvador@techadventures.net To: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, mhocko@suse.com, penguin-kernel@i-love.sakura.ne.jp, keescook@chromium.org, nicolas.pitre@linaro.org, Oscar Salvador Subject: [PATCH] fs, elf: Make sure to page align bss in load_elf_library Date: Thu, 5 Jul 2018 16:55:39 +0200 Message-Id: <20180705145539.9627-1-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Oscar Salvador 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. Signed-off-by: Oscar Salvador Tested-by: Tetsuo Handa Reported-by: syzbot+5dcb560fe12aa5091c06@syzkaller.appspotmail.com Acked-by: Kees Cook --- fs/binfmt_elf.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 0ac456b52bdd..816cc921cf36 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1259,9 +1259,8 @@ static int load_elf_library(struct file *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)