From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410300; b=dyNQUytqojigOA3gEuq34UhXQrLBq8C3Tlj+i8AuY9MzEJPbE1cX3TbHssPMcKJo+Ua4 fwRgq261b06koAWMu+7tRLXAOfSLhhGvxiFHc0iCaX532lMHx4dLYtL9vt2VWFDNaPovB USZSDKHj2SOGt0UhCDMabQckOOxKh/7NfcSS1xqEt8YzwjehyzUOKqAK/7OQrUPqwW3So RysnTm4R0X4H9nP8+I9WvlfwWBbpDP1Rl8pcumK4H//EQFCDyQh1d/+je1pNx+e77PL0W h8cmVKz6+EsxZxDguNUS1jHUQ+NMAWxay7nW86O6wEwl8Hud4XJwnkBg9iXn8n12gQA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796410300; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=IVQYLzbWPzwjvKjMXdrwWUBqxYL6fxxMMS7pfYFWoCA=; b=tXSbzOKnk17rAjTaYHCPzBdcmSpHTsZkIKr0odoScYzma2CjtUbg/lX88UFEoaedU6TV 3M6jXPXb7gj6thrJvB7x1kIvl3sydxIJi2uSfLqFIvnflAjJg9TUnHFeVAgDo8azvnvhT aMgHVb5M+tI+yKSldscEy2TGi+DCSbBvG4TLhbeVOzkTd2IVFttDm7NTnhb1821TpcoCJ st6bBdrX7M+Msv7hrgdFBnfZ4D/E+G/xEP3BCqtwCnXUh0JFa967MK4BENpxWHmFK9S3K UqCIsBGCTlHDde1NzDVYqmy58D9FIOy1DHz1G3xn2z79r2lnXwpR3yyv4qauIz6Mlgg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=KOv5mtGd; arc=none smtp.remote-ip=74.125.82.177 Received: from mail-dy1-f177.google.com (mail-dy1-f177.google.com [74.125.82.177]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5557F606A33E for ; Fri, 4 Dec 2026 18:51:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5557F606A33E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=KOv5mtGd Received: by mail-dy1-f177.google.com with SMTP id 5a478bee46e88-386bd881d39so2280302eec.1 for ; Fri, 04 Dec 2026 10:51:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796410300; x=1797015100; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=IVQYLzbWPzwjvKjMXdrwWUBqxYL6fxxMMS7pfYFWoCA=; b=KOv5mtGdQ5x1uih+NVFB72t9Og8SMxvqHVObJZhm7q4hinZRid//QFqitKeESXzXyw kniYG/9GIq9mESuFG4YEMAZFnYc87aAHpv0+CiewCW0ths6FRn6fxm5y2ejyC2eQ+x/h dgzSJt9Pwhic1rQhXHHyGPrYw3pfwu+Zt0oa/7470TnUmwu1EIcNyL/wvJI0JCFLkwjT tCWq6W6SeDGlTELBCxvFMqJiYxn0JRCw+iBtrQGaNeEqOFZLQSwaxVm9tLQmeur8ouyW Gu/yZzgLI+N4M8vIZ/VmN9xTS6iiOG+Bni0EjMNB67JubWUszqyJ0ii1AnncInZAZ9bB qRkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796410300; x=1797015100; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=IVQYLzbWPzwjvKjMXdrwWUBqxYL6fxxMMS7pfYFWoCA=; b=bVggcCaZGQlbt3fwnv6EhidSZFDxDeaKJLTv1V1y3XPnRdltvBmsg0uxsElNqoDGpE AwAu16FjuOigqfWeylTYb1eBdjJVn+fgd2fw+EueGhgs/ECm3nMnUlYsQueEdDjHWGHh Mz6lKWxvMbcZrAp+wmeNL52nIqJL9+4OTHK9VE4ZLeLHJOxzlhStXC3c2Ax2/HqU/AHc cr/KwQ6lN3iAGnqX5ynnEKbIIe1X1CR91hg0Uw+SbY2ejQQPBLcBOo20f1JGtKNSSXD8 L4A7EkwOEZ0DzQi1nXZX2XlYruzbWGgBC1GfCd6CeDkYEThfVBy1PgrpGZlH+mdoufQY 1WpQ== X-Forwarded-Encrypted: i=1; AL+hErEM9WHJNdrjxkOvmu2gOwDbyqEBQmO4ZqPHhAddkzKv5wA68vC8FeN6muJTNtI/W40cQP59uXzhsAekcmE=@vger.kernel.org X-Gm-Message-State: AB4q+uFIFeOm3H7MN+3V+zgp46rWModXGlbsvKgQqaSY3W3F/GhZwPxr 9EErTiATjXSTYceovQiEHAkjhyO0q6tZ8ojyPRwcAuXbvPBbSn+rOK8J X-Gm-Gg: AZFdTZcFM+N5DiGOySzN+W/7QhTlfb0GPwSFELfxsN5K7IxaJ17+ZqHMVt2h3JKrelm w4/rLXZhb7+oBs46Uei7/SyQqA+yCKRK7AepVers+lo1CaL+aRuxoNHuhJSJM0qGLAwh2S5Xv2/ hX4wFiI0LDDN4Z4wvkH9d08vQfijGH2LTvpjxLF86iT9NuZXb8QqtvknZtbfM8ePAg1cJFD6Si0 GdiXKKJX6CR1Li7/0JxHpdppEduX23gQxZ8eGx8m8gwh264Set14sspx4dd8TJKG6QgofjqTxUN LPEcuPy/BgELGQWz0qMm9d+T4uto682HJBlDN5kXfCK4MPZxAMJk/EM+BTkZShDYLTNDsBuA+Dw pdPSz2pPy5aqihlC7se3EW27WKUuIy91r08t+cAwDuT9HPTp5E0BK69r+g19SUMAGR/ywltaXqu tqr+AFEE0vUa+v6WbP/vy4K1FXvqYe6GzaLcj33t2EikH6qj1F4CjQ+lVoOtGFdbZuyTQYSE34i orla+poXlpfF14w/2wQiLYRdTDu3OzUXv6Wzw1K+EjGeBSXHpvetOxHoSvXAOSJv5/rRqGcJRdY LlPVl1WFZF1GWtj70toq+9d9CiHjAGPfGp1awCeuJUJCCWtjuN2seEs5D6/wl/J1I0w= X-Received: by 2002:a05:7301:1a83:b0:387:11c7:1ff0 with SMTP id 5a478bee46e88-38752105321mr2587467eec.15.1796410299365; Fri, 04 Dec 2026 10:51:39 -0800 (PST) Received: from localhost.localdomain (wood.seclab.cs.ucsb.edu. [128.111.49.37]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3875224895asm10279596eec.27.2026.12.04.10.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 10:51:39 -0800 (PST) From: Praneeth Balasubramanian To: Helge Deller , Bernie Thompson Cc: Mikulas Patocka , Xiang Mei , linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Praneeth Balasubramanian , stable@vger.kernel.org Subject: [PATCH] fbdev: udlfb: Hold info->lock when edid_store() sets the mode Date: Fri, 4 Dec 2026 10:51:36 -0800 Message-Id: <20261204185136.1688369-1-praneethb2002@gmail.com> X-Mailer: git-send-email 2.25.1 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-Transfer-Encoding: 8bit edid_store() calls dlfb_setup_modes(), which takes info->lock and drops it before it returns, and then calls dlfb_ops_set_par() with no lock held. Since commit 7433914efd58 ("udlfb: allow reallocating the framebuffer"), dlfb_ops_set_par() calls dlfb_realloc_framebuffer(), whose comment says "Assumes &info->lock held by caller". The fbdev core holds info->lock when it calls ->fb_set_par(), for example for FBIOPUT_VSCREENINFO. The edid attribute has mode 0666. Two writes to it at the same time go through dlfb_setup_modes() one after the other, but then call dlfb_ops_set_par() at the same time. dlfb_setup_modes() refuses to run while the device is open, but a process can open /dev/fbN after that check and race FBIOPUT_VSCREENINFO with the write in the same way. Either way dlfb_realloc_framebuffer() runs twice at once. Both runs can queue the same old buffer on dlfb->deferred_free, which is then vfree()d twice when the device goes away, and the unlocked list_add() can corrupt that list. The stores to info->screen_buffer and info->fix.smem_len can also interleave, so the green screen fill in dlfb_ops_set_par() and later writes to /dev/fbN can use the length of one buffer with the other, smaller one. Take info->lock around dlfb_ops_set_par() in edid_store(), as the fbdev core does. The missing lock was found by a static check that turns the locking rule in a function's comment into a Clang context-analysis requirement on its callers. The sashiko review of an earlier udlfb fix also points it out. Link: https://lore.kernel.org/all/20260912212923.016901F000FF@smtp.kernel.org/ Fixes: 7433914efd58 ("udlfb: allow reallocating the framebuffer") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by a compiler-based check, part of research at UCSB SecLab. The locking rule stated in the kernel-doc comment of the called function was turned into a Clang context-analysis requirement (__must_hold) on that function, and Clang 23 with CONFIG_WARN_CONTEXT_ANALYSIS then checked every caller. An LLM was used only to turn the comment into a machine-readable rule; the report itself comes from the compiler. The patch and changelog were drafted with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64, clang 23, allmodconfig). Not runtime-tested; I do not have this hardware, and I have not observed the race myself. drivers/video/fbdev/udlfb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c index 8b7b4bdac4fb..521a8392df82 100644 --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -1496,7 +1496,9 @@ static ssize_t edid_store( if (!dlfb->edid || memcmp(src, dlfb->edid, src_size)) return -EINVAL; + mutex_lock(&fb_info->lock); ret = dlfb_ops_set_par(fb_info); + mutex_unlock(&fb_info->lock); if (ret) return ret; -- 2.25.1