From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id xmqiGlT70meNVQ4AWB0awg (envelope-from ) for ; Thu, 13 Mar 2025 11:35:48 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=E4fCzed7; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+bOyzEcv; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=E4fCzed7; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+bOyzEcv; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 5CFAC1E105; Thu, 13 Mar 2025 11:35:48 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 943371E08E for ; Thu, 13 Mar 2025 11:35:47 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3EE623857C6D for ; Thu, 13 Mar 2025 15:35:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3EE623857C6D Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=E4fCzed7; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+bOyzEcv; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=E4fCzed7; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=+bOyzEcv 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 DEB8F3858D33 for ; Thu, 13 Mar 2025 15:35:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DEB8F3858D33 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 DEB8F3858D33 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=1741880114; cv=none; b=n/4bNgRWygHXXU5XpDL/OhBS3M9Mm8EEMNHNbluXFZyNES50hzKqtIYYeyVsHJ4s/89jsvZ/mV+LFbsf06nBgJjQCb3JvdZR6ahXLnCVih45PqEkJESR/vOdxqpa0QVXM8/bvYTfwu/4/6iJJgCSeIZn/mzDUB//hYQsPbNMZSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741880114; c=relaxed/simple; bh=fvMbPG3BX2trOWoQsvlPzcCowe/fSYq4UbLCEdo5Ssk=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature: Message-ID:Date:MIME-Version:Subject:To:From; b=tnC4mQMUV1b9ml+ptWzNqjRUmGuVEokGVaxbVfbsVB2FWkXRdhgEU7SMdHUVLVdVvYPN1F+5+WPVI7KP+BbuEaXdeVk3nZMTHSVcNYWkjjS78UjXhlDAXeFKMMv5T55k++yOBWfQ/iqLktOEf1T6bj5dvq1VJBeMHKkFNcQ65rE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DEB8F3858D33 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 545C621191; Thu, 13 Mar 2025 15:35:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1741880112; 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=9mpv0HZYqjgZh4r2SMqNLQf03UQcZMzEv4xi7viq++E=; b=E4fCzed7FanN3wFuszCGSkbx0XK3Sq5v+CSCJ3n4+fPfF3zXGVM/2HuwcqfUufBP6bkpoB E9vlLpEzufDkNHc8oPr62fUrIaiQoF5PlwzQ8yTjeXHI2+5lx+I5fyeqL5I5ohtmzTHKMB zkEFj+Cn+csPOnoz6BXW50ncFqL47YU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1741880112; 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=9mpv0HZYqjgZh4r2SMqNLQf03UQcZMzEv4xi7viq++E=; b=+bOyzEcvxneBTm2bWbOwNNCu4Mhz5wHcXJE2qgi+nKhOMQ3Be6zmWyLyXkEw+Gm/xDldMI DM0f9aXD2eiuu6Cg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=E4fCzed7; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=+bOyzEcv DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1741880112; 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=9mpv0HZYqjgZh4r2SMqNLQf03UQcZMzEv4xi7viq++E=; b=E4fCzed7FanN3wFuszCGSkbx0XK3Sq5v+CSCJ3n4+fPfF3zXGVM/2HuwcqfUufBP6bkpoB E9vlLpEzufDkNHc8oPr62fUrIaiQoF5PlwzQ8yTjeXHI2+5lx+I5fyeqL5I5ohtmzTHKMB zkEFj+Cn+csPOnoz6BXW50ncFqL47YU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1741880112; 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=9mpv0HZYqjgZh4r2SMqNLQf03UQcZMzEv4xi7viq++E=; b=+bOyzEcvxneBTm2bWbOwNNCu4Mhz5wHcXJE2qgi+nKhOMQ3Be6zmWyLyXkEw+Gm/xDldMI DM0f9aXD2eiuu6Cg== 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 3E06E137BA; Thu, 13 Mar 2025 15:35:12 +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 EPTGDTD70mcpHwAAD6G6ig (envelope-from ); Thu, 13 Mar 2025 15:35:12 +0000 Message-ID: <599cd257-0b61-4710-ac16-9ccff2819565@suse.de> Date: Thu, 13 Mar 2025 16:35:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [gdb/tdep] Backport i386_canonicalize_syscall rewrite to gdb-16-branch To: Guinevere Larsen , gdb-patches@sourceware.org References: <20250313095325.23876-1-tdevries@suse.de> <6cab43c6-85c9-4834-9f44-9cc1267621b7@redhat.com> <8d94c39e-86f3-4f4c-8443-4f9ce786743f@suse.de> <43745ab1-66a3-4056-be24-ed178300faa2@redhat.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <43745ab1-66a3-4056-be24-ed178300faa2@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 545C621191 X-Rspamd-Action: no action X-Spamd-Result: default: False [-4.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 3/13/25 16:20, Guinevere Larsen wrote: > On 3/13/25 10:06 AM, Tom de Vries wrote: >> On 3/13/25 13:40, Guinevere Larsen wrote: >>> On 3/13/25 6:53 AM, Tom de Vries wrote: >>>> Commit fbfb29b304e ("[gdb/tdep] Rewrite i386_canonicalize_syscall") >>>> fixes >>>> PR32770, which reproduces on the gdb-16-branch, but the commit is >>>> not ideal >>>> for backporting because it completely rewrites >>>> i386_canonicalize_syscall. >>>> >>>> Instead, this is a version of the patch that adds a single line >>>> entry for each >>>> syscall value for which i386_canonicalize_syscall gives a different >>>> result >>>> with and without the patch. >>>> >>>> Consequently, the two versions give identical results.  I've checked >>>> this for >>>> syscalls 0 to 466. >>>> >>>> Tested on x86_64-linux with target board unix/-m32, on top of >>>> gdb-16- branch. >>>> >>>> PR tdep/32770 >>>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32770 >>>> --- >>> >>> Hi! >>> >>> I looked over all the special cases, and it mostly looks ok. There >>> are quite a few syscalls where we have an older or similar enough >>> version, like execveat and execve, or faccessat and faccessat2, but I >>> can see from the accept4 patch why you wouldn't have done that... >>> however, for the semtimedop_time64 syscall, you just converted to the >>> semtimedop version. What is special about that one? >>> >> >> Good question. >> >> This was one of the syscalls I came across while reviewing the >> gdb_syscall enum values >= 500.  And since the recording support >> doesn't actually record the timeout parameter, the time64 part of >> semtimedop_time64 seemed irrelevant. >> >> So, what was special here was that gdb_sys_semtimedop was supported, >> but there was no corresponding mapping from i386. >> >> For the execveat case, gdb_sys_execveat is missing.  That makes it >> similar to the accept4 case. > > I see... so other syscalls ending with _time64 where GDB wouldn't record > the time64 portion could just be swapped for the regular version? > > I'm asking because I noticed a couple, but I didn't double check what > exactly they recorded, but it could be a quick improvement in that case. > > The reason I ask for execveat, is that we don't actually record > anything, so for GDB it would be the same as execve, which we do > support. I'm basically trying to narrow down when to include a gdb_sys > version, and when I can return a close-enough syscall... I think the goal is to maximize the same-name mappings, so, support execveat like this: ... diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index 3fb1c1765e4..dcb973fd4c7 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -758,7 +758,7 @@ i386_canonicalize_syscall (int syscall) SYSCALL_MAP (getrandom); UNSUPPORTED_SYSCALL_MAP (memfd_create); UNSUPPORTED_SYSCALL_MAP (bpf); - UNSUPPORTED_SYSCALL_MAP (execveat); + SYSCALL_MAP (execveat); SYSCALL_MAP (socket); SYSCALL_MAP (socketpair); SYSCALL_MAP (bind); diff --git a/gdb/linux-record.c b/gdb/linux-record.c index 0b2709b30b2..c442d13a9bc 100644 --- a/gdb/linux-record.c +++ b/gdb/linux-record.c @@ -289,6 +289,7 @@ record_linux_system_call (enum gdb_syscall syscall, case gdb_sys_link: case gdb_sys_unlink: case gdb_sys_execve: + case gdb_sys_execveat: case gdb_sys_chdir: break; diff --git a/gdb/linux-record.h b/gdb/linux-record.h index 6d6ba073089..e8b33f81013 100644 --- a/gdb/linux-record.h +++ b/gdb/linux-record.h @@ -542,6 +542,7 @@ enum gdb_syscall { gdb_sys_msgctl = 531, gdb_sys_semtimedop = 532, gdb_sys_accept4 = 533, + gdb_sys_execveat = 534, gdb_sys_newfstatat = 540, }; diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c index 2168ce642b9..b9ba265f4f8 100644 --- a/gdb/loongarch-linux-tdep.c +++ b/gdb/loongarch-linux-tdep.c @@ -851,7 +851,7 @@ loongarch_canonicalize_syscall (enum loongarch_syscall syscall_number) SYSCALL_MAP (getrandom); UNSUPPORTED_SYSCALL_MAP (memfd_create); UNSUPPORTED_SYSCALL_MAP (bpf); - UNSUPPORTED_SYSCALL_MAP (execveat); + SYSCALL_MAP (execveat); UNSUPPORTED_SYSCALL_MAP (userfaultfd); UNSUPPORTED_SYSCALL_MAP (membarrier); UNSUPPORTED_SYSCALL_MAP (mlock2); ... Thanks, - Tom