]> git.baikalelectronics.ru Git - kernel.git/commit
scsi: sr: Do not leak information in ioctl
authorTom Rix <trix@redhat.com>
Mon, 11 Apr 2022 17:47:56 +0000 (13:47 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Apr 2022 12:38:58 +0000 (14:38 +0200)
commit1e69d7b6fab0acaea068c35bdda5973f792d7f41
treed473225464a40eee13a2c5608ba688ebcaec6dee
parenteeeeade24b18967c0dcca8416794fc1347c43da4
scsi: sr: Do not leak information in ioctl

[ Upstream commit 067aeaa6593ac1f3ab86c16d6e3b76ece15c6c50 ]

sr_ioctl.c uses this pattern:

  result = sr_do_ioctl(cd, &cgc);
  to-user = buffer[];
  kfree(buffer);
  return result;

Use of a buffer without checking leaks information. Check result and jump
over the use of buffer if there is an error.

  result = sr_do_ioctl(cd, &cgc);
  if (result)
    goto err;
  to-user = buffer[];
err:
  kfree(buffer);
  return result;

Additionally, initialize the buffer to zero.

This problem can be seen in the 2.4.0 kernel.

Link: https://lore.kernel.org/r/20220411174756.2418435-1-trix@redhat.com
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/scsi/sr_ioctl.c