Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3335361imu; Sun, 11 Nov 2018 12:38:06 -0800 (PST) X-Google-Smtp-Source: AJdET5cfMYR6OjNV62bEqZZg1936SppGa0wUJTMlFiCfxTuu+hzI3/y3MZmSZ6Oq8bl+Z9pqSZFO X-Received: by 2002:a62:1095:: with SMTP id 21-v6mr17276871pfq.227.1541968686884; Sun, 11 Nov 2018 12:38:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541968686; cv=none; d=google.com; s=arc-20160816; b=K1okpEkJ3gCYe7kKgWf3OwqnQ9IDZZXwlzH5sNlnvIxS9z4dBiOkC0+74o/m6yMsuk KqEXLkAAyFSy+tdniUOtzxgRK9w2lj+OVIcDWlbdWl7CVldL89kWNZicOodCgNRaNMnw dhzxO/G2zf5Xzdd/Ts1xhk0Qh1AO4v5Hj89mAhEG9bC/C1VfoWlvIu+9GRCNZPskdVcy Tp1GhVjjGhSSyKH1ZwwTNvuPq411U2wuN+CqxzOQTkNU7m9s8/3UTSYOoVBG7U080o2S nmP138X3jwF9VapP/O/dnpHZUjpVgTL2HVDDhaZlf3+6RSQ088CXL47siy0uvZmKZAQc WdIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=ALmkoeGswmIUH6YhDINf0Ah92uhJCH70HbtepbJPliQ=; b=zryaTydX61CgVuinlOSdg46beUycjk9ih2AiRRf6mL5wl6XPw1nh7f3UAIMT0tHsqf FDbcZdxyeVl9yX5rwyqWRNk6JRFwP4ER37t9r+Wgjg9PsAQbZ5WNPFhs7RRuju6BWsAS gDVhyAPD2u9zrcjFr4eAfk/yrnv6RQTO4ZWeQs+p9WFtltNd3msUk85Rl72vMAjrtSsr zCEsZTRulYUpWn/gXrDOHXJDHcByF1Q3U8e4f5eSTa756qJDEhwuOFO/7oQKuSJbCR9n TAytbZo7G5gIi58Ppm1ns8ZvzERLOi16mMNA2rD8+qlpBzqSm2YK8RmIDRvDuwk4riLt nEIA== 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 r10-v6si14731426pls.380.2018.11.11.12.37.52; Sun, 11 Nov 2018 12:38:06 -0800 (PST) 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 S1730356AbeKLGZt (ORCPT + 99 others); Mon, 12 Nov 2018 01:25:49 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:49866 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730145AbeKLFsM (ORCPT ); Mon, 12 Nov 2018 00:48:12 -0500 Received: from [192.168.4.242] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gLvsY-0000lM-Pb; Sun, 11 Nov 2018 19:58:42 +0000 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1gLvsW-0001iy-D7; Sun, 11 Nov 2018 19:58:40 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Michal Hocko" , "Alexander Viro" , "Linus Torvalds" , "Vlastimil Babka" Date: Sun, 11 Nov 2018 19:49:05 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 250/366] mm, elf: handle vm_brk error In-Reply-To: X-SA-Exim-Connect-IP: 192.168.4.242 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.61-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Michal Hocko commit ecc2bc8ac03884266cf73f8a2a42b911465b2fbc upstream. 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. Signed-off-by: Michal Hocko Acked-by: Vlastimil Babka Cc: Alexander Viro Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Ben Hutchings --- fs/binfmt_elf.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -1084,8 +1084,11 @@ static int load_elf_library(struct 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: