Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp685903pxj; Wed, 2 Jun 2021 08:54:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDibL2EvkJ7RmGSHwJ9IW7lB+MjjbS/wyFCfw6rcV8RKZEU7tZzMZ5OMFOwedgGgSCmtfv X-Received: by 2002:a17:906:308d:: with SMTP id 13mr34108445ejv.554.1622649297029; Wed, 02 Jun 2021 08:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622649297; cv=none; d=google.com; s=arc-20160816; b=KULRWvv0ZuG/fXGflonBX0AhJIIukWHbmDR7+GFn7tqjE56pErU9ctAynjda3FwKPF oJpAuy3sppmxjTpyGVOgOMMw1jG5gVsK31Xi5SzAgIWV1MD9BpcRKyQQrM144RhujyZa lz5moTS1DPVUKBaBKOdOlHAnfC4UulJxyX66f1hwrk+hGy4ZtstEN+zsBo19iv6nOSJ7 l9Oupo7bPlrqWhTKMrfc5nWnA2ljpuG7pwZq4/MU897BOYE1XDmy7iuVySm1xqCLSX5J y1MvgW/b0qo2P3GQSpYsCl90fx02gd1xByaL3gRgO8fwbEBOch1vZWSjqk/uVCtc4CA7 A+Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=dnyH3hhgMm0QLYQu2916j5BCaqKcPOJxSVGm/2lEymk=; b=KeKtihQ9aA8PFfmQ3LhU8sm9CXRxjHhm2iL7dbBY4LdumeQi7j1Z/GvA02e+wwH2R4 XJOpiRtA4M9GBk9JHcZ0iv/tx6Dc4c2uldSXD8j0QgCtswSZaBLvvWFHMWb9DH+sCMgR 7nMmePXAP5KZzNObHU1punQCszRrKsgwLLZOTzrbq++9yJGw9MDIDl6PlqQdqf+b18q/ wWe2ns9OarOGo+ucpnxb2Zh/+iRZwkrjdT9qcwsIiEwOE2+yRVTDwBSiuM0ZrSXFwCHM lnTkZFY2ZJS7la81z/bjP59YzdVUxBLuRZrPcgxtetjdcgfvj4dO3ytTfBXYDji6XaHM v0BA== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h13si237077ede.256.2021.06.02.08.54.33; Wed, 02 Jun 2021 08:54:57 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232421AbhFBPwV (ORCPT + 99 others); Wed, 2 Jun 2021 11:52:21 -0400 Received: from mga04.intel.com ([192.55.52.120]:63042 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232294AbhFBPwT (ORCPT ); Wed, 2 Jun 2021 11:52:19 -0400 IronPort-SDR: lkcplOfVo969KZkDKXhbCSEc0otnNXeX6keT8PMN3rYlNGk5TtnJNNK2+xUSqtJ8fAALGwii1I c4B67YljkyQQ== X-IronPort-AV: E=McAfee;i="6200,9189,10003"; a="201961714" X-IronPort-AV: E=Sophos;i="5.83,242,1616482800"; d="scan'208";a="201961714" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2021 08:50:30 -0700 IronPort-SDR: Kkd7mOWhPSX4fG894Dp0r1PpTOmhWjZEFY5rCDv30mbj0WX4Cn+1Afzrs8WrR7Dj0RoPAiNwUb +00z0sN5nq/w== X-IronPort-AV: E=Sophos;i="5.83,242,1616482800"; d="scan'208";a="438453038" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2021 08:50:27 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1loT8S-00Gk80-Q1; Wed, 02 Jun 2021 18:50:24 +0300 Date: Wed, 2 Jun 2021 18:50:24 +0300 From: Andy Shevchenko To: Tian Tao Cc: gregkh@linuxfoundation.org, rafael@kernel.org, akpm@linux-foundation.org, jonathan.cameron@huawei.com, song.bao.hua@hisilicon.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/3] drivers/base/node.c: use bin_attribute to avoid buff overflow Message-ID: References: <1622641734-22538-1-git-send-email-tiantao6@hisilicon.com> <1622641734-22538-4-git-send-email-tiantao6@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1622641734-22538-4-git-send-email-tiantao6@hisilicon.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 02, 2021 at 09:48:54PM +0800, Tian Tao wrote: > Reading sys/devices/system/cpu/cpuX/nodeX/ returns cpumap and cpulist. > However, the size of this file is limited to PAGE_SIZE because of the > limitation for sysfs attribute. so we use bin_attribute instead of > attribute to avoid NR_CPUS too big to cause buff overflow. ... > -static ssize_t node_read_cpumap(struct device *dev, bool list, char *buf) > +static ssize_t node_read_cpumap(struct device *dev, bool list, > + char *buf, loff_t off, size_t count) Why you moved char *buf to the next line? Replacing ) by , doesn't change character count. Perhaps you need to reconfigure your editor. ... > +static struct bin_attribute *node_dev_bin_attrs[] = { > + &bin_attr_cpumap, > + &bin_attr_cpulist, > + NULL, No comma. > +}; ... > +static const struct attribute_group *node_dev_groups[] = { > + &node_dev_group, > + NULL, Ditto. > +}; -- With Best Regards, Andy Shevchenko