From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 285F63858D33; Wed, 12 Apr 2023 09:18:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 285F63858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681291127; bh=eP4pMGTMq9IKbs549A6a8dwx6EBV/xwl22+alnFMV4M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Igb4qvVrUwHB63HqERyo8uSa+04RdWXwAswYG2c7fl5927Qfw0wZNLA5mdYXoQ1Vj aXfM1FOOV8lI51aicyhRLzyOk189M7GvSJZqLttjNVfbmez68GuB1NANDtDlox2T9t X6tzUwVOZr6geMPbGmbkuntcE3hOK27lqAZHT0Qg= From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/109446] Possible destination array overflow without diagnosis in memcpy Date: Wed, 12 Apr 2023 09:18:46 +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: rguenther at suse dot de 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 #12 from rguenther at suse dot de --- On Wed, 12 Apr 2023, marxin at gcc dot gnu.org wrote: > 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 que= stion is > > > > why ASAN doesn't instrument the generated aggregate copy? Maybe be= cause > > > > in C/C++ you cannot write an aggregate array copy? > > >=20 > > > We do instrument those. But only instrument them by checking the fir= st and > > > last byte > > > of the copy, not all bytes in between (because that would be for inli= ne > > > checking too large - we'd need to emit inline a loop over those bytes= ). > >=20 > > OK, that's lack of an appropriate API then? But still the first and la= st > > 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. 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.=