Richard writes: "This pull request contains fixes for UBIFS: - A wrong UBIFS assertion in mount code - Fix for a NULL pointer deref in mount code - Revert of a bad fix for xattrs" * tag 'upstream-4.19-rc4' of git://git.infradead.org/linux-ubifs: Revert "ubifs: xattr: Don't operate on deleted inodes" ubifs: drop false positive assertion ubifs: Check for name being NULL while mounting
Unified · Split
| @@ -1912,7 +1912,9 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data) · 1911 unmodified lines | ||
| 1912 | 1912 | mutex_unlock(&c->bu_mutex); |
| 1913 | 1913 | } |
| 1914 | 1914 | |
| 1915 | − ubifs_assert(c, c->lst.taken_empty_lebs > 0); | |
| 1915 | + if (!c->need_recovery) | |
| 1916 | + ubifs_assert(c, c->lst.taken_empty_lebs > 0); | |
| 1917 | + | |
| 1916 | 1918 | return 0; |
| 1917 | 1919 | } |
| 1918 | 1920 | |
| @@ -1954,6 +1956,9 @@ static struct ubi_volume_desc *open_ubi(const char *name, int mode) · 35 unmodified lines | ||
| 1954 | 1956 | int dev, vol; |
| 1955 | 1957 | char *endptr; |
| 1956 | 1958 | |
| 1959 | + if (!name || !*name) | |
| 1960 | + return ERR_PTR(-EINVAL); | |
| 1961 | + | |
| 1957 | 1962 | /* First, try to open using the device node path method */ |
| 1958 | 1963 | ubi = ubi_open_volume_path(name, mode); |
| 1959 | 1964 | if (!IS_ERR(ubi)) |
| @@ -152,12 +152,6 @@ static int create_xattr(struct ubifs_info *c, struct inode *host, · 151 unmodified lines | ||
| 152 | 152 | ui->data_len = size; |
| 153 | 153 | |
| 154 | 154 | mutex_lock(&host_ui->ui_mutex); |
| 155 | − | |
| 156 | − if (!host->i_nlink) { | |
| 157 | − err = -ENOENT; | |
| 158 | − goto out_noent; | |
| 159 | − } | |
| 160 | − | |
| 161 | 155 | host->i_ctime = current_time(host); |
| 162 | 156 | host_ui->xattr_cnt += 1; |
| 163 | 157 | host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm)); |
| @@ -190,7 +184,6 @@ out_cancel: · 26 unmodified lines | ||
| 190 | 184 | host_ui->xattr_size -= CALC_XATTR_BYTES(size); |
| 191 | 185 | host_ui->xattr_names -= fname_len(nm); |
| 192 | 186 | host_ui->flags &= ~UBIFS_CRYPT_FL; |
| 193 | −out_noent: | |
| 194 | 187 | mutex_unlock(&host_ui->ui_mutex); |
| 195 | 188 | out_free: |
| 196 | 189 | make_bad_inode(inode); |
| @@ -242,12 +235,6 @@ static int change_xattr(struct ubifs_info *c, struct inode *host, · 45 unmodified lines | ||
| 242 | 235 | mutex_unlock(&ui->ui_mutex); |
| 243 | 236 | |
| 244 | 237 | mutex_lock(&host_ui->ui_mutex); |
| 245 | − | |
| 246 | − if (!host->i_nlink) { | |
| 247 | − err = -ENOENT; | |
| 248 | − goto out_noent; | |
| 249 | − } | |
| 250 | − | |
| 251 | 238 | host->i_ctime = current_time(host); |
| 252 | 239 | host_ui->xattr_size -= CALC_XATTR_BYTES(old_size); |
| 253 | 240 | host_ui->xattr_size += CALC_XATTR_BYTES(size); |
| @@ -269,7 +256,6 @@ static int change_xattr(struct ubifs_info *c, struct inode *host, · 15 unmodified lines | ||
| 269 | 256 | out_cancel: |
| 270 | 257 | host_ui->xattr_size -= CALC_XATTR_BYTES(size); |
| 271 | 258 | host_ui->xattr_size += CALC_XATTR_BYTES(old_size); |
| 272 | −out_noent: | |
| 273 | 259 | mutex_unlock(&host_ui->ui_mutex); |
| 274 | 260 | make_bad_inode(inode); |
| 275 | 261 | out_free: |
| @@ -496,12 +482,6 @@ static int remove_xattr(struct ubifs_info *c, struct inode *host, · 220 unmodified lines | ||
| 496 | 482 | return err; |
| 497 | 483 | |
| 498 | 484 | mutex_lock(&host_ui->ui_mutex); |
| 499 | − | |
| 500 | − if (!host->i_nlink) { | |
| 501 | − err = -ENOENT; | |
| 502 | − goto out_noent; | |
| 503 | − } | |
| 504 | − | |
| 505 | 485 | host->i_ctime = current_time(host); |
| 506 | 486 | host_ui->xattr_cnt -= 1; |
| 507 | 487 | host_ui->xattr_size -= CALC_DENT_SIZE(fname_len(nm)); |
| @@ -521,7 +501,6 @@ out_cancel: · 13 unmodified lines | ||
| 521 | 501 | host_ui->xattr_size += CALC_DENT_SIZE(fname_len(nm)); |
| 522 | 502 | host_ui->xattr_size += CALC_XATTR_BYTES(ui->data_len); |
| 523 | 503 | host_ui->xattr_names += fname_len(nm); |
| 524 | −out_noent: | |
| 525 | 504 | mutex_unlock(&host_ui->ui_mutex); |
| 526 | 505 | ubifs_release_budget(c, &req); |
| 527 | 506 | make_bad_inode(inode); |
| @@ -561,9 +540,6 @@ static int ubifs_xattr_remove(struct inode *host, const char *name) · 33 unmodified lines | ||
| 561 | 540 | |
| 562 | 541 | ubifs_assert(c, inode_is_locked(host)); |
| 563 | 542 | |
| 564 | − if (!host->i_nlink) | |
| 565 | − return -ENOENT; | |
| 566 | − | |
| 567 | 543 | if (fname_len(&nm) > UBIFS_MAX_NLEN) |
| 568 | 544 | return -ENAMETOOLONG; |
| 569 | 545 | |