From: Tejun Heo <tj@kernel.org>
To: Eric Biggers <ebiggers3@gmail.com>
Cc: linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com,
Mark Lord <mlord@pobox.com>, Eric Biggers <ebiggers@google.com>
Subject: Re: [PATCH] libata: fix length validation of ATAPI-relayed SCSI commands
Date: Mon, 12 Feb 2018 09:20:10 -0800 [thread overview]
Message-ID: <20180212172010.GB695913@devbig577.frc2.facebook.com> (raw)
In-Reply-To: <20180204043056.16466-1-ebiggers3@gmail.com>
On Sat, Feb 03, 2018 at 08:30:56PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> syzkaller reported a crash in ata_bmdma_fill_sg() when writing to
> /dev/sg1. The immediate cause was that the ATA command's scatterlist
> was not DMA-mapped, which causes 'pi - 1' to underflow, resulting in a
> write to 'qc->ap->bmdma_prd[0xffffffff]'.
>
> Strangely though, the flag ATA_QCFLAG_DMAMAP was set in qc->flags. The
> root cause is that when __ata_scsi_queuecmd() is preparing to relay a
> SCSI command to an ATAPI device, it doesn't correctly validate the CDB
> length before copying it into the 16-byte buffer 'cdb' in 'struct
> ata_queued_cmd'. Namely, it validates the fixed CDB length expected
> based on the SCSI opcode but not the actual CDB length, which can be
> larger due to the use of the SG_NEXT_CMD_LEN ioctl. Since 'flags' is
> the next member in ata_queued_cmd, a buffer overflow corrupts it.
>
> Fix it by requiring that the actual CDB length be <= 16 (ATAPI_CDB_LEN).
Applied to libata/for-4.16-fixes.
Thanks.
--
tejun
prev parent reply other threads:[~2018-02-12 17:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <001a114aa95cfa4339055cd4e8e0@google.com>
2018-02-04 4:30 ` [PATCH] libata: fix length validation of ATAPI-relayed SCSI commands Eric Biggers
2018-02-12 17:20 ` Tejun Heo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180212172010.GB695913@devbig577.frc2.facebook.com \
--to=tj@kernel.org \
--cc=ebiggers3@gmail.com \
--cc=ebiggers@google.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mlord@pobox.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox