From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27267 invoked by alias); 21 Nov 2017 22:22:51 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 27256 invoked by uid 89); 21 Nov 2017 22:22:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=honest X-HELO: mail-ot0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=f0oH3iI9PEDLsiQyyy/bHty6iP3OjTXcybQogR/GkqI=; b=E6Hs/wtq+O8fmtIZfZjSouCTe0ueqosUaY1lEC/OkTBOt9zJefCJ7IpnwvGjd5us5E SjGgQ/tUGRTQz7gCJh5Wiz+QEV5zmeSuzQof5VAOrsGJIbI0VbcelL8jzd5vo3IUiQ+1 yoYwqvmn2jMbfRWxRMA+aPCr5lnbVGCfj3ko9tEFJUTSDsHWea76sMDbAy423KwLs0Im uxCbwNgARY2Iubm/iT0prIVNWZ8ZJhuklxA5t56IAB4ODzZ6DaJddr1iM1jc39lb3OT/ lDYkZTdmcOh7YoTxVcuz6avxQMswyyHzZvZLrr+b8ccw4CfIq7fG5+B8FOPqZZgTD1kN XkbQ== X-Gm-Message-State: AJaThX6I0KuASvdPfTfOFIUnffSskcbrwgxm4PZJ/SUdvCf0xrlK46hZ 7HVprR3WcwrPLoLyvQD8jRI+VmUlaQB+lau7TN+1aQ== X-Google-Smtp-Source: AGs4zMaLeeciihLEVNDCFWtz5mUkYytjR1Qf7U3rITtkPaDq89wt3WdXE1R2dMpBxBIwvopZY61DI9bslGOGjYgXMiQ= X-Received: by 10.157.89.173 with SMTP id u45mr1129125oth.341.1511302967693; Tue, 21 Nov 2017 14:22:47 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <20171107223908.GB46190@intel.com> <33f4a80e-b377-a9c8-1fba-c136211154be@redhat.com> <7874b7d1-bf58-4fb2-b3e3-aba07db76bfa@redhat.com> <3a270ef7-eae6-e8cb-f7bb-7de8b9a926dc@redhat.com> <08d27473-93ca-a0fe-83ac-78db1732befc@redhat.com> <5e692320-fe48-88c4-9440-0276f2b8795b@redhat.com> From: "H.J. Lu" Date: Tue, 21 Nov 2017 22:22:00 -0000 Message-ID: Subject: Re: [PATCH 2/2] jmpbuf: Add paddings for target specific usage To: Florian Weimer Cc: GNU C Library Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2017-11/txt/msg00762.txt.bz2 On Wed, Nov 15, 2017 at 5:20 AM, H.J. Lu wrote: > On Wed, Nov 15, 2017 at 3:10 AM, Florian Weimer wrote: >> On 11/14/2017 02:10 PM, H.J. Lu wrote: >>> >>> +static int >>> +do_test (void) >>> +{ >>> + sigjmp_buf sj; >>> + struct support_next_to_fault sigset_t_buf >>> + = support_next_to_fault_allocate (SIZEOF_SIGSET_T); >>> + sigset_t *m_p = (sigset_t *) sigset_t_buf.buffer; >>> + sigset_t m; >>> + >>> + sigemptyset (&m); >>> + memcpy (m_p, &m, SIZEOF_SIGSET_T); >>> + sigprocmask (SIG_SETMASK, m_p, NULL); >>> + memcpy (&m, m_p, SIZEOF_SIGSET_T); >>> + if (sigsetjmp (sj, 0) == 0) >>> + { >>> + sigaddset (&m, SIGUSR1); >>> + memcpy (m_p, &m, SIZEOF_SIGSET_T); >>> + sigprocmask (SIG_SETMASK, m_p, NULL); >>> + memcpy (&m, m_p, SIZEOF_SIGSET_T); >>> + siglongjmp (sj, 1); >>> + return EXIT_FAILURE; >>> + } >>> + sigprocmask (SIG_SETMASK, NULL, m_p); >>> + memcpy (&m, m_p, SIZEOF_SIGSET_T); >>> + return sigismember (&m, SIGUSR1) ? EXIT_SUCCESS : EXIT_FAILURE; >>> +} >> >> >> Sorry, I don't understand anymore what this test is supposed to test and >> how. > > This tests the reduced __jmp_buf_sigset_t used by __saved_mask is > bigger than sigset expected by kernel. > >> To be honest, I don't like how you inject the internal definition of >> jmp_buf. Is this the way we do it for the nptl types? > > I only need to make some room in > > /* Calling environment, plus possibly a saved signal mask. */ > struct __jmp_buf_tag > { > /* NOTE: The machine-dependent definitions of `__sigsetjmp' > assume that a `jmp_buf' begins with a `__jmp_buf' and that > `__mask_was_saved' follows it. Do not move these members > or add others before it. */ > __jmp_buf __jmpbuf; /* Calling environment. */ > int __mask_was_saved; /* Saved the signal mask? */ > __sigset_t __saved_mask; /* Saved signal mask. */ > }; > > for target specific purpose. I changed it to > > struct __jmp_buf_tag > { > /* NOTE: The machine-dependent definitions of `__sigsetjmp' > assume that a `jmp_buf' begins with a `__jmp_buf' and that > `__mask_was_saved' follows it. Do not move these members > or add others before it. */ > __jmp_buf __jmpbuf; /* Calling environment. */ > int __mask_was_saved; /* Saved the signal mask? */ > union > { > __sigset_t __saved_mask_compat; > struct > { > __jmp_buf_sigset_t __saved_mask; > /* Paddings for architecture specific usage. */ > unsigned long int __padding[12]; > } __saved; > } __saved_mask; > }; > > #define __saved_mask __saved_mask.__saved.__saved_mask > > I did only to __sigset_t in __jmp_buf_tag and this test verifies that the size > of __jmp_buf_sigset_t works with sigprocmask. > > Are you suggesting we make some room in __sigset_t directly? This will > require very extensive changes. If not, what do you exactly suggest? > >> I think you should check _JUMP_BUF_SIGSET_NSIG against a kernel constant >> (_NSIGS?) somewhere. > > There is a _Static_assert in include/setjmp.h. But it isn't triggered. This > updated patch moves it to sysdeps/unix/sysv/linux/__saved_mask.h. Now > I got > > ../sysdeps/unix/sysv/linux/__saved_mask.h:32:1: error: static > assertion failed: "size of ___saved_mask < size of > __sigprocmask_sigset_t" > _Static_assert (sizeof (___saved_mask) >= sizeof (__sigprocmask_sigset_t), > > if __jmp_buf_sigset_t is too small. > > -- > H.J. Any comments, suggestions or objections? The patch is at https://sourceware.org/ml/libc-alpha/2017-11/msg00510.html -- H.J.