Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp442378iog; Mon, 13 Jun 2022 06:05:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKOQ6DyaxqFrV5rZOhcv0KTfrCeGK4fklWRZ2nRm59O+6OciMADBZtdOFJ/8+zJL+5dvqX X-Received: by 2002:a05:6402:42c6:b0:42d:ed84:6fe0 with SMTP id i6-20020a05640242c600b0042ded846fe0mr64989322edc.58.1655125551860; Mon, 13 Jun 2022 06:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125551; cv=none; d=google.com; s=arc-20160816; b=K9Z6dTXfa1WDzUQrFU3l1xmvFShZdujgJ7LH+VDF+ejaYpmZJJYScop8OtDnsaTSV6 qFchEH/j57zAAxvUAcHHXHfXuUTs59as9kaKUA6k+8+D8gxUYphrmQnhiKWc3JZgkF8H HBX3g5dReT36bqt6IAkUz1DLOuVSo2WiGBTkT+hWbSae9t3qJ5DNutNMLatS8GqgtMRU peHEWs5MdIady7mi1jURxO7hDdSvWv2A0pZKReOycJ1meBPBd7/xRgv932ui7uSGtUHY f72cyP0L/y5k2akiXO0VsjFFps40BypEcf8Gi63rdody9rEOZJAzcWlXbj27x1cCUMXQ Wq1w== 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=QFA6Q9Y8q6E3AHUWgQxqC2RxEhcEG7MB+JvxCEM3c1U=; b=Df88CpkowmfvE1xbCtjEVQjmb80v0AzZG3WRnf8ciEHVfWJCG7QaSIoKBokFpMGCga 1Nag5A9K/PtFHGHTfpqxP26YzqV5yKt5Ps/qvp5y2joPCGXznEYOyVL0EhDPIGFmBxSV bZEusAAKkUNJrgKoBhiw2d/me6ef7OguH+xbZvf4c62ICt0eXY261SO6lRxrHbtsYHLP ZB73payUvkp+tpvsRRSrK9ku0nQRozJhpKDRIKKEUjUeeYly49biLg4iUaY8Rl3qYjoM ieFXDzIbSDoPe2w2vk2wi7y7S8EOPXUfRvZZPc/QQFOm6u9VVgE8S9q5rJLdLG3FDe19 73BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f6WTcSC9; 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 l22-20020a50d6d6000000b0042db0cc3333si7079298edj.149.2022.06.13.06.05.18; Mon, 13 Jun 2022 06:05:51 -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=f6WTcSC9; 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 S1355571AbiFMLto (ORCPT + 99 others); Mon, 13 Jun 2022 07:49:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357465AbiFMLqL (ORCPT ); Mon, 13 Jun 2022 07:46:11 -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 6A8BA25DD; Mon, 13 Jun 2022 03:52:21 -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 E7E36B80E59; Mon, 13 Jun 2022 10:52:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BB4AC34114; Mon, 13 Jun 2022 10:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117538; bh=B3CqHOh+r9Ah6UrcI7btJ319nsIqtZeEw+NhcbAMHUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f6WTcSC9hNHsp+o7FFO9AyYV+s9zMARAUNSq5lfasuEgxHDzRkOAsOVher/TV65J9 Jz8Uh5Jp0iBIE2R8XJjg5Uj6JuMWYe/KnhQD5P0jWvFax56z5B7Cim5q2EyPDdKZwR YMMKjSCDun3hMGv1avWeAuCxfR3W6TaIJJZHjWhE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Kubecek , Steffen Klassert , Sasha Levin Subject: [PATCH 5.4 387/411] Revert "net: af_key: add check for pfkey_broadcast in function pfkey_process" Date: Mon, 13 Jun 2022 12:11:00 +0200 Message-Id: <20220613094940.276049065@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094928.482772422@linuxfoundation.org> References: <20220613094928.482772422@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=-8.3 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: Michal Kubecek [ Upstream commit 9c90c9b3e50e16d03c7f87d63e9db373974781e0 ] This reverts commit 4dc2a5a8f6754492180741facf2a8787f2c415d7. A non-zero return value from pfkey_broadcast() does not necessarily mean an error occurred as this function returns -ESRCH when no registered listener received the message. In particular, a call with BROADCAST_PROMISC_ONLY flag and null one_sk argument can never return zero so that this commit in fact prevents processing any PF_KEY message. One visible effect is that racoon daemon fails to find encryption algorithms like aes and refuses to start. Excluding -ESRCH return value would fix this but it's not obvious that we really want to bail out here and most other callers of pfkey_broadcast() also ignore the return value. Also, as pointed out by Steffen Klassert, PF_KEY is kind of deprecated and newer userspace code should use netlink instead so that we should only disturb the code for really important fixes. v2: add a comment explaining why is the return value ignored Signed-off-by: Michal Kubecek Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/key/af_key.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/net/key/af_key.c b/net/key/af_key.c index dd064d5eff6e..32fe99cd01fc 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -2830,10 +2830,12 @@ static int pfkey_process(struct sock *sk, struct sk_buff *skb, const struct sadb void *ext_hdrs[SADB_EXT_MAX]; int err; - err = pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL, - BROADCAST_PROMISC_ONLY, NULL, sock_net(sk)); - if (err) - return err; + /* Non-zero return value of pfkey_broadcast() does not always signal + * an error and even on an actual error we may still want to process + * the message so rather ignore the return value. + */ + pfkey_broadcast(skb_clone(skb, GFP_KERNEL), GFP_KERNEL, + BROADCAST_PROMISC_ONLY, NULL, sock_net(sk)); memset(ext_hdrs, 0, sizeof(ext_hdrs)); err = parse_exthdrs(skb, hdr, ext_hdrs); -- 2.35.1