Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752501AbcDZM74 (ORCPT ); Tue, 26 Apr 2016 08:59:56 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34385 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752177AbcDZM4g (ORCPT ); Tue, 26 Apr 2016 08:56:36 -0400 From: Michal Hocko To: , Andrew Morton Cc: LKML , Michal Hocko , Alexander Viro , Vlastimil Babka Subject: [PATCH 05/18] mm, elf: handle vm_brk error Date: Tue, 26 Apr 2016 14:56:12 +0200 Message-Id: <1461675385-5934-6-git-send-email-mhocko@kernel.org> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1461675385-5934-1-git-send-email-mhocko@kernel.org> References: <1461675385-5934-1-git-send-email-mhocko@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1118 Lines: 35 From: Michal Hocko load_elf_library doesn't handle vm_brk failure although nothing really indicates it cannot do that because the function is allowed to fail due to vm_mmap failures already. This might be not a problem now but later patch will make vm_brk killable (resp. mmap_sem for write waiting will become killable) and so the failure will be more probable. Cc: Alexander Viro Acked-by: Vlastimil Babka Signed-off-by: Michal Hocko --- fs/binfmt_elf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 81381cc0dd17..37455ee5aeec 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1176,8 +1176,11 @@ static int load_elf_library(struct file *file) len = ELF_PAGESTART(eppnt->p_filesz + eppnt->p_vaddr + ELF_MIN_ALIGN - 1); bss = eppnt->p_memsz + eppnt->p_vaddr; - if (bss > len) - vm_brk(len, bss - len); + if (bss > len) { + error = vm_brk(len, bss - len); + if (BAD_ADDR(error)) + goto out_free_ph; + } error = 0; out_free_ph: -- 2.8.0.rc3