* [PATCH] Check sk before sendpage
@ 2019-07-10 7:30 Yang Bin
[not found] ` <1562743809-31133-1-git-send-email-yang.bin18-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Yang Bin @ 2019-07-10 7:30 UTC (permalink / raw)
To: lduncan
Cc: cleech, jejb, martin.petersen, open-iscsi, linux-scsi,
linux-kernel, xue.zhihong, wang.yi59, wang.liang82, Yang Bin
From: " Yang Bin "<yang.bin18@zte.com.cn>
Before xmit,iscsi may disconnect just now.
So must check connection sock NULL or not,or kernel will crash for
accessing NULL pointer.
Signed-off-by: Yang Bin <yang.bin18@zte.com.cn>
---
drivers/scsi/iscsi_tcp.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 7bedbe8..a59c49f 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -264,6 +264,9 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn,
unsigned int copied = 0;
int r = 0;
+ if (!sk)
+ return -ENOTCONN;
+
while (!iscsi_tcp_segment_done(tcp_conn, segment, 0, r)) {
struct scatterlist *sg;
unsigned int offset, copy;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <1562743809-31133-1-git-send-email-yang.bin18-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org>]
* Re: [PATCH] Check sk before sendpage 2019-07-10 7:30 [PATCH] Check sk before sendpage Yang Bin @ 2019-07-10 17:47 ` Lee Duncan 0 siblings, 0 replies; 5+ messages in thread From: Lee Duncan @ 2019-07-10 17:47 UTC (permalink / raw) To: Yang Bin Cc: open-iscsi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org, jejb-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org, martin.petersen-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org, cleech-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-scsi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, wang.liang82-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org, wang.yi59-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org, xue.zhihong-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org On 7/10/19 12:30 AM, Yang Bin wrote: > From: " Yang Bin "<yang.bin18-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org> > > Before xmit,iscsi may disconnect just now. > So must check connection sock NULL or not,or kernel will crash for > accessing NULL pointer. > > Signed-off-by: Yang Bin <yang.bin18-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org> > --- > drivers/scsi/iscsi_tcp.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c > index 7bedbe8..a59c49f 100644 > --- a/drivers/scsi/iscsi_tcp.c > +++ b/drivers/scsi/iscsi_tcp.c > @@ -264,6 +264,9 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn, > unsigned int copied = 0; > int r = 0; > > + if (!sk) > + return -ENOTCONN; > + > while (!iscsi_tcp_segment_done(tcp_conn, segment, 0, r)) { > struct scatterlist *sg; > unsigned int offset, copy; > If the socket can be closed right before iscsi_sw_tcp_xmit_segment() is called, can it be called in the middle of sending segments? (In which case the check would have to be in the while loop.) -- Lee Duncan -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org Visit this group at https://groups.google.com/group/open-iscsi. To view this discussion on the web visit https://groups.google.com/d/msgid/open-iscsi/1bc364ff-5bff-47ac-611a-f75c43f4bd1b%40suse.com. For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Check sk before sendpage @ 2019-07-10 17:47 ` Lee Duncan 0 siblings, 0 replies; 5+ messages in thread From: Lee Duncan @ 2019-07-10 17:47 UTC (permalink / raw) To: Yang Bin Cc: open-iscsi@googlegroups.com, jejb@linux.ibm.com, martin.petersen@oracle.com, cleech@redhat.com, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, wang.liang82@zte.com.cn, wang.yi59@zte.com.cn, xue.zhihong@zte.com.cn On 7/10/19 12:30 AM, Yang Bin wrote: > From: " Yang Bin "<yang.bin18@zte.com.cn> > > Before xmit,iscsi may disconnect just now. > So must check connection sock NULL or not,or kernel will crash for > accessing NULL pointer. > > Signed-off-by: Yang Bin <yang.bin18@zte.com.cn> > --- > drivers/scsi/iscsi_tcp.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c > index 7bedbe8..a59c49f 100644 > --- a/drivers/scsi/iscsi_tcp.c > +++ b/drivers/scsi/iscsi_tcp.c > @@ -264,6 +264,9 @@ static int iscsi_sw_tcp_xmit_segment(struct iscsi_tcp_conn *tcp_conn, > unsigned int copied = 0; > int r = 0; > > + if (!sk) > + return -ENOTCONN; > + > while (!iscsi_tcp_segment_done(tcp_conn, segment, 0, r)) { > struct scatterlist *sg; > unsigned int offset, copy; > If the socket can be closed right before iscsi_sw_tcp_xmit_segment() is called, can it be called in the middle of sending segments? (In which case the check would have to be in the while loop.) -- Lee Duncan ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] Check sk before sendpage 2019-07-10 17:47 ` Lee Duncan (?) @ 2019-07-10 18:52 ` James Bottomley [not found] ` <1562784731.3213.98.camel-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org> -1 siblings, 1 reply; 5+ messages in thread From: James Bottomley @ 2019-07-10 18:52 UTC (permalink / raw) To: Lee Duncan, Yang Bin Cc: open-iscsi@googlegroups.com, martin.petersen@oracle.com, cleech@redhat.com, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, wang.liang82@zte.com.cn, wang.yi59@zte.com.cn, xue.zhihong@zte.com.cn On Wed, 2019-07-10 at 17:47 +0000, Lee Duncan wrote: > On 7/10/19 12:30 AM, Yang Bin wrote: > > > From: " Yang Bin "<yang.bin18@zte.com.cn> > > > > Before xmit,iscsi may disconnect just now. > > So must check connection sock NULL or not,or kernel will crash for > > accessing NULL pointer. > > > > Signed-off-by: Yang Bin <yang.bin18@zte.com.cn> > > --- > > drivers/scsi/iscsi_tcp.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c > > index 7bedbe8..a59c49f 100644 > > --- a/drivers/scsi/iscsi_tcp.c > > +++ b/drivers/scsi/iscsi_tcp.c > > @@ -264,6 +264,9 @@ static int iscsi_sw_tcp_xmit_segment(struct > > iscsi_tcp_conn *tcp_conn, > > unsigned int copied = 0; > > int r = 0; > > > > + if (!sk) > > + return -ENOTCONN; > > + > > while (!iscsi_tcp_segment_done(tcp_conn, segment, 0, r)) { > > struct scatterlist *sg; > > unsigned int offset, copy; > > > > If the socket can be closed right before iscsi_sw_tcp_xmit_segment() > is called, can it be called in the middle of sending segments? (In > which case the check would have to be in the while loop.) I think the important point is: is this an actual observed bug or just a theoretical problem? The reason for asking is this call is controlled directly by the ISCSI_UEVENT_DESTROY_CONN event sent by the iscsi daemon. Obviously if the daemon goes haywire and doesn't shut down the connection before sending the destroy event, we may get the crash, but I would be inclined to say fix the daemon. James ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <1562784731.3213.98.camel-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>]
* Re:[PATCH] Check sk before sendpage [not found] ` <1562784731.3213.98.camel-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org> @ 2019-07-11 7:42 ` yang.bin18-Th6q7B73Y6EnDS1+zs4M5A 0 siblings, 0 replies; 5+ messages in thread From: yang.bin18-Th6q7B73Y6EnDS1+zs4M5A @ 2019-07-11 7:42 UTC (permalink / raw) To: jejb-tEXmvtCZX7AybS5Ee8rs3A, LDuncan-IBi9RG/b67k Cc: open-iscsi-/JYPxA39Uh5TLH3MbocFFw, martin.petersen-QHcLZuEGTsvQT0dZR+AlfA, cleech-H+wXaHxf7aLQT0dZR+AlfA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, linux-scsi-u79uwXL29TY76Z2rM5mHXA, wang.liang82-Th6q7B73Y6EnDS1+zs4M5A, wang.yi59-Th6q7B73Y6EnDS1+zs4M5A, xue.zhihong-Th6q7B73Y6EnDS1+zs4M5A [-- Attachment #1.1: Type: text/plain, Size: 2585 bytes --] > On Wed, 2019-07-10 at 17:47 +0000, Lee Duncan wrote: > > On 7/10/19 12:30 AM, Yang Bin wrote: > > > > > From: " Yang Bin "<yang.bin18-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org> > > > > > > Before xmit,iscsi may disconnect just now. > > > So must check connection sock NULL or not,or kernel will crash for > > > accessing NULL pointer. > > > > > > Signed-off-by: Yang Bin <yang.bin18-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org> > > > --- > > > drivers/scsi/iscsi_tcp.c | 3 +++ > > > 1 file changed, 3 insertions(+) > > > > > > diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c > > > index 7bedbe8..a59c49f 100644 > > > --- a/drivers/scsi/iscsi_tcp.c > > > +++ b/drivers/scsi/iscsi_tcp.c > > > @@ -264,6 +264,9 @@ static int iscsi_sw_tcp_xmit_segment(struct > > > iscsi_tcp_conn *tcp_conn, > > > unsigned int copied = 0; > > > int r = 0; > > > > > > + if (!sk) > > > + return -ENOTCONN; > > > + > > > while (!iscsi_tcp_segment_done(tcp_conn, segment, 0, r)) { > > > struct scatterlist *sg; > > > unsigned int offset, copy; > > > > > > > If the socket can be closed right before iscsi_sw_tcp_xmit_segment() > > is called, can it be called in the middle of sending segments? (In > > which case the check would have to be in the while loop.) > I think the important point is: is this an actual observed bug or just > a theoretical problem? > The reason for asking is this call is controlled directly by the > ISCSI_UEVENT_DESTROY_CONN event sent by the iscsi daemon. Obviously if > the daemon goes haywire and doesn't shut down the connection before > sending the destroy event, we may get the crash, but I would be > inclined to say fix the daemon. > James We have repproduced this bug several times . It`s a good idea that sending ISCSI_UEVENT_STOP_CONN event first. But there is another choice , adding "iscsi_suspend_tx" int the front of "destroy" , for not increasing dependence between kernel and daemon. Yangbin -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org Visit this group at https://groups.google.com/group/open-iscsi. To view this discussion on the web visit https://groups.google.com/d/msgid/open-iscsi/201907111542202002207%40zte.com.cn. For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-07-11 7:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-10 7:30 [PATCH] Check sk before sendpage Yang Bin
[not found] ` <1562743809-31133-1-git-send-email-yang.bin18-Th6q7B73Y6EnDS1+zs4M5A@public.gmane.org>
2019-07-10 17:47 ` Lee Duncan
2019-07-10 17:47 ` Lee Duncan
2019-07-10 18:52 ` James Bottomley
[not found] ` <1562784731.3213.98.camel-tEXmvtCZX7AybS5Ee8rs3A@public.gmane.org>
2019-07-11 7:42 ` yang.bin18-Th6q7B73Y6EnDS1+zs4M5A
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.