History

target/pscsi: Reject cross page boundary case in pscsi_map_sg

We can only have one page of data in each sg element, so we can not cross a page boundary. Fail this case. The 'while (len > 0 && data_len > 0) {}' loop is not necessary. The loop can only be executed once.

Asias He committed 13 years ago

Commit 8f27d481 parent f002a241 file · +8 −3Browse files

Unified · Split

drivers/target/target_core_pscsi.c+8−3
@@ -883,7 +883,14 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, · 882 unmodified lines
883 pr_debug("PSCSI: i: %d page: %p len: %d off: %d\n", i,883 pr_debug("PSCSI: i: %d page: %p len: %d off: %d\n", i,
884 page, len, off);884 page, len, off);
885 885
886 while (len > 0 && data_len > 0) {886 /*
887 * We only have one page of data in each sg element,
888 * we can not cross a page boundary.
889 */
890 if (off + len > PAGE_SIZE)
891 goto fail;
892
893 if (len > 0 && data_len > 0) {
887 bytes = min_t(unsigned int, len, PAGE_SIZE - off);894 bytes = min_t(unsigned int, len, PAGE_SIZE - off);
888 bytes = min(bytes, data_len);895 bytes = min(bytes, data_len);
889 896
@@ -940,9 +947,7 @@ pscsi_map_sg(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents, · 50 unmodified lines
940 bio = NULL;947 bio = NULL;
941 }948 }
942 949
943 len -= bytes;
944 data_len -= bytes;950 data_len -= bytes;
945 off = 0;
946 }951 }
947 }952 }
948 953

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t