<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/scsi/sg.c, branch linux-4.4.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-05-20T06:11:42Z</updated>
<entry>
<title>scsi: sg: add sg_remove_request in sg_write</title>
<updated>2020-05-20T06:11:42Z</updated>
<author>
<name>Wu Bo</name>
</author>
<published>2020-04-14T02:13:28Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=af9a86cc9f1acfc380e96a9beb59462f32a4b6c4'/>
<id>urn:sha1:af9a86cc9f1acfc380e96a9beb59462f32a4b6c4</id>
<content type='text'>
commit 83c6f2390040f188cc25b270b4befeb5628c1aee upstream.

If the __copy_from_user function failed we need to call sg_remove_request
in sg_write.

Link: https://lore.kernel.org/r/610618d9-e983-fd56-ed0f-639428343af7@huawei.com
Acked-by: Douglas Gilbert &lt;dgilbert@interlog.com&gt;
Signed-off-by: Wu Bo &lt;wubo40@huawei.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
[groeck: Backport to v5.4.y and older kernels]
Signed-off-by: Guenter Roeck &lt;linux@roeck-us.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>scsi: sg: add sg_remove_request in sg_common_write</title>
<updated>2020-04-24T05:57:21Z</updated>
<author>
<name>Li Bin</name>
</author>
<published>2020-04-13T11:29:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=82e798f39ee8eed9f38689127125565ddeb82f83'/>
<id>urn:sha1:82e798f39ee8eed9f38689127125565ddeb82f83</id>
<content type='text'>
commit 849f8583e955dbe3a1806e03ecacd5e71cce0a08 upstream.

If the dxfer_len is greater than 256M then the request is invalid and we
need to call sg_remove_request in sg_common_write.

Link: https://lore.kernel.org/r/1586777361-17339-1-git-send-email-huawei.libin@huawei.com
Fixes: f930c7043663 ("scsi: sg: only check for dxfer_len greater than 256M")
Acked-by: Douglas Gilbert &lt;dgilbert@interlog.com&gt;
Signed-off-by: Li Bin &lt;huawei.libin@huawei.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>scsi: sg: fix minor memory leak in error path</title>
<updated>2018-08-06T14:24:42Z</updated>
<author>
<name>Tony Battersby</name>
</author>
<published>2018-07-12T20:30:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6ff21107ba21e59a3831825a55e882afc8a1b3f1'/>
<id>urn:sha1:6ff21107ba21e59a3831825a55e882afc8a1b3f1</id>
<content type='text'>
commit c170e5a8d222537e98aa8d4fddb667ff7a2ee114 upstream.

Fix a minor memory leak when there is an error opening a /dev/sg device.

Fixes: cc833acbee9d ("sg: O_EXCL and other lock handling")
Cc: &lt;stable@vger.kernel.org&gt;
Reviewed-by: Ewan D. Milne &lt;emilne@redhat.com&gt;
Signed-off-by: Tony Battersby &lt;tonyb@cybernetics.com&gt;
Reviewed-by: Bart Van Assche &lt;bart.vanassche@wdc.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>scsi: sg: mitigate read/write abuse</title>
<updated>2018-07-11T14:03:48Z</updated>
<author>
<name>Jann Horn</name>
</author>
<published>2018-06-25T14:25:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9a737329c7c4a341009b7398164db8fa8e5358f0'/>
<id>urn:sha1:9a737329c7c4a341009b7398164db8fa8e5358f0</id>
<content type='text'>
commit 26b5b874aff5659a7e26e5b1997e3df2c41fa7fd upstream.

As Al Viro noted in commit 128394eff343 ("sg_write()/bsg_write() is not fit
to be called under KERNEL_DS"), sg improperly accesses userspace memory
outside the provided buffer, permitting kernel memory corruption via
splice().  But it doesn't just do it on -&gt;write(), also on -&gt;read().

As a band-aid, make sure that the -&gt;read() and -&gt;write() handlers can not
be called in weird contexts (kernel context or credentials different from
file opener), like for ib_safe_file_access().

If someone needs to use these interfaces from different security contexts,
a new interface should be written that goes through the -&gt;ioctl() handler.

I've mostly copypasted ib_safe_file_access() over as sg_safe_file_access()
because I couldn't find a good common header - please tell me if you know a
better way.

[mkp: s/_safe_/_check_/]

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Jann Horn &lt;jannh@google.com&gt;
Acked-by: Douglas Gilbert &lt;dgilbert@interlog.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>scsi: sg: allocate with __GFP_ZERO in sg_build_indirect()</title>
<updated>2018-05-26T06:49:00Z</updated>
<author>
<name>Alexander Potapenko</name>
</author>
<published>2018-05-18T14:23:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=93314640426ddb6af618d0802e622f6fa771792c'/>
<id>urn:sha1:93314640426ddb6af618d0802e622f6fa771792c</id>
<content type='text'>
commit a45b599ad808c3c982fdcdc12b0b8611c2f92824 upstream.

This shall help avoid copying uninitialized memory to the userspace when
calling ioctl(fd, SG_IO) with an empty command.

Reported-by: syzbot+7d26fc1eea198488deab@syzkaller.appspotmail.com
Cc: stable@vger.kernel.org
Signed-off-by: Alexander Potapenko &lt;glider@google.com&gt;
Acked-by: Douglas Gilbert &lt;dgilbert@interlog.com&gt;
Reviewed-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>scsi: sg: don't return bogus Sg_requests</title>
<updated>2018-03-31T16:12:32Z</updated>
<author>
<name>Johannes Thumshirn</name>
</author>
<published>2017-05-10T07:53:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cf7a1cf58580521e17ce882d3bb04308ccd6b04a'/>
<id>urn:sha1:cf7a1cf58580521e17ce882d3bb04308ccd6b04a</id>
<content type='text'>
commit 48ae8484e9fc324b4968d33c585e54bc98e44d61 upstream.

If the list search in sg_get_rq_mark() fails to find a valid request, we
return a bogus element. This then can later lead to a GPF in
sg_remove_scat().

So don't return bogus Sg_requests in sg_get_rq_mark() but NULL in case
the list search doesn't find a valid request.

Signed-off-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Reported-by: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Cc: Hannes Reinecke &lt;hare@suse.de&gt;
Cc: Christoph Hellwig &lt;hch@lst.de&gt;
Cc: Doug Gilbert &lt;dgilbert@interlog.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.de&gt;
Acked-by: Doug Gilbert &lt;dgilbert@interlog.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Cc: Tony Battersby &lt;tonyb@cybernetics.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>scsi: sg: only check for dxfer_len greater than 256M</title>
<updated>2018-03-22T08:23:32Z</updated>
<author>
<name>Johannes Thumshirn</name>
</author>
<published>2017-07-27T07:11:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=036c4bdd66b72b45e43e0815294598c6b580c72a'/>
<id>urn:sha1:036c4bdd66b72b45e43e0815294598c6b580c72a</id>
<content type='text'>
commit f930c7043663188429cd9b254e9d761edfc101ce upstream.

Don't make any assumptions on the sg_io_hdr_t::dxfer_direction or the
sg_io_hdr_t::dxferp in order to determine if it is a valid request. The
only way we can check for bad requests is by checking if the length
exceeds 256M.

Signed-off-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Fixes: 28676d869bbb (scsi: sg: check for valid direction before starting the request)
Reported-by: Jason L Tibbitts III &lt;tibbs@math.uh.edu&gt;
Tested-by: Jason L Tibbitts III &lt;tibbs@math.uh.edu&gt;
Suggested-by: Doug Gilbert &lt;dgilbert@interlog.com&gt;
Cc: Doug Gilbert &lt;dgilbert@interlog.com&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>scsi: sg: fix static checker warning in sg_is_valid_dxfer</title>
<updated>2018-03-22T08:23:32Z</updated>
<author>
<name>Johannes Thumshirn</name>
</author>
<published>2017-07-17T13:11:42Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=db259b6768cf52ae1c0c92b7fc6e093a28969d71'/>
<id>urn:sha1:db259b6768cf52ae1c0c92b7fc6e093a28969d71</id>
<content type='text'>
commit 14074aba4bcda3764c9a702b276308b89901d5b6 upstream.

dxfer_len is an unsigned int and we always assign a value &gt; 0 to it, so
it doesn't make any sense to check if it is &lt; 0. We can't really check
dxferp as well as we have both NULL and not NULL cases in the possible
call paths.

So just return true for SG_DXFER_FROM_DEV transfer in
sg_is_valid_dxfer().

Signed-off-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Reported-by: Colin Ian King &lt;colin.king@canonical.com&gt;
Reported-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Cc: Douglas Gilbert &lt;dgilbert@interlog.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>scsi: sg: fix SG_DXFER_FROM_DEV transfers</title>
<updated>2018-03-22T08:23:31Z</updated>
<author>
<name>Johannes Thumshirn</name>
</author>
<published>2017-07-07T08:56:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6d85835042a7f94b0ccc02d0103bd2000ebe25f6'/>
<id>urn:sha1:6d85835042a7f94b0ccc02d0103bd2000ebe25f6</id>
<content type='text'>
commit 68c59fcea1f2c6a54c62aa896cc623c1b5bc9b47 upstream.

SG_DXFER_FROM_DEV transfers do not necessarily have a dxferp as we set
it to NULL for the old sg_io read/write interface, but must have a
length bigger than 0. This fixes a regression introduced by commit
28676d869bbb ("scsi: sg: check for valid direction before starting the
request")

Signed-off-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Fixes: 28676d869bbb ("scsi: sg: check for valid direction before starting the request")
Reported-by: Chris Clayton &lt;chris2553@googlemail.com&gt;
Tested-by: Chris Clayton &lt;chris2553@googlemail.com&gt;
Cc: Douglas Gilbert &lt;dgilbert@interlog.com&gt;
Reviewed-by: Hannes Reinecke &lt;hare@suse.com&gt;
Tested-by: Chris Clayton &lt;chris2553@googlemail.com&gt;
Acked-by: Douglas Gilbert &lt;dgilbert@interlog.com&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Cc: Cristian Crinteanu &lt;crinteanu.cristian@gmail.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>scsi: sg: close race condition in sg_remove_sfp_usercontext()</title>
<updated>2018-03-22T08:23:26Z</updated>
<author>
<name>Hannes Reinecke</name>
</author>
<published>2017-04-07T07:34:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4a8e8e0af9a520a685e0ab2d489327d5220d7ce2'/>
<id>urn:sha1:4a8e8e0af9a520a685e0ab2d489327d5220d7ce2</id>
<content type='text'>
[ Upstream commit 97d27b0dd015e980ade63fda111fd1353276e28b ]

sg_remove_sfp_usercontext() is clearing any sg requests, but needs to
take 'rq_list_lock' when modifying the list.

Reported-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Hannes Reinecke &lt;hare@suse.com&gt;
Reviewed-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Tested-by: Johannes Thumshirn &lt;jthumshirn@suse.de&gt;
Reviewed-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Martin K. Petersen &lt;martin.petersen@oracle.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
