Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp692969rwb; Thu, 8 Dec 2022 01:30:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf4EbqpNj1dsVsvw9QbX8ySY6tLZuvdPk6ki5Z7UY4G6rtOcRdbW4CcuEOsxAjxRAyLGCVUW X-Received: by 2002:a17:906:39c8:b0:7ad:79c0:5482 with SMTP id i8-20020a17090639c800b007ad79c05482mr68756161eje.730.1670491848208; Thu, 08 Dec 2022 01:30:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670491848; cv=none; d=google.com; s=arc-20160816; b=yPFMOe4+OZtgTLrTGoEVJBP2/NgbD/0qUoRIfgdYme9vAySvKVexwg/Nq+uRw2Zhvp t64d/E9h9QiSefarah9xskK72hvl1y+k2hxScy7tZ/1Xc8cSjxFOxQfq7O7JrQQtBcDb vmqkdQhjXfFu1wTUbRVoHugqpPLaQNlvSNWPefgNDbK8elCGkhGjcnvCD0HI8B8o2Als izXFWPyo5MahVi6aRhjY1hLoVK+1o+InjcQt+7Qi5A0kglfDZwRvgZAwPCrTKBZlCpdX thzYaWmpTYyRvuedP5z4iezi5D73mHmhFULZ+S3G4JRZd/WAbUBkPu+DwplOGJhriWhO r4lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=s0kXhZ5QwF8NQVrywWavoH3BbIaBSkcol4p+WMzzHbA=; b=oCazLBKOIQY3KmldKlzlBVpLVBCcoTls7TkNH2Ry1KVQuX/V9+GA0FFDeqhNdA2f25 rL3IZTD5PUbhFFYkp73IsXulVTvTsOWOYqA3PzPM10fS7En0OmbRHgmlKMdX7flhtaXS FW0uJrYZE2vvnbXXhJLNYciaWAaVq4sMWrA9byY/DszW8UL2m19oqnzm1s7DB3KdXLyH +RLoxDqg3fMIjGihFW7id0MDhcHKkbRXcC3MKak594zN2KIsbM1POkF+ULrqD7mGaXBW Vv9vclTTrhH77By0IU18gAH4NOnSGM7z1lBMUnaYVR+JMyFNd+cW5Ima+IIxW+Yn1OEK RzDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infotecs.ru header.s=mx header.b="Odhxsp/y"; 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=REJECT sp=NONE dis=NONE) header.from=infotecs.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j12-20020aa7c40c000000b0046900e66a54si5536383edq.517.2022.12.08.01.30.30; Thu, 08 Dec 2022 01:30:48 -0800 (PST) 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=@infotecs.ru header.s=mx header.b="Odhxsp/y"; 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=REJECT sp=NONE dis=NONE) header.from=infotecs.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229781AbiLHIe6 (ORCPT + 72 others); Thu, 8 Dec 2022 03:34:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbiLHIe5 (ORCPT ); Thu, 8 Dec 2022 03:34:57 -0500 Received: from mx0.infotecs.ru (mx0.infotecs.ru [91.244.183.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4AD65E9E1; Thu, 8 Dec 2022 00:34:55 -0800 (PST) Received: from mx0.infotecs-nt (localhost [127.0.0.1]) by mx0.infotecs.ru (Postfix) with ESMTP id CC69B1182B4F; Thu, 8 Dec 2022 11:26:57 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx0.infotecs.ru CC69B1182B4F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=infotecs.ru; s=mx; t=1670488018; bh=s0kXhZ5QwF8NQVrywWavoH3BbIaBSkcol4p+WMzzHbA=; h=From:To:CC:Subject:Date:From; b=Odhxsp/yQQ9jHQH54WIsk46NzZXhtblFcJ6Ujtjvtjb8aYD/EZeLdV4DSDye3AlUL VKlJ8qHPtW3mIhPrlyx8l9ugaezJiHpXk4kobWaxPgvg7AOtQcpWqvxtEb8YFXq/Oj bcMsHGqEzgu2kKYvTTHTc/kECV9TU6q20ZrDAIdk= Received: from msk-exch-01.infotecs-nt (msk-exch-01.infotecs-nt [10.0.7.191]) by mx0.infotecs-nt (Postfix) with ESMTP id C9A80301A0D5; Thu, 8 Dec 2022 11:26:57 +0300 (MSK) Received: from msk-exch-01.infotecs-nt (10.0.7.191) by msk-exch-01.infotecs-nt (10.0.7.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.12; Thu, 8 Dec 2022 11:26:57 +0300 Received: from msk-exch-01.infotecs-nt ([fe80::89df:c35f:46be:fd07]) by msk-exch-01.infotecs-nt ([fe80::89df:c35f:46be:fd07%14]) with mapi id 15.02.1118.012; Thu, 8 Dec 2022 11:26:57 +0300 From: Gavrilov Ilia To: Jiri Pirko CC: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Arkadi Sharshevsky , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] net: devlink: Add missing error check to devlink_resource_put() Thread-Topic: [PATCH] net: devlink: Add missing error check to devlink_resource_put() Thread-Index: AQHZCt7VLcCQYXqvEkyWdGuOlfYO7w== Date: Thu, 8 Dec 2022 08:26:57 +0000 Message-ID: <20221208082338.3923376-1-Ilia.Gavrilov@infotecs.ru> Accept-Language: ru-RU, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.17.0.10] x-exclaimer-md-config: 208ac3cd-1ed4-4982-a353-bdefac89ac0a Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 174026 [Dec 08 2022] X-KLMS-AntiSpam-Version: 5.9.59.0 X-KLMS-AntiSpam-Envelope-From: Ilia.Gavrilov@infotecs.ru X-KLMS-AntiSpam-Rate: 0 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Auth: dkim=none X-KLMS-AntiSpam-Info: LuaCore: 502 502 69dee8ef46717dd3cb3eeb129cb7cc8dab9e30f6, {Tracking_from_domain_doesnt_match_to}, infotecs.ru:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2 X-MS-Exchange-Organization-SCL: -1 X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, bases: 2022/12/08 05:05:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2022/12/08 05:14:00 #20660675 X-KLMS-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 When the resource size changes, the return value of the 'nla_put_u64_64bit' function is not checked. That has been fixed to avoid rechecking at the next step. Found by InfoTeCS on behalf of Linux Verification Center (linuxtesting.org) with SVACE. Fixes: d9f9b9a4d05f ("devlink: Add support for resource abstraction") Signed-off-by: Ilia.Gavrilov --- net/core/devlink.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index 89baa7c0938b..ff078bcef9ba 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -4193,9 +4193,10 @@ static int devlink_resource_put(struct devlink *devl= ink, struct sk_buff *skb, nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_ID, resource->id, DEVLINK_ATTR_PAD)) goto nla_put_failure; - if (resource->size !=3D resource->size_new) - nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW, - resource->size_new, DEVLINK_ATTR_PAD); + if (resource->size !=3D resource->size_new && + nla_put_u64_64bit(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW, + resource->size_new, DEVLINK_ATTR_PAD)) + goto nla_put_failure; if (devlink_resource_occ_put(resource, skb)) goto nla_put_failure; if (devlink_resource_size_params_put(resource, skb)) --=20 2.30.2