From: Jiri Slaby <jirislaby@kernel.org>
To: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Cc: agordeev@linux.ibm.com, borntraeger@linux.ibm.com,
dsterba@suse.com, elder@linaro.org, gor@linux.ibm.com,
gregkh@linuxfoundation.org, hca@linux.ibm.com,
jcmvbkbc@gmail.com, linux-kernel@vger.kernel.org,
linux-s390@vger.kernel.org, stable@vger.kernel.org,
svens@linux.ibm.com
Subject: Re: [PATCH v3] char: tty3270: fix a missing check on list iterator
Date: Tue, 29 Mar 2022 08:07:16 +0200 [thread overview]
Message-ID: <02741f84-ee8f-2f4c-e2eb-5f74183f60f8@kernel.org> (raw)
In-Reply-To: <20220328102732.28910-1-xiam0nd.tong@gmail.com>
On 28. 03. 22, 12:27, Xiaomeng Tong wrote:
> On Mon, 28 Mar 2022 12:09:59 +0200, Jiri Slaby wrote:
>> On 28. 03. 22, 11:35, Xiaomeng Tong wrote:
>>> The bug is here:
>>> if (s->len != flen) {
>>>
>>> The list iterator 's' will point to a bogus position containing
>>> HEAD if the list is empty or no element is found.
>>
>> Could you also explain how that can happen?
>>
>
> When list_for_each_entry_* do not early exits (if the list is empty
> or no break/goto/return hit inside the loop), it will set pos ('s' here)
> with a bogus pointer that point to a invalid struct computed based
> on &HEAD using container_of.
>
> #define list_for_each_entry(pos, head, member) \
> for (pos = list_first_entry(head, typeof(*pos), member); \
> !list_entry_is_head(pos, head, member); \
> pos = list_next_entry(pos, member))
No, I didn't mean what happens on that site on the code level. I think
everyone understands that. Instead, I meant: what circumstances lead to
this _situation_ in reality?
thanks,
--
js
suse labs
next prev parent reply other threads:[~2022-03-29 6:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 9:35 [PATCH v3] char: tty3270: fix a missing check on list iterator Xiaomeng Tong
2022-03-28 10:09 ` Jiri Slaby
2022-03-28 10:26 ` Sven Schnelle
2022-03-28 10:27 ` Xiaomeng Tong
2022-03-29 6:07 ` Jiri Slaby [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-03-28 12:10 Xiaomeng Tong
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=02741f84-ee8f-2f4c-e2eb-5f74183f60f8@kernel.org \
--to=jirislaby@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=dsterba@suse.com \
--cc=elder@linaro.org \
--cc=gor@linux.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=hca@linux.ibm.com \
--cc=jcmvbkbc@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=svens@linux.ibm.com \
--cc=xiam0nd.tong@gmail.com \
/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