Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3688024lfo; Mon, 23 May 2022 11:28:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9wBOqkHVlZGjVxvYBfEJuml02x7alQV9WHYzZHSu9fyTAmLSH6+/FvQxSvkbNs3a4dl/6 X-Received: by 2002:a17:90a:31cf:b0:1c9:f9b8:68c7 with SMTP id j15-20020a17090a31cf00b001c9f9b868c7mr352689pjf.34.1653330533273; Mon, 23 May 2022 11:28:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653330533; cv=none; d=google.com; s=arc-20160816; b=sD0fz+Nfwe/IzPlTBSOGbNm8iEGFckZXR44XMjrLQiOKpLM+62pjmIhfWs6Qzz/FTF 3VVLTWkKfxEb/XwAagCHW4LoXUZKq+ArN/nW2s84xYNsaN0tjD0BX1qztP9BgpWbxlU2 uvUqiVpsobiL67NOyQg9OTUrR1Z/QlGiUlBOyj9HPhfGAVigA8qwoDRchL0s0izGIyB6 ezBnieHSR/p/eYA1axYcjEbAqqBwmyv6z0ihKnl6M3S66KmTDNEjXuCoIOWaY1AKzF5T ZWYw2506S6yPgk8bIA1vmTUjWF6rMmX61BCy8qjZ8u3L6w4boJ6sfQroXO18O4fkn/ta Z6XA== 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=OWdZfFiFo+Z7jm4wEEwcZoIyRysinQ3mziCRbtafiNw=; b=ty2otL/vn3fe665ceQOMquj3MjD56GDVCc/oimc4zeAZ4b/yhUGvE+yeeyCq/qMRL4 PBOoPv87gmbbvxG+1MVnwPne7NWwWezJSrXiQHdP5Rj7CfOFU07VY01DJ5Oon2fT1u/n SEK5uUaN9pztCdH/5iLimGEPTONfu7lg3jvqQBRiWLUNMVHQ0ScyP7zW5VCtaB+rI1+o JgOlsRU/bnMfKzHeu2Tp7th4Vf9U8CTwp2eb+dYAYfvjzgacdThqyKxAfEB5PghkbNik jy70CkcbarKoGUx5BK8e/Zs/XdowrTtPn37so8HCevuRmTlgdUFsV0iJW8/66DeZuzA1 NQFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M2cSnvPI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c5-20020a631c45000000b003f66d05b2fdsi10458621pgm.413.2022.05.23.11.28.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:28:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=M2cSnvPI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 14220122B50; Mon, 23 May 2022 11:28:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243162AbiEWRh4 (ORCPT + 99 others); Mon, 23 May 2022 13:37:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241571AbiEWR0v (ORCPT ); Mon, 23 May 2022 13:26:51 -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 BC0C474DF6; Mon, 23 May 2022 10:22:02 -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 65107B81212; Mon, 23 May 2022 17:13:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2979C385A9; Mon, 23 May 2022 17:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653326034; bh=KoZnL/bfoOswGTzV21JkUWM92+cM9p73jMe94PFGOds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M2cSnvPI62UVmdmh5YrvhBuwb61a4HOiYGsvnAFPR9w/7mfv1ZCTpE7PZ5+X1vZ9Q cg1MMZ0efrGU+ASicv3ig8wu/IxR+lU8pyfaQzO8glkkHZ3xSwg6ZezpSpkjX/Y1je C5HVEw+Ie9HeEHVeNVAbnXfXlHa9oaXeVOHmxSqw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Steffen Klassert , Sasha Levin Subject: [PATCH 5.4 45/68] net: af_key: add check for pfkey_broadcast in function pfkey_process Date: Mon, 23 May 2022 19:05:12 +0200 Message-Id: <20220523165810.033341096@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165802.500642349@linuxfoundation.org> References: <20220523165802.500642349@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=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Jiasheng Jiang [ Upstream commit 4dc2a5a8f6754492180741facf2a8787f2c415d7 ] If skb_clone() returns null pointer, pfkey_broadcast() will return error. Therefore, it should be better to check the return value of pfkey_broadcast() and return error if fails. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jiasheng Jiang Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/key/af_key.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/key/af_key.c b/net/key/af_key.c index 2ac9560020f9..f67d3ba72c49 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -2830,8 +2830,10 @@ static int pfkey_process(struct sock *sk, struct sk_buff *skb, const struct sadb void *ext_hdrs[SADB_EXT_MAX]; int err; - pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL, - BROADCAST_PROMISC_ONLY, NULL, sock_net(sk)); + err = pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL, + BROADCAST_PROMISC_ONLY, NULL, sock_net(sk)); + if (err) + return err; memset(ext_hdrs, 0, sizeof(ext_hdrs)); err = parse_exthdrs(skb, hdr, ext_hdrs); -- 2.35.1