From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 E3A3737CD5D for ; Wed, 8 Apr 2026 12:01:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649720; cv=none; b=pUJ9zH9r4AqLCtFKI2VBnlL1nHzVJ7SLIAAsYvGTIyoGKBc3ISNALHnng/n6o/6uYJB7F6AqmqLaeFNU7WXvDu83LUqThhgU1tsgH71Odx8dHNaFCF5t9GqWM5XN8+AhEukKjZgLU2zARBOGWYyETTPHewbYJ0Pw2wt7LBOr0zc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775649720; c=relaxed/simple; bh=9NbnFzTEGh6+lE1PwksEW7af7i8jzYb/dCKoYyURmxQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=phOqv5gHXgV3tv1oMexLJ+qrpf0ZoE0O/WtTocj+ZaKEfOuqbthzc9Jzn+wSfFO+51bPcw70gGkPVmXJ4JuyJufqM9EjxWC0aw5N6M7iz3Q/ICs3ey5OMFumd51mCbGi5oiLkMjDlbgSJObF9aQmWhjeOszasiifVqUoPF9uPFg= 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=FcozcVtG; arc=none smtp.client-ip=209.85.210.181 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="FcozcVtG" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-82ce0a9b3f7so2614204b3a.0 for ; Wed, 08 Apr 2026 05:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775649718; x=1776254518; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PYNm6J9AhUQ6HT8V6B6W7Iuh7E+aasxrExqJ2exyz7U=; b=FcozcVtG9cxE+N635I6r7uMJ3TvmOLaFn35Phn8ibNkhGn3TjmDONgqxtA9W+dwdvB /AAawq1I4g/JIrlXTMFmFRmpGBb0unoUhbUV6F3jYboi83haRf+vUeWbk8D+Q3gH7sbv 6lFzn3z0h+drRLHGKyllmRKbqEm9/95tcMilqGJoG+xHqlCH0PSVMnv6I20KQlUQRUZI EhqbTglBZIubP6SBiOi0aUmbjZPYbiJ6COHfIVGt7Y9x9o9j226uO5biv6wuepQm6SLN 4nBM7TvNRC//zIWStfk5brec6BIhh5a/XAkOGKq7/WLmsN901gz6J1Pwa3/l4/mU6+DG +uOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649718; x=1776254518; 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; bh=PYNm6J9AhUQ6HT8V6B6W7Iuh7E+aasxrExqJ2exyz7U=; b=tPpdr94I72BHlbG0U6AiJEo1t4JrIWn07FlN0V73Wd4agDXY9aoREquTF/6/jcTGKt zakCi1pYB4vKRtw4oIFDhRHC91K15nrwh60LpRFCs7B1agb6LhauOFdzPPl5O3ag4HUv gySqSGPJLxBKoCnb+28d0pPk15/eaXKy57STM4Cdc28IkgP9dSlxZ6rYu/SnV4XK1TEQ NHhn/w2YiPdHxxOk4qm848T/BulCe9Ddl+VX4irpgSvd/xVL98LZfUGzQ19kI53VFKDd zLnt9NTp035I6AzRe7s0e7hKafe5Bwc4ehWvHDL3SQnrxO2blL0NfdM0tmvHNE3JqE08 gdLg== X-Forwarded-Encrypted: i=1; AJvYcCXume9MAhRIBCd0DZkjZbVNNIwdP7WcmcixPY0eRm2heqdGlBhJa+M29L1+1JW6BdqbS0ORP56rPbpIQfQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzmFfhkuKC47WSZGmM4D4UNQvu+6+5TQbGEurv2ypBDg4oqExqz MUWZC438o2CHb3epmEtD9G22z9B4WEZ71e2TcwaXt1eg37EuC5r28gwDTtmPvw== X-Gm-Gg: AeBDiev8ceAh3dwCm9EAPz43Bdt132e5Rzrs063blFOOfnw2F51f5TL8OfuJoyxQgHv d9x6ooGkd9B2qCWS/mCFgVvueHnG6K8kFoxBO7+dv4H74VYIjjTZbWYQqa+EACKOS7wmBH9Xn8c XDchsTnV9NI9X5R7Do+2zNEDwBJoiFR/DKLUsu+e+xsn6Avl7klJ11UFHSrFoSfNSI5UUp3jJms cmB5yBtfovFetyp847iFExx/wowKE8DyGGeatfaK7FoIQ4GVGdw1hdj+QJn5N1rsaun7aH+KHgt TAGB5qav5bpi+Ix21142PwmijU8GH5jnciv5Gd2eXIG1Pe4TrD9yKhXkDbNbOXIHBpEWj9t7DHW auqw3xO6HBw0Te94msSSbnZBHUauXjCJj95moGQskWlEyR8tnF+zF5d3SsmxdY1mCNpRiLxa7iW lAtvB4T8yxAAi6aek/enb++nNI5CXv/KRKFZhokBrZhCvy X-Received: by 2002:a05:6a00:92a9:b0:82c:ed02:a242 with SMTP id d2e1a72fcca58-82d0dc05906mr20919689b3a.52.1775649718138; Wed, 08 Apr 2026 05:01:58 -0700 (PDT) Received: from Mac.localdomain ([49.205.216.49]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82cf9b3e169sm21209322b3a.18.2026.04.08.05.01.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 08 Apr 2026 05:01:57 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org, Haren Myneni Cc: Madhavan Srinivasan , Christophe Leroy , Venkat Rao Bagalkote , Nicholas Piggin , linux-kernel@vger.kernel.org, "Ritesh Harjani (IBM)" , stable@vger.kernel.org Subject: [RFC v2 01/10] pseries/papr-hvpipe: Fix race with interrupt handler Date: Wed, 8 Apr 2026 17:31:31 +0530 Message-ID: <54c52b89a626627aa57191b67a3ee22710b46f7f.1775648406.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit While executing ->ioctl handler or ->release handler, if an interrupt fires on the same cpu, then we can enter into a deadlock. This patch fixes both these handlers to take spin_lock_irq{save|restore} versions of the lock to prevent this deadlock. Cc: stable@vger.kernel.org Fixes: 814ef095f12c9 ("powerpc/pseries: Add papr-hvpipe char driver for HVPIPE interfaces") Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/platforms/pseries/papr-hvpipe.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/platforms/pseries/papr-hvpipe.c b/arch/powerpc/platforms/pseries/papr-hvpipe.c index 14ae480d060a..c41d45e1986d 100644 --- a/arch/powerpc/platforms/pseries/papr-hvpipe.c +++ b/arch/powerpc/platforms/pseries/papr-hvpipe.c @@ -444,13 +444,14 @@ static int papr_hvpipe_handle_release(struct inode *inode, struct file *file) { struct hvpipe_source_info *src_info; + unsigned long flags; /* * Hold the lock, remove source from src_list, reset the * hvpipe status and release the lock to prevent any race * with message event IRQ. */ - spin_lock(&hvpipe_src_list_lock); + spin_lock_irqsave(&hvpipe_src_list_lock, flags); src_info = file->private_data; list_del(&src_info->list); file->private_data = NULL; @@ -461,10 +462,10 @@ static int papr_hvpipe_handle_release(struct inode *inode, */ if (src_info->hvpipe_status & HVPIPE_MSG_AVAILABLE) { src_info->hvpipe_status = 0; - spin_unlock(&hvpipe_src_list_lock); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); hvpipe_rtas_recv_msg(NULL, 0); } else - spin_unlock(&hvpipe_src_list_lock); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); kfree(src_info); return 0; @@ -480,20 +481,21 @@ 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; + unsigned long flags; - spin_lock(&hvpipe_src_list_lock); + spin_lock_irqsave(&hvpipe_src_list_lock, flags); /* * Do not allow more than one process communicates with * each source. */ src_info = hvpipe_find_source(srcID); if (src_info) { - spin_unlock(&hvpipe_src_list_lock); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); pr_err("pid(%d) is already using the source(%d)\n", src_info->tsk->pid, srcID); return -EALREADY; } - spin_unlock(&hvpipe_src_list_lock); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); src_info = kzalloc_obj(*src_info, GFP_KERNEL_ACCOUNT); if (!src_info) @@ -510,18 +512,18 @@ static int papr_hvpipe_dev_create_handle(u32 srcID) return fdf.err; retain_and_null_ptr(src_info); - spin_lock(&hvpipe_src_list_lock); + spin_lock_irqsave(&hvpipe_src_list_lock, flags); /* * If two processes are executing ioctl() for the same * source ID concurrently, prevent the second process to * acquire FD. */ if (hvpipe_find_source(srcID)) { - spin_unlock(&hvpipe_src_list_lock); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); return -EALREADY; } list_add(&src_info->list, &hvpipe_src_list); - spin_unlock(&hvpipe_src_list_lock); + spin_unlock_irqrestore(&hvpipe_src_list_lock, flags); return fd_publish(fdf); } -- 2.39.5