Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6135476iog; Thu, 23 Jun 2022 12:05:24 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t6Nrx3/al9knr7mMcBkQ/oJMgB7WRYEgW4yp/CVf1oeGE2nJqYT0i/Nw+aDt87seskb77H X-Received: by 2002:a17:902:d2c9:b0:16a:578f:c356 with SMTP id n9-20020a170902d2c900b0016a578fc356mr5049468plc.4.1656011123851; Thu, 23 Jun 2022 12:05:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011123; cv=none; d=google.com; s=arc-20160816; b=PeEMYhRNlkIUfEe4A2MlHMVUSSuebOMjw79AtQQRID1R/Qr3za1Z5nSCpBxD33r/Jn zEQQc3T3EiJJC/O6WE0gKkgP45z9JqSOBdS4DZs+rvbJsP4fmbgpme9o7kWTzi8e6L4d wK2gBZIE7+ArHt+wKl5nv8DTsn64KFGnuoDoJAgkcBHzKbH0lWdLNTySBoMVzUaz9MhJ HMbqxbwDBmEFbqhhDD0elkHimAVBv+U4Pho+IU+WoKxBojLFD81Ux12zosYvBg9fhQMr 3LiMuIQAQgxpocVtUD0UYTpx3M0cXz+B8ovMWsFeNK2xqed2EqsX40Zqh2g+1IaM6m6L ZgOw== 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=AHlN5450XZP5O0e+xN3IO8w9HGF0UkZ1as9pziTcerM=; b=awAquBUMaJOnRBGXmQXfHVJ6JyzMX7IXm4gJWbnITeRQWanVMZ66K0G4GS2Ef3W07I gkPV5ss4lyR4jSUE1XiVJ6CZQO/+hp3u3E6cWOgNpeV7fwTmKp/fkUmJtAamgPsBpSP6 Z4Sqan4zbyzJsUcZmSuGlB7xDvO9pBw3sYypzwbpuyPIiTQZHL2Zrdj38q5Ybuz9Vsov v+m/aH/sGWHC7Qi28CWW/Hr9Fm2ZHHNJu9oJlyx8RgsXqm1939ji/1NBQ8PFtuq5wt5V E/XV0ye7VvSdYK4onHw+F3oXgXJ1SAzRu+Ldk26F58T9iSx0hyUgf4idBj1kZS24RAjk y7bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=eHJLPzzB; 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 b5-20020a1709027e0500b0016a4179aec5si335648plm.361.2022.06.23.12.05.09; Thu, 23 Jun 2022 12:05:23 -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=eHJLPzzB; 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 S231634AbiFWRLc (ORCPT + 99 others); Thu, 23 Jun 2022 13:11:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229639AbiFWRJz (ORCPT ); Thu, 23 Jun 2022 13:09:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA06755367; Thu, 23 Jun 2022 09:57:33 -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 10CE9B8248C; Thu, 23 Jun 2022 16:57:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E0B8C341C6; Thu, 23 Jun 2022 16:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656003427; bh=hpr7dPZ5XWl9ycqC+kESLO4L50zCczShqrP2GtHInnc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eHJLPzzB2GCJvPp9bJcjBqjNEbf4vTphrPod6i7XSLInhdhI8JV9qV9EDxlp7bvKF jy4fEzoFpoUZPX5RWuSph29Km4WsexvuOzicafq/eJ4j//kOIQYVjJXc1HMlooLSfz uvKeeT8qAMbBw88TvhdT0mTtyp49Vyc39pyJw0jA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wang Yufen , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.9 235/264] ipv6: Fix signed integer overflow in l2tp_ip6_sendmsg Date: Thu, 23 Jun 2022 18:43:48 +0200 Message-Id: <20220623164350.725799345@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@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: Wang Yufen [ Upstream commit f638a84afef3dfe10554c51820c16e39a278c915 ] When len >= INT_MAX - transhdrlen, ulen = len + transhdrlen will be overflow. To fix, we can follow what udpv6 does and subtract the transhdrlen from the max. Signed-off-by: Wang Yufen Link: https://lore.kernel.org/r/20220607120028.845916-2-wangyufen@huawei.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/l2tp/l2tp_ip6.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c index 76ef758db112..e412020029df 100644 --- a/net/l2tp/l2tp_ip6.c +++ b/net/l2tp/l2tp_ip6.c @@ -518,14 +518,15 @@ static int l2tp_ip6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) struct ipcm6_cookie ipc6; int addr_len = msg->msg_namelen; int transhdrlen = 4; /* zero session-id */ - int ulen = len + transhdrlen; + int ulen; int err; /* Rough check on arithmetic overflow, better check is made in ip6_append_data(). */ - if (len > INT_MAX) + if (len > INT_MAX - transhdrlen) return -EMSGSIZE; + ulen = len + transhdrlen; /* Mirror BSD error message compatibility */ if (msg->msg_flags & MSG_OOB) -- 2.35.1