Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE9637EA for ; Mon, 27 Mar 2023 06:20:22 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3CE312210A; Mon, 27 Mar 2023 06:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1679898015; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pEqxKXaLJ+RT4hSIBRfllRZDOs58iGL5M5/Zs05kTp8=; b=ho5yJl0+UDCiSk0i25QC//Sba5qlkM6zIbrlvWeerXmzCrvzLGHeEcwPWt6IMhFWlyIRI4 nXroqUhPmfvCecHcFMp9IeISXUhWeMvgBCcjvnJOAhyu4HQzselpH/gm0GFKjJdjzvi1DB Xuu9q8LGgZgh44ks9FRvSFMGR2dRUMo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1679898015; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pEqxKXaLJ+RT4hSIBRfllRZDOs58iGL5M5/Zs05kTp8=; b=gDRehq4RK+rYmWRPqKR3tjACmtlpXo3dknwgLfiNd0ljHx/j60I1B9BDf8+IT58reG1i11 dyVXWfNjOaMm5BAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F16BD13329; Mon, 27 Mar 2023 06:20:14 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IcC6OZ41IWQ0CQAAMHmgww (envelope-from ); Mon, 27 Mar 2023 06:20:14 +0000 Message-ID: <7c3da604-251f-209e-db6d-d1bee5a838c5@suse.de> Date: Mon, 27 Mar 2023 08:20:15 +0200 Precedence: bulk X-Mailing-List: kernel-tls-handshake@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH 15/18] nvmet-tcp: enable TLS handshake upcall Content-Language: en-US To: Sagi Grimberg , Chuck Lever III Cc: Christoph Hellwig , Keith Busch , "linux-nvme@lists.infradead.org" , Chuck Lever , "kernel-tls-handshake@lists.linux.dev" References: <20230321124325.77385-1-hare@suse.de> <20230321124325.77385-16-hare@suse.de> <6f69983c-17bd-dd72-b941-95f55db10180@grimberg.me> <68AA3629-6B88-4098-AA03-BEDF614F8D0B@oracle.com> <3ad50302-6b3c-6d6a-669e-0b11c2df6a6b@suse.de> From: Hannes Reinecke In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 3/26/23 09:18, Sagi Grimberg wrote: > [ .. ] >> >> Nearly there. >> >> The actual patch would be: >> >> @@ -2031,10 +1988,16 @@ static void nvmet_tcp_listen_data_ready(struct >> sock *sk) >>          trace_sk_data_ready(sk); >> >>          read_lock_bh(&sk->sk_callback_lock); >> +       /* Ignore if the callback has been changed */ >> +       if (sk->sk_data_ready != nvmet_tcp_listen_data_ready) >> +               goto out; >>          port = sk->sk_user_data; >>          if (!port) >>                  goto out; >> >> +       if (port->data_ready) >> +               port->data_ready(sk); >> + >>          if (sk->sk_state == TCP_LISTEN) >>                  queue_work(nvmet_wq, &port->accept_work); >>   out: >> >> As the callbacks will be changed once TLS is activated, and we really >> should not attempt to run if sk_data_ready() points to another function, >> as then the sk_user_data pointer will most likely be changed, too, >> causing all sorts of issues. > > Umm, something is unclear to me. if nvmet_tcp_listen_data_ready is > called doesn't it by definition mean that sk->sk_data_ready == > nvmet_tcp_listen_data_ready ? > > Are you talking about a situation where between > nvmet_tcp_listen_data_ready is starting and until the > sk->sk_callback_lock the data_ready cb (and the user data > pointer) is changed? No. Far simpler: Starting kTLS will change the callbacks. So sk->sk_data_ready will point to our callback before the upcall, but to the kTLS version _after_ the upcall. It typically doesn't matter, as we're setting it to nvmet_tcp_data_ready() anyway. But there might be the odd case where the data_ready callback is invoked after kTLS has been started but before we're setting it to nvmet_tcp_data_ready(). Then we cannot guarantee that sk_user_data really is set to the 'queue' pointer, so we should skip the function. Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman