Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp120551pxj; Thu, 3 Jun 2021 02:24:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxw2JDnH1+dzLRX8J5rIONd0FUPii8SRsbtCqfIrcJ8AHo9vvOzkRGiXvoukllW+HiXXA9f X-Received: by 2002:aa7:cb19:: with SMTP id s25mr43229321edt.194.1622712256228; Thu, 03 Jun 2021 02:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622712256; cv=none; d=google.com; s=arc-20160816; b=CabWSh9kmimaGV+K0nixp9wVC2sUqmPf/fqZFXwwZkhaA3fvWPMe7LggbbYBVTv8Dj 9996ZwPy1HC/tyhUwKG4l/dvGYHcV3RgGaoE11cdJrX11oHfWhBh+p8l99iOsGXP8f45 58hVDFgnp+0Xa4ArvLmZ5rC1UmZv693qciltUkUq5uuG5TJmwFuLZvjZbhgo4ecOEg4h KIA5WvfeILVMXTvlufym460WuNXoofBA3aNgNijxkpFwCaGrveGvHm51hKx8vtD++Lu1 3mIJa5ZBytdECuHmNjw53iFkWmLSF6p7nMZ0a0Xw9rSTI/faFbMSikFVvUsBeQEjjsnz fqBA== 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=if0RONZndBnYooKJ5uJJ9B/7QfwwsJWZuaj48I+XqU0=; b=V1e7hvLzlS9f284WUT+dPMeCHjqq4nWVoLTtJ+LdQN3Umr6L4jsxK3N+fTr0psn1HB 2uY+HZA6zw36NX9Du1LUeoS5l30Vuu0QnwwSFGXWNeAl4HUdQ3dficC3DmeJ7uFehkyp n/ccbmMZu5satgJ7u6vnxQUI3iAn1IdKiKOsTZCTNNyxR05plHqBpXHdpquMwgwUeLBk PPQnyhdXpLy4k1wys3RglS6tCVVlxXS8MlleYCPQUPbVKKppO+/Z21WByLUdlh9/C1kn a55bMfGGU5cnvxxE0cceJzZapEiPAcG+lCQPnnzd2p5HF7xmFDcupJ636xLI/SwV/qP0 F+uw== 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 j20si1892593edw.53.2021.06.03.02.23.53; Thu, 03 Jun 2021 02:24:16 -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 S229734AbhFCJYl (ORCPT + 99 others); Thu, 3 Jun 2021 05:24:41 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:7086 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229506AbhFCJYk (ORCPT ); Thu, 3 Jun 2021 05:24:40 -0400 Received: from dggeme759-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4FwgN93HZMzYqKG; Thu, 3 Jun 2021 17:20:09 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggeme759-chm.china.huawei.com (10.3.19.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 3 Jun 2021 17:22:54 +0800 From: Tian Tao To: , , , CC: , , , Tian Tao Subject: [PATCH v3 0/3] use bin_attribute to avoid buff overflow Date: Thu, 3 Jun 2021 17:22:39 +0800 Message-ID: <1622712162-7028-1-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggeme759-chm.china.huawei.com (10.3.19.105) 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. 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. 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 | 3 ++ include/linux/cpumask.h | 21 +++++++++ lib/bitmap.c | 37 +++++++++++++++- 5 files changed, 156 insertions(+), 72 deletions(-) -- 2.7.4