public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "D. Wythe" <alibuda@linux.alibaba.com>
To: Jeongjun Park <aha310510@gmail.com>
Cc: wintera@linux.ibm.com, gbayer@linux.ibm.com,
	guwen@linux.alibaba.com, jaka@linux.ibm.com,
	tonylu@linux.alibaba.com, wenjia@linux.ibm.com,
	davem@davemloft.net, dust.li@linux.alibaba.com,
	edumazet@google.com, kuba@kernel.org,
	linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org,
	netdev@vger.kernel.org, pabeni@redhat.com
Subject: Re: [PATCH net,v4] net/smc: prevent NULL pointer dereference in txopt_get
Date: Thu, 15 Aug 2024 14:43:55 +0800	[thread overview]
Message-ID: <6bcd6097-13dd-44fd-aa67-39a3bcc69af2@linux.alibaba.com> (raw)
In-Reply-To: <CAO9qdTGFGxgD_8RYQKTx9NJbwa0fiFziFyx2FJpnYk3ZvFbUmw@mail.gmail.com>



On 8/15/24 11:15 AM, Jeongjun Park wrote:
> 2024년 8월 15일 (목) 오전 11:51, D. Wythe <alibuda@linux.alibaba.com>님이 작성:
>>
>>
>> On 8/14/24 11:05 PM, Jeongjun Park wrote:
>>> Alexandra Winter wrote:
>>>> On 14.08.24 15:11, D. Wythe wrote:
>>>>>       struct smc_sock {                /* smc sock container */
>>>>> -    struct sock        sk;
>>>>> +    union {
>>>>> +        struct sock        sk;
>>>>> +        struct inet_sock    inet;
>>>>> +    };
>>>> I don't see a path where this breaks, but it looks risky to me.
>>>> Is an smc_sock always an inet_sock as well? Then can't you go with smc_sock->inet_sock->sk ?
>>>> Or only in the IPPROTO SMC case, and in the AF_SMC case it is not an inet_sock?
>>
>> There is no smc_sock->inet_sock->sk before. And this part here was to
>> make smc_sock also
>> be an inet_sock.
>>
>> For IPPROTO_SMC, smc_sock should be an inet_sock, but it is not before.
>> So, the initialization of certain fields
>> in smc_sock(for example, clcsk) will overwrite modifications made to the
>> inet_sock part in inet(6)_create.
>>
>> For AF_SMC,  the only problem is that  some space will be wasted. Since
>> AF_SMC don't care the inet_sock part.
>> However, make the use of sock by AF_SMC and IPPROTO_SMC separately for
>> the sake of avoid wasting some space
>> is a little bit extreme.
>>
> Okay. I think using inet_sock instead of sock is also a good idea, but I
> understand for now.
>
> However, for some reason this patch status has become Changes Requested
> , so we will split the patch into two and resend the v5 patch.
>
> Regards,
> Jeongjun Park

Why so hurry ? Are you rushing for some tasks ? Please be patient.

The discussion is still ongoing, and you need to wait for everyone's 
opinions,
at least you can wait a few days to see if there are any other opinions, 
even if you think
your patch is correct.

There is no need to send a new patch. If this patch is approved, the net 
maintainer will handle it,
regardless of whether it is a change request or not.

And your new patch, I don't want to go too far, as you are a newcomer, I 
appreciate your report and
willingness to fix this issue. But it's wrong.

If you want to split them, embedding inet_sock should be the first 
patch, which is a basic logical issue.

Then, don't send patches so frequently, I'm very worried that you will 
immediately send out v6 after
seeing it.

Best wishes,
D. Wythe

>>> hmm... then how about changing it to something like this?
>>>
>>> @@ -283,7 +283,7 @@ struct smc_connection {
>>>    };
>>>
>>>    struct smc_sock {                           /* smc sock container */
>>> -     struct sock             sk;
>>> +     struct inet_sock        inet;
>>>        struct socket           *clcsock;       /* internal tcp socket */
>>>        void                    (*clcsk_state_change)(struct sock *sk);
>>
>> Don't.
>>
>>>                                                /* original stat_change fct. */
>>> @@ -327,7 +327,7 @@ struct smc_sock {                         /* smc sock container */
>>>                                                 * */
>>>    };
>>>
>>> -#define smc_sk(ptr) container_of_const(ptr, struct smc_sock, sk)
>>> +#define smc_sk(ptr) container_of_const(ptr, struct smc_sock, inet.sk)
>>>
>>>    static inline void smc_init_saved_callbacks(struct smc_sock *smc)
>>>    {
>>>
>>> It is definitely not normal to make the first member of smc_sock as sock.
>>>
>>> Therefore, I think it would be appropriate to modify it to use inet_sock
>>> as the first member like other protocols (sctp, dccp) and access sk in a
>>> way like &smc->inet.sk.
>>>
>>> Although this fix would require more code changes, we tested the bug and
>>> confirmed that it was not triggered and the functionality was working
>>> normally.
>>>
>>> What do you think?
>>>
>>> Regards,
>>> Jeongjun Park


  reply	other threads:[~2024-08-15  6:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-14 10:49 [PATCH net,v4] net/smc: prevent NULL pointer dereference in txopt_get Jeongjun Park
2024-08-14 13:11 ` D. Wythe
2024-08-14 13:21   ` Alexandra Winter
2024-08-14 15:05     ` Jeongjun Park
2024-08-15  2:51       ` D. Wythe
2024-08-15  3:15         ` Jeongjun Park
2024-08-15  6:43           ` D. Wythe [this message]
2024-08-15  7:03             ` Alexandra Winter
2024-08-15  7:34               ` D. Wythe
2024-08-15  7:56                 ` Alexandra Winter
2024-08-15  8:09                   ` D. Wythe

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=6bcd6097-13dd-44fd-aa67-39a3bcc69af2@linux.alibaba.com \
    --to=alibuda@linux.alibaba.com \
    --cc=aha310510@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dust.li@linux.alibaba.com \
    --cc=edumazet@google.com \
    --cc=gbayer@linux.ibm.com \
    --cc=guwen@linux.alibaba.com \
    --cc=jaka@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tonylu@linux.alibaba.com \
    --cc=wenjia@linux.ibm.com \
    --cc=wintera@linux.ibm.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