From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410300; b=LBb3ZOgnpzUMi2zo8dPWsj1w5MupJ8XlB9n6kJhUBXb4GH/RABuaB8mKch84brpS/pCI pil4ehobhxXLIO4MsmQYG0FeKDJ/uSnCD12UDSSepLOg+p8NbHW6ZEBV/My86sLFhCEi7 6xW85hTN4rfWp75ybTlpa1Is6FXK4i+l26Egk7OesgSiqN0oxsTdaG7UsYw0szICkwCCm xOtHs9dAMZzWb47QpcOUX5uIA66z+uPIAAU8/TkcuyO/jEvqPdrcy/xGIG6e5D9dglr7K xhqSTNHNSY+jBZ//jUW/WNluVYb0oHGqAO91tL+7lOXb0M0xlIADGzlbgYBQCBxWAOQ== 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=1UdEgwP+zHL/CfwgBRuLxaN5mUqkFWIcZYANH/n1bXpIelabik7EtWrNzrgDrISECFxp PxPFdW2RN4OkpEvZ1gEzAZ+RtU0mUq3CMgxXAHP6BCiM43yEESnBnKPFWcCTFO224Aqk+ ctTqwpnYr5ex7dj2WJhU+KazIaftuk+huqyiYOg9rnQ2mNp6gs/W4xwaKLJ+nYDHlrlKt q7Tjtf6OENY28dwdew9c3v6mBT3pw2iprIxaI4A2jg1/qY5eaQuWaX1PlfGuhJ7nplgpk pxPtDOMA0H0FI6wpiz4Tj7WRU+lxTV5dmv8xnzp5+wfqhVVGty1NqdW4eoanAq5TIzA== 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.45 Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45]) (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 70AD5606A335 for ; Fri, 4 Dec 2026 18:51:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 70AD5606A335 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-dl1-f45.google.com with SMTP id a92af1059eb24-1b546061d58so2935205c88.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=0CjrEgyUP7IZmzVJZmTmO9yicUADIpQzomCP3I3GC9LWl2HlrOV85dY2yf5BIZacc/ d1Noy1Eu3iGNXKatSr6f3MhW0UE7lA+t51EgJgyV9QC/hY6W86yUpIsBZ5FkY48zyrQV zEuRitO+1yd5WDEBrM93OTeycVUVJiN6tiASx+qV2Kj6scn6RgaPmY6I5z/Kaim0ooeH PW5AmS0CHc/InOlIgA7omwhIUVzBIHp2IfpCeg1v0b0o3hzxzcnS2rnQkzg2MMqOCMuN oyOZKGa/AJuW9+v81WujIw35TJyNt6WSaKUV59S/XFqZ7cLBQUAKr0Ym0x/2jvPeAEBD bx0A== X-Forwarded-Encrypted: i=1; AL+hErG0T601irsb+giZda9jMtC++RYukDnFnVUjdv358IaLNL70nMWQZTWZI8CeZ9sjK5dxFkM1AgI=@vger.kernel.org X-Gm-Message-State: AB4q+uHFr4BIiZ10TjlnVsOspfLOktxdOzOEZcSbg+SAcP2hAodg4uQg 1tbOWnfYNtMWz71QJpxyktaIhg/SA+ktzn9lPch3mKCYg9F5fSd6jHDs X-Gm-Gg: AZFdTZctawN996p/sDaYctJ9J9FrHE/Rw0EWijTHi+9HS/uOvDcs+CefYec6x8ZjOci I/EhTGC20otQc3119bCr57myn/JOfzDMdM7XMfQpwrKhbT+PDDWUVsU58lOtkfx5qt8lrqPivIm 3iv8hqtrQrs0E4eqsB+jFCixealHBqjgCly/4rU93MmscRf5qnjC1pPlk4katNoIyH5L78u5h2D X5DPYFo477QHy/5FG7bbNqnfZPTfrlDk8dbKFwHm/vIxlumr9FX7zjXSkZz+tiihQfwff4WNg91 0bFP6QCgtw1MObto5xaQv0Sln4PFp++tcj1LTUJSGnLXx6DxorBeH6ZGJOdJ9u65X34ckbKPEWn qFV7hGbz6pPRrQ4R5Y/ilCQrz7tOJ3mH/D8INt3kuiEEfa9Jv/TqzSzvQXqTJeSxCyQIkja704j Bz4JrPZOqniJA+WthaOrbwb0rXm2V8L8aa4szDBsTygysJDYKr9JG+Uvsr1Qdv58FqjOfM90LNb KxufUGwPv5YCKJi0wm3ge2kCROzRJ22eRfbOFacodSz99Bz0Vfr37KYhOK/Iot2B1Cd91hMs0pG 9jdEj8u5yVdQ5Bt6aHZt1P9J1cDFqIrwR2o08aysgQRD7HlvO00rwh9ApbUbmpNbELM= 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: stable@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