From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.10 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793866394; b=WC1Ss3rssQ7fH0Bv6SzdbsZ7pNMzbrnKKkHZ5seTRCq5FAGL7+65mNou4pLVxmSdKvB6 G7iJak8Nr5Jl7HccFmVh1Hd1RJMR1yFlxFLZwi89VU8Kol8fD7GvPAtEuG5FIFq1Hj1Et bF7tS4TjHfr4l7XsyI3mjXNASYKzhoQlqk+WlSi1ei3kfY71bCh4ANnKX0dPU6JPeYtWs gUwGmtUMUit7yuRvkO9kJHPQkZbDDAKSN+B0I+0O886kIHvXTdBnZPUl4d8bg2MVeAuEQ aUViqDBogUaDVYs00qYqNJIVXA5yY4wtYMXtY17kTLbVf9cpZNrAX5ElSnxf4wmgn5Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793866394; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=pzyTF+YCyBmuOsCK2HopAmTXfJO1/Kz+71WIRqgcgkQ=; b=0dX8ZjBSBcMybMy26sIinbE1/eCjHVb9F1tD2oy1UWd+dZdvm5lwX+QLnFbCi8SDT0aL ePe/q+KxqVY07QQCzj0n/70VrRmGVMnQt/uuxPuu23821XN06eRsnGkO4oiw9vEoDvHkx Qt8ihFZrGCIbllqfCOUXo30OjuVyiQuqGj/2M/wrM/jBpS8y8poRzPbhKWa11K0XDUizY ODUtjUp+Iof1p7yKWv7D/eo/8wSt58sHfBET82wiQdgGG9jvlZ0awSlWxlw+cyiNSQOlW lTfVY29qRvPbws1Zpf2PGgDzp3cskqUPacrwKOVFPYjgr3ZFSuPDDIVCIZwOLM4XfOg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=PPLZtSRm; arc=none smtp.remote-ip=198.175.65.10 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C3B2606A326 for ; Thu, 5 Nov 2026 08:13:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7C3B2606A326 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=PPLZtSRm DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1793866392; x=1825402392; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2Iru4H8XdSj0jlhBugEi4B6U3aBSwDnqs48wxlGEtzU=; b=PPLZtSRmYXbbuA6rxUQodq7dClIv/Du5Y2IQJOdyYlSDYD731WSkORzK I8vz5mnnhYtNOPEQbD1mmOUr/xXvbNoWT3X5N3HdP+dzkVCu1Bu++JMis UV9jnBM1LcAH5PEpt1wOPHCYSXtFFkt6G3I22Yjwh2QF+UbS3AWtdqXc3 CopVFnmzZonj/x6aVa6XdtPXczd6ZVu5+ZEf471yYMH8LoTgu94Fg/zSE 0kfIb8lxkbrP3Yo2fF/3d+odT2cbW3vYZUi0bW0MJrpsJMklEOYjJy6Y2 GplX7haLVLXGJ7B8uMyVc9fNTaBdf6Wjyt7Fyf+/kmkwcsLd/HJZUKEbB A==; X-CSE-ConnectionGUID: JHaKmm81TH+y+R7C+4J0XQ== X-CSE-MsgGUID: cPQRFDSpQduTg9895zEdtg== X-IronPort-AV: E=McAfee;i="6800,10657,11956"; a="2544159" X-IronPort-AV: E=Sophos;i="6.27,196,1787036400"; d="scan'208";a="2544159" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2026 00:13:11 -0800 X-CSE-ConnectionGUID: 90Xx8q/eRS6YpbpxgQ0DCg== X-CSE-MsgGUID: 0QaQZvT8Sj61hItdIsDXdQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,196,1787036400"; d="scan'208";a="7072993" Received: from yufei-super-server.sh.intel.com ([10.239.92.104]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2026 00:13:08 -0800 From: "Yu, Fei" To: tursulin@ursulin.net Cc: christian.koenig@amd.com, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, maarten.lankhorst@linux.intel.com, madhurkumar004@gmail.com, mripard@kernel.org, simona@ffwll.ch, syzbot+95416f957d84e858b377@syzkaller.appspotmail.com, tzimmermann@suse.de Subject: Re: [PATCH v2] drm/syncobj: Limit the number of handles and use kvmalloc for user-sized arrays Date: Thu, 5 Nov 2026 16:18:45 +0800 Message-ID: <20261105081845.1230910-1-fei.yu@intel.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <39be711e-cd56-4a04-87ee-6aa2a0b69779@ursulin.net> References: <39be711e-cd56-4a04-87ee-6aa2a0b69779@ursulin.net> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Fei Yu On 04/11/2026 10:27, Tvrtko Ursulin wrote: > On 04/11/2026 09:44, Christian König wrote: >> On 11/4/26 04:09, Yu, Fei wrote: >>> +#define DRM_SYNCOBJ_MAX_HANDLES (INT_MAX / sizeof(struct syncobj_wait_entry)) >> >> I really wonder if we should put that into the uAPI files? >> >> Not that userspace is potentially using it, but this is part of the uAPI >> and makes sense for documentation purposes. I thought about that, but I'd prefer to keep it kernel internal, at least for this fix: - The value is derived from the size of a kernel internal struct and from the kvmalloc() size limit, so it is not the same on 32-bit and 64-bit. To put it in drm.h I would have to replace it with a fixed number, and that number becomes ABI. We could not easily raise or lower it later. - Tvrtko's series below avoids most of these allocations. Once that lands, the right limit may be different, and an internal define is easier to change. - The patch has a Fixes tag, and keeping it out of the uAPI header keeps the stable backport small. For documentation, I could send a follow-up that adds a sentence to the uAPI struct comments, saying that count_handles above an implementation defined limit is rejected with -EINVAL. That documents the behavior without fixing a number. Would that work for you? >> That kvmalloc_array() + the following copy_from_user should probably be >> replaced by using vmemdup_array_user(). But that should of course be a >> separate patch. > > Btw I tried to do that some time ago: > > https://lore.kernel.org/dri-devel/20251106132645.28208-1-tvrtko.ursulin@igalia.com/#t > > I have as local, more recent version which applies, but apparently never > sent it. > > Interesting part should also be the other patches from the above linked > series which avoid allocations altogether for the vast majority of cases. > > If there is interest I can re-base and re-send after this is merged. Thanks, I wasn't aware of that series. I'll leave the vmemdup_array_user() and points array cleanups to it, so we don't duplicate work. Happy to test it once this fix is in. Regards, Fei