From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (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 4A98B27CB04 for ; Tue, 6 Jan 2026 08:24:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767687878; cv=none; b=K/44jRe9k7NJrHgg1uBAk87xdzKtFXSq7aCaCuOpk/RO+/3D8mzrfWyV4tawmmm2Q7iIBi8ubw6Uys1fFu7qsUYrDCRRs1g/fnXFC+mSatpNRpwhqMv6kbH0jlW+sIfqIevizhNpPePoKm/p653jQerrvXsagvToLTN7r3+udGo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767687878; c=relaxed/simple; bh=FP+IzAXil9gbU0l1lU4kudzpOUm8iYdtTfZ+HhdP6UY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=sHXDjqTx+wC5lq5CEXZQRbGuhtV3Mk1EvhhghyYmmjuyd6V7ZViSXo2mlBDZpkRCMDP1CmRqVOJhUDRSRATKbuR/GbaF8byxpdgmWZaK/0E2yE0cE+nfkLWGelQ06aDvGg6bGitGaLlURwYEkKKmPa58PAn9B9gENwPMa0XWS4I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=Yj1cl1pu; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="Yj1cl1pu" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=jGid+2QU/PnqS3t8pccEDNJG7Jp1DDV32r7aN9w2ABQ=; b=Yj1cl1pusg5D/9aI3/FYSMFQ7S yl/VLmtHQPGR1wR97/6CyUrThwl9QJHIWCFD0MyZaZf2BkuJnBDaDPCrWct/f20qhAxJnFgcfA/oD kuy86P7I+pn2hpAPbO3DmNY0PiuMPDci3/kMywSCxIUfnhW1ArBtumob65TK6qVw/E41m6gmfvYvc c5O8LbzK/YgAymmohn3L8CEDXz5palV3qcP9xN13x+TSUCXh9AE8zTIeFF7MMl4RrHOf/KSILcMr1 jjXluMxfrCnbCZpIkycjw7zkf1eXzIeZd5fFSMeabmufVxc7nR5F2CagyOF7rSGMlF5BJC1YiItx9 7rIkmdpQ==; Received: from [90.240.106.137] (helo=[192.168.0.101]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_128_GCM:128) (Exim) id 1vd2Mc-0025e5-Lm; Tue, 06 Jan 2026 09:24:26 +0100 Message-ID: <56655db6-b087-4a94-b5d5-fba2f368b5ea@igalia.com> Date: Tue, 6 Jan 2026 08:24:25 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] drm/panic: Ensure drm_panic_type is initialized to a valid value To: Nathan Chancellor , Jocelyn Falempe , Javier Martinez Canillas , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20260105-drm_panic-handle-invalid-drm_panic_screen-v1-0-55228bd4b0f8@kernel.org> <20260105-drm_panic-handle-invalid-drm_panic_screen-v1-1-55228bd4b0f8@kernel.org> Content-Language: en-GB From: Tvrtko Ursulin In-Reply-To: <20260105-drm_panic-handle-invalid-drm_panic_screen-v1-1-55228bd4b0f8@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 06/01/2026 06:19, Nathan Chancellor wrote: > If a user has set an invalid CONFIG_DRM_PANIC_SCREEN value (such as > "qr_code" without CONFIG_DRM_PANIC_SCREEN_QR_CODE=y due to missing or > incorrect Rust dependencies), there is a panic when accessing > /sys/module/drm/parameters/panic_screen: > > [ 12.218375] BUG: unable to handle page fault for address: 0000000796dd8818 > [ 12.219737] #PF: supervisor read access in kernel mode > ... > [ 12.227167] RIP: 0010:drm_panic_type_get+0x1b/0x30 > > If drm_panic_type_set() does not find a valid drm_panic_type enumeration > in drm_panic_type_map based on the provided value, it does not change > drm_panic_type from the default -1 value, which is not a valid index for > accessing drm_panic_type_map in drm_panic_type_get(), resulting in the > crash. > > Validate the value of CONFIG_DRM_PANIC_SCREEN at boot time via the > return value of drm_panic_type_set() in drm_panic_init() and explicitly > fall back to the default of "user" with a message to the user so that > they can adjust their configuration or fix missing dependencies. > > [ 0.800697] Unsupported value for CONFIG_DRM_PANIC_SCREEN ('qr_code'), falling back to 'user'... > > Fixes: e85e9ccf3f84 ("drm/panic: Report invalid or unsupported panic modes") > Signed-off-by: Nathan Chancellor > --- > drivers/gpu/drm/drm_panic.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/drm_panic.c b/drivers/gpu/drm/drm_panic.c > index eb7ef17b9c71..0cd574dd9d88 100644 > --- a/drivers/gpu/drm/drm_panic.c > +++ b/drivers/gpu/drm/drm_panic.c > @@ -1072,8 +1072,11 @@ void drm_panic_unregister(struct drm_device *dev) > */ > void __init drm_panic_init(void) > { > - if (drm_panic_type == -1) > - drm_panic_type_set(CONFIG_DRM_PANIC_SCREEN, NULL); > + if (drm_panic_type == -1 && drm_panic_type_set(CONFIG_DRM_PANIC_SCREEN, NULL)) { > + pr_warn("Unsupported value for CONFIG_DRM_PANIC_SCREEN ('%s'), falling back to 'user'...\n", > + CONFIG_DRM_PANIC_SCREEN); > + drm_panic_type = DRM_PANIC_TYPE_USER; > + } > drm_panic_qr_init(); > } I actually tested bad string on the kernel command line but did not think to test a bad string in CONFIG_DRM_PANIC_SCREEN. :( And that is despite the fact I saw that the kconfig is a free-form input so again my bad. Even worse is, I briefly considered converting kconfig to a mutually exclusive fixed list but then gave up not wanting to think about kconfig backward compatibility issues. We should probably tackle that problem since free form inputs are bad. We have another one in DRM as well for the fbdev client IIRC. Reviewed-by: Tvrtko Ursulin Regards, Tvrtko