From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eastern.birch.relay.mailchannels.net (eastern.birch.relay.mailchannels.net [23.83.209.55]) by sourceware.org (Postfix) with ESMTPS id E791A3858D35 for ; Wed, 22 Nov 2023 12:23:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E791A3858D35 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=sourceware.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=sourceware.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E791A3858D35 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=23.83.209.55 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700655835; cv=pass; b=vZhth0bdiP+dRXbVolxhKmeTqlvsxaTN8mlbSvK4ZUzBJilzFEICHiXfkHbgvzWCKzYUVQSZGpTyxon4WuU2WsLnrHQ6qVb1gHn0o2GHzvDi4PnySgiEn5GDGQ2X8Fm90zbxLamCPE4bQpuSSkSI8igFG8jv5tRd0Bsm2jZS/EU= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1700655835; c=relaxed/simple; bh=UTmhfai82OYnVHWyc4k1GMoi69Z3wVLnjit+6vEKVPU=; h=Message-ID:Date:MIME-Version:Subject:To:From; b=jXIEXU56nTV6hBlPoILrU0gdWW5oVumm79Ny7jt0PleRTslc6PRCEaO6OVRcxLUjrLxjVRbf6JsIghuZ5Rfkt9Q0JH6RKYhQAz16b2ew0H0qIDD9WpTWI34uzz/NAgmj4nAR2FhwKSJan+l4J6+VQcHZf/szw6G0P6tfKw+gk2o= ARC-Authentication-Results: i=2; server2.sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A85BC4C21E3; Wed, 22 Nov 2023 12:23:52 +0000 (UTC) Received: from pdx1-sub0-mail-a217.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 27C9F4C2481; Wed, 22 Nov 2023 12:23:52 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1700655832; a=rsa-sha256; cv=none; b=vja5vLpWhYBlpdG4WrgDQ8+Q7wX7Ps+iMr2d2icVbh5FmiqJu4OeQLlMSPdOOVBq4dR06C RZfh4WG+HygKHhGtgHp0GqIEsnUeOVlE1UNM/8ZawR4kRnl2QQW5xr508sPLNvNJYhmMuk cD54vBac+EZOen9bpeY6I7w2P/CcKrdG8zi9YE4eWyDIgbohD3DQOeO6a2DlVGYrLrGCsC rENbmRnQKjjeIEa53BQzB6iApMO0pnfECQr0VJHM7P+3lTUWi8taCWx7pcdVoM8mcdAnxa y5o7fAUbltGZ6tgBbTTMBH4tCxJjla0t1sEdoFGwS+1Z0BfG2qWIWMcpn89rxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1700655832; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZI0hN2Kxu782aiXBshL4IFDfQ3SAmEs8a7tGQKWhhrc=; b=MfarjwokHLvqBKq8jZqBSiC8opmrcEnyQVewd2GPI8Ls/y0CVAI1QnC/1FcI4yNAgJ1FKl u0Jo7FERbCTn3E+CKCP3ARJ4mxiTmzLzQ4fQCisw3oF4nN6dKGPCRcOYNU3hXDJ9/BqDDM DGFc6j0tpTDq7IfRoqc7b6ZiMl2ewQqD+893PBPN8C80WvQrMNpozN9ulKmVD7t02VGrn7 pRIiLj9usR9g7KTLgSrSV0fKVY5UZcd++LNFxQZEUhKzahX/QIYmz/4b+Ga7apTL9r1QV6 nqHZEkINi0In+MzocID3GbfVOWbv9VDZY+145QtFRhf97ZJ+RtsBsxIIjH6G3g== ARC-Authentication-Results: i=1; rspamd-5f5ccc4f7-7jcmm; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@sourceware.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Daffy-Cure: 3ebfdda42e04a233_1700655832305_140911298 X-MC-Loop-Signature: 1700655832304:1342805531 X-MC-Ingress-Time: 1700655832304 Received: from pdx1-sub0-mail-a217.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.97.99.7 (trex/6.9.2); Wed, 22 Nov 2023 12:23:52 +0000 Received: from [192.168.2.12] (bras-vprn-toroon4834w-lp130-02-142-113-138-136.dsl.bell.ca [142.113.138.136]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a217.dreamhost.com (Postfix) with ESMTPSA id 4Sb0lq5tcCz32; Wed, 22 Nov 2023 04:23:51 -0800 (PST) Message-ID: <7692cb6a-0832-403c-b704-b4f143b21e12@sourceware.org> Date: Wed, 22 Nov 2023 07:23:50 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 11/19] elf: Do not duplicate the GLIBC_TUNABLES string Content-Language: en-US To: Adhemerval Zanella Netto , libc-alpha@sourceware.org References: <20231106202552.3404059-1-adhemerval.zanella@linaro.org> <20231106202552.3404059-12-adhemerval.zanella@linaro.org> <0be5babe-a123-47af-98e1-abab4d1c7fd2@sourceware.org> From: Siddhesh Poyarekar In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1164.7 required=5.0 tests=BAYES_00,BODY_8BITS,KAM_DMARC_NONE,KAM_DMARC_STATUS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_SOFTFAIL,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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 2023-11-21 13:12, Adhemerval Zanella Netto wrote: >>> -tunable_initialize (tunable_t *cur, const char *strval) >>> +tunable_initialize (tunable_t *cur, const char *strval, size_t len) >>>   { >>> -  tunable_val_t val; >>> +  tunable_val_t val = { 0 }; >>>       if (cur->type.type_code != TUNABLE_TYPE_STRING) >>>       val.numval = (tunable_num_t) _dl_strtoul (strval, NULL); >> >> There's an implicit assumption that strval is NULL terminated for numeric values.  Is that safe?  Maybe all you need to do here is copy strval into a static buffer of size 21 (basically size of the string representing -1ULL) and pass that to _dl_strtoul. > > Afaiu the environment variable will always be NULL terminated (although some > might overlap). This is due how the kernel will layout the argv/envp on > process creation at sys_execve: Sure, but the strval here should not be the entire envvar, just the value portion of it. Granted that _dl_strtoul will bail out on the first non-numeric character, so maybe it's not >>> -      if (disable) >>> +      if (n.disable) >>>           { >>>             CHECK_GLIBC_IFUNC_CPU_OFF (n, cpu_features, POPCNT, 6); >>>             CHECK_GLIBC_IFUNC_CPU_OFF (n, cpu_features, SSE4_1, 6); >>>             CHECK_GLIBC_IFUNC_CPU_OFF (n, cpu_features, SSE4_2, 6); >>> -          if (memcmp (n, "XSAVEC", 6) == 0) >>> +          if (memcmp (n.str, "XSAVEC", 6) == 0) >> >> Why does this use the bare memcmp and not the tunables_strcmp? > > If I recall correctly, I did tried it and it resulted in worse codegen. The > tunable_str_comma_strcmp also checks the size, which on the x86 code is not > required and for some reason compiler can not eliminate. Why isn't it required? Couldn't n.str be smaller than 6 chars? Thanks, Sid