From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83F5D3403E1 for ; Sat, 11 Jul 2026 06:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783752890; cv=none; b=UmYMIDoWP6f7lefbzevR4CsgyXZ+VPkMbsOov3oIGb535oKXJoGep4hr3rCdRI6zsfl3BdejDSTypQmY0ih19X/RQmSOq30DcK64RVfSzgmzuDoqzZFIj8Xi2luhrqe9yNu7v6C/3ZJMT+8CG2/vB7IxhQ1mWsFTR5Xs6DJrmdk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783752890; c=relaxed/simple; bh=8fT0Gg/8Igu9jt6gZKh1bW7ODGFpVtDQrf69dpWU9zE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V25Z4rToZmkBM+z141DxT+2ocAKjqFsOqfNAJDQ1muyXUH29FVV4ueLepoEIhNAeWQdGf/yFSAKLNFmvFkvggywQRAPD2rc9ALN0c/v5PxO8iERPd5jBOeSAQysQukn3JiQ39js77obD3YNNEDO3+Z2YEMivdPbSl3Bp1ufy21U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-2cc97653887so18091165ad.1 for ; Fri, 10 Jul 2026 23:54:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783752886; x=1784357686; h=content-transfer-encoding:mime-version:references:in-reply-to :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=DNuv1LlOXCQ1HK6vbtUi5c2rok5gLYfCN2rAKCK3bnw=; b=ERN0P86ySyExhTr+t39BHAD0y1p6kD/iNu0uhhZ/QW7rcFHlSt3KnoXgp7QLggAXhc n1VWSzEfs1xGAI4NOTMc3wXtCH81y8dwwsHAx1s+oYwe1vR6ZLldoJJ1fa9iUJY1Ys9h zujDRouDs7Y77bSpp5DvFwmWjEkDjtv6L6I/VOys0fnDeexzYZBniUPd0/8bjLqacD8f mpzkOWHosMQ1njhqqkl1VVs4XKgndWs4/I1hSzT8YmyaH/D5Ihb0A2/roM0kljDJHqwu Yj7wX2hKaGbS9UKGUcZx3kIQC9KIIwT7RdTa0yKE3IN/5joilf967A+7/P4YF5KU4pmy lSTA== X-Forwarded-Encrypted: i=1; AHgh+RrJd5MiJ9rgwHfyHzLE231bHACrYNEqyueH6BPapkzNE2E8VxkdV1xdOTybftxJsRfOdZIA0wgH2GSQjAM=@vger.kernel.org X-Gm-Message-State: AOJu0YxKlRBhSUQiiBHidT9fGJd3+yU0xmhQJcy4MBcWzDTZdcxCgzFK 73/CVhOxEi6+2NKkqfdRwmNVp1Dukozr+NtO9MEJ7qSIcVvsuzEYEI8= X-Gm-Gg: AfdE7ckIKJOCEAZ561LiX74/bD3DAwSGNP2Hh5s0VSu+OZEwMa9txCSza/z0HO6Twwe rFxOFO3AMAOjC/pnPE46I/EZEr92ufOmvWhKnuc7Yh5TMoeY8+mPdwdvUaRez2vCDL8CIGAQHvX aIRfmKxRB5ImfALIlv1oW7q3FcDONuXYjRK+356qnprnMDKyAZmFZI24K565PVbl8MMJ1/q177Y i6WiduM4tnXZKZyvtTo0Wm8QuiaCMihNfGxU9UlJ2WmBq6tZE33VXtQtQQQYnNDI2koOPU8M6t+ f4cFp3Z7dgOxkAelkf2ZMSyXgXZUlAE0qRGY5sMphiqeU0ZFVk38QRe1dIX5Eogw4oSXT+dfXBd fQOPxW4DTAYT5oDHB9AeRbjWOheGiYnj8fT83FsfRhLlzEGFO2vyISjiofF4jx9SeIWEBTaR8bQ 0mRX3QcJgEZoYF59roi93Tpa66oui1/oTrJMtKvwSrOweS4fTtegm4T8Tn/q2PnRANYLIjlj0Yp 4nC7WDkhpYMeaCg7tGnDOj+wwR8E9h/U4Uf X-Received: by 2002:a17:902:d987:b0:2c9:df1b:e948 with SMTP id d9443c01a7336-2ce9e9a7128mr24297395ad.4.1783752885868; Fri, 10 Jul 2026 23:54:45 -0700 (PDT) Received: from penguin.tail0a1999.ts.net (61-228-52-13.dynamic-ip.hinet.net. [61.228.52.13]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ce8f5183b9sm18272535ad.5.2026.07.10.23.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 23:54:45 -0700 (PDT) From: Shih-Yuan Lee To: Dmitry Torokhov Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Shih-Yuan Lee Subject: [PATCH v2 3/3] Input: applespi - fix NULL pointer dereference in tp_dim open Date: Sat, 11 Jul 2026 14:54:15 +0800 Message-Id: <20260711065415.7396-4-fourdollars@debian.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20260711065415.7396-1-fourdollars@debian.org> References: <20260711055247.5412-1-fourdollars@debian.org> <20260711065415.7396-1-fourdollars@debian.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The tp_dim debugfs file is registered synchronously during driver probe in applespi_probe(). However, the applespi->touchpad_input_dev is initialized and registered asynchronously in the driver's worker thread. If a userspace process opens the debugfs file before the worker thread has completed initialization, applespi_tp_dim_open() will dereference the NULL applespi->touchpad_input_dev pointer, causing a kernel panic. Fix this by using smp_load_acquire() to safely load touchpad_input_dev and return -ENODEV if it is not yet initialized. Signed-off-by: Shih-Yuan Lee --- drivers/input/keyboard/applespi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c index b6b4d258d0dd..1f8e4ae90285 100644 --- a/drivers/input/keyboard/applespi.c +++ b/drivers/input/keyboard/applespi.c @@ -968,12 +968,18 @@ static void applespi_debug_update_dimensions(struct applespi_data *applespi, static int applespi_tp_dim_open(struct inode *inode, struct file *file) { struct applespi_data *applespi = inode->i_private; + struct input_dev *touchpad; file->private_data = applespi; + /* Pairs with smp_store_release in applespi_register_touchpad_device() */ + touchpad = smp_load_acquire(&applespi->touchpad_input_dev); + if (!touchpad) + return -ENODEV; + snprintf(applespi->tp_dim_val, sizeof(applespi->tp_dim_val), "0x%.4x %dx%d+%u+%u\n", - applespi->touchpad_input_dev->id.product, + touchpad->id.product, applespi->tp_dim_min_x, applespi->tp_dim_min_y, applespi->tp_dim_max_x - applespi->tp_dim_min_x, applespi->tp_dim_max_y - applespi->tp_dim_min_y); -- 2.39.5