Release 4.11 net/ax25/ax25_uid.c
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Copyright (C) Jonathan Naylor G4KLX (g4klx@g4klx.demon.co.uk)
*/
#include <linux/capability.h>
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/socket.h>
#include <linux/in.h>
#include <linux/kernel.h>
#include <linux/timer.h>
#include <linux/string.h>
#include <linux/sockios.h>
#include <linux/net.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <net/ax25.h>
#include <linux/inet.h>
#include <linux/netdevice.h>
#include <linux/if_arp.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include <linux/uaccess.h>
#include <linux/fcntl.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/notifier.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/stat.h>
#include <linux/sysctl.h>
#include <linux/export.h>
#include <net/ip.h>
#include <net/arp.h>
/*
* Callsign/UID mapper. This is in kernel space for security on multi-amateur machines.
*/
static HLIST_HEAD(ax25_uid_list);
static DEFINE_RWLOCK(ax25_uid_lock);
int ax25_uid_policy;
EXPORT_SYMBOL(ax25_uid_policy);
ax25_uid_assoc *ax25_findbyuid(kuid_t uid)
{
ax25_uid_assoc *ax25_uid, *res = NULL;
read_lock(&ax25_uid_lock);
ax25_uid_for_each(ax25_uid, &ax25_uid_list) {
if (uid_eq(ax25_uid->uid, uid)) {
ax25_uid_hold(ax25_uid);
res = ax25_uid;
break;
}
}
read_unlock(&ax25_uid_lock);
return res;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ralf Bächle | 37 | 57.81% | 3 | 60.00% |
Linus Torvalds (pre-git) | 22 | 34.38% | 1 | 20.00% |
Eric W. Biedermann | 5 | 7.81% | 1 | 20.00% |
Total | 64 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL(ax25_findbyuid);
int ax25_uid_ioctl(int cmd, struct sockaddr_ax25 *sax)
{
ax25_uid_assoc *ax25_uid;
ax25_uid_assoc *user;
unsigned long res;
switch (cmd) {
case SIOCAX25GETUID:
res = -ENOENT;
read_lock(&ax25_uid_lock);
ax25_uid_for_each(ax25_uid, &ax25_uid_list) {
if (ax25cmp(&sax->sax25_call, &ax25_uid->call) == 0) {
res = from_kuid_munged(current_user_ns(), ax25_uid->uid);
break;
}
}
read_unlock(&ax25_uid_lock);
return res;
case SIOCAX25ADDUID:
{
kuid_t sax25_kuid;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
sax25_kuid = make_kuid(current_user_ns(), sax->sax25_uid);
if (!uid_valid(sax25_kuid))
return -EINVAL;
user = ax25_findbyuid(sax25_kuid);
if (user) {
ax25_uid_put(user);
return -EEXIST;
}
if (sax->sax25_uid == 0)
return -EINVAL;
if ((ax25_uid = kmalloc(sizeof(*ax25_uid), GFP_KERNEL)) == NULL)
return -ENOMEM;
atomic_set(&ax25_uid->refcount, 1);
ax25_uid->uid = sax25_kuid;
ax25_uid->call = sax->sax25_call;
write_lock(&ax25_uid_lock);
hlist_add_head(&ax25_uid->uid_node, &ax25_uid_list);
write_unlock(&ax25_uid_lock);
return 0;
}
case SIOCAX25DELUID:
if (!capable(CAP_NET_ADMIN))
return -EPERM;
ax25_uid = NULL;
write_lock(&ax25_uid_lock);
ax25_uid_for_each(ax25_uid, &ax25_uid_list) {
if (ax25cmp(&sax->sax25_call, &ax25_uid->call) == 0)
break;
}
if (ax25_uid == NULL) {
write_unlock(&ax25_uid_lock);
return -ENOENT;
}
hlist_del_init(&ax25_uid->uid_node);
ax25_uid_put(ax25_uid);
write_unlock(&ax25_uid_lock);
return 0;
default:
return -EINVAL;
}
return -EINVAL; /*NOTREACHED */
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 206 | 59.54% | 2 | 33.33% |
Ralf Bächle | 104 | 30.06% | 3 | 50.00% |
Eric W. Biedermann | 36 | 10.40% | 1 | 16.67% |
Total | 346 | 100.00% | 6 | 100.00% |
#ifdef CONFIG_PROC_FS
static void *ax25_uid_seq_start(struct seq_file *seq, loff_t *pos)
__acquires
(ax25_uid_lock)
{
read_lock(&ax25_uid_lock);
return seq_hlist_start_head(&ax25_uid_list, *pos);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 13 | 36.11% | 1 | 12.50% |
Linus Torvalds (pre-git) | 7 | 19.44% | 1 | 12.50% |
Ralf Bächle | 7 | 19.44% | 3 | 37.50% |
Eric Dumazet | 4 | 11.11% | 1 | 12.50% |
Li Zefan | 4 | 11.11% | 1 | 12.50% |
Alan Cox | 1 | 2.78% | 1 | 12.50% |
Total | 36 | 100.00% | 8 | 100.00% |
static void *ax25_uid_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
return seq_hlist_next(v, &ax25_uid_list, pos);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 23 | 74.19% | 1 | 33.33% |
Ralf Bächle | 4 | 12.90% | 1 | 33.33% |
Li Zefan | 4 | 12.90% | 1 | 33.33% |
Total | 31 | 100.00% | 3 | 100.00% |
static void ax25_uid_seq_stop(struct seq_file *seq, void *v)
__releases
(ax25_uid_lock)
{
read_unlock(&ax25_uid_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 21 | 84.00% | 1 | 50.00% |
Eric Dumazet | 4 | 16.00% | 1 | 50.00% |
Total | 25 | 100.00% | 2 | 100.00% |
static int ax25_uid_seq_show(struct seq_file *seq, void *v)
{
char buf[11];
if (v == SEQ_START_TOKEN)
seq_printf(seq, "Policy: %d\n", ax25_uid_policy);
else {
struct ax25_uid_assoc *pt;
pt = hlist_entry(v, struct ax25_uid_assoc, uid_node);
seq_printf(seq, "%6d %s\n",
from_kuid_munged(seq_user_ns(seq), pt->uid),
ax2asc(buf, &pt->call));
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 40 | 45.45% | 1 | 16.67% |
Linus Torvalds (pre-git) | 19 | 21.59% | 1 | 16.67% |
Li Zefan | 12 | 13.64% | 1 | 16.67% |
Ralf Bächle | 8 | 9.09% | 1 | 16.67% |
Eric W. Biedermann | 8 | 9.09% | 1 | 16.67% |
Joe Perches | 1 | 1.14% | 1 | 16.67% |
Total | 88 | 100.00% | 6 | 100.00% |
static const struct seq_operations ax25_uid_seqops = {
.start = ax25_uid_seq_start,
.next = ax25_uid_seq_next,
.stop = ax25_uid_seq_stop,
.show = ax25_uid_seq_show,
};
static int ax25_uid_info_open(struct inode *inode, struct file *file)
{
return seq_open(file, &ax25_uid_seqops);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 22 | 88.00% | 1 | 50.00% |
Linus Torvalds (pre-git) | 3 | 12.00% | 1 | 50.00% |
Total | 25 | 100.00% | 2 | 100.00% |
const struct file_operations ax25_uid_fops = {
.owner = THIS_MODULE,
.open = ax25_uid_info_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release,
};
#endif
/*
* Free all memory associated with UID/Callsign structures.
*/
void __exit ax25_uid_free(void)
{
ax25_uid_assoc *ax25_uid;
write_lock(&ax25_uid_lock);
again:
ax25_uid_for_each(ax25_uid, &ax25_uid_list) {
hlist_del_init(&ax25_uid->uid_node);
ax25_uid_put(ax25_uid);
goto again;
}
write_unlock(&ax25_uid_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ralf Bächle | 25 | 50.00% | 3 | 50.00% |
Linus Torvalds (pre-git) | 20 | 40.00% | 2 | 33.33% |
Pavel Emelyanov | 5 | 10.00% | 1 | 16.67% |
Total | 50 | 100.00% | 6 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 360 | 42.30% | 3 | 13.04% |
Ralf Bächle | 208 | 24.44% | 6 | 26.09% |
Stephen Hemminger | 182 | 21.39% | 1 | 4.35% |
Eric W. Biedermann | 49 | 5.76% | 1 | 4.35% |
Li Zefan | 20 | 2.35% | 1 | 4.35% |
Eric Dumazet | 9 | 1.06% | 1 | 4.35% |
Pavel Emelyanov | 5 | 0.59% | 1 | 4.35% |
Thomas Gleixner | 4 | 0.47% | 1 | 4.35% |
Randy Dunlap | 3 | 0.35% | 1 | 4.35% |
Tejun Heo | 3 | 0.35% | 1 | 4.35% |
Paul Gortmaker | 3 | 0.35% | 1 | 4.35% |
Alan Cox | 1 | 0.12% | 1 | 4.35% |
Joe Perches | 1 | 0.12% | 1 | 4.35% |
Arjan van de Ven | 1 | 0.12% | 1 | 4.35% |
Philippe De Muyter | 1 | 0.12% | 1 | 4.35% |
Linus Torvalds | 1 | 0.12% | 1 | 4.35% |
Total | 851 | 100.00% | 23 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.