From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 21C9D384640E for ; Wed, 24 Apr 2024 21:35:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 21C9D384640E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 21C9D384640E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713994548; cv=none; b=axVqu+OJTsc6bzIYDbvYPvIdqIEaRo1taGeU5wzWtPHrTX1RYg9q6+8sLiGvOxN9I99iPZGEhTkHQAT6ok4n3iFkGMNyvXiSOFDaZ4eW2/vnsMNpb5p+ya2K+bAbJstCIkH1kj+d61Q0XE12UkcqnANn9xGBf3zDVaI4sze8GJ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713994548; c=relaxed/simple; bh=9/7Lh+/jTWJEW4CyIsu6P/SuhCkcqUc/Ijl0SijtHgQ=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=aX2ydfq9ozOLoLClImHkNJGrChIQL52fEf71s/K/LL00kw/sM5HFOuMOKhxEbcIxaCyaJXtVE7GAdKc27Kr8jJTRvuSdtBevj8qExONkFwjaIdHyzVAMe2uhM59ASwIjNqUbckd1tGvWJZoGQgUTfJpsl/SUw28eOS6yvYhMEmM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 119DA21C06; Wed, 24 Apr 2024 21:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713994546; h=from:from:reply-to: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=rC1emi/UQQViTa00UHWTgmpsZxZk6pmdLnR+qMLNFNc=; b=AuSU451UE7QrjdW0FLZh911OeUlpmUzrDMGdxqnvRI7rxEhUyTUwUbVOdbw8z9SscpVu89 eI17KAEyqp8TYZpM+aHT1VsVIvdvHTud4bHygat73BKtn/R9ZNJn3E16Sm5BLU0iIeGmDs TRj2atPKViVS5xK2KqUUNc96IVbK3Ig= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713994546; h=from:from:reply-to: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=rC1emi/UQQViTa00UHWTgmpsZxZk6pmdLnR+qMLNFNc=; b=Np06kB0V5ERnQI8xkwiPHrjZVHvc17wo2fEtL2D593uUCrNCTrnGxZ8oT4d8vU4dAaVEQj hVGg+QKMRiLVOKCQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=AuSU451U; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Np06kB0V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713994546; h=from:from:reply-to: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=rC1emi/UQQViTa00UHWTgmpsZxZk6pmdLnR+qMLNFNc=; b=AuSU451UE7QrjdW0FLZh911OeUlpmUzrDMGdxqnvRI7rxEhUyTUwUbVOdbw8z9SscpVu89 eI17KAEyqp8TYZpM+aHT1VsVIvdvHTud4bHygat73BKtn/R9ZNJn3E16Sm5BLU0iIeGmDs TRj2atPKViVS5xK2KqUUNc96IVbK3Ig= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713994546; h=from:from:reply-to: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=rC1emi/UQQViTa00UHWTgmpsZxZk6pmdLnR+qMLNFNc=; b=Np06kB0V5ERnQI8xkwiPHrjZVHvc17wo2fEtL2D593uUCrNCTrnGxZ8oT4d8vU4dAaVEQj hVGg+QKMRiLVOKCQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F007813690; Wed, 24 Apr 2024 21:35:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id z294OTF7KWbTCgAAD6G6ig (envelope-from ); Wed, 24 Apr 2024 21:35:45 +0000 Message-ID: <32a3ddea-c75b-4686-b87a-864cd32583d6@suse.de> Date: Wed, 24 Apr 2024 23:35:51 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] [gdb/testsuite] Handle ptrace operation not permitted in can_spawn_for_attach To: Pedro Alves , gdb-patches@sourceware.org References: <20240418063237.1545-1-tdevries@suse.de> Content-Language: en-US From: Tom de Vries In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -4.50 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 119DA21C06 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.50 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; MX_GOOD(-0.01)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_TWO(0.00)[2]; MIME_TRACE(0.00)[0:+]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received,2a07:de40:b281:104:10:150:64:97:from]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DWL_DNSWL_BLOCKED(0.00)[suse.de:dkim]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:dkim] X-Spam-Status: No, score=-6.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP 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 4/24/24 21:40, Pedro Alves wrote: > On 2024-04-18 07:32, Tom de Vries wrote: >> When running the testsuite on a system with kernel.yama.ptrace_scope set to 1, >> we run into attach failures. >> >> Fix this by recognizing "ptrace: Operation not permitted" in >> can_spawn_for_attach. >> >> Tested on aarch64-linux. > > I really don't like relying on "attach" 's behavior to decide whether to test attach. > It's an inversion of responsibilities. > Hi Pedro, I don't see it that way, I think this approach accurately handles that if there's no permission to attach to a spawned process, you cannot spawn-for-attach. > can_spawn_for_attach means "can I spawn a process, such that I will attach to it later", a > simple atomic thing. > > Also, with this change, it means, "can I spawn a process and does attaching to it work?" > So it ends up misnamed. > I see what you mean, though I don't see it as misnamed, but if that bothers you I'm glad to rename it something else. Can_spawn_and_attach? You have another suggestion? > Someone tried to add something very much like this a while ago, and I objected then: > > https://inbox.sourceware.org/gdb-patches/e5f08136-fa4d-2f21-ff83-8adf4d3a158e@palves.net/ > > We ended up with gdb_attach, added in a7e6a19e87f3, which handles the "ptrace: Operation not permitted" > scenarios too. Some testcases have meanwhile been converted to use gdb_attach, but there are more, > of course. IMO we should continue that direction. gdb_attach is not unlike "gdb_run_cmd" for example. > > See also: > > https://inbox.sourceware.org/gdb-patches/3b845985-cbd4-4996-145e-14191338b095@polymtl.ca/ > I think the gdb_attach approach is problematic for the reasons that: - it's not versatile enough to handle all the cases where it's needed, and - it's required to be used in all the attach sites. On the contrary, the proposed patch very simply handles all the cases, and in only one proc which is already used in a trivial way in most test-cases that need it. So it seems obvious to me that the proposed solution is preferable. Thanks, - Tom