From: Dan Carpenter <dan.carpenter@oracle.com>
To: almaz.alexandrovich@paragon-software.com
Cc: ntfs3@lists.linux.dev
Subject: [bug report] fs/ntfs3: Rework file operations
Date: Thu, 2 Sep 2021 13:25:28 +0300 [thread overview]
Message-ID: <20210902102528.GA7209@kili> (raw)
Hello Konstantin Komarov,
This is a semi-automatic email about new static checker warnings.
The patch 78ab59fee07f: "fs/ntfs3: Rework file operations" from Aug
31, 2021, leads to the following Smatch complaint:
fs/ntfs3/frecord.c:2887 ni_remove_name_undo()
error: we previously assumed 'de2' could be null (see line 2876)
fs/ntfs3/frecord.c
2871 bool ni_remove_name_undo(struct ntfs_inode *dir_ni, struct ntfs_inode *ni,
2872 struct NTFS_DE *de, struct NTFS_DE *de2, int undo_step)
2873 {
2874 struct ntfs_sb_info *sbi = ni->mi.sbi;
2875 struct ATTRIB *attr;
2876 u16 de_key_size = de2 ? le16_to_cpu(de2->key_size) : 0;
^^^
This assumes "de2" can be NULL.
2877
2878 switch (undo_step) {
2879 case 4:
2880 if (ni_insert_resident(ni, de_key_size, ATTR_NAME, NULL, 0,
2881 &attr, NULL, NULL)) {
2882 return false;
2883 }
2884 memcpy(Add2Ptr(attr, SIZEOF_RESIDENT), de2 + 1, de_key_size);
2885
2886 mi_get_ref(&ni->mi, &de2->ref);
^^^^^^^^^
Unchecked dereference.
2887 de2->size = cpu_to_le16(ALIGN(de_key_size, 8) +
2888 sizeof(struct NTFS_DE));
2889 de2->flags = 0;
2890 de2->res = 0;
2891
2892 if (indx_insert_entry(&dir_ni->dir, dir_ni, de2, sbi, NULL,
2893 1)) {
2894 return false;
2895 }
2896 fallthrough;
2897
2898 case 2:
2899 de_key_size = le16_to_cpu(de->key_size);
No need for this assignment.
2900
2901 if (ni_insert_resident(ni, de_key_size, ATTR_NAME, NULL, 0,
2902 &attr, NULL, NULL)) {
2903 return false;
2904 }
2905
2906 memcpy(Add2Ptr(attr, SIZEOF_RESIDENT), de + 1, de_key_size);
2907 mi_get_ref(&ni->mi, &de->ref);
2908
2909 if (indx_insert_entry(&dir_ni->dir, dir_ni, de, sbi, NULL, 1)) {
2910 return false;
2911 }
2912 }
regards,
dan carpenter
reply other threads:[~2021-09-02 10:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210902102528.GA7209@kili \
--to=dan.carpenter@oracle.com \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=ntfs3@lists.linux.dev \
/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).