Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6140904iog; Thu, 23 Jun 2022 12:11:45 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tAwvkp+Y9ACHwl542cGI1H9kXw8SGfmPgjEXzy8TWmcHYXumjbt8eNycubfPqnOFEeS00E X-Received: by 2002:a17:902:cec4:b0:16a:1fc3:b6e6 with SMTP id d4-20020a170902cec400b0016a1fc3b6e6mr23280602plg.129.1656011505077; Thu, 23 Jun 2022 12:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656011505; cv=none; d=google.com; s=arc-20160816; b=TRqMXPmb6L54Pp9sOEy0rMCEg7hfSQoFAqpI7q7sLK7x/uOL7d8pX0ST8O7xqIXO7e AsBydyYMgCX4uCrkue4nsA8aV9Vxy9TTBxLSTItryvQT6w+HtNZ6KbJPE76R9mWX/RIP Czph6gYEgq1BMCk4/MxlK6c0a2+jUhL+k6PchW8PWlKnBqNgA01a56LnoCDHBTZqzp3i RnUt4K/wUO/7TE45zw5+IcyqmmjGvJ4DKb0m5y3IWiQA2lDl3NINBdt0J6XIApMyUVgO YPbDYxqCaTymB3O4wjX+AyM+jzjQCULUgb1nT6lQmIMASeZECQvPoOzuDZPHYaqd+ZQ9 rQBQ== 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=1QSUCldHfxcyLI3i3W24dgeN/Hlp3loL3FfNellWC6s=; b=SVkAnQq1spTenyHrTbF0x+c80OqslXgBZLnA6ePwJh5yp68sh4yOc8n80pchD7MyTr 3DYjhUMed9YZjNVcGGKHV9W0KAuFt6X0V9Dz4nNDVsUp5PPUqv0a3I+RyreveE7vkjjx 2PAXohlBs7eUQk2A4iN2arARSmVBoyUHtH6hjYPeQW5rAzuELXoOom+yjLzTh2dytWhK ItqdH/fzOHRD0ZITI1hZdMj1kTnXnTHKr7q01+YIjFCoJXkHsO2RNdaNjTvSnpXMWEr4 lYJXp3Lr4yNSgwL4icSUEnCzbuwla20ECOw8isMBBSWm2irMTBQ2v4Bm1uLyNWdRO3pZ RLfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="U/pB3EpZ"; 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 b23-20020a17090acc1700b001eac98dbaedsi219248pju.78.2022.06.23.12.11.33; Thu, 23 Jun 2022 12:11:45 -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="U/pB3EpZ"; 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 S236969AbiFWSTV (ORCPT + 99 others); Thu, 23 Jun 2022 14:19:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234164AbiFWSQD (ORCPT ); Thu, 23 Jun 2022 14:16:03 -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 BF275C1639; Thu, 23 Jun 2022 10:22:16 -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 3ADDAB824B8; Thu, 23 Jun 2022 17:22:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AD51C341CA; Thu, 23 Jun 2022 17:22:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656004933; bh=ELWPu2WsVA7XBvgFySoXF2QkOya+kpglczV7K/lrUXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U/pB3EpZNsAiFYmgv0nLsdXMbP9VzDOkcEGIVU3seV55f/UHK5n/wZUPNajTc8qIV LMD94uXDemnSraCKjyDpbDGH9UqYfKCpOi4uPNA50wi5nHmAmOVczzcMJnAn61uj9G wNtOMuOFMKWze7MEJUqwbSchh6fxvxbkmP4o+Lmg= 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.19 196/234] ipv6: Fix signed integer overflow in l2tp_ip6_sendmsg Date: Thu, 23 Jun 2022 18:44:23 +0200 Message-Id: <20220623164348.594784982@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164343.042598055@linuxfoundation.org> References: <20220623164343.042598055@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 2ff25c445b82..9dae10d8880c 100644 --- a/net/l2tp/l2tp_ip6.c +++ b/net/l2tp/l2tp_ip6.c @@ -519,14 +519,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