Received: by 10.192.165.156 with SMTP id m28csp1149927imm; Wed, 11 Apr 2018 13:22:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx49iSVsYwtFjsq3a/cRoqp+vRrwI9wvH0+gyeJ1Pn0zvod6Q7ecwx7e9Dvn3RHMyDVzZuaJ+ X-Received: by 2002:a17:902:10c:: with SMTP id 12-v6mr6419445plb.405.1523478169649; Wed, 11 Apr 2018 13:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523478169; cv=none; d=google.com; s=arc-20160816; b=hDQQAyqwtQmfr3453vbdRhMhk5mB0nbBpshnWJyHfXffpE603vJ6FMJXW03foNLs1r GyrRJjU87ZH9K0UinBkJvfOW7U3bDUbJN720CFsQy/wW8pqMwLqY/leofL7Mc0uG7fQ2 6oPL2a58aEPzFXiwkPFAv/JNG9n1Tkss914VosgbexsR7zq3JnoDlpF2eaGX8WqB06e6 UiJJluPPFSguWvKBbAHH8efssA/OS1Fsk8N4AWpZtj/1JXbpEQjymUZlwTtcpulpMIDO OfSv+tbH1UPIIy/RLYZXnhJGbsJ0wJacLgE2PLPwjYabkH6/N6M2H9us4ur6QxHq/t+X 7UGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8MdfAWcGScj08y1BqlClp0LFtjXcydfZ1co1XWJSf2I=; b=zCVbn9QIiLbiTmMrkHr39EQPggv+si8ekznGRR8ZGSUJiDgq0so7ttW8ySvY+HHq9S QCSkTFZpfKegfagxHtvAAsNXJ5KS+uS8aO4BinNCXxdOGeGlh+0G+v7KsVvjWrg8Llcp b88do/7ZI91d95LsutC+5TZpTGXiW8M0eqgKHQWcCwbM+BDOSYZX0+zhiz2/UIG0AOr3 WfKhDOb3ppcHk6qElVXZ+h3PVlMRSDQpW5pSmtkr54HPosvCn7E7b3k8T0z/qE9FGl7K ebpmS+08yDHRv7IMuuo4P3INd3F8shrYaBuwOrevMgINS2a7GOc6toZYeqAVlowrpASu Vaig== 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 d22-v6si1829402plr.581.2018.04.11.13.22.13; Wed, 11 Apr 2018 13:22:49 -0700 (PDT) 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 S1756327AbeDKURL (ORCPT + 99 others); Wed, 11 Apr 2018 16:17:11 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33552 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933142AbeDKSws (ORCPT ); Wed, 11 Apr 2018 14:52:48 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id AE2FFE93; Wed, 11 Apr 2018 18:52:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Konovalov , Steffen Klassert , Sasha Levin Subject: [PATCH 4.9 012/310] af_key: Fix slab-out-of-bounds in pfkey_compile_policy. Date: Wed, 11 Apr 2018 20:32:31 +0200 Message-Id: <20180411183622.833783366@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Steffen Klassert [ Upstream commit d90c902449a7561f1b1d58ba5a0d11728ce8b0b2 ] The sadb_x_sec_len is stored in the unit 'byte divided by eight'. So we have to multiply this value by eight before we can do size checks. Otherwise we may get a slab-out-of-bounds when we memcpy the user sec_ctx. Fixes: df71837d502 ("[LSM-IPSec]: Security association restriction.") Reported-by: Andrey Konovalov Tested-by: Andrey Konovalov Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/key/af_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -3305,7 +3305,7 @@ static struct xfrm_policy *pfkey_compile p += pol->sadb_x_policy_len*8; sec_ctx = (struct sadb_x_sec_ctx *)p; if (len < pol->sadb_x_policy_len*8 + - sec_ctx->sadb_x_sec_len) { + sec_ctx->sadb_x_sec_len*8) { *dir = -EINVAL; goto out; }