From patchwork Tue Jun 23 19:56:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 223519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC4A6C433E0 for ; Tue, 23 Jun 2020 20:18:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A011921527 for ; Tue, 23 Jun 2020 20:18:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592943484; bh=4dCn1E3y2lsNH/aZZpCpK8OpPJhFa/TNxEoJEzBdOJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Qv6owbLGvNRRvrdGqO+90Lpi6NqHIBQi6N36R9fxMg75KYoSh04P5sajDWAj4CP8y CT4+Q0dwLexDm0ahauFncvuhg8GHLaEx/8Ry3uu9oYBb/xaL8OvQip9os0bnBP8Ir0 qyAJmdTmxqkta7zEqs6r62ZAYwTUkAylhSt7Uz7Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389623AbgFWUSB (ORCPT ); Tue, 23 Jun 2020 16:18:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:34524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389616AbgFWUR6 (ORCPT ); Tue, 23 Jun 2020 16:17:58 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 521F12064B; Tue, 23 Jun 2020 20:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592943477; bh=4dCn1E3y2lsNH/aZZpCpK8OpPJhFa/TNxEoJEzBdOJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gHp54yvqZXAB9oCLJ7R1aLO2wD22BidZ7/EyHy5na4ntQGfZtRgP4lkf2938e2wMJ BZ41AnCS+sxAfgrB5ysa4NiqVRebGsNjE6UPgv7HyB9UkCH6pLsBiSeMi8cgp4UkcT OpKMRHmOrlQG4I4XWHVNHwYjVinMft/84ueSwX8M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kbuild test robot , Tony Luck , Borislav Petkov , Thomas Gleixner , Sasha Levin Subject: [PATCH 5.7 367/477] x86/mce/dev-mcelog: Fix -Wstringop-truncation warning about strncpy() Date: Tue, 23 Jun 2020 21:56:04 +0200 Message-Id: <20200623195424.879067556@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195407.572062007@linuxfoundation.org> References: <20200623195407.572062007@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tony Luck [ Upstream commit 7ccddc4613db446dc3cbb69a3763ba60ec651d13 ] The kbuild test robot reported this warning: arch/x86/kernel/cpu/mce/dev-mcelog.c: In function 'dev_mcelog_init_device': arch/x86/kernel/cpu/mce/dev-mcelog.c:346:2: warning: 'strncpy' output \ truncated before terminating nul copying 12 bytes from a string of the \ same length [-Wstringop-truncation] This is accurate, but I don't care that the trailing NUL character isn't copied. The string being copied is just a magic number signature so that crash dump tools can be sure they are decoding the right blob of memory. Use memcpy() instead of strncpy(). Fixes: d8ecca4043f2 ("x86/mce/dev-mcelog: Dynamically allocate space for machine check records") Reported-by: kbuild test robot Signed-off-by: Tony Luck Signed-off-by: Borislav Petkov Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20200527182808.27737-1-tony.luck@intel.com Signed-off-by: Sasha Levin --- arch/x86/kernel/cpu/mce/dev-mcelog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/mce/dev-mcelog.c b/arch/x86/kernel/cpu/mce/dev-mcelog.c index d089567a9ce82..bcb379b2fd42e 100644 --- a/arch/x86/kernel/cpu/mce/dev-mcelog.c +++ b/arch/x86/kernel/cpu/mce/dev-mcelog.c @@ -343,7 +343,7 @@ static __init int dev_mcelog_init_device(void) if (!mcelog) return -ENOMEM; - strncpy(mcelog->signature, MCE_LOG_SIGNATURE, sizeof(mcelog->signature)); + memcpy(mcelog->signature, MCE_LOG_SIGNATURE, sizeof(mcelog->signature)); mcelog->len = mce_log_len; mcelog->recordlen = sizeof(struct mce);