All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Ichikawa <masami.ichikawa@miraclelinux.com>
To: Dan Carpenter <error27@gmail.com>
Cc: cip-dev <cip-dev@lists.cip-project.org>,
	 Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Subject: Re: New CVE entries this week
Date: Thu, 19 Jan 2023 22:56:22 +0900	[thread overview]
Message-ID: <CAODzB9rHqzUTn1dmaP1j1SsiYh5UcJ5AKSjVL7PpxYE5ifRVCA@mail.gmail.com> (raw)
In-Reply-To: <Y8j2dnYDZnw+DcEw@kili>

Hi.

On Thu, Jan 19, 2023 at 4:51 PM Dan Carpenter <error27@gmail.com> wrote:
>
> On Thu, Dec 15, 2022 at 12:25:18PM +0900, Masami Ichikawa wrote:
> > CVE-2022-4378: Linux kernel stack-based buffer overflow in __do_proc_dointvec
> >
> > CVSS v3 score is not provided
> >
> > A stack overflow bug was found in __do_proc_dointvec() which missed
> > checking on user input.
> > This bug affected all stable kernels. It seems as if 4.4 is affected too.
> >
> > Fixed status
> > mainline: [bce9332220bd677d83b19d21502776ad555a0e73,
> > e6cfaf34be9fcd1a8285a294e18986bfc41a409c]
>
> One thing that we used to do at Oracle was a bi-weekly meeting where we
> would go through these lists and try to be a bit proactive about
> preventing future bugs.  For me I'm trying to use Smatch for static
> analysis.
>
> There are some bugs which Smatch can't identify like race conditions or
> if there is an issue with the spec.  But for a lot of bugs can be
> prevented.  So it's often an issue of 1) There isn't a Smatch check for
> that.  2) The Smatch check exists but isn't working correctly.  3) The
> Smatch check prints a warning but there are too many warning for that
> check so I can't go through them all.
>
> First of all, why wasn't *size marked as user controlled?  It turned out
> that it comes from iov_iter_count() and that wasn't marked as user
> controlled.  Fix that:
> https://github.com/error27/smatch/commit/70ee7aa1ae8cc07767096e16fa2de68a62507a3e
>
> Once that was fixed, it turned out that I did have an unpublished check
> which printed a warning.
> kernel/sysctl.c:358 proc_get_long() warn: check 'tmp[len]' for negative offsets 'len' = s32min.  extra = 's32min-21'
>
> But it turns out that warning was because of a bug.  The check was
> asking can "*size" be user controlled and what is the minimum possible
> value negative, but it should have been asking if the minimum user
> controled value is negative.
>
> Fixing the check to as about user controlled values silenced the
> warning.  The issue with that is:
>
>         left -= proc_skip_spaces(&p);
>
> Subtractions are very hard to handle correctly because you need to keep
> track of the relationships between multiple variables.  Smatch
> deliberately assumes that this subtraction cannot underflow.  Otherwise
> you end up with too many false positives...
>
> I've been sitting on this check for the past ten years without
> publishing it.  May as well attach it now and also the results.  I don't
> know why the check has __per_cpu_offset stuff or why it ignores ntohl().
> I should probably delete that and see what happens.  Going through the
> results, a bunch of false positives are cause by subtraction (which is
> complicated).  Or because Smatch doesn't understand about
> array_index_nospec() (I should fix that).
>
> Anyway, even though I wasn't able to generate a warning for this bug,
> it was still useful to have the discussion and improve Smatch.
>

Thank you for the information about Smatch. It's really helpful. I
think it is important to learn from reported bugs then prevent future
bugs as you did.
I'll try to use Smatch.

> regards,
> dan carpenter
>

Regards,
-- 
Masami Ichikawa
Cybertrust Japan Co., Ltd.

