From nobody Tue Jun 16 19:33:45 2026 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 C733E3E959E for ; Mon, 20 Apr 2026 13:25:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776691504; cv=none; b=QQeMVD7CPWCWpMNqyLLpHcqJG5VDV/fXcVbn3EWQJgcl19O87WNRQqfpYW6xA7b/3hS8NJo1aEX48L88Hfp36aT4WvQQEDvuxpcFVvxIIJ6Ye0Ix9C24jzfBxj0VdOixxrU7or8LPF/l8ExrIYZpsnnQSFKtDujv/jqFX0AGjr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776691504; c=relaxed/simple; bh=ZOSRbokGZapfu8PcFVycPRLR0QXSPkkl/mLiRDTmFNk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=egxisaTA1v6b7NWYck8hEbXFvJ1O9J+e38aac6+NjLbYx5n4x3jG9bwHa8LpVUaL6k0KvkgVhbuoQ+J8HPt3R8AKWINtNjjdkENTverf838ESsoahsd4iIlAMXADG/DIKWFEn3WeKtdHbBUcMTk8AN9QgDwp5rj1KGoChUiSxww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ah5RLloF; arc=none smtp.client-ip=209.85.210.177 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.b="ah5RLloF" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-82fb2d0c5d1so668299b3a.0 for ; Mon, 20 Apr 2026 06:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776691502; x=1777296302; 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; bh=gr0oztocKaKLkdTKEsH8odatBVVrOkD1g/pdHlqb6Es=; b=ah5RLloFm6yD4ohlcWE3LfGOJidnkDgYhywVG6EL7UrV98U4X5laPQovCUQll+ScZ/ tIpoiCggfHF3RiMclo/9Ey9powapy2xdCiYAxqVKxnxDaPfVaUTjZ8CJeRGQXjNoscs6 zDJwPoq2iqGWf7YUNpRHbdP5Yh12/jy9H2FByRZ3WJvtOS1UzgS8DQQxIcyeTOT+13Gc RR8RidPain9/gwja36CktI1kWINBC+7d0eyc2BsI3XTrtXi0IZlvsJxuENnrGHM+FfXx lq3MWemcwm4P1rimcVZnCQ1FUrzh/dTQDZCCJDEFieFqopXCKU38EsZCPL+/eCu7B1mZ IfZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776691502; x=1777296302; 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; bh=gr0oztocKaKLkdTKEsH8odatBVVrOkD1g/pdHlqb6Es=; b=dOHL2AWoEGQfNNck+ADzfXuk2cwTebiOt/FAOPsK9dq/4rHHl109XSybu75q7s+Lhn i98hdLz+jCxJ0d1g6nYXFqATZBsm+bqM99CP5TiEreeefNKON0ZbwkcqEv07TJtuawys ys/vbtG1ZTwTaG6VxgI+RM3WZ/HRzGICZ+jV5yy2kSev7WUM9Y1SirxPCC1knLA0DHgD 28SctuprUqDWQbB83z79N9li/E5ZVOQckQz3v/Dk1Ij2YUqeNUEhBFfPgdsMLOtskJlR SERy33SqKzWTBmw2SzuaFb7XLOifsHEooV5jC+JeJKBmI/b0ZS0RrIWljV17hfYQ15+3 860g== X-Forwarded-Encrypted: i=1; AFNElJ9+9KUBFog/ezgj5F93Kl5CwK8lpIQ+vk+J8QSkYV2ioEz10Ftrc2jSxqK2CenPmU2nyMZpajMzIGztqOU=@vger.kernel.org X-Gm-Message-State: AOJu0YxN959VMPjkjWpSniTgZcvQM0CJxOQkKl9eVTensVwIb26ukZO6 W588xESUXkVxD7d3VUFy+hSgRcJluAhy1BcZLLEU0btRY4VWTEAK95hs X-Gm-Gg: AeBDieuar1HEGciJl35BBEEzvwQ5iCnyWYSAcEKO9HYJzA5P6jOVJEXciA2xQx/bLEF iSdqoOMkq88hwbcZfFjwiqZLdwRaxOJ924SzCrkOyzYVpAe43QeJEP+lzKWY+MblsmDYneiAMI5 978I5T3SjJSTTOy+NPJR6JyPx7UyQuQNfc3PA/OmzKtZLSB+Z7cVhfQwyjXsSRfNJgtaCNdihFI nQWCLhu7G2naxcv8FazqtTQhu5QFUUzDqanksn+xLXzUi1Y5U4ywc462CAB7tUUfuKXHUe3hgs7 56IcbfcQUD0NFxIg09JLshY48hKkUiLwgcQI8wSktSrCTdX1m2AQwjaF1n3KAxt5UAovr2KL1Wo CiIV+uQVkhEKVW7JPxBUybYqeIFExO+HcQk4+KKfXv2SeJHvqZ+rX0lRwyIgoyGBvnESflMUUQL MA3XzIRgxp+QJagVSArFDVqYASDbyQ1RF2LGc= X-Received: by 2002:a05:6a20:3d06:b0:3a2:d5b8:bfa7 with SMTP id adf61e73a8af0-3a2d5b8c92fmr2099312637.1.1776691502065; Mon, 20 Apr 2026 06:25:02 -0700 (PDT) Received: from lgs.. ([2408:8417:d50:4775:1153:f731:14e3:b103]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7976f8fcbdsm7907037a12.6.2026.04.20.06.24.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 06:25:01 -0700 (PDT) From: Guangshuo Li To: Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Mahesh Salgaonkar , Haren Myneni , Tyrel Datwyler , Christian Brauner , Kees Cook , Guangshuo Li , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Subject: [PATCH v2] powerpc/pseries/papr-hvpipe: fix NULL dereference in handle creation Date: Mon, 20 Apr 2026 21:24:29 +0800 Message-ID: <20260420132429.128075-1-lgs201920130244@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" papr_hvpipe_dev_create_handle() transfers ownership of src_info with retain_and_null_ptr(src_info) after anon_inode_getfile() succeeds. However, retain_and_null_ptr() clears src_info immediately, and the function then still dereferences src_info in the subsequent list_add(). Store the transferred pointer in a separate variable and use that for the list insertion. Manually identified during code review. Fixes: 6d3789d347a7 ("papr-hvpipe: convert papr_hvpipe_dev_create_handle() = to FD_PREPARE()") Cc: stable@vger.kernel.org Signed-off-by: Guangshuo Li --- v2: - Fix the Fixes tag to use the documented 12-character SHA-1 format arch/powerpc/platforms/pseries/papr-hvpipe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/pl= atforms/pseries/papr-hvpipe.c index 14ae480d060a..497eb967611b 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -480,6 +480,7 @@ static const struct file_operations papr_hvpipe_handle_= ops =3D { static int papr_hvpipe_dev_create_handle(u32 srcID) { struct hvpipe_source_info *src_info __free(kfree) =3D NULL; + struct hvpipe_source_info *owned_src_info; =20 spin_lock(&hvpipe_src_list_lock); /* @@ -509,7 +510,7 @@ static int papr_hvpipe_dev_create_handle(u32 srcID) if (fdf.err) return fdf.err; =20 - retain_and_null_ptr(src_info); + owned_src_info =3D retain_and_null_ptr(src_info); spin_lock(&hvpipe_src_list_lock); /* * If two processes are executing ioctl() for the same @@ -520,7 +521,7 @@ static int papr_hvpipe_dev_create_handle(u32 srcID) spin_unlock(&hvpipe_src_list_lock); return -EALREADY; } - list_add(&src_info->list, &hvpipe_src_list); + list_add(&owned_src_info->list, &hvpipe_src_list); spin_unlock(&hvpipe_src_list_lock); return fd_publish(fdf); } --=20 2.43.0