Received: by 10.213.65.68 with SMTP id h4csp2139823imn; Sun, 8 Apr 2018 20:43:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx49ptAM6tA0lIiT/0GXugJaMQUEh2dYmGL1o2dPw7duZtn9vvk7YdVrzSafT1xR1EfDXUb6+ X-Received: by 10.98.205.69 with SMTP id o66mr28021110pfg.34.1523245412005; Sun, 08 Apr 2018 20:43:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523245411; cv=none; d=google.com; s=arc-20160816; b=KwfznNvedNJfNDHVbz6A5UE7ybUtVMI7btI+8u2mENfbzyg0G3uiJxWNAaL9HTqK+C zQ09lsENpxD7QwRQu5ZD3uvU9ySq+Ye+RfJsb4taL3h7BOh8f1eCcGz54GEGAjck2NYB CGqCNm7B8LVUuCvS1xQZEYkG2FzSYhMnCOVf0vm7p4mH7BrwBdI1SPCH7B6twmxydl34 CH68sDOHJVKI3NQ3F2Jo1MoOXYa23DbUBKTicloJ7rmgRcm5/UDpSl82OWhNkDVE2DkM zLh4PQIBm7qT4AWLTnyIO9XGWQvvKV6ApzyzmqU/8HtJy5jAhziu01A6QFHbsLwuhfkC RefA== 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=i29+go92zk4ryS/tJ/9O12hsF805V9pPVEV5EZQeIP4=; b=cjZCQ83ewBjfr8eBDaBLGlVg78CnL2L5rlCdqwikLF6/IfJV2t83hSx5OAHAqRFDJt ScQiOymE+5n5W+vSHJyNtBp6YTo/Hf74XuwdZ5vMm91XG7AR9uOaZn0aJ83BO/+oBmiu LruRkUacLoR0A/OZmGKFPiP5rvq0Q06GHMNgfblSXGSGtAL/EPGf4As51MK+kIbAt74G N8NmHn7p6ZH6FG3eZjvcFmsDk2yWlTG5dOW/1Q8PCVpaHNq4mW4vU1iP64/BL3Ryn7ey 7i9wy3xZTL6X+cRmd/UDDa6zGp5sYbp5fBHO412tgPwnxHr2mbeh0Bequqbn4ja4sKZy DF0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=SLCN9U6M; 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 1-v6si13109690ply.119.2018.04.08.20.42.54; Sun, 08 Apr 2018 20:43:31 -0700 (PDT) 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=SLCN9U6M; 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 S1754726AbeDIDfI (ORCPT + 99 others); Sun, 8 Apr 2018 23:35:08 -0400 Received: from mail-bl2nam02on0107.outbound.protection.outlook.com ([104.47.38.107]:21664 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754417AbeDIAVQ (ORCPT ); Sun, 8 Apr 2018 20:21:16 -0400 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=i29+go92zk4ryS/tJ/9O12hsF805V9pPVEV5EZQeIP4=; b=SLCN9U6MxTU1Ue/GuMzCRgVcN/kg2E7urFq1wMXZv87qRIj3kXNU3n8+48XIbeYIhppWC/ya3zgSxLIQh7/5Ev26f5qX/80fKt9m93uNq77IhYZ6y807qIRbcRS4AhPXxVBc9xKTmw0POQTXXUnSi/iFQRqCnslUJ7UaUUC6a2c= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1125.namprd21.prod.outlook.com (52.132.130.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:21:11 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:21:11 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Hoang Le , Jon Maloy , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL for 4.15 172/189] tipc: fix skb truesize/datasize ratio control Thread-Topic: [PATCH AUTOSEL for 4.15 172/189] tipc: fix skb truesize/datasize ratio control Thread-Index: AQHTz5heujeJ1c5eakyfP9EYSKwlbg== Date: Mon, 9 Apr 2018 00:19:05 +0000 Message-ID: <20180409001637.162453-172-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-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;DM5PR2101MB1125;7:RDarRnrSvgWM+kooLooMgz0SfDkxB/SSsTEPzUB4BtjlhMKc7TQ7vRt9saWI4nhOBIsITc9kX90lWS+EsBVTZGmfY5nNlidLTmtmHKCqqBMpgJGxNEOrm2Sf8fqmdAmh++BxA9sJu3ivuDHvAhz2mLC7kfD7OM1oIV+KCrHFYnW2bHPFKrJ7Tw36zmze+t5o+88g3C9uDa/lugQJulytE+fCbT+RIf7p7Z4PZpPnJLz2W/DdYw6FEJbO5KFBCakf;20:F5OXB/fC0XPbe4xYnV08D6QY9lgdUw0tKbFd8ke/4dZO3ezfi+GRHDKcI3AWP6+j1XWrzOKxCZ1PcVM0cEog++imLJsU+oq9gTprM2pDoD0exxDoQLbEFyS3u+unGh6U53MffTaZx//WyA4G+2ovwC2gefH4TopS4KdzBBNs1bc= X-MS-Office365-Filtering-Correlation-Id: f6ae27a9-7926-45e6-fea4-08d59dafcc49 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020);SRVR:DM5PR2101MB1125; x-ms-traffictypediagnostic: DM5PR2101MB1125: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(37575265505322)(28532068793085)(89211679590171)(788757137089)(46150409022019); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3231221)(944501327)(52105095)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB1125;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1125; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(366004)(376002)(396003)(39380400002)(39860400002)(346002)(199004)(189003)(105586002)(7736002)(8676002)(97736004)(81166006)(59450400001)(106356001)(81156014)(305945005)(14454004)(66066001)(1076002)(102836004)(5250100002)(478600001)(2501003)(2900100001)(22452003)(72206003)(68736007)(26005)(86362001)(575784001)(8936002)(76176011)(6506007)(6116002)(6486002)(186003)(5660300001)(3660700001)(316002)(54906003)(110136005)(25786009)(2906002)(10090500001)(6512007)(3280700002)(6666003)(10290500003)(53936002)(99286004)(86612001)(3846002)(6436002)(486006)(4326008)(2616005)(11346002)(107886003)(36756003)(476003)(446003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1125;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: 5vIhuuf+aCOxpBQwrO7v2IB4fMeQoMwZnR/IJbCQ/m2ebEHd0Tj5dTxTRiQ7VY+RwVRYfHwAbgQF9JzEXsGJmZR4g4TqEIKp0jqJp39nliI1EwSbqNIdr+rZwZeNgF21oJhZyZfIU51N7y6lymxrXb73U54IGjl9mqVzOVdr0Z8hQ8S9ipZsNoxoCBTpxA+B3a1/bXsSr+mvMaKm7f+W8oqAqdjR40HuxLi5TEdJlqfjBHuFhdo14kfJxqV6Zl2FxsdHhvxbYmFaY/1RIVLOUHtPiKMMV/ew7xyJfUcDYgz9g4ahTGxG0jnhoIH5UFx++v1jOYr5TFLhRv10QSVb6KFrtLyNRR/qOOfNgH5fzJx1XIILTzjbIKWoLhtuVyqMyh1/qLGbXXSWZOG1EYULgT2g+gwnX+RWFQPqVISncIY= 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: f6ae27a9-7926-45e6-fea4-08d59dafcc49 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:19:05.4240 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1125 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hoang Le [ Upstream commit 55b3280d1e471795c08dbbe17325720a843e104c ] In commit d618d09a68e4 ("tipc: enforce valid ratio between skb truesize and contents") we introduced a test for ensuring that the condition truesize/datasize <=3D 4 is true for a received buffer. Unfortunately this test has two problems. - Because of the integer arithmetics the test if (skb->truesize / buf_roundup_len(skb) > 4) will miss all ratios [4 < ratio < 5], which was not the intention. - The buffer returned by skb_copy() inherits skb->truesize of the original buffer, which doesn't help the situation at all. In this commit, we change the ratio condition and replace skb_copy() with a call to skb_copy_expand() to finally get this right. Acked-by: Jon Maloy Signed-off-by: Jon Maloy Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/tipc/msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/tipc/msg.c b/net/tipc/msg.c index b0d07b35909d..fb8dda66db6d 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c @@ -208,8 +208,8 @@ bool tipc_msg_validate(struct sk_buff **_skb) int msz, hsz; =20 /* Ensure that flow control ratio condition is satisfied */ - if (unlikely(skb->truesize / buf_roundup_len(skb) > 4)) { - skb =3D skb_copy(skb, GFP_ATOMIC); + if (unlikely(skb->truesize / buf_roundup_len(skb) >=3D 4)) { + skb =3D skb_copy_expand(skb, BUF_HEADROOM, 0, GFP_ATOMIC); if (!skb) return false; kfree_skb(*_skb); --=20 2.15.1