public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Colin King (gmail)" <colin.i.king@gmail.com>
To: Anand Jain <anand.jain@oracle.com>, David Sterba <dsterba@suse.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: re: btrfs: add btrfs_read_policy_to_enum helper and refactor read, policy store
Date: Thu, 19 Dec 2024 15:40:32 +0000	[thread overview]
Message-ID: <cd8135e4-2de5-48d7-a7de-65afb201b3fe@gmail.com> (raw)

Hi,

Static analysis on linux-next today has found a potential buffer 
overflow in fs/btrfs/sysfs.c in function btrfs_read_policy_to_enum()

The strcpy to string param has no length checks on str and hence if str 
is longer than param a buffer overflow on the stack occurs. This can 
potentially occur when a user writes a long string to the btrfs sysfs 
file read_policy via btrfs_read_policy_store()

int btrfs_read_policy_to_enum(const char *str, s64 *value)
{
         char param[32] = {'\0'};
         char *__maybe_unused value_str;
         int index;
         bool found = false;

         if (!str || strlen(str) == 0)
                 return 0;

         strcpy(param, str);   /* issue here */

	....
}

Colin

             reply	other threads:[~2024-12-19 15:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-19 15:40 Colin King (gmail) [this message]
2024-12-19 18:59 ` btrfs: add btrfs_read_policy_to_enum helper and refactor read, policy store Anand Jain
2024-12-19 19:08   ` Colin King (gmail)
2024-12-19 19:30     ` Anand Jain

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=cd8135e4-2de5-48d7-a7de-65afb201b3fe@gmail.com \
    --to=colin.i.king@gmail.com \
    --cc=anand.jain@oracle.com \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox