From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 22803385042D for ; Tue, 9 May 2023 12:25:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 22803385042D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=linux.vnet.ibm.com Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 349BDUu5019206; Tue, 9 May 2023 12:24:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=5A5XMPea4aTE7v6w8iZ699KgZ9uO1rv3hRQsck/tBeI=; b=d9GQTi5RPDCXdTJkmY0FruENqTrqHovIXYNgDh6NOYM99DdUUxR5+1Qih3R83NK0lyN+ iFUVbFxO4jAXtlGAm+KwFBTk3N9GQviJVbpZuRTN5uWnV7fI1rrepT/xlrzm1zpk1Taz XjgS464pj275Zg8Zxna6qkav1mvSQF64lk3BZtzhEi9GIBtJ0Sm/3iEa5jW0eVjRQ+R0 pmHbzDhkc4lsllEq94PFRbE7cFh9QpJQlpt+uKjLDYiVDrmPGYioYqYCHIP3WTyQC2ly 0nL8oaFIjq8dm1rJgbXDKclvQr936xKTPLjuEJU46rNLHNbGkSt7I5GriJPnnyLp7CXj 3g== Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qfkth4f51-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 May 2023 12:24:59 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3499TUO0002555; Tue, 9 May 2023 12:24:58 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([9.208.130.97]) by ppma05wdc.us.ibm.com (PPS) with ESMTPS id 3qf88u37j2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 09 May 2023 12:24:58 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 349COulP39518558 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 9 May 2023 12:24:57 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B315C5806A; Tue, 9 May 2023 12:24:56 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A65845805F; Tue, 9 May 2023 12:24:54 +0000 (GMT) Received: from [9.43.108.18] (unknown [9.43.108.18]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 9 May 2023 12:24:54 +0000 (GMT) Message-ID: <47ceecd1-1abd-383f-b4d6-0fd47b1969fc@linux.vnet.ibm.com> Date: Tue, 9 May 2023 17:54:52 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH] powerpc: Use sysconf (_SC_SIGSTKSZ) to set SIGSTKSZ and MINSIGSTKSZ. To: Tulio Magno Quites Machado Filho , Manjunath Matti via Libc-alpha Cc: rajis@linux.ibm.com, Manjunath Matti References: <20230424105208.301614-1-mmatti@linux.ibm.com> <874jozevbl.fsf@ascii.art.br> <7620a9b1-fe92-0764-6011-81d3a19e5590@linux.vnet.ibm.com> <871qjxe26c.fsf@ascii.art.br> <87wn1mdfwl.fsf@ascii.art.br> From: Manjunath S Matti In-Reply-To: <87wn1mdfwl.fsf@ascii.art.br> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: d8_lP15UTQRa291Hg4OehEbGEx9b1TcG X-Proofpoint-GUID: d8_lP15UTQRa291Hg4OehEbGEx9b1TcG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-09_08,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 spamscore=0 adultscore=0 phishscore=0 suspectscore=0 mlxlogscore=866 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305090097 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 05/05/23 7:44 pm, Tulio Magno Quites Machado Filho wrote: > Manjunath S Matti writes: > >> On 03/05/23 11:18 pm, Tulio Magno Quites Machado Filho wrote: >>> Manjunath S Matti writes: >>> >>>> On 28/04/23 11:35 pm, Tulio Magno Quites Machado Filho wrote: >>>>> Manjunath Matti via Libc-alpha writes: >>>>> >>>>>> +/* Minimum stack size for a signal handler: SIGSTKSZ/4. */ >>>>>> +# undef MINSIGSTKSZ >>>>>> +# define MINSIGSTKSZ (SIGSTKSZ >> 2) >>>>>> +#endif >>>>> I didn't understand this part. >>>>> Why SIGSTKSZ/4 ? I know this is correct now, but I think the kernel is >>>>> allowed to use another value. >>>>> Why is this part not using sysconf(_SC_MINSIGSTKSZ)? >>>>> I'm not suggesting to use sysconf() here, but I'm trying to understand >>>>> why the same source of value for both SIGSTKSZ and MINSIGSTKSZ is not >>>>> being used. >>>> In file: sysdeps/unix/sysv/linux/sysconf-sigstksz.h >>>> >>>>  28   if (minsigstacksize < MINSIGSTKSZ) >>>>  29     minsigstacksize = MINSIGSTKSZ; >>>>  30   /* MAX (MINSIGSTKSZ, sysconf (_SC_MINSIGSTKSZ)) * 4.  */ >>>>  31   long int sigstacksize = minsigstacksize * 4; >>>> >>>> So we are not changing the default implementation. >>> I'm not sure I understood you. Are you trying to tell me that you want >>> sysconf_sigstksz() to continue to return the same result? >> Do you want me to implement a powerpc specific function ? >>> If this is the case, be careful with the creation of >>> sysdeps/unix/sysv/linux/powerpc/bits/sigstksz.h because it is an >>> installed header. That means the values that are being set here will leak >>> to user code if __USE_DYNAMIC_STACK_SIZE is defined. >>> >>> If that happens, user code may end up having >>> MINSIGSTKSZ != getauxval(AT_MINSIGSTKSZ) if the kernel decides to change >>> the value of AT_MINSIGSTKSZ. >> My observation is that, MINSIGSTKSZ is not the same as >> getauxval(AT_MINSIGSTKSZ). > OK. And I'm trying to warn you there is a risk of having > MINSIGSTKSZ < getauxval(AT_MINSIGSTKSZ) when __USE_DYNAMIC_STACK_SIZE > is defined. Am I missing some thing, please help me understand the file sysdeps/unix/sysv/linux/sysconf-sigstksz.h sets up the value of minsigstacksize =_dl_minsigstacksize and then compares if it is less than MINSIGSTKSZ line no 28. then sig  24   long int minsigstacksize = GLRO(dl_minsigstacksize);  25   assert (minsigstacksize != 0);  26   _Static_assert (__builtin_constant_p (MINSIGSTKSZ),  27                   "MINSIGSTKSZ is constant");  28   if (minsigstacksize < MINSIGSTKSZ)  29     minsigstacksize = MINSIGSTKSZ;  30   /* MAX (MINSIGSTKSZ, sysconf (_SC_MINSIGSTKSZ)) * 4.  */  31   long int sigstacksize = minsigstacksize * 4;  32   /* Return MAX (SIGSTKSZ, sigstacksize).  */  33   _Static_assert (__builtin_constant_p (SIGSTKSZ),  34                   "SIGSTKSZ is constant");  35   if (sigstacksize < SIGSTKSZ)  36     sigstacksize = SIGSTKSZ;  37   return sigstacksize; > I'm afraid we're diverging from the original discussion, which is: > the minimum stack size for a signal handler is calculated from the > amount of data the kernel needs to save in the stack. > > The kernel calculates that and provide it via getauxval(AT_MINSIGSTKSZ). > AFAIU, calculating the minimum stack size for a signal handler based on > getauxval(AT_SIGSTKSZ) may lead to errors because there are no > guarantees that getauxval(AT_SIGSTKSZ)/4 > getauxval(AT_MINSIGSTKSZ), > even if that is true now, it isn't future proof. We are infact deriving sigstacksize value from minsigstacksize * 4, line number 30, 32, 35 to 37. > Besides that, the test I suggested to implement would guarantee that > glibc code remains up-to-date according to the interpretation that is > adopted. I will definitely add a testcases just to check what value are we getting from the kernel. > Thanks for elaborating your explanation! > That was really helpful. > Thank you for helping me out here!