From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id B34833858001 for ; Fri, 16 Feb 2024 12:47:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B34833858001 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B34833858001 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::42d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708087660; cv=none; b=rz1bPBiPcz3yPOVwP5TqUdY0LXyVARA541YQ0so4hVqGqdkHtNKSPxu6SBAFtoI7azHJncIVqZeMyQffcPQ01DZ5lyxxBPmrKszBHIUFpyLnw1di/gnCAFCKV7kgy4ecsHB8LyB5Dc43LjX50bIHyDxpa+0oq1BLuwMOiMohhWw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708087660; c=relaxed/simple; bh=w/2konn1s0e1+GJyj1XPosY0/tRzyS6M9WotnrLZaDg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=rKFBQhx7iluNvDI1jKA2DaSSMoYPnptPapWYDlBvZ7ZbQTl6+ZAbBGawTgnzrEcVG8S5C8iXR+le3yqwnLxTb1At/74g1HmAmkxkY70eQHBxbBIfIt8Le4L97p+7osB5CRwEA2OLJLoq4jOG6xcCts5VdB791MURlUZreLR3Zvw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6e0507eb60cso1342045b3a.3 for ; Fri, 16 Feb 2024 04:47:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1708087655; x=1708692455; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=twbHqUsLD0vY0YKmMUJsYcyBUfCGPeGZdJ9EGEZhDI4=; b=Kjz9UJYdIYM9J9xmClzMsiwCJHoZ1YeB8GazmshCGAbDdNXV4kINrMRsLXozQZcgeh bWWMp/deS0yKIHMsqcYDENd9esSBZEacl+EKohiGXujxjsJbihICXB9BKiZV1+YF7YGp 876Q1fWErhMFlCEoozQPcLBjVw0+QFPPkNpsb669yHtKAimwtup8uvSyRFkZcanFj178 eNlGGvgcc2j5f6qbrKF77mhsrf5v6p4S3Mqr/TJ2ePb9V/+LlsHZlRlJHVEEl4MysnU/ WEO6r/MYnNMAvps6Y5HjvKgKwilG/h61QaTihMeIWL16vPHntheg0xTmbbesyNprtCWk jghw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708087655; x=1708692455; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=twbHqUsLD0vY0YKmMUJsYcyBUfCGPeGZdJ9EGEZhDI4=; b=F4ybrR0htRb6Lgv51gka+hO6n1hRFxSHJWJmr1UXLGFLbB493VZCz+OA4K3RgBNbbX 7F3j2iUQzmVpp04CmZ4JmrbP/8mBz7GyPKvYMxo5VBlI9znKYFVuY1zaxOFIYEblCbs5 E+/sWxt2ELbwDzfVz/Hh4Aa6oids+Hm0cy6vu44kTZg2rlKy1jMO2KABLvRMS865KaaP Nlu629N/SfNGdhico5NDF9k4yDgDvl/vgtSGEwsksktgwS5cKncHvJUOH9cIWDndccwp rvfnqMEtWlI6fWPDi0nWqixYPydNZaU34awcHu092NG1Cpuufhtugkvk70DcyqMUMZCh t07A== X-Gm-Message-State: AOJu0YweGLrruML1xTdm9PtLcL06gRjwbsF3hYJjpyhuQ7UgNRFU4MJP UUACry92H7/95SqlaSGCeIS7gDBp2908edkyboAkWCnVxMf79JXkMvXCW/a7xFM= X-Google-Smtp-Source: AGHT+IEiEDpBTtgq47yeTa937xviPae4/+YKW0ByI1R47+26i4AdP7hMg6WIQAsR4eb6okO2CaHs2g== X-Received: by 2002:a05:6a20:d707:b0:19e:be98:fc68 with SMTP id iz7-20020a056a20d70700b0019ebe98fc68mr5232175pzb.52.1708087654681; Fri, 16 Feb 2024 04:47:34 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c0:8177:542a:9f26:15a9:5ce4? ([2804:1b3:a7c0:8177:542a:9f26:15a9:5ce4]) by smtp.gmail.com with ESMTPSA id b13-20020a63340d000000b005dc48e56191sm3086096pga.11.2024.02.16.04.47.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Feb 2024 04:47:34 -0800 (PST) Message-ID: <984b51c6-920a-40c5-aa1f-182efdd1af92@linaro.org> Date: Fri, 16 Feb 2024 09:47:30 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 2/2] x86: Update _dl_tlsdesc_dynamic to preserve caller-saved registers Content-Language: en-US To: "H.J. Lu" , Florian Weimer Cc: libc-alpha@sourceware.org, Fangrui Song , Carlos O'Donell References: <20240213041501.2494232-1-hjl.tools@gmail.com> <20240213041501.2494232-3-hjl.tools@gmail.com> <871q9d7wra.fsf@oldenburg.str.redhat.com> <87mss061s0.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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 16/02/24 09:37, H.J. Lu wrote: > On Fri, Feb 16, 2024 at 4:20 AM H.J. Lu wrote: >> >> On Fri, Feb 16, 2024 at 4:18 AM Florian Weimer wrote: >>> >>> * H. J. Lu: >>> >>>> On Thu, Feb 15, 2024 at 10:23 PM Florian Weimer wrote: >>>>> >>>>> * Adhemerval Zanella Netto: >>>>> >>>>>>> diff --git a/elf/malloc-for-test.map b/elf/malloc-for-test.map >>>>>>> new file mode 100644 >>>>>>> index 0000000000..8437cf4346 >>>>>>> --- /dev/null >>>>>>> +++ b/elf/malloc-for-test.map >>>>>>> @@ -0,0 +1,6 @@ >>>>>>> +GLIBC_2.0 { >>>>>> >>>>>> You need to use the correct version to override the malloc: >>>>>> >>>>>> $ gdb --args tst-gnu2-tls2 --direct >>>>>> [...] >>>>>> (gdb) b apply_tls >>>>>> (gdb) r >>>>>> Thread 2 "tst-gnu2-tls2" hit Breakpoint 1, apply_tls (p=0x7ffff7bfee80) at tst-gnu2-tls2mod1.c:25 >>>>>> 25 { >>>>>> (gdb) b malloc >>>>>> Breakpoint 2 at 0x7ffff7ca8ad0: malloc. (3 locations) >>>>>> (gdb) c >>>>>> Continuing. >>>>> >>>>> Why do we need to set a symbol version here? I think this can be >>>>> removed. >>>> >>>> malloc-for-test.so provides a fake malloc to clobber caller-save >>>> registers. Since malloc in ld.so has a symbol version, >>>> >>>> struct r_found_version version; >>>> version.name = symbol_version_string (libc, GLIBC_2_0); >>>> version.hidden = 0; >>>> version.hash = _dl_elf_hash (version.name); >>>> version.filename = NULL; >>>> >>>> void *new_calloc = lookup_malloc_symbol (main_map, "calloc", &version); >>>> void *new_free = lookup_malloc_symbol (main_map, "free", &version); >>>> void *new_malloc = lookup_malloc_symbol (main_map, "malloc", &version); >>>> void *new_realloc = lookup_malloc_symbol (main_map, "realloc", &version); >>>> >>>> malloc in malloc-for-test.so must have the same version. Otherwise, >>>> it won't be used in the test. >>> >>> I thought that unversioned symbols interpose all versioned symbols. Has >>> this changed in the dynamic linker? >> >> Only for this case. >> > > I was wrong. Version isn't needed. Will fix it. > Indeed, but I think we also improve the register check testing since just clobbering on malloc does not really provide much coverage.