From: Dan Carpenter <dan.carpenter@oracle.com>
To: Yu Zhao <yuzhao@google.com>
Cc: Linux-MM <linux-mm@kvack.org>
Subject: Re: [bug report] mm: multi-gen LRU: debugfs interface
Date: Tue, 23 Aug 2022 09:39:32 +0300 [thread overview]
Message-ID: <20220823063932.GD2719@kadam> (raw)
In-Reply-To: <CAOUHufZoysZ+Yv4P6=L0jTtkb655ThOELJ5KLOu4veOgdq4dfQ@mail.gmail.com>
On Mon, Aug 22, 2022 at 10:49:20AM -0600, Yu Zhao wrote:
> On Mon, Aug 22, 2022 at 5:22 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > Hello Yu Zhao,
> >
> > The patch e02f70ddcaca: "mm: multi-gen LRU: debugfs interface" from
> > Aug 15, 2022, leads to the following Smatch static checker warning:
> >
> > mm/vmscan.c:5706 lru_gen_seq_write()
> > warn: uncapped user index 'cur[end]'
> >
> > mm/vmscan.c
> > 5654 static ssize_t lru_gen_seq_write(struct file *file, const char __user *src,
> > 5655 size_t len, loff_t *pos)
>
> ...
>
> > 5704 n = sscanf(cur, "%c %u %u %lu %n %u %n %lu %n", &cmd, &memcg_id, &nid,
> > 5705 &seq, &end, &swappiness, &end, &opt, &end);
> > --> 5706 if (n < 4 || cur[end]) {
> > ^^^^^^^^
> > The static checker is correct that "end" comes from the user and it
> > can be any unsigned int.
>
> Thanks. No, %n is not a conversion -- sscanf() stores the number of
> chars consumed so far upon seeing it.
>
> What would be the recommended way to suppress this warning, if there is one?
Ah. Sorry!
I didn't realize %n can be in the middle like that so Smatch only looks
for %n at the end of the string. Easily fixed in Smatch.
regards,
dan carpenter
prev parent reply other threads:[~2022-08-23 6:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-22 11:21 [bug report] mm: multi-gen LRU: debugfs interface Dan Carpenter
2022-08-22 16:49 ` Yu Zhao
2022-08-23 6:39 ` 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=20220823063932.GD2719@kadam \
--to=dan.carpenter@oracle.com \
--cc=linux-mm@kvack.org \
--cc=yuzhao@google.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).