linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Namjae Jeon <namjae.jeon@samsung.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-cifs@vger.kernel.org,
	linux-cifsd-devel@lists.sourceforge.net,
	aurelien.aptel@gmail.com, sandeen@sandeen.net,
	willy@infradead.org, hch@infradead.org, senozhatsky@chromium.org,
	christian@brauner.io, viro@zeniv.linux.org.uk,
	ronniesahlberg@gmail.com, hch@lst.de, metze@samba.org,
	smfrench@gmail.com, hyc.lee@gmail.com,
	Steve French <stfrench@microsoft.com>
Subject: Re: [PATCH v7 08/13] ksmbd: add smb3 engine part 1
Date: Thu, 5 Aug 2021 14:02:20 +0300	[thread overview]
Message-ID: <20210805110219.GJ22532@kadam> (raw)
In-Reply-To: <20210805060546.3268-9-namjae.jeon@samsung.com>

On Thu, Aug 05, 2021 at 03:05:41PM +0900, Namjae Jeon wrote:
> +/**
> + * check_session_id() - check for valid session id in smb header
> + * @conn:	connection instance
> + * @id:		session id from smb header
> + *
> + * Return:      1 if valid session id, otherwise 0
> + */
> +static inline int check_session_id(struct ksmbd_conn *conn, u64 id)

Make this bool.  Same for all the is_* functions.

> +{
> +	struct ksmbd_session *sess;
> +
> +	if (id == 0 || id == -1)
> +		return 0;
> +
> +	sess = ksmbd_session_lookup_all(conn, id);
> +	if (sess)
> +		return 1;
> +	pr_err("Invalid user session id: %llu\n", id);
> +	return 0;
> +}
> +
> +struct channel *lookup_chann_list(struct ksmbd_session *sess, struct ksmbd_conn *conn)
> +{
> +	struct channel *chann;
> +
> +	list_for_each_entry(chann, &sess->ksmbd_chann_list, chann_list) {
> +		if (chann->conn == conn)
> +			return chann;
> +	}
> +
> +	return NULL;
> +}
> +
> +/**
> + * smb2_get_ksmbd_tcon() - get tree connection information for a tree id
> + * @work:	smb work
> + *
> + * Return:      matching tree connection on success, otherwise error

This documentation seems out of date.

> + */
> +int smb2_get_ksmbd_tcon(struct ksmbd_work *work)
> +{
> +	struct smb2_hdr *req_hdr = work->request_buf;
> +	int tree_id;
> +
> +	work->tcon = NULL;
> +	if (work->conn->ops->get_cmd_val(work) == SMB2_TREE_CONNECT_HE ||
> +	    work->conn->ops->get_cmd_val(work) ==  SMB2_CANCEL_HE ||
> +	    work->conn->ops->get_cmd_val(work) ==  SMB2_LOGOFF_HE) {
> +		ksmbd_debug(SMB, "skip to check tree connect request\n");
> +		return 0;
> +	}
> +
> +	if (xa_empty(&work->sess->tree_conns)) {
> +		ksmbd_debug(SMB, "NO tree connected\n");
> +		return -1;

Better to return -EINVAL.

> +	}
> +
> +	tree_id = le32_to_cpu(req_hdr->Id.SyncId.TreeId);
> +	work->tcon = ksmbd_tree_conn_lookup(work->sess, tree_id);
> +	if (!work->tcon) {
> +		pr_err("Invalid tid %d\n", tree_id);
> +		return -1;
> +	}
> +
> +	return 1;
> +}

