Re: sg_io HARDENED_USERCOPY_PAGESPAN trace
From: Dave Jones
Date: Fri Dec 30 2016 - 10:01:58 EST
On Fri, Dec 30, 2016 at 05:37:12AM -0800, Christoph Hellwig wrote:
> On Thu, Dec 29, 2016 at 10:43:51AM -0500, Dave Jones wrote:
> > On Wed, Dec 28, 2016 at 11:56:42PM -0800, Christoph Hellwig wrote:
> > > On Wed, Dec 28, 2016 at 04:40:16PM -0500, Dave Jones wrote:
> > > > sg_io+0x113/0x470
> > >
> > > Can you resolve that to a source line using a gdb?
> >
> > It's the copy_from_user in an inlined copy of blk_fill_sghdr_rq.
>
> That must be this line right at the beginning of blk_fill_sghdr_rq
>
> if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
> return -EFAULT;
>
> We're copying the SCSI CDB from the userspace pointer inside the hdr
> we copied earlier into the request.
>
> req->cmd is set to req->__cmd which is a u8 array with 16 members in
> struct request by default, but if hdr->cmd_len is bigger than BLK_MAX_CDB
> (16) we do a separate allocation for it in the caller:
>
> if (hdr->cmd_len > BLK_MAX_CDB) {
> rq->cmd = kzalloc(hdr->cmd_len, GFP_KERNEL);
> if (!rq->cmd)
> goto out_put_request;
> }
>
> so I'm not really sure what the problem here could be.
I threw this debug printk into the pagespan code to see what exactly
it was complaining about..
ptr:ffff88042614cff8 end:ffff88042614d003 n:c
so it was copying 12 bytes that spanned two pages.
>From my reading of the config option help text, this thing is
complaining that wasn't allocated with __GFP_COMP maybe ?
Dave