Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3688607lfo; Mon, 23 May 2022 11:29:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdEUYR5pUbnlB+OlQvYBPK2HomGz2MDaAjGKnGW6xtoOqcNL4+iyX8auJNx696+EooAxw5 X-Received: by 2002:a63:5d22:0:b0:3f6:55cf:45aa with SMTP id r34-20020a635d22000000b003f655cf45aamr17977389pgb.96.1653330597982; Mon, 23 May 2022 11:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653330597; cv=none; d=google.com; s=arc-20160816; b=kVlOLe9Pg1mHlvg0F5P5Z7h8JyAQiNMdisKTAJc9t1UeEFmKB5zOmUzyoF1qeFJjR3 GNekvLZgffyjwWfZanUMr6MoMkWRDUwu9ipw77+yEl2+H4t058ETbeop3vNMU0cL6eyk nKBEP9oAPFkxyEJMK4j4S/40yI2FPzK4/k+qkgd4+EAjaztipx0/TL61rXo+hs5yEw/U clhgwb+Iesvfsye3VHqHfoj0/77FxTpuAUblQ+Q8x2hJiF8gj5tO3gwxE5nlorQPg/yE cGD/0JWaW5aJkfTKNp2R660u1B3XUiu3K8AYVFIGaVXZrHtxVsVTD+RMa0WQFS/sGtjo Tu2w== 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=ZvzN0gnVHEDRn8ud2a433Yt6tKz/TdO40BqhmcenQMw=; b=F/XcJZy2YB9jhV6v06wyxvcQjYVaIosrI55/bTSi40HSGAuE0zCslBYPfTS6zlG0Ia v9PTJWsuIXaOzQskxDSSmjY5aQ7YQjL1qD7FIFgJJuOM5hMqc3lnTvSeFGvj348vre3s nEyEtk+QqcZtSptQ21E7/+T1eGbZDNnSCZZh6S6zDzJHzqfsHqCdXA4fOxiqM8wRNnuM nwjjK/Gdn+3lzqu64jD+uE1i438ryKhZy7lLMB3+Z15d83+YoHgFVABlmblsLViPmdPn MIYujlfPCopAZ24anaQ32oL8jerQ2avSC/V0Vr2dTZOaOqnu8yJJr6rhFV/X3tIilddJ Aebw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mzNM2gXy; 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 p33-20020a635b21000000b003f5f3fc0d1fsi10924064pgb.57.2022.05.23.11.29.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:29:57 -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=mzNM2gXy; 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 B1C15719DA; Mon, 23 May 2022 11:29:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240185AbiEWRQG (ORCPT + 99 others); Mon, 23 May 2022 13:16:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240350AbiEWRL6 (ORCPT ); Mon, 23 May 2022 13:11:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D338E1BE98; Mon, 23 May 2022 10:11:27 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 963D1614E9; Mon, 23 May 2022 17:09:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 949D3C385AA; Mon, 23 May 2022 17:09:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653325776; bh=uDIOecDU8Abr+cZEuvulgCr1RfQHBxfq9SyEzp2mV1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mzNM2gXywURdWaPHZ0kSfVTm/ufRrFc2MOloT5T+Qs7n4EII6J62GOyzHt/FrgMvP tSPN/U3z/f6UzZh0o5+1/LTMRWFqqgPhvI2E5sdGpKf3em+PPpFvr8ylvKlYOmRXiq +mhkuljnTP6Fah1CtBajFwy/MAagLVX7Tt3pAYSk= 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 4.14 19/33] net: af_key: add check for pfkey_broadcast in function pfkey_process Date: Mon, 23 May 2022 19:05:08 +0200 Message-Id: <20220523165751.192947211@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165746.957506211@linuxfoundation.org> References: <20220523165746.957506211@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 d7adac31b0fd..3d5a46080169 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -2834,8 +2834,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