Received: by 10.223.176.5 with SMTP id f5csp832353wra; Sat, 3 Feb 2018 11:17:31 -0800 (PST) X-Google-Smtp-Source: AH8x224CHp0G9JsAfbxQ20pbyjKhpNmdVYCrHL7B1KAJJ7CoIRgcHs9CcH0Q6JX+iSJFI2tCNgpP X-Received: by 10.98.98.1 with SMTP id w1mr36578204pfb.9.1517685451555; Sat, 03 Feb 2018 11:17:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517685451; cv=none; d=google.com; s=arc-20160816; b=a1xscbGxPqgBpWmn0mfyy7qHeiI65Z6YeItTfDq69LyEuTGbiP6eVCIpK3f3wW69l9 fd8mUIbqt/VggYJDdXjRBlitvTTJBmNNP5MbGn6Bdn8lecJxWjO2mL1RUw52K6riMk2+ Jla7t9NjajqW1ac+UA0qV07VhRaCD4dSQ7NXWKeE0Z0CSBucZ+vXX5vkfb0cE+/tcDFP sLbfHiwyknsmxlEs0Ukyk9gnb5xMAqFQfvGpHHZz/MYxyyes1nLGWmLNBO2LfK7xLMct Ku2osmScWV6SRnqDkAHNiTEbcbcOd/EJBUeYAspSSNkK8RBYoeJTVx/Ar+D5aNh+1Pt3 Q/8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=BKvcv48zABM1KdC2w5CRC1rLZV0TjQcCMUlqB4snUtU=; b=m/yebpE5oCsXWtwktuaG41rIlhDiur6Lsz/+S3F83qu+Lsyhjwzy0fu8e6EQLxSOLg MVr7Pgb6TBwIdhkaK850ItKOtuhST4udm3AiNQU/EZ4BGJuafXysO338vaTmnM3cFWwQ rFT41QgjQkJ39mT6FWvvdxGy5ptQQVB7lbdYoKxRfDCLjP9uiBTRRoGx93LG/wePXryV JDeejuvxfwJrWzAzsUrEE+6aU4hJq3abmtJmpdsh2PIfwfE1gOkHOzyzvlECN6d1W02n YEbKL07fGNaiQw149aCi5zzdYkPXe4EBt+csz2xtd/AhihEWcscmCjaMttMoNKBfOTQ6 QlpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=LwlEPQZJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d15-v6si4293239pln.320.2018.02.03.11.17.17; Sat, 03 Feb 2018 11:17:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=LwlEPQZJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753240AbeBCSDZ (ORCPT + 99 others); Sat, 3 Feb 2018 13:03:25 -0500 Received: from mail-cys01nam02on0123.outbound.protection.outlook.com ([104.47.37.123]:2624 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752716AbeBCSAl (ORCPT ); Sat, 3 Feb 2018 13:00:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=BKvcv48zABM1KdC2w5CRC1rLZV0TjQcCMUlqB4snUtU=; b=LwlEPQZJn29UeRZVmD5IUcxUIvKHOprws0sOjZZRAwv5dOkQHDi/MUVwWO5fwROGPvPtDfM3JR6aJMMDrWMWCT4rwb4+dAxV071Ue8ICdcKHGo9SH2NmhNHqkikmpVSwtpoOXjJeWJ74HtPPg2bqeT2ROaq+8o6MvtbPszt8ys0= Received: from BL0PR2101MB1027.namprd21.prod.outlook.com (52.132.20.161) by BL0PR2101MB1090.namprd21.prod.outlook.com (52.132.24.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.506.1; Sat, 3 Feb 2018 18:00:39 +0000 Received: from BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9]) by BL0PR2101MB1027.namprd21.prod.outlook.com ([fe80::a8da:b5d9:d710:9bf9%3]) with mapi id 15.20.0485.006; Sat, 3 Feb 2018 18:00:39 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Xin Long , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 019/110] sctp: fix the issue that a __u16 variable may overflow in sctp_ulpq_renege Thread-Topic: [PATCH AUTOSEL for 4.14 019/110] sctp: fix the issue that a __u16 variable may overflow in sctp_ulpq_renege Thread-Index: AQHTnRjkYeYOzvAZ1EalFmrzR8HiFQ== Date: Sat, 3 Feb 2018 18:00:36 +0000 Message-ID: <20180203180015.29073-19-alexander.levin@microsoft.com> References: <20180203180015.29073-1-alexander.levin@microsoft.com> In-Reply-To: <20180203180015.29073-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BL0PR2101MB1090;7:2EP4a+nZ+Gcuq/JQGU8QwH2+O4UvHvHm0f24CUqNTPLqSWj7W+c5GmCUxFW1Ok7qsUm4oBp42cmZtM1bFJlwhpWEbj2JHSmOuiTOYXJxI/ppmgIY0cC633FyCjYjlL1IwKBMwEdPSFf+RNSnXNpOwGq1PzeuZa4iLdTrzxMS08Qf+o+H6IWOUK04/B49gQPoCMXkHVFqejfzYHGmmHYZKB+NnBvhV8QE8nYnP1nh0S76rx9OYlTIiAnDV4LyGliY x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: ae44d71c-2c2d-4dda-eefa-08d56b3008aa x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7193020);SRVR:BL0PR2101MB1090; x-ms-traffictypediagnostic: BL0PR2101MB1090: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231101)(2400082)(944501161)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:BL0PR2101MB1090;BCL:0;PCL:0;RULEID:;SRVR:BL0PR2101MB1090; x-forefront-prvs: 05724A8921 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(366004)(396003)(39380400002)(39860400002)(346002)(10913002)(199004)(189003)(2900100001)(5660300001)(316002)(25786009)(4326008)(14454004)(2950100002)(478600001)(39060400002)(107886003)(72206003)(6666003)(22452003)(10290500003)(186003)(3660700001)(86612001)(76176011)(86362001)(53936002)(3280700002)(106356001)(6436002)(6486002)(59450400001)(81166006)(81156014)(2501003)(6506007)(97736004)(26005)(7736002)(6512007)(6346003)(102836004)(105586002)(68736007)(8936002)(5250100002)(305945005)(36756003)(1076002)(6116002)(3846002)(8676002)(110136005)(66066001)(54906003)(2906002)(10090500001)(99286004)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL0PR2101MB1090;H:BL0PR2101MB1027.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: 6DzLFrW+/zAwYCCm5J8KqwIKgsnttDS/YyMNjeAxnMiTeMUVY7VletdT0FhK0Nk51y2sBP2s2KJU6tKLeg8cGw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae44d71c-2c2d-4dda-eefa-08d56b3008aa X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2018 18:00:36.4565 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR2101MB1090 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xin Long [ Upstream commit 5c468674d17056148da06218d4da5d04baf22eac ] Now when reneging events in sctp_ulpq_renege(), the variable freed could be increased by a __u16 value twice while freed is of __u16 type. It means freed may overflow at the second addition. This patch is to fix it by using __u32 type for 'freed', while at it, also to remove 'if (chunk)' check, as all renege commands are generated in sctp_eat_data and it can't be NULL. Reported-by: Marcelo Ricardo Leitner Signed-off-by: Xin Long Acked-by: Neil Horman Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sctp/ulpqueue.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c index a71be33f3afe..e36ec5dd64c6 100644 --- a/net/sctp/ulpqueue.c +++ b/net/sctp/ulpqueue.c @@ -1084,29 +1084,21 @@ void sctp_ulpq_partial_delivery(struct sctp_ulpq *u= lpq, void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk, gfp_t gfp) { - struct sctp_association *asoc; - __u16 needed, freed; - - asoc =3D ulpq->asoc; + struct sctp_association *asoc =3D ulpq->asoc; + __u32 freed =3D 0; + __u16 needed; =20 - if (chunk) { - needed =3D ntohs(chunk->chunk_hdr->length); - needed -=3D sizeof(struct sctp_data_chunk); - } else - needed =3D SCTP_DEFAULT_MAXWINDOW; - - freed =3D 0; + needed =3D ntohs(chunk->chunk_hdr->length) - + sizeof(struct sctp_data_chunk); =20 if (skb_queue_empty(&asoc->base.sk->sk_receive_queue)) { freed =3D sctp_ulpq_renege_order(ulpq, needed); - if (freed < needed) { + if (freed < needed) freed +=3D sctp_ulpq_renege_frags(ulpq, needed - freed); - } } /* If able to free enough room, accept this chunk. */ - if (chunk && (freed >=3D needed)) { - int retval; - retval =3D sctp_ulpq_tail_data(ulpq, chunk, gfp); + if (freed >=3D needed) { + int retval =3D sctp_ulpq_tail_data(ulpq, chunk, gfp); /* * Enter partial delivery if chunk has not been * delivered; otherwise, drain the reassembly queue. --=20 2.11.0