From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x331.google.com (mail-ot1-x331.google.com [IPv6:2607:f8b0:4864:20::331]) by sourceware.org (Postfix) with ESMTPS id 729303858006 for ; Mon, 24 Jan 2022 14:17:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 729303858006 Received: by mail-ot1-x331.google.com with SMTP id j38-20020a9d1926000000b0059fa6de6c71so2666047ota.10 for ; Mon, 24 Jan 2022 06:17:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=ddXl30IjKk6ukoGrBESCEqRk55f3zzRGJu9IcfxbBh4=; b=vis1rGjEjLjhfZpqwfN62A1OxIdAl6SWBBriTQBGux2qjHSqrPDymSvfMJCBnrFYvn Bb3fc2JMZbz7+vUdnEZrvIcslwJ4lRWnMbTIeZwaCFbyrg+SeFgEEvgAhjg+tbxisOsT jkzaPo+qQlbVvzuqHMK+J2MsNOvXdsBvxh4Xpd+jfJSMk8I6asd11mg5uJOCFZkK0AIs pP3Yu+CnFXqqwZUg3f81Cp4pujuno5P6dbum4N6TxuCTcZ7imyycB9EVu2bzew3+e/mk IM7bFLrgcEFc9r3ExIHttGCLkKF36tRIv6PxkFMDbBrVK3uPD4JIub8Fn+MKeIzSaE0t PhVg== X-Gm-Message-State: AOAM531Z8jFnuHRdQgWwIZ+ykOvy2pjVYEJqvfL//cRVm7fgoCGK5/Dx lAkrDh/VRm+ZmSTixIRNm9H2Bg== X-Google-Smtp-Source: ABdhPJxB4zycaOzfPcVj08dAfSousKCRqSjwc8FkbIyNS9i8YSbXi137wYIv4cn/5PBua9F/dDyHFA== X-Received: by 2002:a05:6830:1df8:: with SMTP id b24mr11620926otj.292.1643033826816; Mon, 24 Jan 2022 06:17:06 -0800 (PST) Received: from ?IPV6:2804:431:c7cb:27f8:c505:63c0:de61:b716? ([2804:431:c7cb:27f8:c505:63c0:de61:b716]) by smtp.gmail.com with ESMTPSA id c26sm4296813oov.22.2022.01.24.06.17.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 24 Jan 2022 06:17:06 -0800 (PST) Message-ID: <4a8d0dab-d167-5755-e17b-b359fe6e1c5d@linaro.org> Date: Mon, 24 Jan 2022 11:17:04 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v9 3/3] elf: Add a test for PT_LOAD segments with invalid p_align [BZ #28688] Content-Language: en-US To: "H.J. Lu" , libc-alpha@sourceware.org Cc: Florian Weimer References: <20220121211205.268178-1-hjl.tools@gmail.com> <20220121211205.268178-4-hjl.tools@gmail.com> From: Adhemerval Zanella In-Reply-To: <20220121211205.268178-4-hjl.tools@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jan 2022 14:17:09 -0000 On 21/01/2022 18:12, H.J. Lu wrote: > Build tst-p_alignmod3.so with 256 byte page size and verify that it is > rejected with a proper error message. LGTM, thanks. Reviewed-by: Adhemerval Zanella > --- > elf/Makefile | 9 +++++++++ > elf/tst-p_align3.c | 27 +++++++++++++++++++++++++++ > elf/tst-p_align3.sh | 27 +++++++++++++++++++++++++++ > elf/tst-p_alignmod3.c | 25 +++++++++++++++++++++++++ > 4 files changed, 88 insertions(+) > create mode 100644 elf/tst-p_align3.c > create mode 100755 elf/tst-p_align3.sh > create mode 100644 elf/tst-p_alignmod3.c > > diff --git a/elf/Makefile b/elf/Makefile > index c63abab44b..ad1c0ea7b6 100644 > --- a/elf/Makefile > +++ b/elf/Makefile > @@ -416,6 +416,7 @@ tests += \ > tst-p_alignmod2-edit \ > tst-p_align1 \ > tst-p_align2 \ > + tst-p_align3 \ > tst-relsort1 \ > tst-ro-dynamic \ > tst-rtld-run-static \ > @@ -733,6 +734,7 @@ modules-names = \ > tst-nodelete-opened-lib \ > tst-null-argv-lib \ > tst-p_alignmod-base \ > + tst-p_alignmod3 \ > tst-relsort1mod1 \ > tst-relsort1mod2 \ > tst-ro-dynamic-mod \ > @@ -2608,3 +2610,10 @@ $(objpfx)tst-p_alignmod2.so: $(objpfx)tst-p_alignmod2-edit \ > cp $(objpfx)tst-p_alignmod-base.so $@ > $(test-wrapper-env) $(run-program-env) $(rtld-prefix) \ > $(objpfx)tst-p_alignmod2-edit $@ > + > +LDFLAGS-tst-p_alignmod3.so += -Wl,-z,max-page-size=0x100,-z,common-page-size=0x100 > + > +$(objpfx)tst-p_align3: $(objpfx)tst-p_alignmod3.so > +$(objpfx)tst-p_align3.out: tst-p_align3.sh $(objpfx)tst-p_align3 > + $(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \ > + $(evaluate-test) > diff --git a/elf/tst-p_align3.c b/elf/tst-p_align3.c > new file mode 100644 > index 0000000000..8be9f311bd > --- /dev/null > +++ b/elf/tst-p_align3.c > @@ -0,0 +1,27 @@ > +/* Check invalid p_align of PT_LOAD segments in a shared library. > + Copyright (C) 2022 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#include "tst-p_align.h" > + > +static int > +do_test (void) > +{ > + return do_load_test (); > +} > + > +#include > diff --git a/elf/tst-p_align3.sh b/elf/tst-p_align3.sh > new file mode 100755 > index 0000000000..688c4b34cc > --- /dev/null > +++ b/elf/tst-p_align3.sh > @@ -0,0 +1,27 @@ > +#!/bin/sh > +# Check invalid p_align of PT_LOAD segments in a shared library. > +# Copyright (C) 2022 Free Software Foundation, Inc. > +# This file is part of the GNU C Library. > + > +# The GNU C Library is free software; you can redistribute it and/or > +# modify it under the terms of the GNU Lesser General Public > +# License as published by the Free Software Foundation; either > +# version 2.1 of the License, or (at your option) any later version. > + > +# The GNU C Library is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > +# Lesser General Public License for more details. > + > +# You should have received a copy of the GNU Lesser General Public > +# License along with the GNU C Library; if not, see > +# . > + > +common_objpfx=$1; shift > +test_program_prefix=$1; shift > + > +${test_program_prefix} \ > + ${common_objpfx}elf/tst-p_align3 \ > + 2> ${common_objpfx}elf/tst-p_align3.out > +test $? -ne 127 && exit 1 > +grep "ELF load command address/offset not page-aligned" ${common_objpfx}elf/tst-p_align3.out > diff --git a/elf/tst-p_alignmod3.c b/elf/tst-p_alignmod3.c > new file mode 100644 > index 0000000000..c15de3d6f2 > --- /dev/null > +++ b/elf/tst-p_alignmod3.c > @@ -0,0 +1,25 @@ > +/* Check invalid p_align of PT_LOAD segment in a shared library. > + Copyright (C) 2022 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ > + > +#include "tst-p_align.h" > + > +int > +do_load_test (void) > +{ > + return 0; > +}