Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2953203pxb; Mon, 18 Apr 2022 11:50:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxE8/A/7uynT/rme1HoUKZLtG0gkXR7MbjVzuZjgEFMizAyu2ZmRYAaQDf8VLkbfNYGoA6f X-Received: by 2002:a17:902:778a:b0:158:da0f:f299 with SMTP id o10-20020a170902778a00b00158da0ff299mr12034923pll.29.1650307855377; Mon, 18 Apr 2022 11:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650307855; cv=none; d=google.com; s=arc-20160816; b=jrSoNlNpjbr7mM8SsXBVjIfUqnBajAQlcEC3GR8DIhBYJtSaGhq0yxNbK3cmsKpoKE FXqh83TTFrVBatmE3R4uuFbFsiHzU705aW9cY6+PaUahti+nk8CAparfT0/PIMtlkPLx TBCh88Gkwi83aiDkZctjoTtzxv/S/Y5yauKoQ6G9iThVwAeYF8Q9ALFIIBq9ktnJDDae HviZvfL2Wl8SK8IHDRvngFrCKaSFc5UsZ82jEr0dCxEKf3pKkOu0HaqilXBsFPbnXt+2 +pcGIlVAmINWu9nc0IEFt08Oqq9Fl5WbRyXzpqn6Jl3Mx+3a+N+gwa/uNmwv7bbG/LZc 7r4g== 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=4Roq7KKO8cq8WYjkPwfAPKniJcmbQxfyxuiXf3gUxBA=; b=uSXoQkjrHBISVWTMK4oZEk2a2IC6SlF+T2JQ8l0SidVvXX5NxMwveQqgczssyLrw7C Y9C7H09d1YCijt4sszbj8O2t6jRFBbq7mxa7Snuq32XVawjfcAi6UowoGRrv2lIrhVIz 872vKvHdGndTrt7+Jscwcw+F9P4JE3diGjOQ+tbGJnJzYpcVaqT2LDxyBJOP4AEU7k69 o1wHwN7wOhQgPd2K2uDMtWC3O5906GA0ET3FgaNQaP9gJ2NLmeTLkVUIZe8E+KUY/M3B K8Rm4EQh03JPqMfjp4ZD6nbj4fjx6zw9JZbkYk0ZBx0QgRT+dpWmsMitkbqU/nQNFL4v OuAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VGN8+KmQ; 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 h134-20020a62838c000000b004fb2e2495e3si9491745pfe.252.2022.04.18.11.50.39; Mon, 18 Apr 2022 11:50:55 -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=VGN8+KmQ; 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 S238459AbiDRMYv (ORCPT + 99 others); Mon, 18 Apr 2022 08:24:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239025AbiDRMXS (ORCPT ); Mon, 18 Apr 2022 08:23:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DAFF1FA5E; Mon, 18 Apr 2022 05:18:48 -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 6853760F01; Mon, 18 Apr 2022 12:18:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74EE9C385A1; Mon, 18 Apr 2022 12:18:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284327; bh=CsCTfSsNjHS16QQ1DIkCgSALfrwY92Y131KIND27RZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VGN8+KmQolXWpXwlROHJiGI7Y4bofTsZyB6OQgcZcnL1J/UwImWtIPs6kRo0pxR67 xYhhUng9U9wRMyen+8Zd/GUaO3EOn68fFbHemwJjI16Uuy2EC7EhbaRiaMLjookbjU moMQFi7fsto7WjLT4GInjoRz77TRNWqPsc2cT+hQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yi Chen , Xin Long , Ondrej Mosnacek , Marcelo Ricardo Leitner , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.17 076/219] sctp: use the correct skb for security_sctp_assoc_request Date: Mon, 18 Apr 2022 14:10:45 +0200 Message-Id: <20220418121208.176976872@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@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: Xin Long [ Upstream commit e2d88f9ce678cd33763826ae2f0412f181251314 ] Yi Chen reported an unexpected sctp connection abort, and it occurred when COOKIE_ECHO is bundled with DATA Fragment by SCTP HW GSO. As the IP header is included in chunk->head_skb instead of chunk->skb, it failed to check IP header version in security_sctp_assoc_request(). According to Ondrej, SELinux only looks at IP header (address and IPsec options) and XFRM state data, and these are all included in head_skb for SCTP HW GSO packets. So fix it by using head_skb when calling security_sctp_assoc_request() in processing COOKIE_ECHO. v1->v2: - As Ondrej noticed, chunk->head_skb should also be used for security_sctp_assoc_established() in sctp_sf_do_5_1E_ca(). Fixes: e215dab1c490 ("security: call security_sctp_assoc_request in sctp_sf_do_5_1D_ce") Reported-by: Yi Chen Signed-off-by: Xin Long Reviewed-by: Ondrej Mosnacek Acked-by: Marcelo Ricardo Leitner Link: https://lore.kernel.org/r/71becb489e51284edf0c11fc15246f4ed4cef5b6.1649337862.git.lucien.xin@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sctp/sm_statefuns.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 7f342bc12735..52edee1322fc 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -781,7 +781,7 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net, } } - if (security_sctp_assoc_request(new_asoc, chunk->skb)) { + if (security_sctp_assoc_request(new_asoc, chunk->head_skb ?: chunk->skb)) { sctp_association_free(new_asoc); return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); } @@ -932,7 +932,7 @@ enum sctp_disposition sctp_sf_do_5_1E_ca(struct net *net, /* Set peer label for connection. */ if (security_sctp_assoc_established((struct sctp_association *)asoc, - chunk->skb)) + chunk->head_skb ?: chunk->skb)) return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); /* Verify that the chunk length for the COOKIE-ACK is OK. @@ -2262,7 +2262,7 @@ enum sctp_disposition sctp_sf_do_5_2_4_dupcook( } /* Update socket peer label if first association. */ - if (security_sctp_assoc_request(new_asoc, chunk->skb)) { + if (security_sctp_assoc_request(new_asoc, chunk->head_skb ?: chunk->skb)) { sctp_association_free(new_asoc); return sctp_sf_pdiscard(net, ep, asoc, type, arg, commands); } -- 2.35.1