From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03BC9C67839 for ; Thu, 13 Dec 2018 04:32:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B58E320880 for ; Thu, 13 Dec 2018 04:32:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544675566; bh=mSPnV8odF5xAoHtLwP67okvSv65+I4DGhocXF0boKkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xBOSgO1FAhbZGoX5tnzAeEjnz+5mosm60MwuuwGFICPGnuX2XKa0efGfTvxuNeovG UoTto3fx2xt03AYsfNQAKNBGGEHihKiW+I8j1RTr+FaJJQ+ZyImbZin++eUFrMnOQY A0b+hB6tFfM+ImqSgNlCZUmJnS+8Px6ZKu7EtaLY= DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B58E320880 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729174AbeLMEcp (ORCPT ); Wed, 12 Dec 2018 23:32:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:45578 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726465AbeLMEcl (ORCPT ); Wed, 12 Dec 2018 23:32:41 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A461520672; Thu, 13 Dec 2018 04:32:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544675561; bh=mSPnV8odF5xAoHtLwP67okvSv65+I4DGhocXF0boKkg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fCeUdQtZ5nuyp/xHE7UJVpFyPvpWSxO2gn/0Xabamka/3Fgx+NRj88PoVfzPEIbot F7jc+RK7C5On6uCJ2yOsmf2YsHx6hJecIM1yC+1yy67kt02RsM77u2SWlOKsh7jovV bTl940htvUJWiidHtHJ3cV/az/nq0QasGevGTetQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 24/34] bpf: check pending signals while verifying programs Date: Wed, 12 Dec 2018 23:31:50 -0500 Message-Id: <20181213043200.76295-24-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181213043200.76295-1-sashal@kernel.org> References: <20181213043200.76295-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexei Starovoitov [ Upstream commit c3494801cd1785e2c25f1a5735fa19ddcf9665da ] Malicious user space may try to force the verifier to use as much cpu time and memory as possible. Hence check for pending signals while verifying the program. Note that suspend of sys_bpf(PROG_LOAD) syscall will lead to EAGAIN, since the kernel has to release the resources used for program verification. Reported-by: Anatoly Trosinenko Signed-off-by: Alexei Starovoitov Acked-by: Daniel Borkmann Acked-by: Edward Cree Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin --- kernel/bpf/verifier.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 1438b7396cb4..335c00209f74 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -2919,6 +2919,9 @@ static int do_check(struct bpf_verifier_env *env) goto process_bpf_exit; } + if (signal_pending(current)) + return -EAGAIN; + if (need_resched()) cond_resched(); -- 2.19.1