From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (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 C51CD3E959D for ; Mon, 20 Apr 2026 13:25:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776691504; cv=none; b=HJ5bAqzP+P9N51QuVgQxVu8Mdemwr1DQOxWUtk5MhERhB20MjDCIbDSmuvFGs95jhgKXb4qj9rCFTcw8Fmqo+6OQZyLbJj2zPODQlp7ZEVXqS7VumZoK8R5pf017JgyHBo5V4igA8jNjOkDPpb9NTLVjYW6ztC039wI/BrwlmMk= 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.215.175 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-pg1-f175.google.com with SMTP id 41be03b00d2f7-c795a47186bso1117020a12.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=Ml/iD7AS6pUKYwzadmPMxewA6w4oVt27XIQ7vzVIo2skdz5IdEM5tnFSkqXF5UWLVn dBJNGq5UiVxCFJp3adPzu4tYydckrE0j2tkyuoKCInF5X6ue1SmdH+tJT+QIsDT1Yshb 5jzG8Gt12PEwo/LcKvpOyZrhAxMNEc8vF87n299tcHdRl/6pxBpcR2syjW8n40zNy1CH 5EGzNBqYeFwBnyeW9+DB4+wlrjZmKWqETAa3Gr6VZ9o3NngOFa0vdH/lU7XrUDHyAnWf PmxijeptUn2ealoCo5z2TJIqNDStw0pNamSXRPK7feuYW+xUSj3FoBzQsaFrbSNQquWZ wGiw== X-Gm-Message-State: AOJu0YwkL3pqQVyIwKMBC1bdJG+hUR85aFgKjAInMlJCgvxGhcHWv7Po 26nFfRNPi1vQCpyp4BBXH14zEmdWa6rOgLzB26fuUc+kFVnsWfXGUCPQ X-Gm-Gg: AeBDietA8TfNXQ8eeypt2Q0EdfS6FLPW548ffaMtzHhDHujqTtZQ/j4BydOpXpY58L9 S4sD56mQ/hNGD+JreFpHWdW2+Tyg1MB4E/OjSMW4ZXUAdD0lSY8bGvQ+MeNY6w3+0zEhFf7iriU 3yclIU/uykAjp8WAaOzOE53D8PPF+2ZU2lvdVrLx76vQ/ET3txkjKWQ+hYcP1N9G39293J0j7Ks Y8AoiHsY0Ks2UozjriPKRVd6DwZ9SvAlPHW6qprqNo/BwdiukzYi2FPiFICEcCAAYS47QQPYX1C eQ2yhkidaGFRZ5dC4Cj9kAsr/YeNbOa4YZKm40lNocGhUh9dJEM9ToF4hK7ulvwrdbDdHQr5ELQ XkgLo7ZJ2228YysFk1QTABjik5Z+ZPZlrbg+uarij0DF7sCz17QWyfyAKsplaaRLcULYtJ3B5vQ u0UJdUY23Tej2o7Ns+Y/JZy6yeVYYREwvoysQ= 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: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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/platforms/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 = { static int papr_hvpipe_dev_create_handle(u32 srcID) { struct hvpipe_source_info *src_info __free(kfree) = NULL; + struct hvpipe_source_info *owned_src_info; 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; - retain_and_null_ptr(src_info); + owned_src_info = 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); } -- 2.43.0