From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (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 57FCF3FD96E for ; Wed, 10 Jun 2026 11:41:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781091687; cv=none; b=YHPBRho3iIMeTz4OFPfwNiPPBoJL9Ehznrfk2y6h2ObjTDKEHJahRWpr1+NMSNp72vJ5HAFtOUrts8fjTVzpwT5LC9pUMhf83z9kcqTAWxLqySBnwH92Qxm7gqDUHS1SU/UijaLRn/I01K5CM6SyQyS/wChZrrmdS8qLLpgkoDE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781091687; c=relaxed/simple; bh=Kz5o+o4V/50TgyMsDM1u+PPBmb+aUdtA7Th63o/S4GM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=K2i8KVZpPelPrW0I9RHJcQD7TlQb3/FScrL45lItecdTIY9b4yI72nPzdVaacamnXbHQl61tgaehNduRjsvpcTyV23BfKDOS5wN31dk/PtTgPx0SmsE4Un1gxbyroK11rKQu/vsZRAllqjjLLthkQACmNefn4YkCKTcK/cVDMgg= 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=UI+dDQhC; arc=none smtp.client-ip=209.85.219.41 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="UI+dDQhC" Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-8ce9df31840so50103206d6.1 for ; Wed, 10 Jun 2026 04:41:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781091683; x=1781696483; 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=/FNVXr9zawygTZbMFPpNLLMPEhT2gh4L5OBjQ+E7NpM=; b=UI+dDQhCBkL2djbo9jRTxvJto/ZNc2U7mZRKQcUdrIyg4ikS6tuNhWNNGfqabwz+Le CqOfZhKp4K6gESU/Bm6kCKNDsGx2HYmB35HvEh0P9UsIki9XhadTEQ+5WCr/JVlUgEA/ zPD6Y51/QbXp9WSTb2pkrHD2zmDZufE/z+X+yu9HJE4w+8KF6A51rTkj3Zmr1fNVIYQ9 XEM32Z0knRNdN+EfS2r3nRL4OFyFe/8w/kV5PBoYVzfXBes56cUewIWZctpM+5wyL2ht QFH6UfCi9xjovuPHwiZOH2Gg8VGcC32hwDhESH6+e4KmWgSeXWHh3OeV86f4oMG3AM12 iMTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781091683; x=1781696483; 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=/FNVXr9zawygTZbMFPpNLLMPEhT2gh4L5OBjQ+E7NpM=; b=NBVT2v2uKEF0HQ7B2P5AK7xA5vfbODMSWZ9FSNB4LAOie8gIWsYAykHudFvd6gqy8C C8JSVmpuaAVkgQTP9h7STQZavm7URvPSRlvKhuCzHQOY3Um82XvWqAd1JEaRoMwEOSKn SrXc4O52scIXGE8UHjPGKb9FBx4j879QtJKToHQR++ZR4iMiSMve+OUzgqGqJOGsCA47 8boyb+BszC6s1nK0GfpV42pBsYk4MW6fK2yotlmaSkZASQ+Ip0Z+RUmBpKykDgmwaC2H E6Xp6zB+nfWrMaExEwl9OsseSdAgbiS8iTN89JN7cMh+6HaSq0vW/lrqov6cta6nlY2n zG7Q== X-Forwarded-Encrypted: i=1; AFNElJ9vzWDUKDM6JrZC7T/eQ/U5sf5rznfj+j10vBQ5quD59tJ0lufKbwmj/fb+lWe4zTs8bU9rFkd/UWZ7v7o=@vger.kernel.org X-Gm-Message-State: AOJu0YxxjcUL6kPD6oyBplCDe5u1Ljhy1me1YAmklNXUhEiJmL/eGfOr THYtzwYjeoW9HaNd5WNKz7CyIVoZ4joAhBWNA88eq0MJY3LSDngzIgOU X-Gm-Gg: Acq92OEM8HAMup+8KpHAdBDdPz1DhSk2lgCgwAkmm4z2j1LarTqfJh3D8F2qsqvIbt3 cVrLQJtze2ILwPNY3CMqeQp9ANQQsxIQW7qRL+db3DhJ89tIK15ORZ0FWxWBfpRtnFcRn8JSHVx NF9xcVVuMQXyLH4QCAD/7oENTdVQAV9uFLFLrL20PYxws2cRu0K+Ewwe7g4RW5/zKzcIzRst4dr 5Axm/LtbWKeq9N48JbsBeAVaEfWbRsswPXGfYiRPWTaDeFqqI5GlSH8tkT+9Ei0g615M2d3OZhi ZW3hjDxtw3EJ4TxaVyii/f5IXqTSNc93losdkW6JNzScci/zplByiy9uTD6jNshd/O2YbeLs0xV XaDJUpCgRmJyZO9DOVhx8q4e4YrzSR73AnPKi6e+aPUjsBngiJIRm4ym+WuaVKq6ivX0E5xYp48 +N82ieHZOncH8sNv4Log4FaezDFgp+CKVh9TXD2JEyR1BVY0BGiuXlKLeuACUlxDfbSDao0Fo5X Rs+hqaSk2hWjxamyeMiNwQUksn1iQY= X-Received: by 2002:a0c:f09c:0:b0:8cc:dfa6:3333 with SMTP id 6a1803df08f44-8cee613313amr408672466d6.32.1781091682895; Wed, 10 Jun 2026 04:41:22 -0700 (PDT) Received: from server0 (c-68-48-65-54.hsd1.mi.comcast.net. [68.48.65.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ceccd9fc7dsm234124256d6.5.2026.06.10.04.41.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 04:41:21 -0700 (PDT) From: Michael Bommarito To: Justin Tee , "James E . J . Bottomley" , "Martin K . Petersen" Cc: Paul Ely , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH] scsi: lpfc: bound RPL ACC payload size to the response structure Date: Wed, 10 Jun 2026 07:41:19 -0400 Message-ID: <20260610114120.3748526-1-michael.bommarito@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7bit lpfc_els_rcv_rpl() handles an unsolicited RPL (Read Port List) ELS request from a fabric peer. For a request with rpl->index != 0 (or index 0 with a small maxsize) it computes the accept payload size as cmdsize = sizeof(uint32_t) + maxsize * sizeof(uint32_t); into a uint16_t, where maxsize comes straight from the peer's request with no upper bound. lpfc_els_rsp_rpl_acc() then builds the response with memcpy(pcmd, &rpl_rsp, cmdsize - sizeof(uint32_t)); The RPL accept always carries exactly one RPL_RSP structure, so a peer-chosen maxsize makes cmdsize - sizeof(uint32_t) exceed sizeof(RPL_RSP): the copy reads past the on-stack RPL_RSP, placing adjacent kernel stack into the response sent back to the peer, and for a large maxsize overruns the command buffer. Bound cmdsize the same way the index == 0 branch already does, since the accept payload is a single RPL_RSP regardless of the requested maxsize. Fixes: 7bb3b137abf2 ("[SCSI] lpfc 8.1.2: Handling of ELS commands RRQ, RPS, RPL and LIRR correctly") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Michael Bommarito --- drivers/scsi/lpfc/lpfc_els.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c index 4e3fe89283e41..555b2e4d78fb9 100644 --- a/drivers/scsi/lpfc/lpfc_els.c +++ b/drivers/scsi/lpfc/lpfc_els.c @@ -9250,7 +9250,11 @@ lpfc_els_rcv_rpl(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, ((maxsize * sizeof(uint32_t)) >= sizeof(RPL_RSP)))) { cmdsize = sizeof(uint32_t) + sizeof(RPL_RSP); } else { - cmdsize = sizeof(uint32_t) + maxsize * sizeof(uint32_t); + u64 sz = sizeof(uint32_t) + (u64)maxsize * sizeof(uint32_t); + + if (sz > sizeof(uint32_t) + sizeof(RPL_RSP)) + sz = sizeof(uint32_t) + sizeof(RPL_RSP); + cmdsize = sz; } lpfc_els_rsp_rpl_acc(vport, cmdsize, cmdiocb, ndlp); -- 2.53.0