All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <chaitanyak@nvidia.com>
To: Haimin Zhang <tcs.kernel@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>
Subject: Re: [PATCH] block-map: add __GFP_ZERO flag for alloc_page in function bio_copy_kern
Date: Wed, 16 Feb 2022 09:12:21 +0000	[thread overview]
Message-ID: <47002290-3064-7de1-25e6-0716a89b94c0@nvidia.com> (raw)
In-Reply-To: <20220216084038.15635-1-tcs.kernel@gmail.com>

On 2/16/22 00:40, Haimin Zhang wrote:
> Add __GFP_ZERO flag for alloc_page in function bio_copy_kern to initialize
> the buffer of a bio.
> 
> Signed-off-by: Haimin Zhang <tcs.kernel@gmail.com>
> ---
> This can cause a kernel-info-leak problem.
> 0. This problem occurred in function scsi_ioctl. If the parameter cmd is SCSI_IOCTL_SEND_COMMAND, the function scsi_ioctl will call sg_scsi_ioctl to further process.
> 1. In function sg_scsi_ioctl, it creates a scsi request and calls blk_rq_map_kern to map kernel data to a request.
> 3. blq_rq_map_kern calls bio_copy_kern to request a bio.
> 4. bio_copy_kern calls alloc_page to request the buffer of a bio. In the case of reading, it wouldn't fill anything into the buffer.

but blk_rq_map_kern() does accept gfp_mask for exactly this same case
and that is passed on to the bio_copy_kern() unless I'm wrong here,
so you need to pass the __GFP_ZERO flag in the step 3 above
(sg_scsi_ioctl) and not force zzeroed allocation the generic API..

-ck



  reply	other threads:[~2022-02-16  9:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-16  8:40 [PATCH] block-map: add __GFP_ZERO flag for alloc_page in function bio_copy_kern Haimin Zhang
2022-02-16  9:12 ` Chaitanya Kulkarni [this message]
     [not found]   ` <56F42AA8-8554-455C-8734-0716AB4FB377@gmail.com>
2022-02-16  9:42     ` Chaitanya Kulkarni
2022-02-16 17:05   ` Christoph Hellwig
2022-02-16 17:12     ` Chaitanya Kulkarni
2022-02-16 17:04 ` Christoph Hellwig
2022-02-17  2:42 ` Jens Axboe

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=47002290-3064-7de1-25e6-0716a89b94c0@nvidia.com \
    --to=chaitanyak@nvidia.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=tcs.kernel@gmail.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 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.