From patchwork Sat Sep 30 05:00:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wedson Almeida Filho X-Patchwork-Id: 146896 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp282051vqb; Sat, 30 Sep 2023 02:16:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0eX4f9BNe32lLn1UUXr4tmPEqhGO2H0R4E1o7UkHo9oXoWKeWc2Z7s7fmb0S0H6Um71CB X-Received: by 2002:a05:6a21:32a6:b0:15d:8eea:27a3 with SMTP id yt38-20020a056a2132a600b0015d8eea27a3mr10622310pzb.3.1696065401261; Sat, 30 Sep 2023 02:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696065401; cv=none; d=google.com; s=arc-20160816; b=xd6qHxJB/e90wyj2qxSQxZGfq+1AIkBOEKRp6x+AIEX5J0e8hEBYqFvuvssxuPYtxf Vui9AdbsuhS38gUi+wgv9o6YxDv0OAnyXmwa9csG1CJCcIKueVYM5UavDXFYuL86dJJ5 XdyLcf3FgD2qh6stRcIh2DFy2vZxaLSUe0leJN4E1CvXC0rIXlQeUVN1N7e+IBFdcPRd sCOYp/bKIPV458M/Y+5jOT7k+wVyZbJczhFRiOjxyR7f+4gMlmalI6ScVQ7a6LumKkat vuXd0wpiTwoKACsA2JuI0tDq2tLPPL/+Xvn97fB8PBaa8PgMtKyJTmdTcoe/Xu6XTIVA qS/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZcuxStbjNijxSJq8zEaQg95VP+4PBlgl17JsgSzTRFE=; fh=wBUngCcKaRcWqf6HA/BgHgkNWrFHB+d21JS9o95oYJ8=; b=lzSU4kUg6XeoxFiFV8zf1pIk3ImvE5RsXaK63j9GPIhOFf/VhtLUedNT96DwhmY74n CABQgmxfviL5oE2zvMPKXaJZKLnyX6jW4GwkcOfqJqjqDvN1YWjjkYqRu3hIYRpkxJDw mH4tuhx72d8ddkaMvHuEA9xgNLNXiryjJEKpwtujPLj04EV8pDg+PURzl83u01+kj0o0 7W7KyvfTzVSDvPlusCQkIEBrNOVmxxGNhIFFldf5H6ImnWEjnQ+Tp+VeOBpB9zL476Pb j+bwg0y0hyL7hwhyc3kEqsBsw0A+TCCrneAZV43E0DfbJg0dVDFeTpJa7q3bHfPqGJyV UWWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WCZJ1Jdy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a7-20020a056a000c8700b00690f8edee16si23375754pfv.275.2023.09.30.02.16.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Sep 2023 02:16:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WCZJ1Jdy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 24D2982F9250; Fri, 29 Sep 2023 22:01:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234017AbjI3FBP (ORCPT + 19 others); Sat, 30 Sep 2023 01:01:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233994AbjI3FBG (ORCPT ); Sat, 30 Sep 2023 01:01:06 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 057361AE; Fri, 29 Sep 2023 22:01:05 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1c60f1a2652so10351695ad.0; Fri, 29 Sep 2023 22:01:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696050064; x=1696654864; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZcuxStbjNijxSJq8zEaQg95VP+4PBlgl17JsgSzTRFE=; b=WCZJ1JdysZkIZlPqNO3x9kE5YTnAV8X2ft3sbU6A5sIdyIZ55bEe/m3IB4pJPNgGnG 4QMjrazQ4otQQLZg74QKzKdOVl68rmAWYihEhSER9kKOgvRY6aapjx4HpDh7aujaHYoz jWI+njEs8+vqver587Le2gTP8sjsdlF5Q5XawTHuIuNI2WSExlQMGcto6tyLGHw4sUW4 mxsrRLVz6TJ4Vl05B5pHYKFBmwkJgS6CTmiV+35iHB6XQ/AUTVD0AxrX7tlHE2/GCHCa 3WoQUCTgpd7uJhe6QGFqmJQchFMnB4swNHG75prfcTQRj+jIg0cjsxVOLqbJk4NcFMIz eMiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696050064; x=1696654864; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ZcuxStbjNijxSJq8zEaQg95VP+4PBlgl17JsgSzTRFE=; b=eDi1E2em9gkvffdv+J/hUInGCf/3m/15ic0PRYswDu6QZsJRiQdHd32RK/fRfdlE9C w828p5SXm5UJNs3QykdDFAXJijQ9w2TiYQmZiTuLa2MPHZS6TuVeb+jX70qImgFp2zEM R1KfTyz/owNiFahHiROLoMvlbY1wqYJPqve+DSmmCr7E1rXUoV5MzHHkPIUt9Pwqx0sm lzgZXBBK13QAf4iIt1Kkj8Ecnn7wSxqrBaONG+BIQo44bunn0tMmBFZEYphf0o2cc6jb c6bUd56jWh+Mzd/BMRugSARqaESMSCugZSZ9jEQDKXZ0wDRK+IVbIG6qV0LiTIioGsZE iGJQ== X-Gm-Message-State: AOJu0YwArFK7ieI3f6oyZ6iDvQRRC1sEQICi+tGiL2MmRHLS389Z2mU3 T17GrGxxR313d7SF3euxag8= X-Received: by 2002:a17:903:184:b0:1bc:5e36:9ab4 with SMTP id z4-20020a170903018400b001bc5e369ab4mr9385815plg.21.1696050064402; Fri, 29 Sep 2023 22:01:04 -0700 (PDT) Received: from wedsonaf-dev.home.lan ([189.124.190.154]) by smtp.googlemail.com with ESMTPSA id y10-20020a17090322ca00b001c322a41188sm392136plg.117.2023.09.29.22.01.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 22:01:04 -0700 (PDT) From: Wedson Almeida Filho To: Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Wedson Almeida Filho , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , v9fs@lists.linux.dev Subject: [PATCH 03/29] 9p: move xattr-related structs to .rodata Date: Sat, 30 Sep 2023 02:00:07 -0300 Message-Id: <20230930050033.41174-4-wedsonaf@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230930050033.41174-1-wedsonaf@gmail.com> References: <20230930050033.41174-1-wedsonaf@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 29 Sep 2023 22:01:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778453474197564898 X-GMAIL-MSGID: 1778453474197564898 From: Wedson Almeida Filho This makes it harder for accidental or malicious changes to v9fs_xattr_user_handler, v9fs_xattr_trusted_handler, v9fs_xattr_security_handler, or v9fs_xattr_handlers at runtime. Cc: Eric Van Hensbergen Cc: Latchesar Ionkov Cc: Dominique Martinet Cc: Christian Schoenebeck Cc: v9fs@lists.linux.dev Signed-off-by: Wedson Almeida Filho Reviewed-by: Christian Schoenebeck Acked-by: Dominique Martinet --- fs/9p/xattr.c | 8 ++++---- fs/9p/xattr.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c index e00cf8109b3f..053d1cef6e13 100644 --- a/fs/9p/xattr.c +++ b/fs/9p/xattr.c @@ -162,27 +162,27 @@ static int v9fs_xattr_handler_set(const struct xattr_handler *handler, return v9fs_xattr_set(dentry, full_name, value, size, flags); } -static struct xattr_handler v9fs_xattr_user_handler = { +static const struct xattr_handler v9fs_xattr_user_handler = { .prefix = XATTR_USER_PREFIX, .get = v9fs_xattr_handler_get, .set = v9fs_xattr_handler_set, }; -static struct xattr_handler v9fs_xattr_trusted_handler = { +static const struct xattr_handler v9fs_xattr_trusted_handler = { .prefix = XATTR_TRUSTED_PREFIX, .get = v9fs_xattr_handler_get, .set = v9fs_xattr_handler_set, }; #ifdef CONFIG_9P_FS_SECURITY -static struct xattr_handler v9fs_xattr_security_handler = { +static const struct xattr_handler v9fs_xattr_security_handler = { .prefix = XATTR_SECURITY_PREFIX, .get = v9fs_xattr_handler_get, .set = v9fs_xattr_handler_set, }; #endif -const struct xattr_handler *v9fs_xattr_handlers[] = { +const struct xattr_handler * const v9fs_xattr_handlers[] = { &v9fs_xattr_user_handler, &v9fs_xattr_trusted_handler, #ifdef CONFIG_9P_FS_SECURITY diff --git a/fs/9p/xattr.h b/fs/9p/xattr.h index b5636e544c8a..3ad5a802352a 100644 --- a/fs/9p/xattr.h +++ b/fs/9p/xattr.h @@ -10,7 +10,7 @@ #include #include -extern const struct xattr_handler *v9fs_xattr_handlers[]; +extern const struct xattr_handler * const v9fs_xattr_handlers[]; ssize_t v9fs_fid_xattr_get(struct p9_fid *fid, const char *name, void *buffer, size_t buffer_size);