Re: [patch 1/4 with proper signed-off]security/selinux/ss/policydb.c: fix sparse warnings

From: Stephen Smalley
Date: Tue Mar 22 2005 - 10:32:57 EST


On Sun, 2005-03-20 at 12:59 +0100, Domen Puncer wrote:
> Signed-off-by: Alexey Dobriyan <adobriyan@xxxxxxx>
> Signed-off-by: Domen Puncer <domen@xxxxxxxxxxxx>
> ---
>
>
> kj-domen/security/selinux/ss/policydb.c | 35 ++++++++++++++++++--------------
> 1 files changed, 20 insertions(+), 15 deletions(-)
>
> diff -puN security/selinux/ss/policydb.c~sparse-security_selinux_ss_policydb security/selinux/ss/policydb.c
> --- kj/security/selinux/ss/policydb.c~sparse-security_selinux_ss_policydb 2005-03-20 12:11:25.000000000 +0100
> +++ kj-domen/security/selinux/ss/policydb.c 2005-03-20 12:11:25.000000000 +0100
> @@ -1494,9 +1497,11 @@ int policydb_read(struct policydb *p, vo
> goto bad;
> }
>
> - if (buf[2] != info->sym_num || buf[3] != info->ocon_num) {
> + if (le32_to_cpu(buf[2]) != info->sym_num ||
> + le32_to_cpu(buf[3]) != info->ocon_num) {
> printk(KERN_ERR "security: policydb table sizes (%d,%d) do "
> - "not match mine (%d,%d)\n", buf[2], buf[3],
> + "not match mine (%d,%d)\n",
> + le32_to_cpu(buf[2]), le32_to_cpu(buf[3]),
> info->sym_num, info->ocon_num);
> goto bad;
> }
> _

You didn't remove the loop that already converted these values to little
endian already (no that isn't the same as the earlier loop that you did
remove), so now you are converting them twice. And why is this new code
better even if you fix this omission?

--
Stephen Smalley <sds@xxxxxxxxxxxxxx>
National Security Agency

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/