From patchwork Wed Jan 27 03:57:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aichun Li X-Patchwork-Id: 12048917 X-Patchwork-Delegate: kuba@kernel.org 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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 33158C43381 for ; Wed, 27 Jan 2021 04:36:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5C8F2070A for ; Wed, 27 Jan 2021 04:36:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239234AbhA0EfA (ORCPT ); Tue, 26 Jan 2021 23:35:00 -0500 Received: from szxga03-in.huawei.com ([45.249.212.189]:2879 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234422AbhA0D6M (ORCPT ); Tue, 26 Jan 2021 22:58:12 -0500 Received: from DGGEMM405-HUB.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4DQVBb4zSrz57GG; Wed, 27 Jan 2021 11:55:51 +0800 (CST) Received: from dggema773-chm.china.huawei.com (10.1.198.217) by DGGEMM405-HUB.china.huawei.com (10.3.20.213) with Microsoft SMTP Server (TLS) id 14.3.498.0; Wed, 27 Jan 2021 11:57:23 +0800 Received: from dggeme752-chm.china.huawei.com (10.3.19.98) by dggema773-chm.china.huawei.com (10.1.198.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2106.2; Wed, 27 Jan 2021 11:57:22 +0800 Received: from dggeme752-chm.china.huawei.com ([10.6.80.76]) by dggeme752-chm.china.huawei.com ([10.6.80.76]) with mapi id 15.01.2106.002; Wed, 27 Jan 2021 11:57:22 +0800 From: liaichun To: "davem@davemloft.net" , "kuba@kernel.org" , "j.vosburgh@gmail.com" , "vfalico@gmail.com" , "andy@greyhouse.net" CC: "netdev@vger.kernel.org" Subject: [PATCH net v2]bonding: fix send_peer_notif data truncation Thread-Topic: [PATCH net v2]bonding: fix send_peer_notif data truncation Thread-Index: Adb0YIIEwPR58P71S3iyTFzAj5Bokg== Date: Wed, 27 Jan 2021 03:57:22 +0000 Message-ID: Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.136.112.224] MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org send_peer_notif is u8, the value of this parameter is obtained from u8*int, it's easy to be truncated. And in practice, more than u8(256) characters are used. Fixes: 07a4ddec3ce9 ("bonding: add an option to specify a delay between peer notifications") Signed-off-by: Aichun Li --- include/net/bonding.h | 2 +- drivers/net/bonding/bond_main.c | 4 ++-- 2 file changed, 3 insertion(+), 3 deletion(-) -- 2.19.1 diff --git a/include/net/bonding.h b/include/net/bonding.h index 0960d9af7b8e..65394566d556 100644 --- a/include/net/bonding.h +++ b/include/net/bonding.h @@ -215,7 +215,7 @@ struct bonding { */ spinlock_t mode_lock; spinlock_t stats_lock; - u8 send_peer_notif; + u32 send_peer_notif; u8 igmp_retrans; #ifdef CONFIG_PROC_FS struct proc_dir_entry *proc_entry; diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index b7db57e6c96a..336460538135 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -880,8 +880,8 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active) if (netif_running(bond->dev)) { bond->send_peer_notif = - bond->params.num_peer_notif * - max(1, bond->params.peer_notif_delay); + (u32)(bond->params.num_peer_notif * + max(1, bond->params.peer_notif_delay)); should_notify_peers = bond_should_notify_peers(bond); }