Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1906560pxb; Mon, 12 Apr 2021 09:21:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdkFr+d5HI8s7r9JQim9lpzPUAdE+1GvpFGF5seuVl8ZSSOXpwcDeLjfKlBvCyjL+E73i4 X-Received: by 2002:a17:907:9116:: with SMTP id p22mr14523355ejq.516.1618244494566; Mon, 12 Apr 2021 09:21:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618244494; cv=none; d=google.com; s=arc-20160816; b=lYs9p4tfHmCWCOyeIbMCPGg7FGxiyLTRDtIL8Mho1Vtuq1M6iCRz2t3GBWCV6yBnkf 7Lr/0kItad3h7dr+2dbjM9JmHcuYeT2plNEekxmqPhDO5z+V1LO/Z18B4zXorl+Xjy3E d5FwUECpR5YA88CQ+7lj4b6+fm4FN65ZduwV9mN01lWbnvjHjVNraq/LxToM3qjX2Z3r fScvX5p2Y5kCia+bC077KCd1Hn0hMGYM4Uq1Jv903Z/DCL/HFb1LyDFCeFecCRdQj6Id TIJoO1B0QSFc56qfRHr2PwBBvQ6jp6pbJZVqJUBP9fQCHcNVcbwJeaR1lt95aeKzxWBn tm8A== 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:subject:cc:to:from:date :dkim-signature; bh=RvkqDQAAF5Fet9laIrU4FO2kjQYJAFZmLvDU+NIzArk=; b=bmyCeYh1x6MHJ92pHbjMmjwyZp5Kvn7vbbtB9OdYuKKa1uHCd+fZq2i3tyKyLSZ4Q8 IK6wCRLiTmxm61SlO4oPtG2LneY5XggC4gV8iDFxXSq0F5Y5AYpZB9Zj77xbWnRx/tY8 xHKdpFDQJqxfthl1KbGvXuvfAjaJHPEmj3NPoKMKd8Sfll48TWr+E7k0d8wxXFl2tZ4p dvYSaXICFMtbwwUkTbvMgcdajYztJOp5eNnb3dGcWwCl2wld0OAn3p7zJrXH3aNUwyBQ vZJtYfCDcnuDOZH1pIaU1j5uzuI1ZqmoA/9B+/rJXkj2PqgG7WvVbh5y/uON+MNyQD/s 3vIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b="VPRmV/bT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x22si7891269ejj.667.2021.04.12.09.21.10; Mon, 12 Apr 2021 09:21:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b="VPRmV/bT"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239351AbhDLQTh (ORCPT + 99 others); Mon, 12 Apr 2021 12:19:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237798AbhDLQTh (ORCPT ); Mon, 12 Apr 2021 12:19:37 -0400 Received: from ustc.edu.cn (email6.ustc.edu.cn [IPv6:2001:da8:d800::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C604C061574 for ; Mon, 12 Apr 2021 09:19:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ustc.edu.cn; s=dkim; h=Received:Date:From:To:Cc:Subject: Message-ID:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=RvkqDQAAF5Fet9laIrU4FO2kjQYJAFZmLv DU+NIzArk=; b=VPRmV/bTCx3Cy8/88weSwsz41KJiMn8F3UNMqwTMOsF2RCviRD jZScpIQlyrEiKt+o7CDofHL5+ZwJ2GvuvsV9Fl6lZcUNt8gRfs6f0jxbwd0WWceg 4ye2JwgVgTjKuBnXR6fm4wKDoMD7cKZnFmXhTnEkHD2HwAlrn1fsZ2xBU= Received: from xhacker (unknown [101.86.20.15]) by newmailweb.ustc.edu.cn (Coremail) with SMTP id LkAmygDHz6fWcnRgLDrLAA--.45336S2; Tue, 13 Apr 2021 00:18:30 +0800 (CST) Date: Tue, 13 Apr 2021 00:13:28 +0800 From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , " =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?=" , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Luke Nelson , Xi Wang , Anup Patel Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 04/10] riscv: Constify sys_call_table Message-ID: <20210413001328.288b2e87@xhacker> In-Reply-To: <20210413001110.7209bae6@xhacker> References: <20210413001110.7209bae6@xhacker> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CM-TRANSID: LkAmygDHz6fWcnRgLDrLAA--.45336S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KFyxuF4kuF1rWw1xXF1kXwb_yoW8GFWfpr sxC34kKryrWF18CFyakF1xurW8Jan8W34agr1qkan8CwnxtrZ8tws0ga4ayFyDGFZrWrW0 gF4I9r90yr48XFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkEb7Iv0xC_Zr1lb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjc xK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG 64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JF0_Jw1lYx0Ex4A2jsIE14v26r 1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvEwIxGrwACI402YVCY1x02628vn2kI c2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14 v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_GFv_WrylIxkG c2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI 0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Gr0_Zr1lIxAIcVC2z280aVAFwI0_Jr0_ Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x07je7K sUUUUU= X-CM-SenderInfo: xmv2xttqjtqzxdloh3xvwfhvlgxou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jisheng Zhang Constify the sys_call_table so that it will be placed in the .rodata section. This will cause attempts to modify the table to fail when strict page permissions are in place. Signed-off-by: Jisheng Zhang Reviewed-by: Anup Patel --- arch/riscv/include/asm/syscall.h | 2 +- arch/riscv/kernel/syscall_table.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/syscall.h b/arch/riscv/include/asm/syscall.h index 49350c8bd7b0..b933b1583c9f 100644 --- a/arch/riscv/include/asm/syscall.h +++ b/arch/riscv/include/asm/syscall.h @@ -15,7 +15,7 @@ #include /* The array of function pointers for syscalls. */ -extern void *sys_call_table[]; +extern void * const sys_call_table[]; /* * Only the low 32 bits of orig_r0 are meaningful, so we return int. diff --git a/arch/riscv/kernel/syscall_table.c b/arch/riscv/kernel/syscall_table.c index f1ead9df96ca..a63c667c27b3 100644 --- a/arch/riscv/kernel/syscall_table.c +++ b/arch/riscv/kernel/syscall_table.c @@ -13,7 +13,7 @@ #undef __SYSCALL #define __SYSCALL(nr, call) [nr] = (call), -void *sys_call_table[__NR_syscalls] = { +void * const sys_call_table[__NR_syscalls] = { [0 ... __NR_syscalls - 1] = sys_ni_syscall, #include }; -- 2.31.0