Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp406429pxj; Thu, 17 Jun 2021 05:36:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQwNWQoZTo8ov4zSDbbpPhXXa29oEQtGqmUBXt7QzaNH3YBDIHqhtG4Wgr4VQzlq8X0g1i X-Received: by 2002:a05:6402:702:: with SMTP id w2mr6144314edx.189.1623933368089; Thu, 17 Jun 2021 05:36:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623933368; cv=none; d=google.com; s=arc-20160816; b=jLuBePvdiih/F4OgnTrtk4ebZ+zt14VD9yqiORJcNfrO8mAlh8wuJj+8chWXWfWYUL wEd2O9PaImfVXBqh1Gx6QzqViOS2GbDIMbkVZN9H8xuGU4OFVQLrafaZO84SvrAmjMbR pksSXGm9XKPerlHFnV8+yAOB0AHGc/TeFZpUhJrfXJCiB0oWGHUNGVIckz9hgPtO3BGK xxiaqqmpPzByZvu0EKUn4HNYDyk2VFQm/AgjWcP5s+sjxwOzrAzFfzJig7K3KuO1QQrz ieUrD0tW7AwHrOx/IDr0rS5t2ihJ3o1qpIyNdnClAn+CKA+ldngPC1YGGyVpkvYH9w89 k6Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=HSDX7Sbj0VEIsD5H9VZexp1qBntB5xTiAjKRMi/pyMI=; b=RzxsYqqM+JMFpXDrFyoFzeBeRI6/9zgP0ez09IC2Z+39xdcUtnOzWp5vaODYEmMMae vhaOKEfPzE9ulFXBni4CyFaYVhKBEWZQXDI37iO9/pt0Apn4ov9jthmVtsqBrkaHBnNK E2WQS1H4gTaflWY4pHoB2lgfIXNPisIUdFN9M8I7SC9OCd7Y/HBrBGXwwbihsD+BxEcR bqhJt8FjltdWWxkU4hAM6PgvRFFToQ/Fhra8jd3ivXa9SM5REoJ0dVEcCHh8lkAb7d+r AEU/cVugrbzmzSX249c7lDaDn/486PMRWh/tdeLVRgknTeHrIlPQvZ2iA1tXZYAwAXLi Cwiw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hisilicon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by13si5551681ejc.433.2021.06.17.05.35.44; Thu, 17 Jun 2021 05:36:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231987AbhFQKWU (ORCPT + 99 others); Thu, 17 Jun 2021 06:22:20 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:4835 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbhFQKWU (ORCPT ); Thu, 17 Jun 2021 06:22:20 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4G5Hx35Zb4zXfMq; Thu, 17 Jun 2021 18:15:03 +0800 (CST) Received: from dggemi761-chm.china.huawei.com (10.1.198.147) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Thu, 17 Jun 2021 18:20:06 +0800 Received: from SWX921481.china.huawei.com (10.126.201.234) by dggemi761-chm.china.huawei.com (10.1.198.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 17 Jun 2021 18:20:00 +0800 From: Barry Song To: , , CC: , , , , , , , , , , , , , , , , , , , Barry Song Subject: [PATCH v4 0/4] use bin_attribute to avoid cpumap buff overflow Date: Thu, 17 Jun 2021 22:19:06 +1200 Message-ID: <20210617101910.13228-1-song.bao.hua@hisilicon.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.126.201.234] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggemi761-chm.china.huawei.com (10.1.198.147) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org patch #1 adds a new function cpumap_print_to_buf and patch #2 uses this function in drivers/base/topology.c, and patch #3 uses this new function in drivers/base/node.c. patch #4 adds test cases for the new API. v4: add test cases for bitmap_print_to_buf API; add Reviewed-by of Jonathan Cameron for patches 1-3, thanks! v3: fixed the strlen issue and patch #1,#2,#3 minor formatting issues, thanks to Andy Shevchenko and Jonathan Cameron. v2: split the original patch #1 into two patches and use kasprintf() in patch #1 to simplify the code. do some minor formatting adjustments. Barry Song (1): lib: test_bitmap: add bitmap_print_to_buf test cases Tian Tao (3): lib: bitmap: introduce bitmap_print_to_buf topology: use bin_attribute to avoid buff overflow drivers/base/node.c: use bin_attribute to avoid buff overflow drivers/base/node.c | 52 +++++++++----- drivers/base/topology.c | 115 +++++++++++++++++-------------- include/linux/bitmap.h | 2 + include/linux/cpumask.h | 21 ++++++ lib/bitmap.c | 37 +++++++++- lib/test_bitmap.c | 149 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 304 insertions(+), 72 deletions(-) -- 2.25.1