From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796353343; b=k2ZrR9p6CBcVbAG0qkxw8iNx2+5O/CiikKqMuea+YNaaNypi2oKUBwO3WVO1Hbvu5HoW sbasZ31UiXHqs0lknCxFfsc7jyAlP4douaG5YI/iYmG6BJKJWU1kIq1hqKOfOa0bHS6a6 9bBXQVYwbEcMPLL+Xyah8cF584zO8ApbOU2Tea2uDlxe1/MVUE89e/iGl5MkkpKFIRMRw UaMs9LOTyQ6UP8D/TsQ8SizPiEN/7/6883kHMlBm1/9yVwB64VohojuEqRBTd7MFC6OAP 2nBabY6oxE5FVyj/t/8eOogiFDCtO8Y9kBkn2UbFxBY3b9vZpGhJ3IdocVQjCVG7eJA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796353343; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=STPMSwaGDZPRSFuRhwh3RPwj5xvv2O9jP5+hinZvpeM=; b=rGJyWkR0R2StwufeC/CcYsSPoPg2J5Md7bpziSeLeAREym69E41OvkqrrKhDWkJhop7A GHQBo6z9S9BujLGVkDLly7XqLi6Ni7Fd2lf5miaCtCsDQm2WVawInV2+W9QYjNTu8cqsk PvPJwJNDagQ+v6TjtHchaly9kQq0/4Bf9ts9qI6gDqkUOFtaOWRMfm41mBhIG1nBsVgS0 5r5te+h+T9yObRTVgCJxuX5YSM2cEOqpglqJc09UTcMSBl24Iv1z9M+wt7TkTbP6Ir7r+ ucayLljTIyJY0sTcvQmgPrlI54VyFg+b4GTFalKul9cc11P0ZUe2CthgvODE3jVLMIg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="JET/M/um"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AEBB160A3836; Fri, 4 Dec 2026 03:02:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JET/M/um Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6ECFB1F00A1C; Fri, 4 Dec 2026 03:02:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796353343; bh=STPMSwaGDZPRSFuRhwh3RPwj5xvv2O9jP5+hinZvpeM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=JET/M/umLzM78SJbzpGFkOz23uVh/S22d/a1aYJUbVmx2TvoSmYw7RghJF4/BMoJk CKKAHAgjtB3j/CGswMCnRex6y8Ha3TPJzBRr3KEUIGrdHXjAiB7swTcvHiu7vLuP0B vI1+WwRkHDuHqbGAqa4FMMDPou8jjyWlgsVdChoNMrte/oC0SA6FDiCSfTIJU7M8kT 6P8biEEWCXsS9WgWkcpQ83zGFrqKxBTtTHsqPp2luiEiT6p+foBsNLTx1WiWKE9MF0 B/jTm1CkxYhCHv4AWwYz+lXeuhcywiLbgWEsbiME/7/vWG2yrtKvas7AwPE5FS44Qv AxQHzf1ZbeTqA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] scsi: target: configfs: Bound the output of target_dev_lba_map_show() Reply-To: sashiko-reviews@lists.linux.dev To: "Anh Nguyen Hoang" Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org In-Reply-To: <20261203-kbug-l986-v1-1-00584b0bc42a@gmail.com> References: <20261203-kbug-l986-v1-1-00584b0bc42a@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 03:02:23 +0000 X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] scsi: target: target_dev_lba_map_show() exceeds 4KB configfs limit -- commit 3c3acef60382791667727ab0d330848e93b99d18 Author: Anh Nguyen Hoang scsi: target: configfs: Bound the output of target_dev_lba_map_show() This commit replaces sprintf() with scnprintf() bounded by PAGE_SIZE - bl in target_dev_lba_map_show() so formatting the LBA map cannot write past the configfs page buffer. > diff --git a/drivers/target/target_core_configfs.c b/drivers/target/targe= t_core_configfs.c > index 2b19a956007b7..bb35d2dc48add 100644 > --- a/drivers/target/target_core_configfs.c > +++ b/drivers/target/target_core_configfs.c > @@ -2601,12 +2601,12 @@ static ssize_t target_dev_lba_map_show(struct con= fig_item *item, char *page) > =20 > spin_lock(&dev->t10_alua.lba_map_lock); > if (!list_empty(&dev->t10_alua.lba_map_list)) > - bl +=3D sprintf(b + bl, "%u %u\n", > - dev->t10_alua.lba_map_segment_size, > - dev->t10_alua.lba_map_segment_multiplier); > + bl +=3D scnprintf(b + bl, PAGE_SIZE - bl, "%u %u\n", > + dev->t10_alua.lba_map_segment_size, > + dev->t10_alua.lba_map_segment_multiplier); > list_for_each_entry(map, &dev->t10_alua.lba_map_list, lba_map_list) { > - bl +=3D sprintf(b + bl, "%llu %llu", > - map->lba_map_first_lba, map->lba_map_last_lba); > + bl +=3D scnprintf(b + bl, PAGE_SIZE - bl, "%llu %llu", > + map->lba_map_first_lba, map->lba_map_last_lba); > list_for_each_entry(mem, &map->lba_map_mem_list, > lba_map_mem_list) { > switch (mem->lba_map_mem_alua_state) { > @@ -2626,10 +2626,10 @@ static ssize_t target_dev_lba_map_show(struct con= fig_item *item, char *page) > state =3D '.'; > break; > } > - bl +=3D sprintf(b + bl, " %d:%c", > - mem->lba_map_mem_alua_pg_id, state); > + bl +=3D scnprintf(b + bl, PAGE_SIZE - bl, " %d:%c", > + mem->lba_map_mem_alua_pg_id, state); > } > - bl +=3D sprintf(b + bl, "\n"); > + bl +=3D scnprintf(b + bl, PAGE_SIZE - bl, "\n"); > } > spin_unlock(&dev->t10_alua.lba_map_lock); > return bl; [Severity: Medium] Can these scnprintf() calls still exceed configfs's 4096-byte attribute limit on kernels where PAGE_SIZE > 4096? In fs/configfs/file.c, fill_read_buffer() caps simple attributes at SIMPLE_ATTR_SIZE (4096) regardless of PAGE_SIZE. On architectures with larger pages such as 16KB or 64KB, an expanding LBA map can still format past 4096 bytes, triggering WARN_ON_ONCE() and returning -EIO. Bounding the output to min_t(size_t, PAGE_SIZE, 4096) (or exposing SIMPLE_ATTR_SIZE) would avoid that on non-4KB-page kernels. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-kbug-l986-= v1-1-00584b0bc42a@gmail.com?part=3D1