Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp657370pxb; Fri, 3 Sep 2021 10:17:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzLralBKOb86gjE8btC0sH1n6Jw2x7GvszjU2d5wDnVU2XTgH7o3HW4XcuhRrnNcyhTLfNd X-Received: by 2002:a17:906:a3c3:: with SMTP id ca3mr5411812ejb.337.1630689457720; Fri, 03 Sep 2021 10:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630689457; cv=none; d=google.com; s=arc-20160816; b=w1U/YVm+EvOwYD6HenTdkBbtnubwMtBSX7ddk4Coux+DNxCfm3pGbFgWWDsVfVsHxL vvjjRHzpMzBjnS/VyNvXXISRWA81vLHkD4cNzNzgmPb5Z6kELe695iCPJcx8Rxp65Bvl FT6I/+G/V9o1YfZr974vI8ufPfVwSFw2PtEypJrdJ2J8Zl3STAlj/XAYq9b1NyO+JkvT VLBDWT0Ynw/WUyHBt4AVLQXj+lxzAxYyrJnldU3v7lEVbSHrUfUYEldfm4ut+cDJxCkC ImGsAkCJMcEKW1ev29m8+J82/UufAsgLgH9rIBsrSPxlL4m9Zu0Q7ZtIh4rnVtrMX5Bn WYaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version; bh=a2mINijpZBBKyaNs7zse+NyKfI4YyqkMYSC6hBzloyQ=; b=i0I82oHcmUeV4aEIxTQG5feTpzN4ydXMnZKCgdzjIyqwEbPi+JhHgZOzGzPff5xSmR YgV8DeIkSD/MYHUZcC3xAac+SLMtU0cmL6TxXycKZ+ee3ihSsqJDzu6YrFXmjbEIY9zl M93KftQqEwJkY4qrZrB1ykzzMoVD6PpYefxZ/V328WokWOkGlc1r8ItK1YFrY1q9B0q3 7PMMVcAWPb1wkHYiptZUgk71W5Phinla8GVEgmdJKIDjs8DQSbjcCkhexgsN/6dXuWP1 mHPU7jaVybf1jMpS465sfxHKfh/GBNKL1K2BxVjgNY6XKD9Tvsf+l/UJBtDlvszMKsIG TV5Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd14si525641ejc.260.2021.09.03.10.17.10; Fri, 03 Sep 2021 10:17:37 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350198AbhICREV (ORCPT + 99 others); Fri, 3 Sep 2021 13:04:21 -0400 Received: from smtprelay0212.hostedemail.com ([216.40.44.212]:49408 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235774AbhICREU (ORCPT ); Fri, 3 Sep 2021 13:04:20 -0400 Received: from omf11.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 9AF37181D861A; Fri, 3 Sep 2021 17:03:19 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA id E361C20A296; Fri, 3 Sep 2021 17:03:18 +0000 (UTC) MIME-Version: 1.0 Date: Fri, 03 Sep 2021 10:03:18 -0700 From: Joe Perches To: Len Baker Cc: Borislav Petkov , Mauro Carvalho Chehab , Tony Luck , James Morse , Robert Richter , David Laight , Kees Cook , linux-hardening@vger.kernel.org, linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6] EDAC/mc: Prefer strscpy or scnprintf over strcpy In-Reply-To: <20210903150539.7282-1-len.baker@gmx.com> References: <20210903150539.7282-1-len.baker@gmx.com> User-Agent: Roundcube Webmail/1.4.11 Message-ID: <3a035a3ec4571a622ce640e042f9a119@perches.com> X-Sender: joe@perches.com Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.10 X-Stat-Signature: j7xjyr4odatdy7rb6mkgdmxeee87f933 X-Rspamd-Server: rspamout02 X-Rspamd-Queue-Id: E361C20A296 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+E6cAmHeP0H2cTANzNcBy/xjzDpz0K7BE= X-HE-Tag: 1630688598-308236 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-09-03 08:05, Len Baker wrote: > strcpy() performs no bounds checking on the destination buffer. > len.baker@gmx.com/ [] > @@ -1113,12 +1115,9 @@ void edac_mc_handle_error(const enum > hw_event_mc_err_type type, > p = e->label; > *p = '\0'; > } else { > - if (p != e->label) { > - strcpy(p, OTHER_LABEL); > - p += strlen(OTHER_LABEL); > - } > - strcpy(p, dimm->label); > - p += strlen(p); > + n += scnprintf(e->label + n, sizeof(e->label) - n, > + "%s%s", prefix, dimm->label); > + prefix = OTHER_LABEL; OTHER_LABEL is a define specific to this module IMO: Used once text macros are just obfuscating and should be removed.