From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02EAB3A4518 for ; Wed, 4 Mar 2026 11:47:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772624851; cv=none; b=kah0M+0RqKwsnSbC3K6MedJEM4UQWxornMndP2uXJCCgoidVzocckRS8zRckHLiJ6jFawhwyse9BjqtgJ6SNoZb6Rghcer0E4WoUS1Q5AvmVFY1i1YbXlnDsw6gBri5cNRuL0QEDH7O5nQLD2PGifZlOWMqdJWm8czMyZRHvpZ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772624851; c=relaxed/simple; bh=oiBhqPbm3At5E6NYX9xQcgVO9x5WHZWoBads35rddq8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=l57X0rvzcUBg3Odd1Ya2yKwpVMUrmU5pGgZR/JEkNQADHEslNlrOrKibO52nvM16m2RC5GQiigV0q/yilFieALDww19UeLxB1+5Jiocr52HOrzJ8Trnf4OU3EGVbuM3t9O0WdbjaWZ5cMdssTJ+jKnjyHohO+FO9GGsOje6zE9M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mailbox.org; spf=pass smtp.mailfrom=mailbox.org; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b=aHK6u5pH; arc=none smtp.client-ip=80.241.56.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mailbox.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.b="aHK6u5pH" Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::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 mout-p-101.mailbox.org (Postfix) with ESMTPS id 4fQrWF3mp7z9thQ; Wed, 4 Mar 2026 12:47:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1772624841; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HwZZKiDaDW77t57N7j3dbsc0ZP/jBXxIW5NtKt1Thu0=; b=aHK6u5pHPOROyZvrER9YfuEO5vItpakggpbiQGD2mrtz+Ri41HF+sgI0l+0DSkxeKbJWnh 12AVbdhC7UqGGmctEOPMksEbpcEjmM9YhDX1/bxHvcc31Ly3cPsFPAivvF9qc3XR2efP3X RZ2wuriP9cB4hyes+6nzXQ11IrIVcsyr514rBRJMlEG0Iead2LA5esolL2FYNTGCxY3h2I 3v5kLokWq7bf1ZBJCT9lkibLH0Zsw+fab+d5Q8cdonhDBbEFsSmSRKeSHLfhNmQpGUHjuL UGo4kYU8j/1DAdEpIrr9EGYfOHypiHToKI4K6wOlWvkqJB7A+Yqyt6yLJ2//Rg== Message-ID: <0847752c-39cb-4233-8e07-8e1325c196cc@mailbox.org> Date: Wed, 4 Mar 2026 12:47:17 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] drm/syncobj: Fix handle <-> fd ioctls with dirty stack To: Julian Orth Cc: Maarten Lankhorst , =?UTF-8?Q?Christian_K=C3=B6nig?= , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Dmitry Osipenko , Rob Clark , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20260301-point-v1-1-21fc5fd98614@gmail.com> <3c969254-ed38-4b13-84b3-5afa365b04cb@amd.com> <2b75199f-b78a-4915-8e75-5d186f63f7c5@mailbox.org> <5464a6fa-5a49-42f5-a1ea-ce9f18a6955e@mailbox.org> <59bd46c0-03d9-4fef-a4fd-14b8f68f9860@mailbox.org> From: =?UTF-8?Q?Michel_D=C3=A4nzer?= Content-Language: en-CA In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MBO-RS-META: 54cn8yai9iz5yops7w8h4qatwudq7nbt X-MBO-RS-ID: 290ba65cea1e1f0082f On 3/4/26 12:25, Julian Orth wrote: > On Wed, Mar 4, 2026 at 12:15 PM Michel Dänzer > wrote: >> On 3/3/26 20:12, Julian Orth wrote: >>> On Tue, Mar 3, 2026 at 7:53 PM Michel Dänzer wrote: >>>> On 3/3/26 18:44, Maarten Lankhorst wrote: >>>>> >>>>> You don't even need to use memset, this would work too: >>>>> >>>>> struct drm_syncobj_handle args = { >>>>> .flags = 0 >>>>> }; >>>> >>>> TL;DR: This method isn't 100% safe either. >>>> >>>> It won't initialize any padding which isn't covered by any struct field. We try to avoid that and have explicit padding fields instead, mistakes may happen though, and in theory such padding could later be used for a new field. >>> >>> I don't think this is workable. >> >> libdrm begs to differ. It shows that it's not only workable but really easy. There's no reason for doing it any other way. > > Using memset to initialize padding bytes between fields is workable. > Having the kernel add checks for this for existing ioctls is not > workable because it would break usespace that doesn't do this. As discussed in this thread, memset is also required for when the size of an ioctl struct is extended, even if there is no such padding. > Which is every rust program out there as far as I can tell. That's surprising. Surely there must be some unsafe code involved which allows uninitialized memory to be passed to ioctl()? > I'm not aware of any ioctls that actually have padding bytes between > fields so this discussion is mostly academic. I covered that in my previous post quoted above. -- Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer https://redhat.com \ Libre software enthusiast