Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3147562pxb; Mon, 18 Apr 2022 17:16:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHCb/2iTOkkdW62dfYzZNzd1PS7EoXNEjoozxetH2WU5Mc0gwRcTRFfJ4B9pniho9TYAQK X-Received: by 2002:a17:90b:4a06:b0:1d2:a600:3020 with SMTP id kk6-20020a17090b4a0600b001d2a6003020mr6576226pjb.87.1650327360441; Mon, 18 Apr 2022 17:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650327360; cv=none; d=google.com; s=arc-20160816; b=PmYjN3Qv8M3fTgM7+JJnyK7FCz6ZshNwF0ti6W64hj9HxY6sabBJRfqBigeD4P2q4s PjBtFoE/kCTP9WxLuIUbYsfbZtjsB585jiRRDDi31FG4aaYeQklKfA/TIQkfb7MfxH2O U4QMPxqxnZY8tSNCjbjvKZ/UOroJcP5cx8Px+xXeA6BFknqQYNYm3io//ogOFtWsLNuC KtzmfxajHoLXE4vB+QEbLJMRO8MPtTZfAqh5xH/yJrv1wG3T3XhuJT0t8gwQKi8mO2Ug RoMQmjnDgAdXjVKBlZYVkb/TZ7T0OqszZjx29+dYuWh5P+rfJiE2JJsnMUD5Xs9yc7fH jYgw== 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=nLYJYPJSLM7vxKspCMEmHGzIB/Y7Ci+ymawwl6sgYnw=; b=CCGo7dNeeHpSfbw9lbn8k5KPsqpAWPGK1KfPhgHxu+zlNVWvE9moMPrcMn1gFJ9GZg xuxp7q/b31cAR9JfU/spY8wriVl98RYviGe1kTum+lSrJXfS4ReZmlHYOct4iWRUr6fn l/MiPT6wC4k2jazC+wd8LMyIV5mbI20h/WkTM+1NWbJKGrdoht+rolm/UA8JS0ukhwDG dYr18d/zCrbrKeFU2bLE5riWa+NBPrJOV/2Cjtxg2IxauVXXjHpIwe22vtii5kPwh0VA tbzm6hoqKd3sASLkAWK6br3xdTW3Ve7cpJb1xuG08dacUu/i9Nj9PeuWSxuFWyXX4w5h qqXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o46xS19S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bj6-20020a170902850600b00153b2d1657esi10284903plb.390.2022.04.18.17.15.44; Mon, 18 Apr 2022 17:16:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o46xS19S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S243437AbiDRNlO (ORCPT + 99 others); Mon, 18 Apr 2022 09:41:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242965AbiDRNJn (ORCPT ); Mon, 18 Apr 2022 09:09:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A424236E0B; Mon, 18 Apr 2022 05:49:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 75A08B80EE1; Mon, 18 Apr 2022 12:49:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC030C385A7; Mon, 18 Apr 2022 12:49:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286144; bh=K+tDWAFZJnPKREwEHMhg1Ie2OWCsnVXB7aQ07ZjAkp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o46xS19S1wp8QQxfxVEGWTuv+gPXGkUYy43/MUfVidbN/EP0J7vps0mPL4kAGYUXd 2IXAuhex//Ej+klpWaIhrmGBIIKOrYixv4H7isSNbmEKlf3BLX1qNIVR12nWMS9kZV JaNZtuqrc5c6DX6wTIHHeQdIIVxmJMxCTTPHWNHg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, TCS Robot , Haimin Zhang , Steffen Klassert , Sasha Levin Subject: [PATCH 4.14 008/284] af_key: add __GFP_ZERO flag for compose_sadb_supported in function pfkey_register Date: Mon, 18 Apr 2022 14:09:49 +0200 Message-Id: <20220418121210.933615085@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haimin Zhang [ Upstream commit 9a564bccb78a76740ea9d75a259942df8143d02c ] Add __GFP_ZERO flag for compose_sadb_supported in function pfkey_register to initialize the buffer of supp_skb to fix a kernel-info-leak issue. 1) Function pfkey_register calls compose_sadb_supported to request a sk_buff. 2) compose_sadb_supported calls alloc_sbk to allocate a sk_buff, but it doesn't zero it. 3) If auth_len is greater 0, then compose_sadb_supported treats the memory as a struct sadb_supported and begins to initialize. But it just initializes the field sadb_supported_len and field sadb_supported_exttype without field sadb_supported_reserved. Reported-by: TCS Robot Signed-off-by: Haimin Zhang Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/key/af_key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/key/af_key.c b/net/key/af_key.c index a10336cd7f97..9b3756aa7ca2 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -1709,7 +1709,7 @@ static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sad xfrm_probe_algs(); - supp_skb = compose_sadb_supported(hdr, GFP_KERNEL); + supp_skb = compose_sadb_supported(hdr, GFP_KERNEL | __GFP_ZERO); if (!supp_skb) { if (hdr->sadb_msg_satype != SADB_SATYPE_UNSPEC) pfk->registered &= ~(1<sadb_msg_satype); -- 2.34.1