Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1616876pxb; Mon, 11 Oct 2021 09:33:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylihffj4Yb1r58TVvigt62Ri7otiqTzyl7Cc79Gch5v46wEZjF3akCh63+f1zGbvHAlJgL X-Received: by 2002:a05:6402:5207:: with SMTP id s7mr37177109edd.260.1633970026646; Mon, 11 Oct 2021 09:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633970026; cv=none; d=google.com; s=arc-20160816; b=PoiXJjUDyFRXzAvvEmjt1++ukXGqB+x1rN8CBXj0KPeWMLe5FaoInyvk9+8DUOjWbv 75vYMqGgqe6cdmOpSrPrH0uVyTOCQp9IJFA8V2fmhnahKhceJjwfntp8qy2TYgLnkvrA hWB6zIfVTc1RPQBL+sxpN3w67/bLVvf3sCthKMBGimrTMjO4GSGJkTHb2562YHMBXy2/ dLtbpBoVcBcTH2SAUT3C3qq6J/oUcX7fEYLCJe6bwpLC/4T+FAs3yySzXuVgM9034jWk M48l9W+yCswSqwhxQrMGMhvv0ea0I/IMkN3eWsTj69pIo8zDHBGB3MJdlXl95sjVTWY9 dzFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dVNnJdpim4n4WHb/dlMjr6HC+OrzCcGLqHaK72NZw50=; b=kJpR5pHucOyk9QK+lFgHD+cxZyEdWw/22SLC60bwSvBVCgik4qlpZes6qNi/pkNiqO 0mY2OB6S8MI/RtcrKPrX0TK771PY1qxSC0BpVyYHv6VMKVzY6lL7ZIwgYob5rAaaxI3g pfgMz8pCQzD1GHnnns5PyRjGgw0Jhn0dKFWou6bhJ2nRR6dNwYky/irNeq40UViKkc/n XH5SSM01Z1b+puL4RmgJN0fqjXXRT7GcknTRuFeILLY0wN6bXxGGCvBIrUwvEUCIVByQ an8QCs4U4XrR+xeaL1695S8xSLK6toGfeF2j5kgIGhZVEaI3PpEURRzvZE26sJblLtDi sq6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uCjenP0B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z3si10893672edl.170.2021.10.11.09.33.22; Mon, 11 Oct 2021 09:33:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uCjenP0B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238380AbhJKOAr (ORCPT + 99 others); Mon, 11 Oct 2021 10:00:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:49208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238454AbhJKN6m (ORCPT ); Mon, 11 Oct 2021 09:58:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7AAE160F38; Mon, 11 Oct 2021 13:55:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633960521; bh=mPjU0xKomhCES4vTJlwmRam0i1r3BCuYgXV59/CXwXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uCjenP0BvYBuFCfOvCcZUWmhZbJh12ixjbisSVunr3wHNjBAxJLxhEhakARqDNQvA YMfT7cq8eLnhDgLrX3wG/RDPnOG3wG1QDdoTFJkGl64w2vyOorkNvbpd6r4vkgrCJ3 viKXth+q7cNaxtaWvZ1HD3Qqp8VokzGSk1IRJMvg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tong Tiangen , Kefeng Wang , Palmer Dabbelt , Sasha Levin Subject: [PATCH 5.10 70/83] riscv/vdso: make arch_setup_additional_pages wait for mmap_sem for write killable Date: Mon, 11 Oct 2021 15:46:30 +0200 Message-Id: <20211011134510.799792173@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011134508.362906295@linuxfoundation.org> References: <20211011134508.362906295@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tong Tiangen [ Upstream commit 8bb0ab3ae7a4dbe6cf32deb830cf2bdbf5736867 ] riscv architectures relying on mmap_sem for write in their arch_setup_additional_pages. If the waiting task gets killed by the oom killer it would block oom_reaper from asynchronous address space reclaim and reduce the chances of timely OOM resolving. Wait for the lock in the killable mode and return with EINTR if the task got killed while waiting. Signed-off-by: Tong Tiangen Reviewed-by: Kefeng Wang Fixes: 76d2a0493a17 ("RISC-V: Init and Halt Code") Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin --- arch/riscv/kernel/vdso.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kernel/vdso.c b/arch/riscv/kernel/vdso.c index 3f1d35e7c98a..73d45931a053 100644 --- a/arch/riscv/kernel/vdso.c +++ b/arch/riscv/kernel/vdso.c @@ -65,7 +65,9 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, vdso_len = (vdso_pages + 1) << PAGE_SHIFT; - mmap_write_lock(mm); + if (mmap_write_lock_killable(mm)) + return -EINTR; + vdso_base = get_unmapped_area(NULL, 0, vdso_len, 0, 0); if (IS_ERR_VALUE(vdso_base)) { ret = vdso_base; -- 2.33.0