* [bug report] [PATCH] sys_sync_file_range()
@ 2018-03-14 19:36 Dan Carpenter
2018-03-14 19:56 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2018-03-14 19:36 UTC (permalink / raw)
To: akpm; +Cc: linux-fsdevel
Hello Andrew Morton,
The patch f79e2abb9bd4: "[PATCH] sys_sync_file_range()" from Mar 31,
2006, leads to the following static checker warning:
fs/sync.c:298 ksys_sync_file_range()
warn: signed overflow undefined. 'offset + nbytes < offset'
fs/sync.c
279 int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
280 unsigned int flags)
281 {
282 int ret;
283 struct fd f;
284 struct address_space *mapping;
285 loff_t endbyte; /* inclusive */
286 umode_t i_mode;
287
288 ret = -EINVAL;
289 if (flags & ~VALID_FLAGS)
290 goto out;
291
292 endbyte = offset + nbytes;
293
294 if ((s64)offset < 0)
295 goto out;
296 if ((s64)endbyte < 0)
297 goto out;
298 if (endbyte < offset)
^^^^^^^^^^^^^^^^
This is undefined but I think it works with the kernel build options?
299 goto out;
300
301 if (sizeof(pgoff_t) == 4) {
302 if (offset >= (0x100000000ULL << PAGE_SHIFT)) {
303 /*
304 * The range starts outside a 32 bit machine's
305 * pagecache addressing capabilities. Let it "succeed"
306 */
307 ret = 0;
308 goto out;
309 }
310 if (endbyte >= (0x100000000ULL << PAGE_SHIFT)) {
311 /*
312 * Out to EOF
313 */
314 nbytes = 0;
315 }
316 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [bug report] [PATCH] sys_sync_file_range()
2018-03-14 19:36 [bug report] [PATCH] sys_sync_file_range() Dan Carpenter
@ 2018-03-14 19:56 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2018-03-14 19:56 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-fsdevel
On Wed, 14 Mar 2018 22:36:21 +0300 Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Hello Andrew Morton,
>
> The patch f79e2abb9bd4: "[PATCH] sys_sync_file_range()" from Mar 31,
> 2006, leads to the following static checker warning:
>
> fs/sync.c:298 ksys_sync_file_range()
> warn: signed overflow undefined. 'offset + nbytes < offset'
>
> fs/sync.c
> 279 int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
> 280 unsigned int flags)
> 281 {
> 282 int ret;
> 283 struct fd f;
> 284 struct address_space *mapping;
> 285 loff_t endbyte; /* inclusive */
> 286 umode_t i_mode;
> 287
> 288 ret = -EINVAL;
> 289 if (flags & ~VALID_FLAGS)
> 290 goto out;
> 291
> 292 endbyte = offset + nbytes;
> 293
> 294 if ((s64)offset < 0)
> 295 goto out;
> 296 if ((s64)endbyte < 0)
> 297 goto out;
> 298 if (endbyte < offset)
> ^^^^^^^^^^^^^^^^
> This is undefined but I think it works with the kernel build options?
>
Yup. -fno-strict-overflow. Please see Dmitry's explanation at
https://bugzilla.kernel.org/show_bug.cgi?id=199099.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-03-14 19:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-14 19:36 [bug report] [PATCH] sys_sync_file_range() Dan Carpenter
2018-03-14 19:56 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).