[PATCH 2/2] jmpbuf: Add paddings for target specific usage

H.J. Lu hjl.tools@gmail.com
Tue Nov 14 13:11:00 GMT 2017


On Tue, Nov 14, 2017 at 4:26 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 11/14/2017 12:22 AM, H.J. Lu wrote:
>>
>> diff --git a/setjmp/tst-sigsetjmp2.c b/setjmp/tst-sigsetjmp2.c
>> new file mode 100644
>> index 0000000000..131531feb0
>> --- /dev/null
>> +++ b/setjmp/tst-sigsetjmp2.c
>> @@ -0,0 +1,50 @@
>> +/* Test that sigprocmask does not read from the unused part of jmpbuf.
>> +   Copyright (C) 2017 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
>> +<http://www.gnu.org/licenses/>.  */
>> +
>> +#include <stdlib.h>
>> +#include <signal.h>
>> +#include <setjmp.h>
>> +#include <stdio.h>
>> +#include <string.h>
>> +#include <errno.h>
>> +#include <jmp_buf-macros.h>
>> +#include <support/next_to_fault.h>
>> +
>> +static int
>> +do_test (void)
>> +{
>> +  struct support_next_to_fault jmpbuf
>> +    = support_next_to_fault_allocate (SAVED_MASK_OFFSET + (_NSIG / 8));
>> +  struct __jmp_buf_tag *sj = (struct __jmp_buf_tag *) jmpbuf.buffer;
>> +
>> +  errno = 0;
>> +  if (sigsetjmp (sj, 1) == 0)
>> +    {
>> +      siglongjmp (sj, 1);
>> +      return EXIT_FAILURE;
>> +    }
>> +  if (errno != 0)
>> +    {
>> +      printf ("sigsetjmp: %s\n", strerror (errno));
>> +      return EXIT_FAILURE;
>> +    }
>> +  return EXIT_SUCCESS;
>> +}
>> +
>> +#define TEST_FUNCTION do_test ()
>> +#include "../test-skeleton.c"
>
>
> Please use <support/test-driver.c>.

Done.

> Wouldn't the test start to fail if sigsetjmp/siglongjmp actually started
> using the padding you are freeing up for use?

You are right.

> I think you need test sigprocmask directly to ensure it has the desired
> property of not clobbering the padding.

Here is the updated patch.   OK for master?

Thanks.


-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-jmpbuf-Add-paddings-for-architecture-specific-usage.patch
Type: text/x-patch
Size: 16310 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20171114/d8e301a7/attachment.bin>


More information about the Libc-alpha mailing list