lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 4 Sep 2021 13:23:03 +0200
From:   Len Baker <len.baker@....com>
To:     Joe Perches <joe@...ches.com>
Cc:     Len Baker <len.baker@....com>, Borislav Petkov <bp@...en8.de>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Tony Luck <tony.luck@...el.com>,
        James Morse <james.morse@....com>,
        Robert Richter <rric@...nel.org>,
        David Laight <David.Laight@...lab.com>,
        Kees Cook <keescook@...omium.org>,
        linux-hardening@...r.kernel.org, linux-edac@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v6] EDAC/mc: Prefer strscpy or scnprintf over strcpy

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@....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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