From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 7FD6E3858D37 for ; Sun, 26 Mar 2023 19:17:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FD6E3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-x42e.google.com with SMTP id y2so4202558pfw.9 for ; Sun, 26 Mar 2023 12:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679858247; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qOSnb6oJbBOz9gMU+2yQJ5jNGnEFAEih1VkES0K3j+w=; b=idmjgbrSkRt6GUmqhLiN7/8/x2v5tWxDMP5criIC3IyNxuZA0E1Nlh8xQ8VOeaUK4U tVvclD8zozFKxUltUrcaWc/jThlHjrFQrMh9scJKelftHtqadPUtFzIZrYmej6lqZsmH Oa2Wi5eWE3onju7IaBJl0oV866xeQYyfmZCrGvJLficwu5mLF58E0cfL76Kw4AWPxaIn DXO/ifsFgCBbAOu8c4amuORzIAGI61Dedwb+XdwYVn7FNIwyHE5yyWjEtFHAqfXiZmv0 +4vYC7zE2AZc5H+6FyjI614hb8fPwn/QY+G9Mgppzq0AfVGTXmmCNrY9rFjTQFJAxXz1 bTwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679858247; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qOSnb6oJbBOz9gMU+2yQJ5jNGnEFAEih1VkES0K3j+w=; b=6HrzZFqBc1tZsnJIgC6/0ju9HMIx/jYhce2BOzDmYxrPSSAK5Td9+cEMt9tdSP2mXE mAb79M520NTKn229gTczYIGkqqBkjZ00jxQquYivo/XXFVnUZ7RtcYuuDzEsGBFds962 6ctqma3bg9bZ3sOKc+UQRU56reQxCTTTp7QqoN02mLTOVlG9qnhZtbXTW5WFTE435E/W wWEo+NsIQ9tbSh2L94t6LGZ8Mt5sXMlVxZPue0K8SRZtI/vO54z6G4lA+0AHFPiW21wy 7xCHelggL1A3paJ9gt8YsweC9vTHmcO5H83FXyetx/p8L/W1zLjLJoPI5Cz/Xp0yxBja qgJg== X-Gm-Message-State: AAQBX9cOZujFuVjHTOwORjk3nV/nQSzG15Dz+HrG+myeg4hw96/WWKe+ vvK49mhZ5vNEeGOzUv9RRD3eDxGLx/xEQtJ9RzE= X-Google-Smtp-Source: AKy350a7/g3Gbo9JG2ozS6YPFr3Q6qpupdlELZiZGV50IJdi1XgRUa7SL8lD8wlmEje0wAwyjXRu/sJyZYXMUwgwt4g= X-Received: by 2002:a63:204a:0:b0:507:469a:ca54 with SMTP id r10-20020a63204a000000b00507469aca54mr2195392pgm.7.1679858247347; Sun, 26 Mar 2023 12:17:27 -0700 (PDT) MIME-Version: 1.0 References: <88bae0e77b0d568b63d5840b782a69ae7d50baa2.camel@mad-scientist.net> In-Reply-To: <88bae0e77b0d568b63d5840b782a69ae7d50baa2.camel@mad-scientist.net> From: Andrew Pinski Date: Sun, 26 Mar 2023 12:17:14 -0700 Message-ID: Subject: Re: GCC ASAN breaks glob()? To: paul@mad-scientist.net Cc: gcc@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sun, Mar 26, 2023 at 12:01=E2=80=AFPM Paul Smith wrote: > > OK here's something super-strange I discovered: > > Enabling -faddress=3Dsanitize in GCC, causes the glob(3) function to > misbehave. > > I'm using GCC 11.3 / glibc 2.35 (x86_64 native). I have this simple > program: Maybe https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D88054 . Thanks, Andrew > > $ cat /tmp/tstglob.c > #include > #include > > int main(int argc, char *argv[]) > { > glob_t gl =3D {0}; > int res =3D glob(argv[1], 0, NULL, &gl); > > switch (res) > { > case 0: printf("success\n"); break; > case GLOB_NOMATCH: printf("no match\n"); break; > default: printf("unknown: %d\n", res); break; > } > > return 0; > } > > Now I create a symlink that doesn't point to anything: > > $ ln -s nosuchfile /tmp/badlink > $ ls -al /tmp/badlink > lrwxrwxrwx 1 pds pds 10 Mar 26 14:52 /tmp/badlink -> nosuchfile > > Now I compile the above program normally and run it: > > $ gcc -o /tmp/tstglob /tmp/tstglob.c > $ /tmp/tstglob /tmp/badlink > success > > This is what I expect: the symlink does exist even though it doesn't > point to anything so glob() should return it. > > But now if I compile with ASAN: > > $ gcc -fsanitize=3Daddress -o /tmp/tstglob /tmp/tstglob.c > $ /tmp/tstglob /tmp/badlink > no match > > ...?!?!?! > > Is there something in the ASAN library that takes over glob(3) and > installs a different version (there have been plenty of versions of > glob(3) over the years in glibc which behave incorrectly when faced > with broken symlinks, heavens knows...) that overrides the glibc > version? > > Or...??