regards,
dan carpenter

  reply	other threads:[~2021-08-05 11:03 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210805061552epcas1p36b9ebf1ea832ba81c5e50daf32268f2d@epcas1p3.samsung.com>
2021-08-05  6:05 ` [PATCH v7 00/13] ksmbd: introduce new SMB3 kernel server Namjae Jeon
     [not found]   ` <CGME20210805061554epcas1p26484b6aa7d1a44930350f8ffed4bbe3f@epcas1p2.samsung.com>
2021-08-05  6:05     ` [PATCH v7 01/13] ksmbd: add document Namjae Jeon
     [not found]   ` <CGME20210805061555epcas1p44014bb9329124846b20b2fd1d7e11d7e@epcas1p4.samsung.com>
2021-08-05  6:05     ` [PATCH v7 02/13] ksmbd: add server handler Namjae Jeon
     [not found]   ` <CGME20210805061556epcas1p43da97b436c033b3890ebce288ab81638@epcas1p4.samsung.com>
2021-08-05  6:05     ` [PATCH v7 03/13] ksmbd: add tcp transport layer Namjae Jeon
     [not found]   ` <CGME20210805061557epcas1p2f4107eb356931b94155772a37466a65b@epcas1p2.samsung.com>
2021-08-05  6:05     ` [PATCH v7 04/13] ksmbd: add ipc " Namjae Jeon
     [not found]   ` <CGME20210805061557epcas1p3f81728c626775f0aa66faa7796005bd3@epcas1p3.samsung.com>
2021-08-05  6:05     ` [PATCH v7 05/13] ksmbd: add rdma " Namjae Jeon
     [not found]   ` <CGME20210805061558epcas1p29b1b7bb60dfd2b6d7158f4feb3b8b841@epcas1p2.samsung.com>
2021-08-05  6:05     ` [PATCH v7 06/13] ksmbd: add a utility code that tracks (and caches) sessions data Namjae Jeon
     [not found]   ` <CGME20210805061559epcas1p4383fada61dec0c39a79a0f09327263e6@epcas1p4.samsung.com>
2021-08-05  6:05     ` [PATCH v7 07/13] ksmbd: add authentication Namjae Jeon
     [not found]   ` <CGME20210805061600epcas1p13ca76c1e21f317f9f3f52860a70a241e@epcas1p1.samsung.com>
2021-08-05  6:05     ` [PATCH v7 08/13] ksmbd: add smb3 engine part 1 Namjae Jeon
2021-08-05 11:02       ` Dan Carpenter [this message]
2021-08-05 21:59         ` [Linux-cifsd-devel] " Namjae Jeon
     [not found]   ` <CGME20210805061601epcas1p1df6f58ded1c770c6843f577f69fee7fa@epcas1p1.samsung.com>
2021-08-05  6:05     ` [PATCH v7 09/13] ksmbd: add smb3 engine part 2 Namjae Jeon
     [not found]   ` <CGME20210805061602epcas1p24cb8d9fc0eb42e93d0f3e5c69638eb39@epcas1p2.samsung.com>
2021-08-05  6:05     ` [PATCH v7 10/13] ksmbd: add oplock/lease cache mechanism Namjae Jeon
     [not found]   ` <CGME20210805061603epcas1p37b156b4f755bf66e0d9c39d076191a47@epcas1p3.samsung.com>
2021-08-05  6:05     ` [PATCH v7 11/13] ksmbd: add file operations Namjae Jeon
     [not found]   ` <CGME20210805061603epcas1p16cdc8cfbd37590e18df36d92a713e333@epcas1p1.samsung.com>
2021-08-05  6:05     ` [PATCH v7 12/13] ksmbd: add Kconfig and Makefile Namjae Jeon
     [not found]   ` <CGME20210805061604epcas1p2ed43153ae466204980ab8200699e0925@epcas1p2.samsung.com>
2021-08-05  6:05     ` [PATCH v7 13/13] MAINTAINERS: add ksmbd kernel server Namjae Jeon
2021-08-05  6:23   ` [PATCH v7 00/13] ksmbd: introduce new SMB3 " Namjae Jeon

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=20210805110219.GJ22532@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=aurelien.aptel@gmail.com \
    --cc=christian@brauner.io \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=hyc.lee@gmail.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-cifsd-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=metze@samba.org \
    --cc=namjae.jeon@samsung.com \
    --cc=ronniesahlberg@gmail.com \
    --cc=sandeen@sandeen.net \
    --cc=senozhatsky@chromium.org \
    --cc=smfrench@gmail.com \
    --cc=stfrench@microsoft.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=willy@infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).