Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2100026rwb; Sun, 15 Jan 2023 09:10:43 -0800 (PST) X-Google-Smtp-Source: AMrXdXssOkRSEia+kS5lmGqYJEDM+s93D+uvM0fKOeQPWKv93MbkGdHiZ0wsN6CqJbTJ6Vl/YAVW X-Received: by 2002:a17:906:9f07:b0:7ec:27d7:1838 with SMTP id fy7-20020a1709069f0700b007ec27d71838mr92465224ejc.22.1673802643682; Sun, 15 Jan 2023 09:10:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673802643; cv=none; d=google.com; s=arc-20160816; b=ltAiEas0ZU9vGIlSD1aJWQDDmft1Rn9LUOjsjHmSyoUluoNnYCWeu79J7jh4OAAJgc Db5FrAtYROvUEqvecoufEvSlTbp2W5DcmX/EuAioGvGTkfm7EfqP7rk7Rkw9oANyB1YO H4iwWHghHP82GINmtrGSoZ/Ua/M6X+Gkl/7ldHzzXb/sMu707odb7q2w9kxTwl82JpRG nM7EPOwYUJdSY8E7BxSVOif1WmufppnsbL0gWJu5/8bwh9kGSGr7T8K+DqQZqXhUFhKv 4g7UmjBeOqA+YHUav2rRRNNLpbAxpmXNB622y9Po79md/rIirO7yK7ZDgmRaZxc5bApt CndQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=3iCpKQNhAZTfqoNRbhsxk1OJR+4gpav6cfM2Fo8UTRs=; b=KT+Nix3xzWNCtE+TDrGoxlQQyVZWvycq6eULJbvc/GIyray1JrCvxbtxBzvYcUdWls /DoN1FET/1jHHkcEpMG1wUC2iruRccSyginY1AlqpLibsE3PDNDLGHIFM8tiXQBQbZ8I NXv/WZG1qmeS+Ex/FTBeMynzi+m6pnAwmjm0lO2deMYDI0y9c4t/2hhl1URGgMbWdcIC EK7G7HoSt/10aT980wSVPeOCeqUxwEn8TdSCl77mjhxvortUQvRX8OAWVNUqHf8oSh8j IIEwUdyVUPujjf4XDIbUZdRzq4tL4oGRvD5VGIZaIZcFseTvZI8xTcMEaRcfz7VzlchS rgqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=YENzDR2B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di19-20020a170906731300b0084bbd97edc4si33943836ejc.573.2023.01.15.09.10.30; Sun, 15 Jan 2023 09:10:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=YENzDR2B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230285AbjAORHb (ORCPT + 52 others); Sun, 15 Jan 2023 12:07:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231487AbjAORHN (ORCPT ); Sun, 15 Jan 2023 12:07:13 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC00612840; Sun, 15 Jan 2023 09:06:57 -0800 (PST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by gnuweeb.org (Postfix) with ESMTPSA id 850E581870; Sun, 15 Jan 2023 17:06:57 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1673802417; bh=dcakJR7qlaPRzeX+cbXVY0AH02DQvlsTZgd8qrY95Xw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=YENzDR2BXOxMKqQZzEeXT2Hry+3iEzqlrZG7JNsx5WLBLxVCe6wPjTkCKUTwBkTY4 SkKZvi5afylGxCkms6UA1NmA3GzAKh/nyoTxXbspkLPeun/Z1GJoaUYACwVVPjAgWf ssKF2r/xFuq83zEN7smPYnHDBGN+WGVsAoZAMXnyRpz6rfRBMp3KEv3zpTMprjFifI B2ok2g1ynlnzPR095GYckVfHk7V59lEMCBV5n1Hi6RE1VF/oGvqyS5gwyQa/0WfKvD /7vb+8ZQjyAOEHrJM+Yj+WssJxYW9hKUXOzN/rEhVJ41RUO9X42WTtGMkzkeFadyQp TWLOpdiucK1gg== Received: by mail-lf1-f41.google.com with SMTP id o20so7810627lfk.5; Sun, 15 Jan 2023 09:06:57 -0800 (PST) X-Gm-Message-State: AFqh2kr948a1htGx5MpZwvGizMEhsfaaU6adrPs0s+/d0M0XKdkTjfEi ysZ7yUfroXCKCQCu3h2sVY/WRjKaYhk/bwgE/Ws= X-Received: by 2002:ac2:4c32:0:b0:4b5:798a:9087 with SMTP id u18-20020ac24c32000000b004b5798a9087mr6093252lfq.314.1673802415554; Sun, 15 Jan 2023 09:06:55 -0800 (PST) MIME-Version: 1.0 References: <20230108135904.851762-1-ammar.faizi@intel.com> <20230108175842.GB18859@1wt.eu> <20230108184930.GC18859@1wt.eu> In-Reply-To: From: Alviro Iskandar Setiawan Date: Mon, 16 Jan 2023 00:06:44 +0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 0/5] nolibc signal handling support To: Ammar Faizi Cc: Willy Tarreau , Shuah Khan , "Paul E. McKenney" , Gilang Fachrezy , "GNU/Weeb Mailing List" , VNLX Kernel Department , Linux Kernel Mailing List , Linux Kselftest Mailing List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 15, 2023 at 11:01 PM Ammar Faizi wrote: > That is not the 'sigset_t' that the kernel wants. The kernel wants the > 'sigset_t' that is in : > > #define _NSIG 64 > #define _NSIG_BPW __BITS_PER_LONG // this 64 on x86-64, but 32= on i386. > #define _NSIG_WORDS (_NSIG / _NSIG_BPW) > > typedef struct { > unsigned long sig[_NSIG_WORDS]; > } sigset_t; > > The above struct is always 8 bytes in size. In other words: > > _NSIG_WORDS =3D=3D 2 on i386 > _NSIG_WORDS =3D=3D 1 on x86-64 > sizeof(unsigned long) =3D=3D 4 on i386 > sizeof(unsigned long) =3D=3D 8 on x86-64 > > Therefore, sizeof(unsigned long [_NSIG_WORDS]) is always 8 on both > architectures. That's the correct size. > > I tried to #include but it conflicts with the > other 'sigset_t' definition. So I can't do that. Read the glibc sigaction implementation, it has different struct sigaction definitions for user and kernel too. https://sourceware.org/git/?p=3Dglibc.git;a=3Dblob;f=3Dsysdeps/unix/sysv/li= nux/libc_sigaction.c;h=3D3cbf241a5fa28296c910fa40a41b09d2b6113b05;hb=3D7e31= d166510ac4adbf53d5e8144c709a37dd8c7a Since nolibc compiles everything in a single translation unit, you can't have a different sigset_t definition. You need to copy the definition to nolibc header and change the type name to something else for internal use only. > Why are there two different definitions of 'sigset_t'? I don't know. > > I probably should read the story behind this syscall to get it > implemented right. Let me ponder this again on Monday. But at least I > tell what I have found so people can give some comments on it... `man 2 rt_sigaction` tells the story. Here is the bedtime story, have a nice dream :-) The original Linux system call was named sigaction(). However, with the addition of real-time signals in Linux 2.2, the fixed-size, 32-bit sigset_t type supported by that system call was no longer fit for purpose. Consequently, a new system call, rt_sigaction(), was added to support an enlarged sigset_t type. The new system call takes a fourth argument, size_t sigsetsize, which specifies the size in bytes of the signal sets in act.sa_mask and oldact.sa_mask. This argument is currently required to have the value sizeof(sigset_t) (or the error EINVAL results). The glibc sigaction() wrapper function hides these details from us, transpar=E2=80=90 ently calling rt_sigaction() when the kernel provides it.