From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E96AC4363D for ; Fri, 25 Sep 2020 12:49:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F4BD221EC for ; Fri, 25 Sep 2020 12:49:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601038165; bh=8cQKWKi3TD7Kebf3kj0UVr3IlrxE6U9GGJNog+QQhd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=j3iwAv+FdxmQANSODV9QwHky1Bo5GnvGMn1pHBHcNU37eId1enyuVM46+zq5P/nWH Dpm3VXLDSHlYFUHBZ+bDqzdYErn+FL2jZvG+lLS0JHGjZXUvgoTFSLXlxgvOfOngUl hwZhndxFdhpGFe0VWuhHJcBfSfREGkfOP1KIRUIQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728875AbgIYMtX (ORCPT ); Fri, 25 Sep 2020 08:49:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:52828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728866AbgIYMtU (ORCPT ); Fri, 25 Sep 2020 08:49:20 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A69221D7A; Fri, 25 Sep 2020 12:49:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601038159; bh=8cQKWKi3TD7Kebf3kj0UVr3IlrxE6U9GGJNog+QQhd8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=snQMQ7q7btAkfYw8iaRPpPxIgSxx/h7SpKMYjiJblSeVmHGc7WLk4h7HF0zJn6Tzl xacMUrKUZ3gjLnxdExTh6diAaufOXIBZRaVlnNa0tUGASJb+OoNNeGjoICBPDABFXK xrTBkIv+PF+Aif5QSAMJBeKg+aXC5ccQq3IF+2DA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Henry Ptasinski , Marcelo Ricardo Leitner , "David S. Miller" Subject: [PATCH 5.8 24/56] net: sctp: Fix IPv6 ancestor_size calc in sctp_copy_descendant Date: Fri, 25 Sep 2020 14:48:14 +0200 Message-Id: <20200925124731.462257427@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200925124727.878494124@linuxfoundation.org> References: <20200925124727.878494124@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Henry Ptasinski [ Upstream commit fe81d9f6182d1160e625894eecb3d7ff0222cac5 ] When calculating ancestor_size with IPv6 enabled, simply using sizeof(struct ipv6_pinfo) doesn't account for extra bytes needed for alignment in the struct sctp6_sock. On x86, there aren't any extra bytes, but on ARM the ipv6_pinfo structure is aligned on an 8-byte boundary so there were 4 pad bytes that were omitted from the ancestor_size calculation. This would lead to corruption of the pd_lobby pointers, causing an oops when trying to free the sctp structure on socket close. Fixes: 636d25d557d1 ("sctp: not copy sctp_sock pd_lobby in sctp_copy_descendant") Signed-off-by: Henry Ptasinski Acked-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/net/sctp/structs.h | 8 +++++--- net/sctp/socket.c | 9 +++------ 2 files changed, 8 insertions(+), 9 deletions(-) --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -226,12 +226,14 @@ struct sctp_sock { data_ready_signalled:1; atomic_t pd_mode; + + /* Fields after this point will be skipped on copies, like on accept + * and peeloff operations + */ + /* Receive to here while partial delivery is in effect. */ struct sk_buff_head pd_lobby; - /* These must be the last fields, as they will skipped on copies, - * like on accept and peeloff operations - */ struct list_head auto_asconf_list; int do_auto_asconf; }; --- a/net/sctp/socket.c +++ b/net/sctp/socket.c @@ -9457,13 +9457,10 @@ void sctp_copy_sock(struct sock *newsk, static inline void sctp_copy_descendant(struct sock *sk_to, const struct sock *sk_from) { - int ancestor_size = sizeof(struct inet_sock) + - sizeof(struct sctp_sock) - - offsetof(struct sctp_sock, pd_lobby); - - if (sk_from->sk_family == PF_INET6) - ancestor_size += sizeof(struct ipv6_pinfo); + size_t ancestor_size = sizeof(struct inet_sock); + ancestor_size += sk_from->sk_prot->obj_size; + ancestor_size -= offsetof(struct sctp_sock, pd_lobby); __inet_sk_copy_descendant(sk_to, sk_from, ancestor_size); }