linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Murad Sadigov <sdgvmrd@gmail.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: axis-fifo: fix integer overflow in write()
Date: Tue, 7 Oct 2025 16:05:53 +0300	[thread overview]
Message-ID: <aOUQMZQr3JwNTUYX@stanley.mountain> (raw)
In-Reply-To: <CAEuvNs2b-_Q=dazKjhUwJoZ5XUpjRsf-FrCOTR_j24T+EG-f=g@mail.gmail.com>

Hi Murad,

This can't happen because vfs_write() caps len at <= MAX_RW_COUNT.

Presumably this is your Linkedin page?
https://www.linkedin.com/in/mrdsdgv/?originalSubdomain=az

When you're doing the analysis on this sort of thing, it's nice to
have the Smatch cross function db built.  I hacked up the vfs_write()
information a bit so it says that len can't be more than 1G when
actually it's capped at 2G.  I did that so that count + len wouldn't
trigger an integer overflow warning.  Those are prevented in
rw_verify_area().

$ smdb axis_fifo_write
file | caller | function | type | parameter | key | value |
     fs/read_write.c |            vfs_write | (struct file_operations)->write |           INTERNAL | -1 |                 | long(*)(struct file*, char*, ulong, llong*)
     fs/read_write.c |            vfs_write | (struct file_operations)->write |           BIT_INFO |  0 |       f->f_mode | 0x40002,0xffffffff
     fs/read_write.c |            vfs_write | (struct file_operations)->write |          USER_DATA |  1 |             buf | 0-u64max[c]
     fs/read_write.c |            vfs_write | (struct file_operations)->write |          USER_DATA |  2 |             len | 0-1000000000
     fs/read_write.c |            vfs_write | (struct file_operations)->write |          USER_DATA |  3 |            *off | 0-1000000000
     fs/read_write.c |            vfs_write | (struct file_operations)->write |           USER_PTR |  3 |             off | 
     fs/read_write.c |            vfs_write | (struct file_operations)->write |        PARAM_VALUE |  0 |               f | 4096-9223372036854775807
     fs/read_write.c |            vfs_write | (struct file_operations)->write |        PARAM_VALUE |  0 |         f->f_op | 4096-ptr_max
     fs/read_write.c |            vfs_write | (struct file_operations)->write |        PARAM_VALUE |  0 |  f->f_op->write | 1-u64max
     fs/read_write.c |            vfs_write | (struct file_operations)->write |        PARAM_VALUE |  2 |             len | 0-1000000000,2147479552
     fs/read_write.c |            vfs_write | (struct file_operations)->write |          FUZZY_MAX |  2 |             len | 2147479552
     fs/read_write.c |            vfs_write | (struct file_operations)->write |        PARAM_VALUE |  3 |            *off | 0-1000000000
     fs/read_write.c |            vfs_write | (struct file_operations)->write |        PARAM_VALUE |  3 |             off | 0,4096-ptr_max
     fs/read_write.c |            vfs_write | (struct file_operations)->write |          CONTAINER |  0 |        -32-80+0 | $(-1)
     fs/read_write.c |            vfs_write | (struct file_operations)->write |        DATA_SOURCE |  0 |               f | $0
     fs/read_write.c |            vfs_write | (struct file_operations)->write |        DATA_SOURCE |  1 |             buf | $1
     fs/read_write.c |            vfs_write | (struct file_operations)->write |        DATA_SOURCE |  2 |             len | $2 [m]
     fs/read_write.c |            vfs_write | (struct file_operations)->write |        DATA_SOURCE |  3 |             off | $3
     fs/read_write.c |            vfs_write | (struct file_operations)->write |               2059 | -1 |                 | y
     fs/read_write.c |            vfs_write | (struct file_operations)->write |               2059 | -1 |                 | y
     fs/read_write.c |            vfs_write | (struct file_operations)->write |           BUF_SIZE |  3 |             off | (-1),8
$

regards,
dan carpenter


      parent reply	other threads:[~2025-10-07 13:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-07 11:58 [PATCH] staging: axis-fifo: fix integer overflow in write() Murad Sadigov
2025-10-07 12:18 ` Greg KH
2025-10-07 13:01   ` Greg KH
2025-10-07 13:05 ` Dan Carpenter [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=aOUQMZQr3JwNTUYX@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=sdgvmrd@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).