From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.178 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796410300; b=QFCYZb6nbE8Byx/wnpTh2N5amJUuhTCzFdJmq6HnBwCF5gMv3A3dMxKBGPupzMmbaF+g 4R1fsL/IREjx8ZLKSGeacsAadsS9qaNmgNzcTxlCpO9m1wI6/sJZmtt8RH2ZTGgiEeHkE B4izIKIRGyJc50fofGIswW/pARoZj6nYUDwrw0gAyTGAe+61IuX1JgTZzQBVkcmIYa8vX Ld3QZbePBSUyj9E3QJwOU1tph8oXqbritZpBl6hxaGeAU+s5w7PwjvUEWbdN674EapSIf KvNX5oDtVpt2OWT1f1lfEguLjhT3F1NZOAY7H0HiQYpISfY1CdOX5zhLfzjleoOggQA== 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=PMRM9pi1AzDdaZJKBA1qSt1a9hXDZcPvDo2xG2/ulzDejRc68rWO0bXEfUJisRAt3eLF zlsWjKsj5+t74YSglhxu64P7CcUTLXQnMGiLCB4a1pTJcfze4xPW3gzRzK4RafEsKVfAi U1w/Euf/cb4+wJ/b872nVulninhKMMULnOOYUd6X7ycwK8pPjHjNiyEzrxfLbPcx79nc6 dRFpWekhHsbzXjmnUB9Kjj03dnH//Etd4jRJ3ysKUmS0JIwNOXrvKFc+R5igF/LsjXs0j QgQ5Pu/2e6H5C+RkA8LYjbdVA8Rbao5ArjUbxXvUPulOyV+CQjCLoczBtaUQIbVS84w== 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.178 Received: from mail-dy1-f178.google.com (mail-dy1-f178.google.com [74.125.82.178]) (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 65897606A32F for ; Fri, 4 Dec 2026 18:51:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 65897606A32F 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-f178.google.com with SMTP id 5a478bee46e88-386bd881d39so2280303eec.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=vFh4XQqKXiUeJEnwHQe9rn3ZnRLxVSmdEOOZOz/53LeRWShdqj19xi00AuzWXLNgAG HWsd/+rOX6PdQbpbaM8vm99oFX7ZVEp+MdZcIhFu0DbsUn4grxK8yzfdVoVU4NzjtcbH nGa4uN8APAnW8h/U8tS2blaExADKZrZkAdfR0CphMBYZMBKpaeqnvOnnvTGrnMR444NG 5TSREYocvSMYv9CWbEEYQLBS3i9bnhRqQMBe2RqDtlSBRgbucSFl9lrQfOvX2cQXq//Y eNwi1W7PyTzZafWJNimtp8ROCHIO+pBZqmSThQFzj+Ky3VjeW4BC8710B+W6Onay5siu NmUg== X-Forwarded-Encrypted: i=1; AL+hErGARWa48bk23/agdCkE9emBaA9HXC/ZrbdMnTbOdw9WirItmidUdfnJ3HN7MxoYCao1766MQJ4lDXKAzw==@vger.kernel.org X-Gm-Message-State: AB4q+uECNla9yzMqC15JHzPTMykWdh86az5p/zmeuPeLNH9vtkRoXrBD gmeB+veDXoIsBqPVl9drwreIyZxui7rRPYMAFKP5m+D74cvp0hdlR4dj X-Gm-Gg: AZFdTZfDTx9FXz+yDf7YXi0CeRLl0rt9mvOqcRS5Aa+HwpWq8yuNWJvoPXQevfA6RQv OjMlmETLKBoJ2+H9Y2GEhFCc5gnuAYUMwk73T902mmQ+Ytei++ibo2inY2JV0srw81K4vF9zbx9 Vv901sAUJHm/R8R53BIYkmq+/8Er13NyCH5gfG9kuRPAFzoWemtbLoI0/mv1IMstCevLgOYsCO2 5nsEKIUzRHqhEJhXZfhTwqlNxk39iwrxa9l07VU4B/yek3CjGL28Gj+DL6PG+4cQ9nMNS5kJh4U ganPielFgETha8azbNZJM67pSS9sZySclVbIyPOsNojgPvMBWEuZqHfxoGCI3QpzkDMrpI+GUhy IGtwHkQ73ZNkU2KVaIHnj/fINmU115E9GSrWp3bcxUXi1btTpND5hp89KNdxdZdNwIxsg1ChDxg EHDln4gXe9hA/VNiRc+2n96Kqys96M3JWo3x6526Zw5eCBzh8XZdrexI+g37Gxc74WbMg0Yj4tI A8Y9W+g7tlx8cbaggXYjroq9LBQHnscOrA6gHQyPRX/iJGXlVwpaaD4jYo36NGAKAa9yAesidfH kI0srI6dxTWek9cfeihG8KXEY/41gpM2rmSUcQMSDP7uWV93GlG1XIXLGooWBkES7nQ= 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-fbdev@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