From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A17063858D39; Wed, 12 Apr 2023 11:16:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A17063858D39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681298175; bh=iczIol7ir+tk/S7c1i4Nxpss1wpR4Ybh6HGL0iOQNq4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PczO+2eSYqNRi2jZkX/eaSkNyeW25LS9cwpKId50OUEYjMae+wc+C7hLGVuEIB6Xp 2gtGVGxVX4xtW/7HuRSjkysQbgVmjaPm2DHDTFT4QY9+3527uRWlHBoArE8NFLBCtF MELCYTgDSiukzn7zOBc5UI8YkRLPAh70gvK63C3U= From: "xry111 at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/109446] Possible destination array overflow without diagnosis in memcpy Date: Wed, 12 Apr 2023 11:16:14 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 8.4.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xry111 at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109446 --- Comment #13 from Xi Ruoyao --- (In reply to rguenther@suse.de from comment #12) > On Wed, 12 Apr 2023, marxin at gcc dot gnu.org wrote: >=20 > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109446 > >=20 > > --- Comment #9 from Martin Li?ka --- > > (In reply to Richard Biener from comment #8) > > > (In reply to Jakub Jelinek from comment #7) > > > > (In reply to Richard Biener from comment #6) > > > > > not sure if we should prevent all of those transforms. But the q= uestion is > > > > > why ASAN doesn't instrument the generated aggregate copy? Maybe = because > > > > > in C/C++ you cannot write an aggregate array copy? > > > >=20 > > > > We do instrument those. But only instrument them by checking the f= irst and > > > > last byte > > > > of the copy, not all bytes in between (because that would be for in= line > > > > checking too large - we'd need to emit inline a loop over those byt= es). > > >=20 > > > OK, that's lack of an appropriate API then? But still the first and = last > > > byte should be sufficient to detect the problem (but maybe I'm missing > > > something here). > >=20 > > No, because the last byte is out of redzone: > >=20 > > =3D>0x7ffff5300000: f1 f1 f1 f1 00 00 00[f3]f3 f3 f3 f3 00 00 00 00 > >=20 > > the 'f3' redzone is covering 5*8 bytes after the data type only. >=20 > OK, so it's lack of an API then. The alternative would be to > do sth similar to stack-checking - instrument every 5*8 byte, > possibly up to some limit. Or, as you probably suggest, avoid > folding memcpy with size larger than 5*8 byte inline. I guess doing so will need to change the cpymemM expand of all targets.=