From: Arnd Bergmann <arnd@kernel.org>
To: Jan Kara <jack@suse.com>
Cc: Arnd Bergmann <arnd@arndb.de>, linux-kernel@vger.kernel.org
Subject: [PATCH] udf: shut up pointer cast warning
Date: Tue, 9 Nov 2021 13:36:08 +0100 [thread overview]
Message-ID: <20211109123621.52474-1-arnd@kernel.org> (raw)
From: Arnd Bergmann <arnd@arndb.de>
On 32-bit architectures, the workaround of storing the directory position
in the private_data pointer causes a warning, as loff_t does not fit in
a pointer:
fs/udf/dir.c: In function 'udf_readdir':
fs/udf/dir.c:78:25: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
78 | if (ctx->pos != (uintptr_t)file->private_data) {
| ^
fs/udf/dir.c:211:30: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
211 | file->private_data = (void *)(uintptr_t)ctx->pos;
| ^
An extra cast to uintptr_t shuts up the warning. This is of course
still broken if the position is ever beyond the first 2^32 bytes (4GB).
I have not found a clear information on whether directories this
large are allowed on UDF, but it seems unlikely.
Fixes: 39a464de961f ("udf: Fix crash after seekdir")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
fs/udf/dir.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index 8ae501d27eff..5aaa82be420a 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -75,7 +75,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
* identifying beginning of dir entry (names are under user control),
* we need to scan the directory from the beginning.
*/
- if (ctx->pos != (loff_t)file->private_data) {
+ if (ctx->pos != (uintptr_t)file->private_data) {
emit_pos = nf_pos;
nf_pos = 0;
}
@@ -208,7 +208,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx)
out:
/* Store position where we've ended */
- file->private_data = (void *)ctx->pos;
+ file->private_data = (void *)(uintptr_t)ctx->pos;
if (fibh.sbh != fibh.ebh)
brelse(fibh.ebh);
brelse(fibh.sbh);
--
2.29.2
next reply other threads:[~2021-11-09 12:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-09 12:36 Arnd Bergmann [this message]
2021-11-10 11:00 ` [PATCH] udf: shut up pointer cast warning Jan Kara
2021-11-10 11:22 ` Arnd Bergmann
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=20211109123621.52474-1-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=arnd@arndb.de \
--cc=jack@suse.com \
--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 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.