From patchwork Sun Jul 5 16:18:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Yakunin X-Patchwork-Id: 1323077 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=yandex-team.ru Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=yandex-team.ru header.i=@yandex-team.ru header.a=rsa-sha256 header.s=default header.b=LwWbbTvg; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4B0DQW5NXdz9sPF for ; Mon, 6 Jul 2020 02:18:27 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727839AbgGEQS0 (ORCPT ); Sun, 5 Jul 2020 12:18:26 -0400 Received: from forwardcorp1j.mail.yandex.net ([5.45.199.163]:39772 "EHLO forwardcorp1j.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727115AbgGEQS0 (ORCPT ); Sun, 5 Jul 2020 12:18:26 -0400 Received: from vla1-fdfb804fb3f3.qloud-c.yandex.net (vla1-fdfb804fb3f3.qloud-c.yandex.net [IPv6:2a02:6b8:c0d:3199:0:640:fdfb:804f]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id B68D72E14F5; Sun, 5 Jul 2020 19:18:16 +0300 (MSK) Received: from vla5-58875c36c028.qloud-c.yandex.net (vla5-58875c36c028.qloud-c.yandex.net [2a02:6b8:c18:340b:0:640:5887:5c36]) by vla1-fdfb804fb3f3.qloud-c.yandex.net (mxbackcorp/Yandex) with ESMTP id z5sFN3YmzU-IGmS4T7m; Sun, 05 Jul 2020 19:18:16 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1593965896; bh=zjTWgrEuhSqZ11G2ZxtLXsfwh6Dg2YOT1b2YEFs6ekA=; h=Message-Id:Date:Subject:To:From; b=LwWbbTvgd2tWKt5eLM78Y/xcN/ufxhniUDK+6POFofCvCN8GY60w43bXv72WpAhZj d8E1DYlcF7CmHwzh5IjTm2kCEbmFghpXi+S/YuZ/h7/hXS5eAtiYZWltvoSfM02hdM X//H5t91VSMJ5bEZbwDc1TUDcw1w193QgoX3YQAI= Authentication-Results: vla1-fdfb804fb3f3.qloud-c.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from unknown (unknown [199.21.99.33]) by vla5-58875c36c028.qloud-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id lVHU6Cz5fl-IGiWrkMY; Sun, 05 Jul 2020 19:18:16 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) From: Dmitry Yakunin To: dsahern@gmail.com, netdev@vger.kernel.org Subject: [PATCH iproute2-next v2] lib: fix checking of returned file handle size for cgroup Date: Sun, 5 Jul 2020 19:18:12 +0300 Message-Id: <20200705161812.45560-1-zeil@yandex-team.ru> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Before this patch check is happened only in case when we try to find cgroup at cgroup2 mount point. v2: - add Fixes line before Signed-off-by (David Ahern) Fixes: d5e6ee0dac64 ("ss: introduce cgroup2 cache and helper functions") Signed-off-by: Dmitry Yakunin --- lib/fs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/fs.c b/lib/fs.c index e265fc0..4b90a70 100644 --- a/lib/fs.c +++ b/lib/fs.c @@ -148,10 +148,10 @@ __u64 get_cgroup2_id(const char *path) strerror(errno)); goto out; } - if (fhp->handle_bytes != sizeof(__u64)) { - fprintf(stderr, "Invalid size of cgroup2 ID\n"); - goto out; - } + } + if (fhp->handle_bytes != sizeof(__u64)) { + fprintf(stderr, "Invalid size of cgroup2 ID\n"); + goto out; } memcpy(cg_id.bytes, fhp->f_handle, sizeof(__u64));