From: Dan Carpenter <dan.carpenter@oracle.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: overlayfs <linux-unionfs@vger.kernel.org>
Subject: Re: [bug report] ovl: make sure that real fid is 32bit aligned in memory
Date: Tue, 5 May 2020 21:08:25 +0300 [thread overview]
Message-ID: <20200505180825.GG1992@kadam> (raw)
In-Reply-To: <CAOQ4uxj0F9V=FOUANKSATR2E==BoLr6OJMqsJe5QCbOLNR0k0A@mail.gmail.com>
On Tue, May 05, 2020 at 07:13:20PM +0300, Amir Goldstein wrote:
> > The patch cbe7fba8edfc: "ovl: make sure that real fid is 32bit
> > aligned in memory" from Nov 15, 2019, leads to the following static
> > checker warning:
> >
> > fs/overlayfs/export.c:791 ovl_fid_to_fh()
> > warn: check that subtract can't underflow
> >
> > fs/overlayfs/export.c
> > 775 static struct ovl_fh *ovl_fid_to_fh(struct fid *fid, int buflen, int fh_type)
> > 776 {
> > 777 struct ovl_fh *fh;
> > 778
> > 779 /* If on-wire inner fid is aligned - nothing to do */
> > 780 if (fh_type == OVL_FILEID_V1)
> > 781 return (struct ovl_fh *)fid;
> > 782
> > 783 if (fh_type != OVL_FILEID_V0)
> > 784 return ERR_PTR(-EINVAL);
> > 785
> > 786 fh = kzalloc(buflen, GFP_KERNEL);
>
> Doesn't Smatch warn on possible kmalloc(0)?
> That can't be good. Right?
No, no. Allocating zero bytes is a useful feature.
size = 0;
buf = kzalloc(size, GFP_KERNEL);
for (i = 0; i < size; i++)
buf[i] = 42;
memcpy(dest, buf, size);
copy_to_user(p, dest, size);
That all works. Neat, huh?
regards,
dan carpenter
next prev parent reply other threads:[~2020-05-05 18:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 13:50 [bug report] ovl: make sure that real fid is 32bit aligned in memory Dan Carpenter
2020-05-05 16:13 ` Amir Goldstein
2020-05-05 18:07 ` [PATCH] ovl: potential crash in ovl_fid_to_fh() Dan Carpenter
2020-05-05 18:15 ` Amir Goldstein
2020-05-05 18:33 ` [PATCH v2] " Dan Carpenter
2020-05-05 18:08 ` Dan Carpenter [this message]
-- strict thread matches above, loose matches on Subject: below --
2019-12-13 10:37 [bug report] ovl: make sure that real fid is 32bit aligned in memory Dan Carpenter
2019-12-13 12:22 ` Miklos Szeredi
2019-12-13 12:58 ` Dan Carpenter
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=20200505180825.GG1992@kadam \
--to=dan.carpenter@oracle.com \
--cc=amir73il@gmail.com \
--cc=linux-unionfs@vger.kernel.org \
/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