Email :masami.ichikawa@cybertrust.co.jp
          :masami.ichikawa@miraclelinux.com


  reply	other threads:[~2023-01-19 13:57 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-15  3:25 New CVE entries this week Masami Ichikawa
2023-01-19  7:51 ` Dan Carpenter
2023-01-19 13:56   ` Masami Ichikawa [this message]
2023-01-19 15:24     ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2023-09-13 22:34 Masami Ichikawa
2023-09-06 23:22 Masami Ichikawa
2023-08-30 23:08 Masami Ichikawa
2023-08-23 22:47 Masami Ichikawa
2023-08-16 23:04 Masami Ichikawa
2023-08-10  0:04 Masami Ichikawa
2023-08-02 23:38 Masami Ichikawa
2023-07-26 23:15 Masami Ichikawa
2023-07-20  0:25 Masami Ichikawa
2023-07-12 23:24 Masami Ichikawa
2023-07-06  0:35 Masami Ichikawa
2023-06-29  0:26 Masami Ichikawa
2023-06-21 23:07 Masami Ichikawa
2023-06-14 22:43 Masami Ichikawa
2023-06-07 22:19 Masami Ichikawa
2023-05-31 23:54 Masami Ichikawa
2023-05-24 22:50 Masami Ichikawa
2023-05-17 23:10 Masami Ichikawa
2023-05-10 23:47 Masami Ichikawa
2023-05-03 22:53 Masami Ichikawa
2023-04-26 23:10 Masami Ichikawa
2023-04-19 23:49 Masami Ichikawa
2023-04-13  0:19 Masami Ichikawa
2023-04-06  0:19 Masami Ichikawa
2023-03-29 23:52 Masami Ichikawa
2023-03-22 23:10 Masami Ichikawa
2023-03-16  0:03 Masami Ichikawa
2023-03-08 23:53 Masami Ichikawa
2023-03-02  1:40 Masami Ichikawa
2023-02-22 23:33 Masami Ichikawa
2023-02-15 23:19 Masami Ichikawa
2023-02-08 23:44 Masami Ichikawa
2023-02-02  0:55 Masami Ichikawa
2023-01-25 23:59 Masami Ichikawa
2023-01-19  0:14 Masami Ichikawa
2023-03-03 14:08 ` Dan Carpenter
2023-01-12  0:21 Masami Ichikawa
2023-01-05  1:04 Masami Ichikawa
2022-12-29  0:00 Masami Ichikawa
2022-12-21 22:58 Masami Ichikawa
2023-02-01  8:09 ` Dan Carpenter
2023-02-01 13:59   ` Dan Carpenter
2022-12-07 23:25 Masami Ichikawa
2022-11-30 23:26 Masami Ichikawa
2022-11-24  1:24 Masami Ichikawa
2022-11-17  0:11 Masami Ichikawa
2022-11-09 23:02 Masami Ichikawa
2022-11-02 23:20 Masami Ichikawa
2022-10-27  0:55 Masami Ichikawa
2022-10-20  0:48 Masami Ichikawa
2022-10-12 23:43 Masami Ichikawa
2022-10-05 23:53 Masami Ichikawa
2022-09-28 23:42 Masami Ichikawa
2022-09-22  0:06 Masami Ichikawa
2022-09-14 23:53 Masami Ichikawa
2022-09-07 23:07 Masami Ichikawa
2022-09-01  0:12 Masami Ichikawa
2022-08-25  1:18 Masami Ichikawa
2022-08-17 23:23 Masami Ichikawa
2022-08-10 23:20 Masami Ichikawa
2022-08-04  0:29 Masami Ichikawa
2022-07-27 23:45 Masami Ichikawa
2022-07-21  0:01 Masami Ichikawa
2022-07-14  0:54 Masami Ichikawa
2022-07-06 23:21 Masami Ichikawa
2022-06-29 22:50 Masami Ichikawa
2022-06-22 23:47 Masami Ichikawa
2022-06-15 23:44 Masami Ichikawa
2022-06-08 23:44 Masami Ichikawa
2022-06-02  0:14 Masami Ichikawa
2022-05-25 23:12 Masami Ichikawa
2022-05-19  0:21 Masami Ichikawa
2022-05-12  0:15 Masami Ichikawa
2022-05-04 22:53 Masami Ichikawa
2022-04-27 23:03 Masami Ichikawa
2022-04-21  0:00 Masami Ichikawa
2022-04-14  0:10 Masami Ichikawa
2022-04-06 23:50 Masami Ichikawa
2022-03-30 23:22 Masami Ichikawa
2022-03-24  0:42 Masami Ichikawa
2022-03-16 23:34 Masami Ichikawa
2022-03-09 23:55 Masami Ichikawa
2022-03-02 23:50 Masami Ichikawa
2022-02-23 23:41 Masami Ichikawa
2022-02-17  0:09 Masami Ichikawa
2022-02-10  1:35 Masami Ichikawa
2022-02-03  0:28 Masami Ichikawa
2022-01-05 23:31 Masami Ichikawa
2021-10-28  0:05 Masami Ichikawa

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=CAODzB9rHqzUTn1dmaP1j1SsiYh5UcJ5AKSjVL7PpxYE5ifRVCA@mail.gmail.com \
    --to=masami.ichikawa@miraclelinux.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=error27@gmail.com \
    --cc=harshit.m.mogalapalli@oracle.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 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.