5.15.80-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 176/181 wifi: wext: use flex array destination for memcpy()
In reply to Greg Kroah-HartmanFrom: Hawkins Jiawei <[email protected]>
commit e3e6e1d16a4cf7b63159ec71774e822194071954 upstream.
Syzkaller reports buffer overflow false positive as follows:
------------[ cut here ]------------ memcpy: detected field-spanning write (size 8) of single field "&compat_event->pointer" at net/wireless/wext-core.c:623 (size 4) WARNING: CPU: 0 PID: 3607 at net/wireless/wext-core.c:623 wireless_send_event+0xab5/0xca0 net/wireless/wext-core.c:623 Modules linked in: CPU: 1 PID: 3607 Comm: syz-executor659 Not tainted 6.0.0-rc6-next-20220921-syzkaller #0 [...] Call Trace: <TASK> ioctl_standard_call+0x155/0x1f0 net/wireless/wext-core.c:1022 wireless_process_ioctl+0xc8/0x4c0 net/wireless/wext-core.c:955 wext_ioctl_dispatch net/wireless/wext-core.c:988 [inline] wext_ioctl_dispatch net/wireless/wext-core.c:976 [inline] wext_handle_ioctl+0x26b/0x280 net/wireless/wext-core.c:1049 sock_ioctl+0x285/0x640 net/socket.c:1220 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:870 [inline] __se_sys_ioctl fs/ioctl.c:856 [inline] __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:856 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd [...] </TASK>
Wireless events will be sent on the appropriate channels in wireless_send_event(). Different wireless events may have different payload structure and size, so kernel uses **len** and **cmd** field in struct __compat_iw_event as wireless event common LCP part, uses **pointer** as a label to mark the position of remaining different part.
Yet the problem is that, **pointer** is a compat_caddr_t type, which may be smaller than the relative structure at the same position. So during wireless_send_event() tries to parse the wireless events payload, it may trigger the memcpy() run-time destination buffer bounds checking when the relative structure's data is copied to the position marked by **pointer**.
This patch solves it by introducing flexible-array field **ptr_bytes**, to mark the position of the wireless events remaining part next to LCP part. What's more, this patch also adds **ptr_len** variable in wireless_send_event() to improve its maintainability.
--- include/linux/wireless.h | 10 +++++++++- net/wireless/wext-core.c | 17 ++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-)
include/linux/wireless.h +9 -1
@@ -26,7 +26,15 @@ struct compat_iw_point {struct __compat_iw_event {__u16 len;/* Real length of this stuff */ __u16 cmd;/* Wireless IOCTL */ -compat_caddr_t pointer; + +union { +compat_caddr_t pointer; + +/* we need ptr_bytes to make memcpy() run-time destination +* buffer bounds checking happy, nothing special +*/ + DECLARE_FLEX_ARRAY(__u8, ptr_bytes); + }; };#define IW_EV_COMPAT_LCP_LEN offsetof(struct __compat_iw_event, pointer)#define IW_EV_COMPAT_POINT_OFF offsetof(struct compat_iw_point, length)
net/wireless/wext-core.c +10 -7
@@ -468,6 +468,7 @@ void wireless_send_event(struct net_devistruct __compat_iw_event *compat_event;struct compat_iw_point compat_wrqu;struct sk_buff *compskb; +int ptr_len;#endif /*
@@ -582,6 +583,9 @@ void wireless_send_event(struct net_devinlmsg_end (skb, nlh);#ifdef CONFIG_COMPAT hdr_len = compat_event_type_size[descr->header_type]; + +/* ptr_len is remaining size in event header apart from LCP */ + ptr_len = hdr_len -IW_EV_COMPAT_LCP_LEN ; event_len = hdr_len + extra_len; compskb =nlmsg_new (NLMSG_DEFAULT_SIZE ,GFP_ATOMIC );
@@ -612,16 +616,15 @@ void wireless_send_event(struct net_deviif (descr->header_type ==IW_HEADER_TYPE_POINT ) { compat_wrqu.length = wrqu->data.length; compat_wrqu.flags = wrqu->data.flags; -memcpy (&compat_event->pointer, - ((char *) &compat_wrqu) +IW_EV_COMPAT_POINT_OFF , - hdr_len -IW_EV_COMPAT_LCP_LEN ); +memcpy (compat_event->ptr_bytes, + ((char *)&compat_wrqu) +IW_EV_COMPAT_POINT_OFF , + ptr_len);if (extra_len) -memcpy (((char *) compat_event) + hdr_len, - extra, extra_len); +memcpy (&compat_event->ptr_bytes[ptr_len], + extra, extra_len); }else {/* extra_len must be zero, so no if (extra) needed */ -memcpy (&compat_event->pointer, wrqu, - hdr_len -IW_EV_COMPAT_LCP_LEN ); +memcpy (compat_event->ptr_bytes, wrqu, ptr_len); }nlmsg_end (compskb, nlh);
Greg Kroah-Hartman
maintainerPATCH 177/181 mm: fs: initialize fsdata passed to write_begin/write_end interface
In reply to Greg Kroah-HartmanFrom: Alexander Potapenko <[email protected]>
commit 1468c6f4558b1bcd92aa0400f2920f9dc7588402 upstream.
Functions implementing the a_ops->write_end() interface accept the void *fsdata parameter that is supposed to be initialized by the corresponding a_ops->write_begin() (which accepts void **fsdata).
However not all a_ops->write_begin() implementations initialize fsdata unconditionally, so it may get passed uninitialized to a_ops->write_end(), resulting in undefined behavior.
Fix this by initializing fsdata with NULL before the call to write_begin(), rather than doing so in all possible a_ops implementations.
This patch covers only the following cases found by running x86 KMSAN under syzkaller:
- generic_perform_write()
- cont_expand_zero() and generic_cont_expand_simple()
- page_symlink()
Other cases of passing uninitialized fsdata may persist in the codebase.
--- fs/buffer.c | 4 ++-- fs/namei.c | 2 +- mm/filemap.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/buffer.c +2 -2
@@ -2352,7 +2352,7 @@ int generic_cont_expand_simple(struct in {struct address_space *mapping = inode->i_mapping;struct page *page; -void *fsdata; +void *fsdata =NULL ;int err; err =inode_newsize_ok (inode, size);
@@ -2378,7 +2378,7 @@ static int cont_expand_zero(struct filestruct inode *inode = mapping->host;unsigned int blocksize =i_blocksize (inode);struct page *page; -void *fsdata; +void *fsdata =NULL ;pgoff_t index, curidx;loff_t curpos;unsigned zerofrom, offset, len;
fs/namei.c +1 -1
@@ -5013,7 +5013,7 @@ int __page_symlink(struct inode *inode, {struct address_space *mapping = inode->i_mapping;struct page *page; -void *fsdata; +void *fsdata =NULL ;int err;unsigned int flags =0 ;if (nofs)
mm/filemap.c +1 -1
@@ -3749,7 +3749,7 @@ ssize_t generic_perform_write(struct filunsigned long offset;/* Offset into pagecache page */ unsigned long bytes;/* Bytes to write to page */ size_t copied;/* Bytes copied from user */ -void *fsdata; +void *fsdata =NULL ; offset = (pos & (PAGE_SIZE -1 )); bytes = min_t(unsigned long, PAGE_SIZE - offset,
Greg Kroah-Hartman
maintainerPATCH 178/181 net/9p: use a dedicated spinlock for trans_fd
In reply to Greg Kroah-HartmanFrom: Dominique Martinet <[email protected]>
commit 296ab4a813841ba1d5f40b03190fd1bd8f25aab0 upstream.
Shamelessly copying the explanation from Tetsuo Handa's suggested patch[1] (slightly reworded):
syzbot is reporting inconsistent lock state in p9_req_put()[2], for p9_tag_remove() from p9_req_put() from IRQ context is using spin_lock_irqsave() on "struct p9_client"->lock but trans_fd (not from IRQ context) is using spin_lock().
Since the locks actually protect different things in client.c and in trans_fd.c, just replace trans_fd.c's lock by a new one specific to the transport (client.c's protect the idr for fid/tag allocations, while trans_fd.c's protects its own req list and request status field that acts as the transport's state machine)
--- net/9p/trans_fd.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-)
net/9p/trans_fd.c +25 -16
@@ -93,6 +93,7 @@ struct p9_poll_wait {* @mux_list: list link for mux to manage multiple connections (?) * @client: reference to client instance for this connection * @err: error state +* @req_lock: lock protecting req_list and requests statuses * @req_list: accounting for requests which have been sent * @unsent_req_list: accounting for requests that haven't been sent * @rreq: read request
@@ -116,6 +117,7 @@ struct p9_conn {struct list_head mux_list;struct p9_client *client;int err; +spinlock_t req_lock;struct list_head req_list;struct list_head unsent_req_list;struct p9_req_t *rreq;
@@ -191,10 +193,10 @@ static void p9_conn_cancel(struct p9_conp9_debug (P9_DEBUG_ERROR ,"mux %p err %d\n" , m, err); -spin_lock (&m->client->lock); +spin_lock (&m->req_lock);if (m->err) { -spin_unlock (&m->client->lock); +spin_unlock (&m->req_lock);return ; }
@@ -207,7 +209,7 @@ static void p9_conn_cancel(struct p9_conlist_move (&req->req_list, &cancel_list); } -spin_unlock (&m->client->lock); +spin_unlock (&m->req_lock);list_for_each_entry_safe (req, rtmp, &cancel_list, req_list) {p9_debug (P9_DEBUG_ERROR ,"call back req %p\n" , req);
@@ -362,7 +364,7 @@ static void p9_read_work(struct work_strif ((m->rreq) && (m->rc.offset == m->rc.capacity)) {p9_debug (P9_DEBUG_TRANS ,"got new packet\n" ); m->rreq->rc.size = m->rc.offset; -spin_lock (&m->client->lock); +spin_lock (&m->req_lock);if (m->rreq->status ==REQ_STATUS_SENT ) {list_del (&m->rreq->req_list);p9_client_cb (m->client, m->rreq,REQ_STATUS_RCVD );
@@ -371,14 +373,14 @@ static void p9_read_work(struct work_strp9_debug (P9_DEBUG_TRANS ,"Ignore replies associated with a cancelled request\n" ); }else { -spin_unlock (&m->client->lock); +spin_unlock (&m->req_lock);p9_debug (P9_DEBUG_ERROR ,"Request tag %d errored out while we were reading the reply\n" , m->rc.tag); err = -EIO ; goto error; } -spin_unlock (&m->client->lock); +spin_unlock (&m->req_lock); m->rc.sdata =NULL ; m->rc.offset =0 ; m->rc.capacity =0 ;
@@ -456,10 +458,10 @@ static void p9_write_work(struct work_st }if (!m->wsize) { -spin_lock (&m->client->lock); +spin_lock (&m->req_lock);if (list_empty (&m->unsent_req_list)) {clear_bit (Wworksched, &m->wsched); -spin_unlock (&m->client->lock); +spin_unlock (&m->req_lock);return ; }
@@ -474,7 +476,7 @@ static void p9_write_work(struct work_st m->wpos =0 ;p9_req_get (req); m->wreq = req; -spin_unlock (&m->client->lock); +spin_unlock (&m->req_lock); } p9_debug(P9_DEBUG_TRANS, "mux %p pos %d size %d\n",
@@ -591,6 +593,7 @@ static void p9_conn_create(struct p9_cliINIT_LIST_HEAD (&m->mux_list); m->client = client; +spin_lock_init (&m->req_lock);INIT_LIST_HEAD (&m->req_list);INIT_LIST_HEAD (&m->unsent_req_list);INIT_WORK (&m->rq, p9_read_work);
@@ -672,10 +675,10 @@ static int p9_fd_request(struct p9_clienif (m->err <0 )return m->err; -spin_lock (&client->lock); +spin_lock (&m->req_lock); req->status =REQ_STATUS_UNSENT ;list_add_tail (&req->req_list, &m->unsent_req_list); -spin_unlock (&client->lock); +spin_unlock (&m->req_lock);if (test_and_clear_bit (Wpending, &m->wsched)) n =EPOLLOUT ;
@@ -690,11 +693,13 @@ static int p9_fd_request(struct p9_clienstatic int p9_fd_cancel (struct p9_client *client,struct p9_req_t *req) { +struct p9_trans_fd *ts = client->trans; +struct p9_conn *m = &ts->conn;int ret =1 ;p9_debug (P9_DEBUG_TRANS ,"client %p req %p\n" , client, req); -spin_lock (&client->lock); +spin_lock (&m->req_lock);if (req->status ==REQ_STATUS_UNSENT ) {list_del (&req->req_list);
@@ -702,21 +707,24 @@ static int p9_fd_cancel(struct p9_clientp9_req_put (client, req); ret =0 ; } -spin_unlock (&client->lock); +spin_unlock (&m->req_lock);return ret; }static int p9_fd_cancelled (struct p9_client *client,struct p9_req_t *req) { +struct p9_trans_fd *ts = client->trans; +struct p9_conn *m = &ts->conn; +p9_debug (P9_DEBUG_TRANS ,"client %p req %p\n" , client, req); -spin_lock (&client->lock); +spin_lock (&m->req_lock);/* Ignore cancelled request if message has been received * before lock. */ if (req->status ==REQ_STATUS_RCVD ) { -spin_unlock (&client->lock); +spin_unlock (&m->req_lock);return 0 ; }
@@ -725,7 +733,8 @@ static int p9_fd_cancelled(struct p9_cli*/ list_del (&req->req_list); req->status =REQ_STATUS_FLSHD ; -spin_unlock (&client->lock); +spin_unlock (&m->req_lock); +p9_req_put (client, req);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 179/181 ntfs: fix use-after-free in ntfs_attr_find()
In reply to Greg Kroah-HartmanFrom: Hawkins Jiawei <[email protected]>
commit d85a1bec8e8d552ab13163ca1874dcd82f3d1550 upstream.
Patch series "ntfs: fix bugs about Attribute", v2.
This patchset fixes three bugs relative to Attribute in record:
Patch 1 adds a sanity check to ensure that, attrs_offset field in first mft record loading from disk is within bounds.
Patch 2 moves the ATTR_RECORD's bounds checking earlier, to avoid dereferencing ATTR_RECORD before checking this ATTR_RECORD is within bounds.
Patch 3 adds an overflow checking to avoid possible forever loop in ntfs_attr_find().
Without patch 1 and patch 2, the kernel triggersa KASAN use-after-free detection as reported by Syzkaller.
Although one of patch 1 or patch 2 can fix this, we still need both of them. Because patch 1 fixes the root cause, and patch 2 not only fixes the direct cause, but also fixes the potential out-of-bounds bug.
This patch (of 3):
Syzkaller reported use-after-free read as follows:
==================================================================
BUG: KASAN: use-after-free in ntfs_attr_find+0xc02/0xce0 fs/ntfs/attrib.c:597 Read of size 2 at addr ffff88807e352009 by task syz-executor153/3607
[...]
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:317 [inline]
print_report.cold+0x2ba/0x719 mm/kasan/report.c:433
kasan_report+0xb1/0x1e0 mm/kasan/report.c:495
ntfs_attr_find+0xc02/0xce0 fs/ntfs/attrib.c:597
ntfs_attr_lookup+0x1056/0x2070 fs/ntfs/attrib.c:1193
ntfs_read_inode_mount+0x89a/0x2580 fs/ntfs/inode.c:1845
ntfs_fill_super+0x1799/0x9320 fs/ntfs/super.c:2854
mount_bdev+0x34d/0x410 fs/super.c:1400
legacy_get_tree+0x105/0x220 fs/fs_context.c:610
vfs_get_tree+0x89/0x2f0 fs/super.c:1530
do_new_mount fs/namespace.c:3040 [inline]
path_mount+0x1326/0x1e20 fs/namespace.c:3370
do_mount fs/namespace.c:3383 [inline]
__do_sys_mount fs/namespace.c:3591 [inline]
__se_sys_mount fs/namespace.c:3568 [inline]
__x64_sys_mount+0x27f/0x300 fs/namespace.c:3568
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
[...]
</TASK>
The buggy address belongs to the physical page:
page:ffffea0001f8d400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7e350
head:ffffea0001f8d400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888011842140
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88807e351f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88807e351f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88807e352000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807e352080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807e352100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================Kernel will loads $MFT/$DATA's first mft record in ntfs_read_inode_mount().
Yet the problem is that after loading, kernel doesn't check whether attrs_offset field is a valid value.
To be more specific, if attrs_offset field is larger than bytes_allocated field, then it may trigger the out-of-bounds read bug(reported as use-after-free bug) in ntfs_attr_find(), when kernel tries to access the corresponding mft record's attribute.
This patch solves it by adding the sanity check between attrs_offset field and bytes_allocated field, after loading the first mft record.
--- fs/ntfs/inode.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/ntfs/inode.c +7 -0
@@ -1829,6 +1829,13 @@ int ntfs_read_inode_mount(struct inode * goto err_out; } +/* Sanity check offset to the first attribute */ +if (le16_to_cpu (m->attrs_offset) >=le32_to_cpu (m->bytes_allocated)) { +ntfs_error (sb,"Incorrect mft offset to the first attribute %u in superblock." , +le16_to_cpu (m->attrs_offset)); + goto err_out; + } +/* Need this to sanity check attribute list references to $MFT. */ vi->i_generation = ni->seq_no =le16_to_cpu (m->sequence_number);
Greg Kroah-Hartman
maintainerPATCH 180/181 ntfs: fix out-of-bounds read in ntfs_attr_find()
In reply to Greg Kroah-HartmanFrom: Hawkins Jiawei <[email protected]>
commit 36a4d82dddbbd421d2b8e79e1cab68c8126d5075 upstream.
Kernel iterates over ATTR_RECORDs in mft record in ntfs_attr_find(). To ensure access on these ATTR_RECORDs are within bounds, kernel will do some checking during iteration.
The problem is that during checking whether ATTR_RECORD's name is within bounds, kernel will dereferences the ATTR_RECORD name_offset field, before checking this ATTR_RECORD strcture is within bounds. This problem may result out-of-bounds read in ntfs_attr_find(), reported by Syzkaller:
==================================================================
BUG: KASAN: use-after-free in ntfs_attr_find+0xc02/0xce0 fs/ntfs/attrib.c:597 Read of size 2 at addr ffff88807e352009 by task syz-executor153/3607
[...]
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
print_address_description mm/kasan/report.c:317 [inline]
print_report.cold+0x2ba/0x719 mm/kasan/report.c:433
kasan_report+0xb1/0x1e0 mm/kasan/report.c:495
ntfs_attr_find+0xc02/0xce0 fs/ntfs/attrib.c:597
ntfs_attr_lookup+0x1056/0x2070 fs/ntfs/attrib.c:1193
ntfs_read_inode_mount+0x89a/0x2580 fs/ntfs/inode.c:1845
ntfs_fill_super+0x1799/0x9320 fs/ntfs/super.c:2854
mount_bdev+0x34d/0x410 fs/super.c:1400
legacy_get_tree+0x105/0x220 fs/fs_context.c:610
vfs_get_tree+0x89/0x2f0 fs/super.c:1530
do_new_mount fs/namespace.c:3040 [inline]
path_mount+0x1326/0x1e20 fs/namespace.c:3370
do_mount fs/namespace.c:3383 [inline]
__do_sys_mount fs/namespace.c:3591 [inline]
__se_sys_mount fs/namespace.c:3568 [inline]
__x64_sys_mount+0x27f/0x300 fs/namespace.c:3568
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
[...]
</TASK>
The buggy address belongs to the physical page:
page:ffffea0001f8d400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x7e350
head:ffffea0001f8d400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888011842140
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff88807e351f00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff88807e351f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88807e352000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff88807e352080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff88807e352100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================This patch solves it by moving the ATTR_RECORD strcture's bounds checking earlier, then checking whether ATTR_RECORD's name is within bounds. What's more, this patch also add some comments to improve its maintainability.
--- fs/ntfs/attrib.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
fs/ntfs/attrib.c +16 -4
@@ -594,11 +594,23 @@ static int ntfs_attr_find(const ATTR_TYPfor (;; a = (ATTR_RECORD *)((u8 *)a +le32_to_cpu (a->length))) {u8 *mrec_end = (u8 *)ctx->mrec +le32_to_cpu (ctx->mrec->bytes_allocated); -u8 *name_end = (u8 *)a +le16_to_cpu (a->name_offset) + - a->name_length *sizeof (ntfschar); -if ((u8 *)a < (u8 *)ctx->mrec || (u8 *)a > mrec_end || - name_end > mrec_end) +u8 *name_end; + +/* check whether ATTR_RECORD wrap */ +if ((u8 *)a < (u8 *)ctx->mrec)break ; + +/* check whether Attribute Record Header is within bounds */ +if ((u8 *)a > mrec_end || + (u8 *)a +sizeof (ATTR_RECORD ) > mrec_end) +break ; + +/* check whether ATTR_RECORD's name is within bounds */ + name_end = (u8 *)a +le16_to_cpu (a->name_offset) + + a->name_length *sizeof (ntfschar); +if (name_end > mrec_end) +break ; + ctx->attr = a;if (unlikely (le32_to_cpu (a->type) >le32_to_cpu (type) || a->type ==AT_END ))
Greg Kroah-Hartman
maintainerPATCH 181/181 ntfs: check overflow when iterating ATTR_RECORDs
In reply to Greg Kroah-HartmanFrom: Hawkins Jiawei <[email protected]>
commit 63095f4f3af59322bea984a6ae44337439348fe0 upstream.
Kernel iterates over ATTR_RECORDs in mft record in ntfs_attr_find(). Because the ATTR_RECORDs are next to each other, kernel can get the next ATTR_RECORD from end address of current ATTR_RECORD, through current ATTR_RECORD length field.
The problem is that during iteration, when kernel calculates the end address of current ATTR_RECORD, kernel may trigger an integer overflow bug in executing a = (ATTR_RECORD*)((u8*)a + le32_to_cpu(a->length)). This may wrap, leading to a forever iteration on 32bit systems.
This patch solves it by adding some checks on calculating end address of current ATTR_RECORD during iteration.
--- fs/ntfs/attrib.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/ntfs/attrib.c +8 -0
@@ -617,6 +617,14 @@ static int ntfs_attr_find(const ATTR_TYPreturn -ENOENT ;if (unlikely (!a->length))break ; + +/* check whether ATTR_RECORD's length wrap */ +if ((u8 *)a +le32_to_cpu (a->length) < (u8 *)a) +break ; +/* check whether ATTR_RECORD's length is within bounds */ +if ((u8 *)a +le32_to_cpu (a->length) > mrec_end) +break ; +if (a->type != type)continue ;/*
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.80 release. There are 181 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.80-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
All tests passing for Tegra ...
Test results for stable-v5.15:
11 builds: 11 pass, 0 fail
28 boots: 28 pass, 0 fail
114 tests: 114 pass, 0 failLinux version: 5.15.80-rc1-g1ac88d934860
Boards tested: tegra124-jetson-tk1, tegra186-p2771-0000,
tegra194-p2972-0000, tegra194-p3509-0000+p3668-0000,
tegra20-ventana, tegra210-p2371-2180,
tegra210-p3450-0000, tegra30-cardhu-a04Jon
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.80 release. There are 181 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
Build reference: v5.15.79-182-g1ac88d934860 Compiler version: arm-linux-gnueabi-gcc (GCC) 11.3.0 Assembler version: GNU assembler (GNU Binutils) 2.39
Building arm:allmodconfig ... failed
--------------
Error log:drivers/rtc/rtc-cmos.c:1299:13: error: 'rtc_wake_setup' defined but not used [-Werror=unused-function]
1299 | static void rtc_wake_setup(struct device *dev)
Oddly enough caused by "rtc: cmos: fix build on non-ACPI platforms".
Guenter
Quoted 8 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.80 release. There are 181 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
Build results:
total: 159 pass: 154 fail: 5
Failed builds:
arm:allmodconfig
mips:allmodconfig
powerpc:allmodconfig
powerpc:ppc32_allmodconfig
sparc64:allmodconfig
Qemu test results:
total: 489 pass: 489 fail: 0
As already reported, the error is:
Error log:drivers/rtc/rtc-cmos.c:1299:13: error: 'rtc_wake_setup' defined but not used [-Werror=unused-function]
1299 | static void rtc_wake_setup(struct device *dev)
Guenter
Quoted 5 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.80 release. There are 181 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Successfully cross-compiled for arm64 (bcm2711_defconfig, GCC 10.2.0) and powerpc (ps3_defconfig, GCC 12.2.0).
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.80 release. There are 181 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.80-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
Built and booted successfully on RISC-V RV64 (HiFive Unmatched).
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.80 release. There are 181 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.15.80-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-5.15.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro's test farm.
No regressions on arm64, arm, x86_64, and i386.
NOTE:
As other reported arm: allmodconfig build failed due to
rtc: cmos: fix build on non-ACPI platforms
[ Upstream commit db4e955ae333567dea02822624106c0b96a2f84f ]
Build error:drivers/rtc/rtc-cmos.c:1299:13: error: 'rtc_wake_setup' defined but not used [-Werror=unused-function]
1299 | static void rtc_wake_setup(struct device *dev)
| ^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
## Build
* kernel: 5.15.80-rc1
* git: https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc
* git branch: linux-5.15.y
* git commit: 1ac88d934860fc481995accb27454e4fe906d4f6
* git describe: v5.15.79-182-g1ac88d934860
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-5.15.y/build/v5.15.79-182-g1ac88d934860
## Test Regressions (compared to v5.15.79)
## Metric Regressions (compared to v5.15.79)
## Test Fixes (compared to v5.15.79)
## Metric Fixes (compared to v5.15.79)
## Test result summary
total: 145866, pass: 126226, fail: 3335, skip: 15985, xfail: 320
## Build Summary
* arc: 5 total, 5 passed, 0 failed
* arm: 147 total, 146 passed, 1 failed
* arm64: 45 total, 43 passed, 2 failed
* i386: 35 total, 33 passed, 2 failed
* mips: 27 total, 27 passed, 0 failed
* parisc: 6 total, 6 passed, 0 failed
* powerpc: 30 total, 30 passed, 0 failed
* riscv: 10 total, 10 passed, 0 failed
* s390: 12 total, 12 passed, 0 failed
* sh: 12 total, 12 passed, 0 failed
* sparc: 6 total, 6 passed, 0 failed
* x86_64: 38 total, 36 passed, 2 failed
## Test suites summary
* boot
* fwts
* igt-gpu-tools
* kselftest-android
* kselftest-arm64
* kselftest-arm64/arm64.btitest.bti_c_func
* kselftest-arm64/arm64.btitest.bti_j_func
* kselftest-arm64/arm64.btitest.bti_jc_func
* kselftest-arm64/arm64.btitest.bti_none_func
* kselftest-arm64/arm64.btitest.nohint_func
* kselftest-arm64/arm64.btitest.paciasp_func
* kselftest-arm64/arm64.nobtitest.bti_c_func
* kselftest-arm64/arm64.nobtitest.bti_j_func
* kselftest-arm64/arm64.nobtitest.bti_jc_func
* kselftest-arm64/arm64.nobtitest.bti_none_func
* kselftest-arm64/arm64.nobtitest.nohint_func
* kselftest-arm64/arm64.nobtitest.paciasp_func
* kselftest-breakpoints
* kselftest-drivers-dma-buf
* kselftest-efivarfs
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-kvm
* kselftest-lib
* kselftest-net
* kselftest-net-forwarding
* kselftest-net-mptcp
* kselftest-netfilter
* kselftest-openat2
* kselftest-seccomp
* kselftest-timens
* kunit
* kvm-unit-tests
* libgpiod
* libhugetlbfs
* log-parser-boot
* log-parser-test
* ltp-cap_bounds
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-filecaps
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simpl
* ltp-fs_perms_simple
* ltp-fsx
* ltp-hugetlb
* ltp-io
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-open-posix-tests
* ltp-pty
* ltp-sched
* ltp-securebits
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* network-basic-tests
* perf
* perf/Zstd-perf.data-compression
* rcutorture
* v4l2-compliance
* vdso
--
Linaro LKFT
https://lkft.linaro.org
Hi Greg,
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 5.15.80 release. There are 181 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 25 Nov 2022 08:45:20 +0000. Anything received after that time might be too late.
Build test (gcc version 12.2.1 20221016):
mips: 62 configs -> 1 failure
arm: 99 configs -> 1 failure
arm64: 3 configs -> no failurex86_64: 4 configs -> no failure
alpha allmodconfig -> no failure
csky allmodconfig -> no failure
powerpc allmodconfig -> 1 failure
riscv allmodconfig -> no failure
s390 allmodconfig -> no failure
xtensa allmodconfig -> no failure
Note:
As reported by others, arm mips and powerpc allmodconfig fails with the error:drivers/rtc/rtc-cmos.c:1299:13: error: 'rtc_wake_setup' defined but not used [-Werror=unused-function]
1299 | static void rtc_wake_setup(struct device *dev)
|
Boot test:x86_64: Booted on my test laptop. No regression.x86_64: Booted on qemu. No regression. [1]
arm64: Booted on rpi4b (4GB model). No regression. [2]
mips: Booted on ci20 board. No regression. [3]
[1]. https://openqa.qa.codethink.co.uk/tests/2209
[2]. https://openqa.qa.codethink.co.uk/tests/2213
[3]. https://openqa.qa.codethink.co.uk/tests/2215
Signature · 2 lines
Regards Sudip