X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715440267; x=1716045067; darn=delorie.com; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Fz6bqC7bXZn5+dpCOI0xHbfqtUfMQbrEHD2rJpca1xs=; b=QPFDi58h4oiybWdiVkrJpDMRZaTdQQQ81kDBS879GnluMSqs1K/rHQVqF8BbkGWiz+ Cw/l1yWDOsh6SXc9TYM8IepRMuqwd8Fyx2DQ5/97s6BU1VwYnTXJVv/h4ChfQtmE2/zi ea/TDdTS5cZxlWaX8hal7wbCrDO1zYV2cXQ2i6qBpyzjsH/kGtNNxzEh5OmsxzleGspK ZemAoSv8i8a3+ADU4w7ywXprfIeme344ccADVQ/WNl/8qxZaHSrkwFQQlLkZxhQ66BVr m+eVfRXXKRUrLl5DzfDlUY9vZrGb9gBa2P1Ifbqe904oXmhnED0OQ0y0NpbD/AQ5UebG P86g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715440267; x=1716045067; h=content-transfer-encoding:in-reply-to:from:references: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=Fz6bqC7bXZn5+dpCOI0xHbfqtUfMQbrEHD2rJpca1xs=; b=QIVQSfluUFngvtHQU0e8jJIpvsOM8gQt1OzQmTqXzfPMzvxC5s3GY7FFZXeJIJbBSm 4Sm/N7Q4bfsGwCUYBE9IvSGLtHN6klDQa43Oz8Or75xNaHjQI0adqDywLbvhYWoRnogp 4vQ0pjw8M8b5RWCT/kXl7d05X48L7nr5o05T0M35wg30x5u9uzpCi18HUi6TudD/dkwz Wz90ltE7b5Fq9gHd3AOBLxsae93soscCnwlujmZHlhxBwGXaaj6HPD4FmrhWP7bvvZWe D8S9Xr8vt0rF1OKnaBRUsDrSfw0YahMK14w2lZB9yW1DfP0ECHiuInWiYuTmI3oSzlfF JqwA== X-Gm-Message-State: AOJu0Ywx32wqIb2NfBNLUDxBXrZjx3a1CdxIBnArgAmCKbVSyD7Rf/Vt MVFbLvk7U18OKaslAA9VF50TeadibenQ0ivcpDK1XiJHfMzyK6Cek+8ZaQ== X-Google-Smtp-Source: AGHT+IH+HUxaM99dVazkTvm2QnckCuXK80ZHt1lSn517VfOt6SVRUJ0WIo69hl68rFYeYsR9IcQn3Q== X-Received: by 2002:a17:906:a050:b0:a59:cdf4:f948 with SMTP id a640c23a62f3a-a5a2d675dc5mr510884966b.65.1715440266055; Sat, 11 May 2024 08:11:06 -0700 (PDT) Message-ID: Date: Sat, 11 May 2024 17:11:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Fix passing fcntl and ioctl variadic arguments to file system extension API Content-Language: en-US To: djgpp AT delorie DOT com, Pali References: <20240509182019 DOT mrbfcyv4jhl3w34x AT pali> <867cg03azy DOT fsf AT gnu DOT org> From: "J.W. Jagersma (jwjagersma AT gmail DOT com) [via djgpp AT delorie DOT com]" In-Reply-To: <867cg03azy.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 2024-05-11 12:21, Eli Zaretskii (eliz AT gnu DOT org) [via djgpp AT delorie DOT com] wrote: >> Date: Thu, 9 May 2024 20:20:19 +0200 >> From: Pali >> Cc: djgpp AT delorie DOT com >> >> Hello. I have there a change which fixes ioctl and fcntl functions when >> file descriptor uses file system extension API. These two functions are >> takes variadic arguments and file system extension API takes va_list >> structure with all corresponding arguments. djgpp code currently do not >> pass all arguments to API functions __FSEXT_ioctl and __FSEXT_fcntl. >> >> My fix, which is below, uses __builtin_apply_args() which returns >> pointer to va_list-compatible structure of all arguments (including >> non-variadic). It works for djgpp i386 calling convention. It does not >> work on e.g. AMD64, but this is not a djgpp case which is 32-bit x86. >> For using __builtin_apply_args, it was required to manually inline >> __FSEXT_func_wrapper function as it takes variadic arguments and not >> va_list structure as the "func" itself. I (still) can't see Pali's message but this sounds similar to a patch I sent in last year: https://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp/2023/06/28/12:14:52 At the moment, fsext-hooked ioctl() and fnctl() are useless and always invoke UB (entirely random effects), so I do think this is a high-priority bug. Linked patch is technically UB too (sometimes reading past the end of va_args), but in that case, there is (should be) no code path where the va_args are used. However I wasn't aware of __builtin_apply_args(). Whatever Pali's solution looks like, it is probably nicer than mine :)