From: David Howells <dhowells@redhat.com>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: dhowells@redhat.com, linux-afs@lists.infradead.org,
linux-kernel@vger.kernel.org,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Kees Cook <keescook@chromium.org>
Subject: Re: [PATCH][next] afs: Use array3_size() helper in afs_extract_to_buf()
Date: Tue, 16 Jun 2020 02:09:07 +0100 [thread overview]
Message-ID: <761787.1592269747@warthog.procyon.org.uk> (raw)
In-Reply-To: <20200615232751.GA22366@embeddedor>
Gustavo A. R. Silva <gustavoars@kernel.org> wrote:
> Use array3_size() helper instead of the open-coded version in
> afs_extract_to_buf(). These sorts of multiplication factors need
> to be wrapped in array3_size().
For afs_deliver_cb_callback(), this adds redundant checking, as does the one
on the kmalloc() on the preceding line:
call->buffer = kmalloc(array3_size(call->count, 3, 4),
GFP_KERNEL);
if (!call->buffer)
return -ENOMEM;
because directly above them is a range check:
if (call->count > AFSCBMAX)
return afs_protocol_error(call, afs_eproto_cb_fid_count);
limiting the array size to 50.
Further, note that it's *not* a 3D array. 3 * 4 is the element size and is
constant. I've written it that way as the block is 3 XDR units, but the block
size is actually 12 bytes.
The one in the kmalloc() should also not be using array3_size() for the same
reason.
David
prev parent reply other threads:[~2020-06-16 1:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-15 23:27 [PATCH][next] afs: Use array3_size() helper in afs_extract_to_buf() Gustavo A. R. Silva
2020-06-16 1:09 ` David Howells [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=761787.1592269747@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=gustavo@embeddedor.com \
--cc=gustavoars@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-afs@lists.infradead.org \
--cc=linux-kernel@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