udf: Avoid using stale lengthOfImpUse
commitc1ad35dd05
upstream. udf_write_fi() uses lengthOfImpUse of the entry it is writing to. However this field has not yet been initialized so it either contains completely bogus value or value from last directory entry at that place. In either case this is wrong and can lead to filesystem corruption or kernel crashes. Reported-by: butt3rflyh4ck <butterflyhuangxx@gmail.com> CC: stable@vger.kernel.org Fixes:979a6e28dd
("udf: Get rid of 0-length arrays in struct fileIdentDesc") Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
3d9c1d3923
Коммит
9e951f2d85
|
@ -75,11 +75,11 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
|
||||||
|
|
||||||
if (fileident) {
|
if (fileident) {
|
||||||
if (adinicb || (offset + lfi < 0)) {
|
if (adinicb || (offset + lfi < 0)) {
|
||||||
memcpy(udf_get_fi_ident(sfi), fileident, lfi);
|
memcpy(sfi->impUse + liu, fileident, lfi);
|
||||||
} else if (offset >= 0) {
|
} else if (offset >= 0) {
|
||||||
memcpy(fibh->ebh->b_data + offset, fileident, lfi);
|
memcpy(fibh->ebh->b_data + offset, fileident, lfi);
|
||||||
} else {
|
} else {
|
||||||
memcpy(udf_get_fi_ident(sfi), fileident, -offset);
|
memcpy(sfi->impUse + liu, fileident, -offset);
|
||||||
memcpy(fibh->ebh->b_data, fileident - offset,
|
memcpy(fibh->ebh->b_data, fileident - offset,
|
||||||
lfi + offset);
|
lfi + offset);
|
||||||
}
|
}
|
||||||
|
@ -88,11 +88,11 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
|
||||||
offset += lfi;
|
offset += lfi;
|
||||||
|
|
||||||
if (adinicb || (offset + padlen < 0)) {
|
if (adinicb || (offset + padlen < 0)) {
|
||||||
memset(udf_get_fi_ident(sfi) + lfi, 0x00, padlen);
|
memset(sfi->impUse + liu + lfi, 0x00, padlen);
|
||||||
} else if (offset >= 0) {
|
} else if (offset >= 0) {
|
||||||
memset(fibh->ebh->b_data + offset, 0x00, padlen);
|
memset(fibh->ebh->b_data + offset, 0x00, padlen);
|
||||||
} else {
|
} else {
|
||||||
memset(udf_get_fi_ident(sfi) + lfi, 0x00, -offset);
|
memset(sfi->impUse + liu + lfi, 0x00, -offset);
|
||||||
memset(fibh->ebh->b_data, 0x00, padlen + offset);
|
memset(fibh->ebh->b_data, 0x00, padlen + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче