Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3344406pxv; Sun, 4 Jul 2021 16:07:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0lfwm5UdM4PJYkHRCeQ8CIiUxxXhkI8CHfUp06DMT77onIgY+GLiFq6tS7jXcb78zp78H X-Received: by 2002:a92:7303:: with SMTP id o3mr6779895ilc.36.1625440036320; Sun, 04 Jul 2021 16:07:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440036; cv=none; d=google.com; s=arc-20160816; b=nGkkf44x1zUdhbO6iZA0N79IijkHi4aOocJuXF2hv46WCjKpfqqUJfsSDWZqiujimx Kydrl/wCKGVOXn0jitGSQD2gELhUj3/QkYQpCXA9cU6NISu2Mndq50ku2aMbG5Biq16M sWvfKAZ1oDA4VWHi+kFPeErklp1e1soMxkwKytnkpwJkjSuz2Orm0PZ5aNou3KcT3P+k FqH6KldEm1CsjCjebinOjTDKvWaMbODF3VblXKcTxVENt3KLOXoll+9R9Atp8s3ZBh5p qbt6ectRT1Z+OGcvrS/GLI0OGJDiwDQgAy4Dx8yC+hBdVzkTigzOZKw/soH+pVxR1HMB zuXQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ligxGlwO6qI34+Q2CalznTLp+nCtyUpP/cZCh03zy1Q=; b=iGqUbevNoVeyLEsGwv+khZwDqUSw8OdywywUBYdP8oM4pSL4aSmdLAwvUqHdDHT361 9s7jb/xcU214F5TR266V9mSFUDmwu7mG2zCvfIlO68jZnTyKD4Jg6JfH5RIWrw/xfu6V nc+HotMGoiJwuiDNd5tr9odWt4TnJVg54hCrbdplDk489BY6J56ejM457Ji6IRHYLO67 01KJC8qLr7LtzDv8xSJ+oKAdqYSojs/l9MRGu4LdIuR/JrWkI9BChLV1fRaiFmv2jw8I 9Mm1eDs6eMWtgPqO7WR/CrHfDw1FyE8yxxDXfNX/9pChqtpfXrOImgFi4GFH7vvPUIEG erow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QoJNtDmF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g20si10855539jaq.77.2021.07.04.16.07.04; Sun, 04 Jul 2021 16:07: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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QoJNtDmF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231161AbhGDXIN (ORCPT + 99 others); Sun, 4 Jul 2021 19:08:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:45944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230367AbhGDXHq (ORCPT ); Sun, 4 Jul 2021 19:07:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1C1ED61364; Sun, 4 Jul 2021 23:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439910; bh=MrO+vFigx9HE56U9auGXEFyBlzQMs0GCkanEowv2yT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QoJNtDmFcX7rj8quHEkKmdwXpvt+qUhTFuSVIvVaJ+L1yNf14EvpLOAGEC1t7YIa/ AuPrYwYrWrUqsFEHyhAc7N8N4O+Pa6XmiCYWjAqBrwbxce73Rq2zIugHlLR5iet+LW JVERVAoX01DuIlFJ5gEP7UZY8aNa6AxTuYX3wFSG3mRIO17DFc+mE9SMIx8Ynr01DO eMabi/xUtFhSa3thYyUzAK/phJe6dBpi1D/ySEdOsM+Nb+J8d6aXtXZRHhxAuG9dWT wJKKhz6l9POXHmzZOk3bwCX4m/oKB+hcDVsraZrxhM/wromE4cI/kkAq2wLSfPvrkK f9PA3yayGk5UA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tian Tao , Will Deacon , Sasha Levin , linux-perf-users@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.13 36/85] arm64: perf: Convert snprintf to sysfs_emit Date: Sun, 4 Jul 2021 19:03:31 -0400 Message-Id: <20210704230420.1488358-36-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230420.1488358-1-sashal@kernel.org> References: <20210704230420.1488358-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tian Tao [ Upstream commit a5740e955540181f4ab8f076cc9795c6bbe4d730 ] Use sysfs_emit instead of snprintf to avoid buf overrun,because in sysfs_emit it strictly checks whether buf is null or buf whether pagesize aligned, otherwise it returns an error. Signed-off-by: Tian Tao Link: https://lore.kernel.org/r/1621497585-30887-1-git-send-email-tiantao6@hisilicon.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/kernel/perf_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c index f594957e29bd..44b6eda69a81 100644 --- a/arch/arm64/kernel/perf_event.c +++ b/arch/arm64/kernel/perf_event.c @@ -312,7 +312,7 @@ static ssize_t slots_show(struct device *dev, struct device_attribute *attr, struct arm_pmu *cpu_pmu = container_of(pmu, struct arm_pmu, pmu); u32 slots = cpu_pmu->reg_pmmir & ARMV8_PMU_SLOTS_MASK; - return snprintf(page, PAGE_SIZE, "0x%08x\n", slots); + return sysfs_emit(page, "0x%08x\n", slots); } static DEVICE_ATTR_RO(slots); -- 2.30.2