From: Len Baker <len.baker@gmx.com>
To: Joe Perches <joe@perches.com>
Cc: Len Baker <len.baker@gmx.com>, Borislav Petkov <bp@alien8.de>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Tony Luck <tony.luck@intel.com>,
James Morse <james.morse@arm.com>,
Robert Richter <rric@kernel.org>,
David Laight <David.Laight@aculab.com>,
Kees Cook <keescook@chromium.org>,
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
Date: Sat, 4 Sep 2021 13:23:03 +0200 [thread overview]
Message-ID: <20210904094451.GA2998@titan> (raw)
In-Reply-To: <3a035a3ec4571a622ce640e042f9a119@perches.com>
Hi,
On Fri, Sep 03, 2021 at 10:03:18AM -0700, Joe Perches wrote:
> 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.
This macro is used in "/include/linux/edac.h" as follows:
struct edac_raw_error_desc {
[...]
char label[(EDAC_MC_LABEL_LEN + 1 + sizeof(OTHER_LABEL)) * EDAC_MAX_LABELS];
[...]
};
If we remove this define the size of label would be:
char label[(EDAC_MC_LABEL_LEN + 6) * EDAC_MAX_LABELS];
So, I think now is more complicated to understand because the size is
what it is. If you prefer this option, I can remove the macro and add
a comment with some explanation.
Regards,
Len
next prev parent reply other threads:[~2021-09-04 11:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-03 15:05 [PATCH v6] EDAC/mc: Prefer strscpy or scnprintf over strcpy Len Baker
2021-09-03 17:03 ` Joe Perches
2021-09-04 11:23 ` Len Baker [this message]
2021-09-04 11:36 ` Borislav Petkov
2021-09-04 13:22 ` Len Baker
2021-09-13 8:59 ` [PATCH] EDAC/mc: Prefer strscpy or scnprintf over strcpy, sprintf and snprintf Robert Richter
2021-09-15 11:58 ` Borislav Petkov
2021-09-18 9:17 ` Len Baker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210904094451.GA2998@titan \
--to=len.baker@gmx.com \
--cc=David.Laight@aculab.com \
--cc=bp@alien8.de \
--cc=james.morse@arm.com \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=linux-edac@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=rric@kernel.org \
--cc=tony.luck@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).