From patchwork Thu Jul 5 11:40:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10508791 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 B9A3E60116 for ; Thu, 5 Jul 2018 11:40:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7B2528FFA for ; Thu, 5 Jul 2018 11:40:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98D7328F9A; Thu, 5 Jul 2018 11:40:48 +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 1050929000 for ; Thu, 5 Jul 2018 11:40:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04F776B0007; Thu, 5 Jul 2018 07:40:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F40876B0008; Thu, 5 Jul 2018 07:40:46 -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 E58AC6B000A; Thu, 5 Jul 2018 07:40:46 -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 8E78A6B0007 for ; Thu, 5 Jul 2018 07:40:46 -0400 (EDT) Received: by mail-wm0-f69.google.com with SMTP id t83-v6so4473914wmt.3 for ; Thu, 05 Jul 2018 04:40:46 -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:date:from:to :cc:subject:message-id:references:mime-version:content-disposition :in-reply-to:user-agent; bh=P7Qtayqql1p8MrBlsozKFPgpWyuKemDGEGL9Qw6Gtyk=; b=p3yHw39a5beW0iWGKPVGskJfkZWxW8YDgJ5k2Yz4j2PxwHkzlJqkPH+FmZm1s/y4v6 jS3pMY++T2M4LrKEixrnj9c64DUj2vYah9MoxSe9GmOQSpYVnBGf21Xd2cWtc/xgGyF/ IDVJMlX0FCmYD4MdzEXossIr6pdRVeG9IgSQVQBshkEDsVMr75vyBerqpWxUjmQJXXXw 4HO7My8FhPIxJgSei3NWLlwkxcuUMJOC1+xLD0sU5MjDUabhkV8qDBoOdLRWPfVMpVMP kDhe81z89NE8fLtc0IA44D1b5XIL4ssuHVDRxCXU8MqN1XO7ilunfcDIktgzouGqdcHY Ppqw== 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: APt69E2f5IoCtukdovDN8LJCL/84X7nIb0DMyQGfgI+kEVpg9azz6QiT OeBTdlGvdMlefDpmW2Q46eKtYiiwvH7KpOmAUwrywWN5LB8FJW/kPiwpShSv3ZCAad9ze3k4Beb doArJbhAFT/ZV/oND4UuOSJQOHGK/ZOKSFSp4mSGQe6CThAXjR20VealNQFye6O8S4a/cTshrYH hLRftWdp9m2Gi+LLafgpTQ6sEUk1f6fIKgCTrsVUt4Xif25X4gwIUxbv6jd5rOp9nf61z34dwl6 H+fIA6oLhOaMf4V8GUvWgCTwxHAdryr5Rj6Se04/FDMeOwKPGix+Oo55dU+rhqoOUwz2F1emgup U7SmkdlK6FmQDz4f7aLY2Goemt/taG93SBWTQzGjKzZNBJN1LvVjGfY45d8ltUyeNHuZXc8W1Q= = X-Received: by 2002:a5d:46c6:: with SMTP id g6-v6mr4085678wrs.76.1530790846141; Thu, 05 Jul 2018 04:40:46 -0700 (PDT) X-Received: by 2002:a5d:46c6:: with SMTP id g6-v6mr4085642wrs.76.1530790845222; Thu, 05 Jul 2018 04:40:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530790845; cv=none; d=google.com; s=arc-20160816; b=zfKRBKy477zvJ++sHMTPWnEBv6qaYGjr6ygsogr7G+FG1oCaUAOB2Gmjkad/yLM2R/ z8a+HNyjLulAKbbRy/toofz/+nmrh1PvaljabttwM8XcpYzoukUw+5PgICenNmsRCNx3 +A5Waj1pgEgsLG5ZogkoHwUYLpC7VkbiglOWYt0CNe1Vbld5OYLR5PblVimt11ZzbZx6 nCA4Nnb9912zLYBVYnEkitXV/ZU60VBCcL66fWEjQO7oomkxJqtpnL57Yl47wrQLWZxi wyCxswZX3uExnKOQhZ0M9XkYgSImlGGqlrVDp0XUpDzECDRaV93f8s/P/zMAJ3f3S+q/ 0CAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:arc-authentication-results; bh=P7Qtayqql1p8MrBlsozKFPgpWyuKemDGEGL9Qw6Gtyk=; b=nMtTOQ/uVqWILvnAZ9eiWpFAgL5uHple8Q/uZHzkTWvdcK6izTd/s6Q+K/iktHf0/W IBiYlWx2BaBkBdXPyrB56f6+GZmCDN/wx/7O+d95FeLcKdE+0XdqDPOEaW2tAoS8M09k kyp+n0/IF6q7JW6lYrtpaYbk+gvzdXII8t8e8DPJrN1l8UeiPNbAU5OAepvhMkUaSCRK HvVnTCvXNmG7kdIrBTBJKHhL0hj2ujMfbshNM8CsSbSJvdwYzV4kmguNPQz5s+aYttm8 ZX4bDGoG0jU2na/BxXLdf2iyf/nGhrf505rHsWhvZgP1sGcXa6Ny2aV8FFb6OeflUUwZ oZSQ== 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 66-v6sor1891600wmg.58.2018.07.05.04.40.45 for (Google Transport Security); Thu, 05 Jul 2018 04:40:45 -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: AAOMgpdh7v2U+NlNCR+a8gyp+dnOIkJBVqlhj7F5w3UTCnFcUGlCJXsjgiUaXkJPJtiaoZ1myaLL4A== X-Received: by 2002:a1c:c541:: with SMTP id v62-v6mr4069411wmf.57.1530790844798; Thu, 05 Jul 2018 04:40:44 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id u13-v6sm7396638wri.72.2018.07.05.04.40.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Jul 2018 04:40:43 -0700 (PDT) Received: by techadventures.net (Postfix, from userid 1000) id 2B7DF123BD7; Thu, 5 Jul 2018 13:40:43 +0200 (CEST) Date: Thu, 5 Jul 2018 13:40:43 +0200 From: Oscar Salvador To: Tetsuo Handa Cc: viro@zeniv.linux.org.uk, Michal Hocko , Zi Yan , syzbot , akpm@linux-foundation.org, aneesh.kumar@linux.vnet.ibm.com, dan.j.williams@intel.com, kirill.shutemov@linux.intel.com, linux-mm@kvack.org, mst@redhat.com, syzkaller-bugs@googlegroups.com, ying.huang@intel.com Subject: Re: kernel BUG at mm/gup.c:LINE! Message-ID: <20180705114043.GC30187@techadventures.net> References: <20180704121107.GL22503@dhcp22.suse.cz> <20180704151529.GA23317@techadventures.net> <201807050035.w650Z4RT018631@www262.sakura.ne.jp> <20180705071808.GA30187@techadventures.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180705071808.GA30187@techadventures.net> User-Agent: Mutt/1.5.23 (2014-03-12) 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 On Thu, Jul 05, 2018 at 09:18:08AM +0200, Oscar Salvador wrote: > > So, indeed "bss" needs to be aligned. > > But ELF_PAGESTART() or ELF_PAGEALIGN(), which one to use? > > > > #define ELF_PAGESTART(_v) ((_v) & ~(unsigned long)(ELF_MIN_ALIGN-1)) > > #define ELF_PAGEALIGN(_v) (((_v) + ELF_MIN_ALIGN - 1) & ~(ELF_MIN_ALIGN - 1)) > > > > Is > > > > - len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr + > > - ELF_MIN_ALIGN - 1); > > + len = ELF_PAGEALIGN(eppnt->p_filesz + eppnt->p_vaddr); > > > > suggesting that > > > > - bss = eppnt->p_memsz + eppnt->p_vaddr; > > + bss = ELF_PAGEALIGN(eppnt->p_memsz + eppnt->p_vaddr); > > > > is the right choice? I don't know... > > Yes, I think that ELF_PAGEALIGN is the right choice here. > Given that bss is 0x7bf88676, using ELF_PAGESTART aligns it but backwards, while ELF_PAGEALIGN does > the right thing: > > bss = 0x7bf88676 > ELF_PAGESTART (bss) = 0x7bf88000 > ELF_PAGEALIGN (bss) = 0x7bf89000 I think this should do the trick: I could only test it in x86_64 (with -m32). Could you test it on x86_32? diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 0ac456b52bdd..6c7e005ae12d 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1259,9 +1259,9 @@ 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)